Skip to main content
summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authornhauge2012-05-29 15:22:26 +0000
committernhauge2012-05-29 15:22:26 +0000
commit21bf713dfb1a6d72de2bc2e1ca10cefb703b97c4 (patch)
treec4694847f199842db5dea94d14fc086512092424 /common
parentb6664f758d0426d7078470485bab671401edfaf5 (diff)
downloadwebtools.dali-21bf713dfb1a6d72de2bc2e1ca10cefb703b97c4.tar.gz
webtools.dali-21bf713dfb1a6d72de2bc2e1ca10cefb703b97c4.tar.xz
webtools.dali-21bf713dfb1a6d72de2bc2e1ca10cefb703b97c4.zip
This commit was manufactured by cvs2svn to create tag 'v201205290000'.v201205290000
Diffstat (limited to 'common')
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/.project17
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/build.properties13
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/feature.properties43
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/feature.xml41
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.html27
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.ini31
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.mappings6
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.properties26
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/build.properties21
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse32.gifbin1706 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse32.pngbin4634 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/epl-v10.html328
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/license.html86
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/plugin.properties13
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/build.properties14
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/feature.properties48
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.html27
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.ini31
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.mappings6
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.properties26
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/build.properties21
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse32.gifbin1706 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse32.pngbin4634 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/epl-v10.html328
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/license.html86
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/plugin.properties13
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/.cvsignore2
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/.project17
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/build.properties15
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.properties43
-rw-r--r--common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.xml30
-rw-r--r--common/features/org.eclipse.jpt.common.feature/.project17
-rw-r--r--common/features/org.eclipse.jpt.common.feature/build.properties13
-rw-r--r--common/features/org.eclipse.jpt.common.feature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.feature/feature.properties43
-rw-r--r--common/features/org.eclipse.jpt.common.feature/feature.xml51
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.html27
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.ini31
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.mappings6
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.properties26
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/build.properties21
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse32.gifbin1706 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse32.pngbin4634 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/epl-v10.html328
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/license.html86
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/plugin.properties13
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/build.properties14
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/feature.properties48
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.html27
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.ini31
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.mappings6
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.properties26
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/build.properties21
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse32.gifbin1706 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse32.pngbin4634 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/epl-v10.html328
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/license.html86
-rw-r--r--common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/plugin.properties13
-rw-r--r--common/features/org.eclipse.jpt.common.tests.feature/.cvsignore1
-rw-r--r--common/features/org.eclipse.jpt.common.tests.feature/.project17
-rw-r--r--common/features/org.eclipse.jpt.common.tests.feature/build.properties17
-rw-r--r--common/features/org.eclipse.jpt.common.tests.feature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common.tests.feature/feature.properties51
-rw-r--r--common/features/org.eclipse.jpt.common.tests.feature/feature.xml38
-rw-r--r--common/features/org.eclipse.jpt.common_sdk.feature/.cvsignore2
-rw-r--r--common/features/org.eclipse.jpt.common_sdk.feature/.project17
-rw-r--r--common/features/org.eclipse.jpt.common_sdk.feature/build.properties15
-rw-r--r--common/features/org.eclipse.jpt.common_sdk.feature/eclipse_update_120.jpgbin21695 -> 0 bytes
-rw-r--r--common/features/org.eclipse.jpt.common_sdk.feature/feature.properties43
-rw-r--r--common/features/org.eclipse.jpt.common_sdk.feature/feature.xml30
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/.cvsignore1
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/.project22
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/META-INF/MANIFEST.MF7
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/about.html34
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/about.ini44
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/about.mappings6
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/about.properties24
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/build.properties17
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/component.xml9
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/icons/WTP_icon_x32_v2.pngbin5616 -> 0 bytes
-rw-r--r--common/plugins/org.eclipse.jpt.common.branding/plugin.properties13
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/.classpath14
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/.cvsignore1
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/.options4
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/.project28
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF83
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/about.html34
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/build.properties19
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/plugin.properties31
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/plugin.xml173
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/property_files/jpt_common_core.properties24
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/schema/libraryValidators.exsd139
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/schema/resourceLocators.exsd191
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/AnnotationProvider.java84
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/GenericAnnotationProvider.java136
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptCommonCorePlugin.java145
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceModel.java50
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceModelListener.java39
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceType.java99
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptCommonCoreMessages.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptPlugin.java280
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/LibraryProviderPropertyTester.java47
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/gen/AbstractJptGenerator.java390
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libprov/JptOsgiBundlesLibraryProviderInstallOperationConfig.java45
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libprov/JptUserLibraryProviderInstallOperationConfig.java45
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibValUtil.java92
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorConfig.java97
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorManager.java149
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationDataModelProvider.java139
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/JptFileCreationDataModelProperties.java33
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ModuleResourceLocator.java87
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/PluginResourceLocator.java99
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ProjectAdapterFactory.java50
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorConfig.java167
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorManager.java160
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleJavaResourceLocator.java219
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleProjectResourceLocator.java68
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/WebModuleResourceLocator.java52
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/AbstractJavaResourceNode.java107
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/NullAnnotation.java94
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAbstractType.java228
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAnnotatedElement.java391
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAnnotation.java68
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAttribute.java429
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryClassFile.java77
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryEnum.java128
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryEnumConstant.java84
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryField.java82
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMember.java305
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMethod.java193
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryNamedAnnotation.java32
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryNode.java107
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryPackageFragment.java152
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java115
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryType.java389
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryTypeCache.java157
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/RootBinaryNode.java82
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAbstractType.java199
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotatedElement.java834
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotation.java220
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAttribute.java396
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceCompilationUnit.java177
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceEnum.java220
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceEnumConstant.java93
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceField.java76
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMember.java156
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMethod.java201
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceNamedAnnotation.java47
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceNode.java379
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackage.java104
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java121
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java622
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceTypeCompilationUnit.java190
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/CallbackJobSynchronizer.java153
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ICUStringCollator.java63
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java256
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JobSynchronizer.java199
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PlatformTools.java115
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/SimpleSchedulingRule.java40
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/SimpleTextRange.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/WorkspaceRunnableAdapter.java31
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/XPointTools.java139
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/AbstractSingleUseQueueingJobCommandExecutor.java105
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/CommandJobCommandAdapter.java47
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/JobCommandCommandAdapter.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/JobCommandJob.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/NotifyingRepeatingJobCommandWrapper.java95
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/RepeatingJobCommandWrapper.java220
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SimpleJobCommandExecutor.java209
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SingleUseQueueingExtendedJobCommandExecutor.java103
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SingleUseQueueingJobCommandExecutor.java39
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ASTTools.java296
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractAnnotationAdapter.java165
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractDeclarationAnnotationAdapter.java153
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractExpressionConverter.java83
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractJDTType.java199
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractNestedDeclarationAnnotationAdapter.java403
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AnnotatedElementAnnotationElementAdapter.java99
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AnnotationStringArrayExpressionConverter.java131
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/BooleanExpressionConverter.java51
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/CharacterStringExpressionConverter.java53
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapter.java500
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ConversionDeclarationAnnotationElementAdapter.java154
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/DefaultAnnotationEditFormatter.java219
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ElementAnnotationAdapter.java27
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ElementIndexedAnnotationAdapter.java74
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/EnumArrayDeclarationAnnotationElementAdapter.java150
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/EnumDeclarationAnnotationElementAdapter.java119
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ExpressionDeclarationAnnotationElementAdapter.java327
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/GenericVisitor.java791
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/IndexedConversionDeclarationAnnotationElementAdapter.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTAnnotatedElement.java202
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTEnum.java132
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTEnumConstant.java123
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTFieldAttribute.java220
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTMember.java89
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTMethodAttribute.java265
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTModifiedDeclaration.java584
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTPackage.java61
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTType.java208
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JPTTools.java283
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NameStringExpressionConverter.java57
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NestedDeclarationAnnotationAdapter.java90
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapter.java325
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullAnnotationEditFormatter.java42
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullDeclarationAnnotationAdapter.java82
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullDeclarationAnnotationElementAdapter.java60
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullExpressionConverter.java54
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NumberIntegerExpressionConverter.java51
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/PrimitiveTypeStringExpressionConverter.java61
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ShortCircuitAnnotationElementAdapter.java104
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ShortCircuitArrayAnnotationElementAdapter.java43
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/SimpleDeclarationAnnotationAdapter.java62
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/SimpleTypeStringExpressionConverter.java63
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/StringArrayExpressionConverter.java116
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/StringExpressionConverter.java52
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/TypeStringExpressionConverter.java55
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/BooleanTranslator.java36
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/EmptyTagBooleanTranslator.java53
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/EnumeratedValueTranslator.java45
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/SimpleRootTranslator.java92
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/SimpleTranslator.java135
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/libprov/JptLibraryProviderInstallOperationConfig.java34
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/libval/LibraryValidator.java31
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/ProjectResourceLocator.java64
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/ResourceLocator.java55
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/Annotation.java60
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/AnnotationDefinition.java64
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAbstractType.java92
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAnnotatedElement.java233
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAttribute.java121
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceClassFile.java34
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceCompilationUnit.java73
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceEnum.java38
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceEnumConstant.java32
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceField.java27
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceMember.java84
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceMethod.java76
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceNode.java97
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackage.java32
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageFragment.java50
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageFragmentRoot.java39
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageInfoCompilationUnit.java30
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceType.java107
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceTypeCache.java48
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/NestableAnnotation.java33
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/NestableAnnotationDefinition.java54
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/AbstractTextRange.java84
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/BodySourceWriter.java303
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/TextRange.java103
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/CombinedCommandExecutor.java107
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/CombinedExtendedCommandExecutor.java164
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/ExtendedJobCommandExecutor.java225
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/InterruptibleJobCommand.java81
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/JobCommand.java111
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/JobCommandExecutor.java129
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/NotifyingRepeatingJobCommand.java105
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/RepeatingJobCommand.java85
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AbstractType.java38
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotatedElement.java82
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotatedPackage.java40
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationAdapter.java63
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationEditFormatter.java34
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationElementAdapter.java68
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Attribute.java46
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/DeclarationAnnotationAdapter.java72
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/DeclarationAnnotationElementAdapter.java63
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Enum.java39
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/EnumConstant.java41
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/ExpressionConverter.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/FieldAttribute.java39
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedAnnotationAdapter.java37
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedDeclarationAnnotationAdapter.java37
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedDeclarationAnnotationElementAdapter.java38
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedExpressionConverter.java34
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Member.java39
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/MethodAttribute.java45
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/ModifiedDeclaration.java105
-rw-r--r--common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Type.java56
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/.cvsignore1
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/.project22
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/META-INF/MANIFEST.MF7
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.html34
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.ini44
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.mappings6
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.properties24
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/build.properties17
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/component.xml7
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/icons/WTP_icon_x32_v2.pngbin5616 -> 0 bytes
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.branding/plugin.properties13
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/.classpath16
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/.cvsignore1
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/.project28
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/META-INF/MANIFEST.MF23
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/about.html34
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/build.properties19
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/plugin.properties23
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/plugin.xml151
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/property_files/jpt_common_eclipselink_core.properties15
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_0.xsd3128
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_1.xsd3248
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_2.xsd3519
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_0.xsd3625
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_1.xsd4108
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_2.xsd4778
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_3.xsd5479
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_0.xsd260
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_1.xsd462
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_2.xsd562
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_3.xsd589
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_1.1.xsd4183
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_1.2.xsd4253
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_2.0.xsd4253
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.0.xsd1477
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.1.xsd1585
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.2.xsd1586
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_2.0.xsd1591
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/JptCommonEclipseLinkCorePlugin.java90
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/internal/JptCommonEclipseLinkCoreMessages.java35
-rw-r--r--common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/internal/libval/EclipseLinkLibValUtil.java84
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/.classpath13
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/.cvsignore1
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/.project28
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF73
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/about.html34
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/build.properties17
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/plugin.properties23
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/property_files/jpt_common_ui.properties30
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/JptCommonUiPlugin.java83
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/WidgetFactory.java240
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptCommonUiMessages.java55
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptUIPlugin.java281
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/Tracing.java161
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/dialogs/OptionalMessageDialog.java107
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemExtendedLabelProvider.java235
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemStructuredStateProviderManager.java280
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemTreeContentProvider.java187
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractSelectionProvider.java82
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ArchiveFileViewerFilter.java71
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ContentProvider.java40
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/EmptySelection.java43
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ImageImageDescriptor.java47
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ItemStructuredStateProviderManager.java45
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ItemTreeStateProviderManager.java101
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/LabelProviderAdapter.java30
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorContentProvider.java135
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorLabelProvider.java117
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/RunnableWithProgressAdapter.java31
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SelectionChangedAdapter.java30
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SimpleItemTreeStateProviderFactoryProvider.java48
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SimpleMessageTreeContent.java100
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemExtendedLabelProvider.java54
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemLabelProvider.java59
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemTreeContentProvider.java79
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StructuredContentProvider.java32
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StructuredContentProviderAdapter.java265
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/TreeContentProvider.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTCollectionChangeListenerWrapper.java141
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTListChangeListenerWrapper.java187
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTPropertyChangeListenerWrapper.java76
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTStateChangeListenerWrapper.java72
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/properties/JptProjectPropertiesPage.java449
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/AbstractComboModelAdapter.java704
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/ColumnAdapter.java55
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/ComboModelAdapter.java210
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/DateTimeModelAdapter.java352
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/DisposeAdapter.java29
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/SpinnerModelAdapter.java214
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TableItemModelAdapter.java209
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TableModelAdapter.java746
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TriStateCheckBoxModelAdapter.java188
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlAligner.java913
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlSwitcher.java147
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledButton.java64
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledControl.java37
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledControlUpdater.java130
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledLabel.java64
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/PaneEnabler.java175
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/PaneVisibilityEnabler.java173
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java449
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/StateController.java320
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/TableLayoutComposite.java207
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AbstractUiCommandExecutor.java60
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AsynchronousUiCommandExecutor.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PageAdapter.java35
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PartAdapter.java41
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PartAdapter2.java50
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PropertyAdapter.java29
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/SynchronousUiCommandExecutor.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/WindowAdapter.java38
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/AbstractListWidgetAdapter.java42
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/BooleanButtonModelBinding.java190
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/BooleanStateController.java213
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/DropDownListBoxSelectionBinding.java283
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/ListBoxSelectionBinding.java305
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/ListWidgetModelBinding.java428
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/MultiControlBooleanStateController.java160
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTComboAdapter.java67
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTListAdapter.java49
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTTools.java392
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SimpleBooleanStateController.java67
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/TextFieldModelBinding.java196
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveListPane.java554
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemovePane.java923
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveTablePane.java314
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ChooserPane.java168
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ClassChooserComboPane.java92
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ClassChooserPane.java394
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ComboPane.java289
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java260
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Dialog.java329
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DialogPane.java109
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumComboViewer.java332
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumDialogComboViewer.java67
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumFormComboViewer.java67
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserComboPane.java105
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserPane.java167
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FolderChooserComboPane.java106
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FolderChooserPane.java140
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java338
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/IntegerCombo.java181
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameDialog.java166
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameDialogBuilder.java179
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameStateObject.java146
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PackageChooserPane.java241
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java3746
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PropertySheetWidgetFactory.java66
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/TriStateCheckBox.java284
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ValidatingDialog.java233
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/wizards/JavaProjectWizardPage.java256
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ExtendedLabelProvider.java29
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemExtendedLabelProvider.java49
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemExtendedLabelProviderFactory.java26
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemLabelProvider.java61
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemLabelProviderFactory.java26
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemStructuredContentProvider.java105
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemStructuredContentProviderFactory.java26
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeContentProvider.java111
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeContentProviderFactory.java29
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeStateProviderFactoryProvider.java34
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/StructuredStateProvider.java32
-rw-r--r--common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/TreeStateProvider.java29
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/.classpath7
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/.cvsignore1
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/.project28
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF122
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/about.html34
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/build.properties15
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/component.xml11
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/plugin.properties24
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/BooleanReference.java166
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ExceptionHandler.java94
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/Filter.java131
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/IndentingPrintWriter.java163
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/JavaType.java135
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/MethodSignature.java73
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ModifiableObjectReference.java29
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ObjectReference.java42
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/Command.java93
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/CommandExecutor.java96
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/ExtendedCommandExecutor.java126
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/InterruptibleCommand.java65
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/InterruptibleCommandExecutor.java65
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/NotifyingRepeatingCommand.java102
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/RepeatingCommand.java80
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/StatefulCommandExecutor.java35
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/StatefulExtendedCommandExecutor.java25
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractAssociation.java69
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractBooleanReference.java85
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractTransformer.java30
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ArrayTools.java3122
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Association.java46
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Bag.java197
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiFilter.java128
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiStringConverter.java157
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiTransformer.java97
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BitTools.java214
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BooleanTools.java105
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ClassName.java431
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Classpath.java939
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CollectingExceptionHandler.java53
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CollectionTools.java1977
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CompositeException.java96
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ConsumerThreadCoordinator.java243
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FileTools.java1002
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FilterAdapter.java30
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FlaggedObjectReference.java69
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/HashBag.java882
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/IdentityHashBag.java924
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/IntReference.java145
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/JDBCTools.java349
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/JDBCType.java162
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/KeyedSet.java129
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/LazyObjectReference.java107
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ListenerList.java171
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ModifiableBooleanReference.java50
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ModifiableIntReference.java40
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NameTools.java377
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NonEmptyStringFilter.java49
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NonNullBooleanTransformer.java79
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NotBooleanTransformer.java57
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NotNullFilter.java51
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NullList.java151
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Queue.java80
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Range.java87
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ReflectionTools.java1544
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ReverseComparator.java40
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/RunnableAdapter.java26
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleAssociation.java69
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleBooleanReference.java127
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleFilter.java114
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleIntReference.java186
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleJavaType.java240
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleMethodSignature.java240
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleObjectReference.java98
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleQueue.java90
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleStack.java100
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleStringMatcher.java259
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleThreadFactory.java53
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Stack.java80
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StackTrace.java124
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringCollator.java62
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringConverter.java83
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringMatcher.java66
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java5141
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedBag.java220
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedBoolean.java650
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedInt.java914
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedObject.java472
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedQueue.java347
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedStack.java325
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Tools.java96
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Transformer.java98
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/TransformerAdapter.java27
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/VersionComparator.java246
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/XMLStringEncoder.java182
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractAsynchronousCommandExecutor.java276
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractQueueingCommandExecutor.java96
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractSafeCommandExecutor.java57
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractSingleUseQueueingCommandExecutor.java165
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractStatefulCommandExecutor.java67
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractThreadLocalCommandExecutor.java63
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousCommandExecutor.java100
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousExtendedCommandExecutor.java153
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousNotifyingRepeatingCommandWrapper.java156
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousRepeatingCommandWrapper.java302
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/CommandRunnable.java38
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/CompositeCommand.java47
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/NotifyingRepeatingCommandWrapper.java98
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/QueueingCommandExecutor.java32
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/QueueingExtendedCommandExecutor.java83
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandState.java220
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandWrapper.java192
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RunnableCommand.java38
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SafeCommandExecutor.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SafeExtendedCommandExecutor.java63
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SimpleStatefulCommandExecutor.java32
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SimpleStatefulExtendedCommandExecutor.java64
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SingleUseQueueingCommandExecutor.java33
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SingleUseQueueingExtendedCommandExecutor.java78
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SynchronizingCommand.java163
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalCommand.java67
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalCommandExecutor.java30
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalExtendedCommandExecutor.java40
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/enumerations/EmptyEnumeration.java62
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/enumerations/IteratorEnumeration.java57
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ArrayIterable.java77
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ArrayListIterable.java59
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ChainIterable.java96
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CloneIterable.java66
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CloneListIterable.java92
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CompositeIterable.java98
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CompositeListIterable.java135
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/EmptyIterable.java65
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/EmptyListIterable.java65
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/FilteringIterable.java95
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/GraphIterable.java156
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LateralIterableWrapper.java47
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LateralListIterableWrapper.java53
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ListIterable.java27
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ListListIterable.java35
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LiveCloneIterable.java85
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LiveCloneListIterable.java85
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/PeekableIterable.java56
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/QueueIterable.java51
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyCompositeListIterable.java100
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyIterable.java50
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyListIterable.java50
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SingleElementIterable.java55
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SingleElementListIterable.java58
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SnapshotCloneIterable.java124
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SnapshotCloneListIterable.java102
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/StackIterable.java51
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SubIterableWrapper.java50
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SubListIterableWrapper.java54
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SuperIterableWrapper.java45
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SuperListIterableWrapper.java54
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TransformationIterable.java91
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TransformationListIterable.java111
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TreeIterable.java137
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ArrayIterator.java88
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ArrayListIterator.java93
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ChainIterator.java163
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CloneIterator.java193
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CloneListIterator.java292
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CompositeIterator.java162
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CompositeListIterator.java270
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EmptyIterator.java68
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EmptyListIterator.java92
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EnumerationIterator.java52
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/FilteringIterator.java148
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/GraphIterator.java286
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/LateralIteratorWrapper.java60
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/LateralListIteratorWrapper.java93
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/PeekableIterator.java112
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/QueueIterator.java59
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyCompositeListIterator.java252
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyIterator.java65
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyListIterator.java108
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ResultSetIterator.java163
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReverseIterator.java82
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SingleElementIterator.java67
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SingleElementListIterator.java98
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/StackIterator.java59
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SubIteratorWrapper.java38
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SubListIteratorWrapper.java56
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SuperIteratorWrapper.java57
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SuperListIteratorWrapper.java88
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SynchronizedIterator.java76
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SynchronizedListIterator.java122
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TransformationIterator.java103
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TransformationListIterator.java152
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TreeIterator.java257
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AbstractModel.java1007
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AspectChangeSupport.java349
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/ChangeSupport.java2844
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/SingleAspectChangeSupport.java380
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTChangeListenerWrapper.java454
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java161
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java211
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java87
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java86
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java161
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractCollectionValueModel.java124
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractListValueModel.java124
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractPropertyValueModel.java125
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractPropertyValueModelAdapter.java118
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractTreeNodeValueModel.java194
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectAdapter.java284
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectCollectionValueModelAdapter.java156
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectListValueModelAdapter.java201
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectPropertyValueModelAdapter.java186
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/BufferedWritablePropertyValueModel.java397
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CachingPropertyValueModelWrapper.java101
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ChangePropertyValueModelAdapter.java101
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionAspectAdapter.java166
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionListValueModelAdapter.java216
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionPropertyValueModelAdapter.java174
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionValueModelWrapper.java132
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeBooleanPropertyValueModel.java352
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeCollectionValueModel.java448
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeListValueModel.java682
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositePropertyValueModel.java197
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/DoubleModifiablePropertyValueModel.java53
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/DoublePropertyValueModel.java165
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ElementPropertyValueModelAdapter.java130
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ExtendedListValueModelWrapper.java211
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringCollectionValueModel.java176
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringPropertyValueModel.java114
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringWritablePropertyValueModel.java89
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemAspectListValueModelAdapter.java274
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemChangeListValueModelAdapter.java68
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemCollectionListValueModelAdapter.java101
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemListListValueModelAdapter.java109
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemPropertyListValueModelAdapter.java124
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemStateListValueModelAdapter.java74
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemTreeListValueModelAdapter.java101
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListAspectAdapter.java186
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListCollectionValueModelAdapter.java232
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListCurator.java229
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListPropertyValueModelAdapter.java176
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListValueModelWrapper.java163
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyCollectionValueModelAdapter.java60
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyListValueModelAdapter.java60
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullCollectionValueModel.java58
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullListValueModel.java71
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullPropertyValueModel.java43
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullTreeValueModel.java52
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyAspectAdapter.java133
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyCollectionValueModelAdapter.java140
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyListValueModelAdapter.java156
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelWrapper.java110
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ReadOnlyWritablePropertyValueModelWrapper.java48
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SetCollectionValueModel.java133
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimpleCollectionValueModel.java188
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimpleListValueModel.java322
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimplePropertyValueModel.java68
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SortedListValueModelAdapter.java125
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SortedListValueModelWrapper.java249
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StatePropertyValueModelAdapter.java100
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticCollectionValueModel.java73
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticListValueModel.java93
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticPropertyValueModel.java53
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticTreeValueModel.java57
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationListValueModel.java308
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationPropertyValueModel.java164
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationWritablePropertyValueModel.java146
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueAspectAdapter.java195
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueChangeAdapter.java75
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueCollectionAdapter.java107
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueListAdapter.java123
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValuePropertyAdapter.java82
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueStateAdapter.java73
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueTreeAdapter.java107
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/prefs/PreferencePropertyValueModel.java349
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java202
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/AbstractTreeModel.java216
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/CheckBoxModelAdapter.java43
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ColumnAdapter.java49
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ComboBoxModelAdapter.java140
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/DateSpinnerModelAdapter.java198
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/DocumentAdapter.java375
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ListModelAdapter.java292
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ListSpinnerModelAdapter.java218
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java223
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ObjectListSelectionModel.java427
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/PrimitiveListTreeModel.java239
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/RadioButtonModelAdapter.java165
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/SpinnerModelAdapter.java207
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/TableModelAdapter.java420
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ToggleButtonModelAdapter.java224
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/TreeModelAdapter.java914
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/AbstractNode.java940
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/AsynchronousValidator.java50
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/DefaultProblem.java85
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/Node.java377
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/PluggableValidator.java127
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/Problem.java51
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/SynchronousValidator.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/CachingComboBoxModel.java42
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/CheckBoxTableCellRenderer.java206
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/ComboBoxTableCellRenderer.java328
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/Displayable.java44
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/EmptyIcon.java54
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/FilteringListBrowser.java140
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/FilteringListPanel.java455
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/ListChooser.java430
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/NodeSelector.java32
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/NonCachingComboBoxModel.java73
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleDisplayable.java170
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleListBrowser.java86
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleListCellRenderer.java128
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SpinnerTableCellRenderer.java186
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/TableCellEditorAdapter.java96
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/synchronizers/CallbackSynchronousSynchronizer.java82
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/synchronizers/SynchronousSynchronizer.java257
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/Model.java143
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ChangeEvent.java66
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionAddEvent.java124
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionChangeEvent.java105
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionClearEvent.java61
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionEvent.java63
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionRemoveEvent.java112
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListAddEvent.java134
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListChangeEvent.java105
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListClearEvent.java61
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListEvent.java64
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListMoveEvent.java120
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListRemoveEvent.java134
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListReplaceEvent.java150
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/PropertyChangeEvent.java109
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/StateChangeEvent.java51
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeAddEvent.java81
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeChangeEvent.java90
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeClearEvent.java61
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeEvent.java62
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeRemoveEvent.java81
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/AbstractChangeListener.java136
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ChangeAdapter.java119
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ChangeListener.java25
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CollectionChangeAdapter.java54
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CollectionChangeListener.java65
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CommandChangeListener.java43
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ListChangeAdapter.java64
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ListChangeListener.java87
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/MultiMethodReflectiveChangeListener.java160
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/PropertyChangeAdapter.java42
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/PropertyChangeListener.java37
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ReflectiveChangeListener.java377
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/SingleMethodReflectiveChangeListener.java60
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/StateChangeAdapter.java31
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/StateChangeListener.java37
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/TreeChangeAdapter.java51
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/TreeChangeListener.java67
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/CollectionValueModel.java42
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ListValueModel.java57
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiableCollectionValueModel.java32
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiableListValueModel.java32
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiablePropertyValueModel.java31
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/PropertyValueModel.java34
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/TreeNodeValueModel.java74
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/TreeValueModel.java36
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/CallbackSynchronizer.java94
-rw-r--r--common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/Synchronizer.java85
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/.classpath13
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/.cvsignore1
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/.project28
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/META-INF/MANIFEST.MF21
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/about.html34
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/build.properties16
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/plugin.properties23
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/JptCommonCoreTests.java30
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestFacetedProject.java85
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestJavaProject.java121
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestPlatformProject.java97
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/JavaResourceModelTestCase.java197
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/JptCommonCoreResourceJavaTests.java28
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/SourceAttributeTests.java135
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/ASTToolsTests.java196
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/AnnotationTestCase.java1099
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java744
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/DefaultAnnotationEditFormatterTests.java75
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JDTToolsTests.java65
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JptCommonCoreUtilityJdtTests.java36
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java1298
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/MiscTests.java48
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java763
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java2229
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java274
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/TypeTests.java52
-rw-r--r--common/tests/org.eclipse.jpt.common.core.tests/test.xml45
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/.classpath12
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/.cvsignore1
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/.project28
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/META-INF/MANIFEST.MF21
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/build.properties13
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/plugin.properties23
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/JptCommonUiTests.java34
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/jface/DelegatingLabelProviderUiTest.java565
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/jface/DelegatingTreeContentProviderUiTest.java554
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/AbstractComboModelAdapterTest.java777
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/ComboModelAdapterTest.java78
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/JptUiSWTTests.java38
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/SpinnerModelAdapterTest.java342
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/TableModelAdapterTest.java1201
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/TriStateCheckBoxModelAdapterUITest.java319
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlAlignerTest.java803
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlEnablerTest.java85
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlSwitcherTest.java189
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlVisibilityEnablerTest.java85
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/JptUiUtilTests.java44
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledButtonTest.java122
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledControlUpdaterTest.java124
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledLabelTest.java122
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/PaneEnablerTest.java93
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/PaneVisibilityEnablerTest.java93
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/BooleanStateControllerUITest.java278
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/CheckBoxModelBindingUITest.java318
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/DropDownListBoxModelBindingUITest.java664
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/ListBoxModelBindingUITest.java626
-rw-r--r--common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/TextFieldModelBindingUITest.java252
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/.classpath11
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/.cvsignore1
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/.project28
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/META-INF/MANIFEST.MF22
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/about.html34
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/build.properties16
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/plugin.properties24
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/resource/ClassTools.java1680
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ArrayToolsTests.java3523
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BagTests.java82
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiFilterTests.java88
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiStringConverterTests.java115
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiTransformerTests.java73
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BitToolsTests.java262
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BooleanToolsTests.java89
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ClassNameTests.java368
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ClasspathTests.java402
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/CollectionToolsTests.java2418
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ExceptionHandlerTests.java65
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/FileToolsTests.java593
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/FilterTests.java78
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/HashBagTests.java555
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/IdentityHashBagTests.java573
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/IndentingPrintWriterTests.java109
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JDBCTypeTests.java67
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JavaTypeTests.java252
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JptCommonUtilityTests.java87
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/KeyedSetTests.java124
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ListenerListTests.java194
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/MethodSignatureTests.java208
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/MultiThreadedTestCase.java141
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/NameToolsTests.java226
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/NotNullFilterTests.java37
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/RangeTests.java74
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ReflectionToolsTests.java440
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ReverseComparatorTests.java102
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleAssociationTests.java112
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleBooleanReferenceTests.java110
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleIntReferenceTests.java314
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleObjectReferenceTests.java88
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleQueueTests.java149
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleStackTests.java148
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java1871
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedBooleanTests.java341
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedIntTests.java361
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedObjectTests.java238
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedQueueTests.java256
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedStackTests.java257
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/TestCommand.java18
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/TestTools.java254
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ToolsTests.java63
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/VersionComparatorTests.java205
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/XMLStringEncoderTests.java136
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/AsynchronousCommandExecutorTests.java46
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/AsynchronousRepeatingCommandWrapperTests.java454
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandExecutorTests.java122
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandRunnableTests.java54
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandTests.java138
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CompositeCommandTests.java60
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/JptUtilityCommandTests.java37
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/EmptyEnumerationTests.java55
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/IteratorEnumerationTests.java100
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/JptUtilityEnumerationsTests.java34
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ArrayIterableTests.java79
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ArrayListIterableTests.java92
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ChainIterableTests.java84
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CloneIterableTests.java144
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CompositeIterableTests.java115
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CompositeListIterableTests.java117
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/EmptyIterableTests.java39
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/EmptyListIterableTests.java39
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/FilteringIterableTests.java98
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/GraphIterableTests.java167
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/JptUtilityIterablesTests.java57
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/LiveCloneIterableTests.java71
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/LiveCloneListIterableTests.java131
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/PeekableIterableTests.java47
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/QueueIterableTests.java48
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyCompositeListIterableTests.java127
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyIterableTests.java68
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyListIterableTests.java74
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SingleElementIterableTests.java66
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SingleElementListIterableTests.java70
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SnapshotCloneIterableTests.java71
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SnapshotCloneListIterableTests.java131
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/StackIterableTests.java50
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SuperIterableWrapperTests.java50
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TransformationIterableTests.java104
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TransformationListIterableTests.java104
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TreeIterableTests.java155
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ArrayIteratorTests.java135
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ArrayListIteratorTests.java140
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ChainIteratorTests.java133
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CloneIteratorTests.java237
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CloneListIteratorTests.java397
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CompositeIteratorTests.java351
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CompositeListIteratorTests.java331
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EmptyIteratorTests.java64
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EmptyListIteratorTests.java128
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EnumerationIteratorTests.java120
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/FilteringIteratorTests.java266
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/GraphIteratorTests.java197
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/JptUtilityIteratorsTests.java56
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/PeekableIteratorTests.java141
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyCompositeListIteratorTests.java205
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyIteratorTests.java119
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java204
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SingleElementIteratorTests.java72
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SingleElementListIteratorTests.java112
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SuperIteratorWrapperTests.java52
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SynchronizedIteratorTests.java310
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SynchronizedListIteratorTests.java524
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TransformationIteratorTests.java230
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TransformationListIteratorTests.java322
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TreeIteratorTests.java211
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/ChangeSupportTests.java4575
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/JptUtilityModelTests.java37
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/NewEventTests.java181
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/SingleAspectChangeSupportTests.java192
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/JptUtilityModelListenerTests.java34
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java331
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java498
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java176
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java145
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveTreeChangeListenerTests.java362
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/BufferedWritablePropertyValueModelTests.java504
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationPropertyValueModelTests.java239
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationWritablePropertyValueModelTests.java259
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionAspectAdapterTests.java370
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java247
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java238
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeBooleanPropertyValueModelTests.java201
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java415
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeListValueModelTests.java1248
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositePropertyValueModelTests.java193
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CoordinatedBag.java163
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CoordinatedList.java264
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoubleModifiablePropertyValueModelTests.java118
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoublePropertyValueModelTests.java223
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ExtendedListValueModelWrapperTests.java313
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java348
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/FilteringPropertyValueModelTests.java194
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java243
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java244
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java335
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java306
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/JptUtilityModelValueTests.java78
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListAspectAdapterTests.java475
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java282
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListCuratorTests.java348
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullCollectionValueModelTests.java44
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullListValueModelTests.java54
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullPropertyValueModelTests.java40
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyAspectAdapterTests.java343
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java162
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyListValueModelAdapterTests.java211
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ReadOnlyWritablePropertyValueModelWrapperTests.java157
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SetCollectionValueModelTests.java328
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java443
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimpleListValueModelTests.java378
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimplePropertyValueModelTests.java97
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java222
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SortedListValueModelWrapperTests.java237
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticCollectionValueModelTests.java62
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticListValueModelTests.java65
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticValueModelTests.java47
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationListValueModelTests.java339
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java206
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueCollectionAdapterTests.java159
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueListAdapterTests.java169
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValuePropertyAdapterTests.java145
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueStateAdapterTests.java145
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/JptUtilityModelValuePrefsTests.java31
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java398
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java312
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencesTestCase.java82
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java135
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java314
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java111
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java393
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java75
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java160
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DocumentAdapterTests.java159
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java256
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/JptUtilityModelValueSwingTests.java42
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListModelAdapterTests.java320
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java370
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java134
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java148
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java205
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java198
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java230
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java260
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java39
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java118
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java344
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TableModelAdapterTests.java641
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java733
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java812
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java425
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/node/AbstractNodeTests.java495
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/node/JptUtilityNodeTests.java29
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/JptUtilitySynchronizersTests.java33
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/SynchronizerTests.java41
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java755
-rw-r--r--common/tests/org.eclipse.jpt.common.utility.tests/test.xml38
1082 files changed, 0 insertions, 236739 deletions
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/.project b/common/features/org.eclipse.jpt.common.eclipselink.feature/.project
deleted file mode 100644
index 04b106dcd1..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.eclipselink.feature</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/build.properties b/common/features/org.eclipse.jpt.common.eclipselink.feature/build.properties
deleted file mode 100644
index 4f50d146f4..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/build.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = feature.xml,\
- eclipse_update_120.jpg,\
- feature.properties
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/eclipse_update_120.jpg b/common/features/org.eclipse.jpt.common.eclipselink.feature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/feature.properties b/common/features/org.eclipse.jpt.common.eclipselink.feature/feature.properties
deleted file mode 100644
index 8a0aad2c52..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/feature.properties
+++ /dev/null
@@ -1,43 +0,0 @@
-###############################################################################
-# Copyright (c) 2010, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-
-# "featureName" property - name of the feature
-featureName=Dali Java Persistence Tools - EclipseLink Common
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse Web Tools Platform
-
-
-# "description" property - description of the feature
-description=Dali Java Persistence Tools - EclipseLink Common
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006, 2011 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-########### end of license property ##########################################
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/feature.xml b/common/features/org.eclipse.jpt.common.eclipselink.feature/feature.xml
deleted file mode 100644
index 6a40c08f53..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/feature.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.common.eclipselink.feature"
- label="%featureName"
- version="1.2.0.qualifier"
- provider-name="%providerName"
- plugin="org.eclipse.jpt.common.eclipselink.branding"
- license-feature="org.eclipse.license"
- license-feature-version="1.0.0.qualifier">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <requires>
- <import feature="org.eclipse.jpt.common.feature" version="1.2.0"/>
- </requires>
-
- <plugin
- id="org.eclipse.jpt.common.eclipselink.core"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.jpt.common.eclipselink.branding"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
-</feature>
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.html b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.html
deleted file mode 100644
index d4916df475..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 06, 2007</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
-
-<h3>Source Code</h3>
-<p>This plug-in contains source code zip files (&quot;Source Zips&quot;) that correspond to binary content in other plug-ins. These Source Zips may be distributed under different license
-agreements and/or notices. Details about these license agreements and notices are contained in &quot;about.html&quot; files (&quot;Abouts&quot;) located in sub-directories in the
-src/ directory of this plug-in. Such Abouts govern your use of the Source Zips in that directory, not the EPL.</p>
-
-</body>
-</html>
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.ini b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.ini
deleted file mode 100644
index 2dee36a2e2..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.ini
+++ /dev/null
@@ -1,31 +0,0 @@
-# about.ini
-# contains information about a feature
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in about.properties
-# This file does not need to be translated.
-
-# Property "aboutText" contains blurb for "About" dialog (translated)
-aboutText=%blurb
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-
-# Property "featureImage" contains path to feature image (32x32)
-featureImage=eclipse32.gif
-
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-
-# Property "appName" contains name of the application (not translated)
-# needed for primary features only
-
-# Property "welcomePage" contains path to welcome page (special XML-based format)
-# optional
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional
-
-
-
-
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.mappings b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.mappings
deleted file mode 100644
index a28390a75e..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.mappings
+++ /dev/null
@@ -1,6 +0,0 @@
-# about.mappings
-# contains fill-ins for about.properties
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file does not need to be translated.
-
-0=@build@
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.properties b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.properties
deleted file mode 100644
index 243586dc0f..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/about.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###############################################################################
-# Copyright (c) 2008, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# about.properties
-# contains externalized strings for about.ini
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# fill-ins are supplied by about.mappings
-# This file should be translated.
-#
-# Do not translate any values surrounded by {}
-
-blurb=Dali Java Persistence Tools - EclipseLink Common Source\n\
-\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-(c) Copyright Eclipse contributors and others 2006, 2011. All rights reserved.\n\
-Visit http://www.eclipse.org/webtools
-
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/build.properties b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/build.properties
deleted file mode 100644
index 1c3e2eb73b..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/build.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-bin.includes = \
- about.html,\
- about.ini,\
- about.mappings,\
- about.properties,\
- eclipse32.gif,\
- plugin.properties,\
- plugin.xml,\
- src/**,\
- META-INF/
-sourcePlugin = true
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse32.gif b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse32.gif
deleted file mode 100644
index e6ad7ccd75..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse32.gif
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse32.png b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse32.png
deleted file mode 100644
index 50ae49de24..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse32.png
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse_update_120.jpg b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/epl-v10.html b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/epl-v10.html
deleted file mode 100644
index 022ad2955b..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html>
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/license.html b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/license.html
deleted file mode 100644
index 5ad00ba719..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/license.html
+++ /dev/null
@@ -1,86 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<title>Eclipse.org Software User Agreement</title>
-</head>
-
-<body lang="EN-US" link=blue vlink=purple>
-<h2>Eclipse Foundation Software User Agreement</h2>
-<p>March 17, 2005</p>
-
-<h3>Usage Of Content</h3>
-
-<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
- (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
- CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
- OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
- NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
- CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
-
-<h3>Applicable Licenses</h3>
-
-<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
- (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
- For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository (&quot;Repository&quot;) in CVS
- modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
-
-<ul>
- <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
-
- <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
- <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
- and/or Fragments associated with that Feature.</li>
- <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
-
-</ul>
-
-<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
-Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
-including, but not limited to the following locations:</p>
-
-<ul>
- <li>The top-level (root) directory</li>
-
- <li>Plug-in and Fragment directories</li>
- <li>Inside Plug-ins and Fragments packaged as JARs</li>
- <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
- <li>Feature directories</li>
-</ul>
-
-
-<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license (&quot;Feature Update License&quot;) during the
-installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
-inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
-that directory.</p>
-
-<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
-
-<ul>
- <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
-
- <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
- <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
- <li>IBM Public License 1.0 (available at <a href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</a>)</li>
- <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
-
- <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
-</ul>
-
-<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
-contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
-
-<h3>Cryptography</h3>
-
-<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
- another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
- possession, or use, and re-export of encryption software, to see if this is permitted.</p>
-
-<small>Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.</small>
-
-</body>
-</html>
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/plugin.properties b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/plugin.properties
deleted file mode 100644
index 11a79f2639..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateBundle/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2010, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-pluginName = Dali Java Persistence Tools - EclipseLink Common
-providerName = Eclipse Web Tools Platform
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/build.properties b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/build.properties
deleted file mode 100644
index 897839fcea..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/build.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2008 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-bin.includes = \
- eclipse_update_120.jpg,\
- feature.xml,\
- feature.properties
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/eclipse_update_120.jpg b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/feature.properties b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/feature.properties
deleted file mode 100644
index 33b324c9b1..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplateFeature/feature.properties
+++ /dev/null
@@ -1,48 +0,0 @@
-###############################################################################
-# Copyright (c) 2010, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# feature.properties
-# contains externalized strings for feature.xml
-# "%foo" in feature.xml corresponds to the key "foo" in this file
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file should be translated.
-
-# "featureName" property - name of the feature
-featureName=Dali Java Persistence Tools - EclipseLink Common
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse Web Tools Platform
-
-
-# "description" property - description of the feature
-description=Source code zips for Dali Java Persistence Tools EclipseLink Common
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006, 2011 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-########### end of license property ##########################################
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.html b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.html
deleted file mode 100644
index d4916df475..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 06, 2007</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
-
-<h3>Source Code</h3>
-<p>This plug-in contains source code zip files (&quot;Source Zips&quot;) that correspond to binary content in other plug-ins. These Source Zips may be distributed under different license
-agreements and/or notices. Details about these license agreements and notices are contained in &quot;about.html&quot; files (&quot;Abouts&quot;) located in sub-directories in the
-src/ directory of this plug-in. Such Abouts govern your use of the Source Zips in that directory, not the EPL.</p>
-
-</body>
-</html>
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.ini b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.ini
deleted file mode 100644
index 2dee36a2e2..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.ini
+++ /dev/null
@@ -1,31 +0,0 @@
-# about.ini
-# contains information about a feature
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in about.properties
-# This file does not need to be translated.
-
-# Property "aboutText" contains blurb for "About" dialog (translated)
-aboutText=%blurb
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-
-# Property "featureImage" contains path to feature image (32x32)
-featureImage=eclipse32.gif
-
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-
-# Property "appName" contains name of the application (not translated)
-# needed for primary features only
-
-# Property "welcomePage" contains path to welcome page (special XML-based format)
-# optional
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional
-
-
-
-
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.mappings b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.mappings
deleted file mode 100644
index a28390a75e..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.mappings
+++ /dev/null
@@ -1,6 +0,0 @@
-# about.mappings
-# contains fill-ins for about.properties
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file does not need to be translated.
-
-0=@build@
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.properties b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.properties
deleted file mode 100644
index b16ba1fbf9..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/about.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###############################################################################
-# Copyright (c) 2010, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# about.properties
-# contains externalized strings for about.ini
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# fill-ins are supplied by about.mappings
-# This file should be translated.
-#
-# Do not translate any values surrounded by {}
-
-blurb=Dali Java Persistence Tools - EclipseLink Common Source\n\
-\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-(c) Copyright Eclipse contributors and others 2006, 2011. All rights reserved.\n\
-Visit http://www.eclipse.org/webtools
-
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/build.properties b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/build.properties
deleted file mode 100644
index 6dcfcd6269..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/build.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###############################################################################
-# Copyright (c) 2008 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-bin.includes = \
- about.html,\
- about.ini,\
- about.mappings,\
- about.properties,\
- eclipse32.gif,\
- plugin.properties,\
- plugin.xml,\
- src/**,\
- META-INF/
-sourcePlugin = true
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse32.gif b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse32.gif
deleted file mode 100644
index e6ad7ccd75..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse32.gif
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse32.png b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse32.png
deleted file mode 100644
index 50ae49de24..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse32.png
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse_update_120.jpg b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/epl-v10.html b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/epl-v10.html
deleted file mode 100644
index 022ad2955b..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html>
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/license.html b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/license.html
deleted file mode 100644
index 5ad00ba719..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/license.html
+++ /dev/null
@@ -1,86 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<title>Eclipse.org Software User Agreement</title>
-</head>
-
-<body lang="EN-US" link=blue vlink=purple>
-<h2>Eclipse Foundation Software User Agreement</h2>
-<p>March 17, 2005</p>
-
-<h3>Usage Of Content</h3>
-
-<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
- (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
- CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
- OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
- NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
- CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
-
-<h3>Applicable Licenses</h3>
-
-<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
- (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
- For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository (&quot;Repository&quot;) in CVS
- modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
-
-<ul>
- <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
-
- <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
- <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
- and/or Fragments associated with that Feature.</li>
- <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
-
-</ul>
-
-<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
-Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
-including, but not limited to the following locations:</p>
-
-<ul>
- <li>The top-level (root) directory</li>
-
- <li>Plug-in and Fragment directories</li>
- <li>Inside Plug-ins and Fragments packaged as JARs</li>
- <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
- <li>Feature directories</li>
-</ul>
-
-
-<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license (&quot;Feature Update License&quot;) during the
-installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
-inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
-that directory.</p>
-
-<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
-
-<ul>
- <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
-
- <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
- <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
- <li>IBM Public License 1.0 (available at <a href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</a>)</li>
- <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
-
- <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
-</ul>
-
-<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
-contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
-
-<h3>Cryptography</h3>
-
-<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
- another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
- possession, or use, and re-export of encryption software, to see if this is permitted.</p>
-
-<small>Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.</small>
-
-</body>
-</html>
diff --git a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/plugin.properties b/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/plugin.properties
deleted file mode 100644
index 11a79f2639..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink.feature/sourceTemplatePlugin/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2010, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-pluginName = Dali Java Persistence Tools - EclipseLink Common
-providerName = Eclipse Web Tools Platform
diff --git a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/.cvsignore b/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/.cvsignore
deleted file mode 100644
index 9d0e114f67..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-feature.temp.folder
-build.xml
diff --git a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/.project b/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/.project
deleted file mode 100644
index 0b7335445e..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.eclipselink_sdk.feature</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/build.properties b/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/build.properties
deleted file mode 100644
index 6f317aefa0..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/build.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = feature.xml,\
- feature.properties,\
- eclipse_update_120.jpg
-
-generate.feature@org.eclipse.jpt.common.eclipselink.feature.source=org.eclipse.jpt.common.eclipselink.feature
diff --git a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/eclipse_update_120.jpg b/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.properties b/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.properties
deleted file mode 100644
index 465b51a640..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.properties
+++ /dev/null
@@ -1,43 +0,0 @@
-###############################################################################
-# Copyright (c) 2010, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-# "featureName" property - name of the feature
-featureName=Dali Java Persistence Tools - EclipseLink Common SDK
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse Web Tools Platform
-
-
-# "description" property - description of the feature
-description=Source code archives for Dali Java Persistence - EclipseLink Common
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006, 2011 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-########### end of license property ##########################################
diff --git a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.xml b/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.xml
deleted file mode 100644
index fcb356af4c..0000000000
--- a/common/features/org.eclipse.jpt.common.eclipselink_sdk.feature/feature.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.common.eclipselink_sdk.feature"
- label="%featureName"
- version="1.2.0.qualifier"
- provider-name="%providerName"
- license-feature="org.eclipse.license"
- license-feature-version="1.0.0.qualifier">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <includes
- id="org.eclipse.jpt.common.eclipselink.feature"
- version="0.0.0"/>
-
- <includes
- id="org.eclipse.jpt.common.eclipselink.feature.source"
- version="0.0.0"/>
-
-</feature>
diff --git a/common/features/org.eclipse.jpt.common.feature/.project b/common/features/org.eclipse.jpt.common.feature/.project
deleted file mode 100644
index d3dad03e08..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.feature</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/common/features/org.eclipse.jpt.common.feature/build.properties b/common/features/org.eclipse.jpt.common.feature/build.properties
deleted file mode 100644
index b6886beb14..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/build.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = feature.xml,\
- eclipse_update_120.jpg,\
- feature.properties
diff --git a/common/features/org.eclipse.jpt.common.feature/eclipse_update_120.jpg b/common/features/org.eclipse.jpt.common.feature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.feature/feature.properties b/common/features/org.eclipse.jpt.common.feature/feature.properties
deleted file mode 100644
index 05d3200141..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/feature.properties
+++ /dev/null
@@ -1,43 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-
-# "featureName" property - name of the feature
-featureName=Dali Java Persistence Tools - Common
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse Web Tools Platform
-
-
-# "description" property - description of the feature
-description=Dali Java Persistence Tools - Common
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006, 2011 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-########### end of license property ##########################################
diff --git a/common/features/org.eclipse.jpt.common.feature/feature.xml b/common/features/org.eclipse.jpt.common.feature/feature.xml
deleted file mode 100644
index e8f1ba703e..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/feature.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.common.feature"
- label="%featureName"
- version="1.2.0.qualifier"
- provider-name="%providerName"
- plugin="org.eclipse.jpt.common.branding"
- license-feature="org.eclipse.license"
- license-feature-version="1.0.0.qualifier">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <plugin
- id="org.eclipse.jpt.common.utility"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.jpt.common.core"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.jpt.common.ui"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
- <plugin
- id="org.eclipse.jpt.common.branding"
- download-size="0"
- install-size="0"
- version="0.0.0"
- unpack="false"/>
-
-</feature>
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.html b/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.html
deleted file mode 100644
index d4916df475..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 06, 2007</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
-
-<h3>Source Code</h3>
-<p>This plug-in contains source code zip files (&quot;Source Zips&quot;) that correspond to binary content in other plug-ins. These Source Zips may be distributed under different license
-agreements and/or notices. Details about these license agreements and notices are contained in &quot;about.html&quot; files (&quot;Abouts&quot;) located in sub-directories in the
-src/ directory of this plug-in. Such Abouts govern your use of the Source Zips in that directory, not the EPL.</p>
-
-</body>
-</html>
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.ini b/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.ini
deleted file mode 100644
index 2dee36a2e2..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.ini
+++ /dev/null
@@ -1,31 +0,0 @@
-# about.ini
-# contains information about a feature
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in about.properties
-# This file does not need to be translated.
-
-# Property "aboutText" contains blurb for "About" dialog (translated)
-aboutText=%blurb
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-
-# Property "featureImage" contains path to feature image (32x32)
-featureImage=eclipse32.gif
-
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-
-# Property "appName" contains name of the application (not translated)
-# needed for primary features only
-
-# Property "welcomePage" contains path to welcome page (special XML-based format)
-# optional
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional
-
-
-
-
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.mappings b/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.mappings
deleted file mode 100644
index a28390a75e..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.mappings
+++ /dev/null
@@ -1,6 +0,0 @@
-# about.mappings
-# contains fill-ins for about.properties
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file does not need to be translated.
-
-0=@build@
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.properties b/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.properties
deleted file mode 100644
index e40c332da8..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/about.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# about.properties
-# contains externalized strings for about.ini
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# fill-ins are supplied by about.mappings
-# This file should be translated.
-#
-# Do not translate any values surrounded by {}
-
-blurb=Dali Java Persistence Tools - Common Source\n\
-\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-(c) Copyright Eclipse contributors and others 2006, 2011. All rights reserved.\n\
-Visit http://www.eclipse.org/webtools
-
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/build.properties b/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/build.properties
deleted file mode 100644
index 1c3e2eb73b..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/build.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-bin.includes = \
- about.html,\
- about.ini,\
- about.mappings,\
- about.properties,\
- eclipse32.gif,\
- plugin.properties,\
- plugin.xml,\
- src/**,\
- META-INF/
-sourcePlugin = true
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse32.gif b/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse32.gif
deleted file mode 100644
index e6ad7ccd75..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse32.gif
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse32.png b/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse32.png
deleted file mode 100644
index 50ae49de24..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse32.png
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse_update_120.jpg b/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/epl-v10.html b/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/epl-v10.html
deleted file mode 100644
index 022ad2955b..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html>
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/license.html b/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/license.html
deleted file mode 100644
index 5ad00ba719..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/license.html
+++ /dev/null
@@ -1,86 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<title>Eclipse.org Software User Agreement</title>
-</head>
-
-<body lang="EN-US" link=blue vlink=purple>
-<h2>Eclipse Foundation Software User Agreement</h2>
-<p>March 17, 2005</p>
-
-<h3>Usage Of Content</h3>
-
-<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
- (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
- CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
- OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
- NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
- CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
-
-<h3>Applicable Licenses</h3>
-
-<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
- (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
- For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository (&quot;Repository&quot;) in CVS
- modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
-
-<ul>
- <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
-
- <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
- <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
- and/or Fragments associated with that Feature.</li>
- <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
-
-</ul>
-
-<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
-Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
-including, but not limited to the following locations:</p>
-
-<ul>
- <li>The top-level (root) directory</li>
-
- <li>Plug-in and Fragment directories</li>
- <li>Inside Plug-ins and Fragments packaged as JARs</li>
- <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
- <li>Feature directories</li>
-</ul>
-
-
-<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license (&quot;Feature Update License&quot;) during the
-installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
-inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
-that directory.</p>
-
-<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
-
-<ul>
- <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
-
- <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
- <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
- <li>IBM Public License 1.0 (available at <a href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</a>)</li>
- <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
-
- <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
-</ul>
-
-<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
-contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
-
-<h3>Cryptography</h3>
-
-<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
- another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
- possession, or use, and re-export of encryption software, to see if this is permitted.</p>
-
-<small>Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.</small>
-
-</body>
-</html>
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/plugin.properties b/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/plugin.properties
deleted file mode 100644
index 5d10675de1..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateBundle/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-pluginName = Dali Java Persistence Tools - Common
-providerName = Eclipse Web Tools Platform
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/build.properties b/common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/build.properties
deleted file mode 100644
index 897839fcea..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/build.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2008 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-bin.includes = \
- eclipse_update_120.jpg,\
- feature.xml,\
- feature.properties
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/eclipse_update_120.jpg b/common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/feature.properties b/common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/feature.properties
deleted file mode 100644
index c96ff3f69b..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplateFeature/feature.properties
+++ /dev/null
@@ -1,48 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# feature.properties
-# contains externalized strings for feature.xml
-# "%foo" in feature.xml corresponds to the key "foo" in this file
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file should be translated.
-
-# "featureName" property - name of the feature
-featureName=Dali Java Persistence Tools - Common
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse Web Tools Platform
-
-
-# "description" property - description of the feature
-description=Source code zips for Dali Java Persistence Tools Common
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006, 2011 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-########### end of license property ##########################################
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.html b/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.html
deleted file mode 100644
index d4916df475..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>June 06, 2007</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
-
-<h3>Source Code</h3>
-<p>This plug-in contains source code zip files (&quot;Source Zips&quot;) that correspond to binary content in other plug-ins. These Source Zips may be distributed under different license
-agreements and/or notices. Details about these license agreements and notices are contained in &quot;about.html&quot; files (&quot;Abouts&quot;) located in sub-directories in the
-src/ directory of this plug-in. Such Abouts govern your use of the Source Zips in that directory, not the EPL.</p>
-
-</body>
-</html>
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.ini b/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.ini
deleted file mode 100644
index 2dee36a2e2..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.ini
+++ /dev/null
@@ -1,31 +0,0 @@
-# about.ini
-# contains information about a feature
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in about.properties
-# This file does not need to be translated.
-
-# Property "aboutText" contains blurb for "About" dialog (translated)
-aboutText=%blurb
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-
-# Property "featureImage" contains path to feature image (32x32)
-featureImage=eclipse32.gif
-
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-
-# Property "appName" contains name of the application (not translated)
-# needed for primary features only
-
-# Property "welcomePage" contains path to welcome page (special XML-based format)
-# optional
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional
-
-
-
-
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.mappings b/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.mappings
deleted file mode 100644
index a28390a75e..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.mappings
+++ /dev/null
@@ -1,6 +0,0 @@
-# about.mappings
-# contains fill-ins for about.properties
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file does not need to be translated.
-
-0=@build@
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.properties b/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.properties
deleted file mode 100644
index e40c332da8..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/about.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# about.properties
-# contains externalized strings for about.ini
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# fill-ins are supplied by about.mappings
-# This file should be translated.
-#
-# Do not translate any values surrounded by {}
-
-blurb=Dali Java Persistence Tools - Common Source\n\
-\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-(c) Copyright Eclipse contributors and others 2006, 2011. All rights reserved.\n\
-Visit http://www.eclipse.org/webtools
-
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/build.properties b/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/build.properties
deleted file mode 100644
index 6dcfcd6269..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/build.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-###############################################################################
-# Copyright (c) 2008 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-bin.includes = \
- about.html,\
- about.ini,\
- about.mappings,\
- about.properties,\
- eclipse32.gif,\
- plugin.properties,\
- plugin.xml,\
- src/**,\
- META-INF/
-sourcePlugin = true
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse32.gif b/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse32.gif
deleted file mode 100644
index e6ad7ccd75..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse32.gif
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse32.png b/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse32.png
deleted file mode 100644
index 50ae49de24..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse32.png
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse_update_120.jpg b/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/epl-v10.html b/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/epl-v10.html
deleted file mode 100644
index 022ad2955b..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/epl-v10.html
+++ /dev/null
@@ -1,328 +0,0 @@
-<html xmlns:o="urn:schemas-microsoft-com:office:office"
-xmlns:w="urn:schemas-microsoft-com:office:word"
-xmlns="http://www.w3.org/TR/REC-html40">
-
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
-<meta name=ProgId content=Word.Document>
-<meta name=Generator content="Microsoft Word 9">
-<meta name=Originator content="Microsoft Word 9">
-<link rel=File-List
-href="./Eclipse%20EPL%202003_11_10%20Final_files/filelist.xml">
-<title>Eclipse Public License - Version 1.0</title>
-<!--[if gte mso 9]><xml>
- <o:DocumentProperties>
- <o:Revision>2</o:Revision>
- <o:TotalTime>3</o:TotalTime>
- <o:Created>2004-03-05T23:03:00Z</o:Created>
- <o:LastSaved>2004-03-05T23:03:00Z</o:LastSaved>
- <o:Pages>4</o:Pages>
- <o:Words>1626</o:Words>
- <o:Characters>9270</o:Characters>
- <o:Lines>77</o:Lines>
- <o:Paragraphs>18</o:Paragraphs>
- <o:CharactersWithSpaces>11384</o:CharactersWithSpaces>
- <o:Version>9.4402</o:Version>
- </o:DocumentProperties>
-</xml><![endif]--><!--[if gte mso 9]><xml>
- <w:WordDocument>
- <w:TrackRevisions/>
- </w:WordDocument>
-</xml><![endif]-->
-<style>
-<!--
- /* Font Definitions */
-@font-face
- {font-family:Tahoma;
- panose-1:2 11 6 4 3 5 4 4 2 4;
- mso-font-charset:0;
- mso-generic-font-family:swiss;
- mso-font-pitch:variable;
- mso-font-signature:553679495 -2147483648 8 0 66047 0;}
- /* Style Definitions */
-p.MsoNormal, li.MsoNormal, div.MsoNormal
- {mso-style-parent:"";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p
- {margin-right:0in;
- mso-margin-top-alt:auto;
- mso-margin-bottom-alt:auto;
- margin-left:0in;
- mso-pagination:widow-orphan;
- font-size:12.0pt;
- font-family:"Times New Roman";
- mso-fareast-font-family:"Times New Roman";}
-p.BalloonText, li.BalloonText, div.BalloonText
- {mso-style-name:"Balloon Text";
- margin:0in;
- margin-bottom:.0001pt;
- mso-pagination:widow-orphan;
- font-size:8.0pt;
- font-family:Tahoma;
- mso-fareast-font-family:"Times New Roman";}
-@page Section1
- {size:8.5in 11.0in;
- margin:1.0in 1.25in 1.0in 1.25in;
- mso-header-margin:.5in;
- mso-footer-margin:.5in;
- mso-paper-source:0;}
-div.Section1
- {page:Section1;}
--->
-</style>
-</head>
-
-<body lang=EN-US style='tab-interval:.5in'>
-
-<div class=Section1>
-
-<p align=center style='text-align:center'><b>Eclipse Public License - v 1.0</b>
-</p>
-
-<p><span style='font-size:10.0pt'>THE ACCOMPANYING PROGRAM IS PROVIDED UNDER
-THE TERMS OF THIS ECLIPSE PUBLIC LICENSE (&quot;AGREEMENT&quot;). ANY USE,
-REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
-OF THIS AGREEMENT.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>1. DEFINITIONS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Contribution&quot; means:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-in the case of the initial Contributor, the initial code and documentation
-distributed under this Agreement, and<br clear=left>
-b) in the case of each subsequent Contributor:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-changes to the Program, and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-additions to the Program;</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>where
-such changes and/or additions to the Program originate from and are distributed
-by that particular Contributor. A Contribution 'originates' from a Contributor
-if it was added to the Program by such Contributor itself or anyone acting on
-such Contributor's behalf. Contributions do not include additions to the
-Program which: (i) are separate modules of software distributed in conjunction
-with the Program under their own license agreement, and (ii) are not derivative
-works of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Contributor&quot; means any person or
-entity that distributes the Program.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Licensed Patents &quot; mean patent
-claims licensable by a Contributor which are necessarily infringed by the use
-or sale of its Contribution alone or when combined with the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>&quot;Program&quot; means the Contributions
-distributed in accordance with this Agreement.</span> </p>
-
-<p><span style='font-size:10.0pt'>&quot;Recipient&quot; means anyone who
-receives the Program under this Agreement, including all Contributors.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>2. GRANT OF RIGHTS</span></b> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-Subject to the terms of this Agreement, each Contributor hereby grants Recipient
-a non-exclusive, worldwide, royalty-free copyright license to<span
-style='color:red'> </span>reproduce, prepare derivative works of, publicly
-display, publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and object code
-form.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-Subject to the terms of this Agreement, each Contributor hereby grants
-Recipient a non-exclusive, worldwide,<span style='color:green'> </span>royalty-free
-patent license under Licensed Patents to make, use, sell, offer to sell, import
-and otherwise transfer the Contribution of such Contributor, if any, in source
-code and object code form. This patent license shall apply to the combination
-of the Contribution and the Program if, at the time the Contribution is added
-by the Contributor, such addition of the Contribution causes such combination
-to be covered by the Licensed Patents. The patent license shall not apply to
-any other combinations which include the Contribution. No hardware per se is
-licensed hereunder. </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>c)
-Recipient understands that although each Contributor grants the licenses to its
-Contributions set forth herein, no assurances are provided by any Contributor
-that the Program does not infringe the patent or other intellectual property
-rights of any other entity. Each Contributor disclaims any liability to Recipient
-for claims brought by any other entity based on infringement of intellectual
-property rights or otherwise. As a condition to exercising the rights and
-licenses granted hereunder, each Recipient hereby assumes sole responsibility
-to secure any other intellectual property rights needed, if any. For example,
-if a third party patent license is required to allow Recipient to distribute
-the Program, it is Recipient's responsibility to acquire that license before
-distributing the Program.</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>d)
-Each Contributor represents that to its knowledge it has sufficient copyright
-rights in its Contribution, if any, to grant the copyright license set forth in
-this Agreement. </span></p>
-
-<p><b><span style='font-size:10.0pt'>3. REQUIREMENTS</span></b> </p>
-
-<p><span style='font-size:10.0pt'>A Contributor may choose to distribute the
-Program in object code form under its own license agreement, provided that:</span>
-</p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it complies with the terms and conditions of this Agreement; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b)
-its license agreement:</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>i)
-effectively disclaims on behalf of all Contributors all warranties and
-conditions, express and implied, including warranties or conditions of title
-and non-infringement, and implied warranties or conditions of merchantability
-and fitness for a particular purpose; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>ii)
-effectively excludes on behalf of all Contributors all liability for damages,
-including direct, indirect, special, incidental and consequential damages, such
-as lost profits; </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iii)
-states that any provisions which differ from this Agreement are offered by that
-Contributor alone and not by any other party; and</span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>iv)
-states that source code for the Program is available from such Contributor, and
-informs licensees how to obtain it in a reasonable manner on or through a
-medium customarily used for software exchange.<span style='color:blue'> </span></span></p>
-
-<p><span style='font-size:10.0pt'>When the Program is made available in source
-code form:</span> </p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>a)
-it must be made available under this Agreement; and </span></p>
-
-<p class=MsoNormal style='margin-left:.5in'><span style='font-size:10.0pt'>b) a
-copy of this Agreement must be included with each copy of the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Contributors may not remove or alter any
-copyright notices contained within the Program. </span></p>
-
-<p><span style='font-size:10.0pt'>Each Contributor must identify itself as the
-originator of its Contribution, if any, in a manner that reasonably allows
-subsequent Recipients to identify the originator of the Contribution. </span></p>
-
-<p><b><span style='font-size:10.0pt'>4. COMMERCIAL DISTRIBUTION</span></b> </p>
-
-<p><span style='font-size:10.0pt'>Commercial distributors of software may
-accept certain responsibilities with respect to end users, business partners
-and the like. While this license is intended to facilitate the commercial use
-of the Program, the Contributor who includes the Program in a commercial
-product offering should do so in a manner which does not create potential
-liability for other Contributors. Therefore, if a Contributor includes the
-Program in a commercial product offering, such Contributor (&quot;Commercial
-Contributor&quot;) hereby agrees to defend and indemnify every other
-Contributor (&quot;Indemnified Contributor&quot;) against any losses, damages and
-costs (collectively &quot;Losses&quot;) arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified Contributor to
-the extent caused by the acts or omissions of such Commercial Contributor in
-connection with its distribution of the Program in a commercial product
-offering. The obligations in this section do not apply to any claims or Losses
-relating to any actual or alleged intellectual property infringement. In order
-to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial Contributor
-to control, and cooperate with the Commercial Contributor in, the defense and
-any related settlement negotiations. The Indemnified Contributor may participate
-in any such claim at its own expense.</span> </p>
-
-<p><span style='font-size:10.0pt'>For example, a Contributor might include the
-Program in a commercial product offering, Product X. That Contributor is then a
-Commercial Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance claims and
-warranties are such Commercial Contributor's responsibility alone. Under this
-section, the Commercial Contributor would have to defend claims against the
-other Contributors related to those performance claims and warranties, and if a
-court requires any other Contributor to pay any damages as a result, the
-Commercial Contributor must pay those damages.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>5. NO WARRANTY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, THE PROGRAM IS PROVIDED ON AN &quot;AS IS&quot; BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING,
-WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
-MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
-responsible for determining the appropriateness of using and distributing the
-Program and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program errors,
-compliance with applicable laws, damage to or loss of data, programs or
-equipment, and unavailability or interruption of operations. </span></p>
-
-<p><b><span style='font-size:10.0pt'>6. DISCLAIMER OF LIABILITY</span></b> </p>
-
-<p><span style='font-size:10.0pt'>EXCEPT AS EXPRESSLY SET FORTH IN THIS
-AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY
-OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
-THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
-THE POSSIBILITY OF SUCH DAMAGES.</span> </p>
-
-<p><b><span style='font-size:10.0pt'>7. GENERAL</span></b> </p>
-
-<p><span style='font-size:10.0pt'>If any provision of this Agreement is invalid
-or unenforceable under applicable law, it shall not affect the validity or
-enforceability of the remainder of the terms of this Agreement, and without
-further action by the parties hereto, such provision shall be reformed to the
-minimum extent necessary to make such provision valid and enforceable.</span> </p>
-
-<p><span style='font-size:10.0pt'>If Recipient institutes patent litigation
-against any entity (including a cross-claim or counterclaim in a lawsuit)
-alleging that the Program itself (excluding combinations of the Program with
-other software or hardware) infringes such Recipient's patent(s), then such
-Recipient's rights granted under Section 2(b) shall terminate as of the date
-such litigation is filed. </span></p>
-
-<p><span style='font-size:10.0pt'>All Recipient's rights under this Agreement
-shall terminate if it fails to comply with any of the material terms or
-conditions of this Agreement and does not cure such failure in a reasonable
-period of time after becoming aware of such noncompliance. If all Recipient's
-rights under this Agreement terminate, Recipient agrees to cease use and
-distribution of the Program as soon as reasonably practicable. However,
-Recipient's obligations under this Agreement and any licenses granted by
-Recipient relating to the Program shall continue and survive. </span></p>
-
-<p><span style='font-size:10.0pt'>Everyone is permitted to copy and distribute
-copies of this Agreement, but in order to avoid inconsistency the Agreement is
-copyrighted and may only be modified in the following manner. The Agreement
-Steward reserves the right to publish new versions (including revisions) of
-this Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the initial
-Agreement Steward. The Eclipse Foundation may assign the responsibility to
-serve as the Agreement Steward to a suitable separate entity. Each new version
-of the Agreement will be given a distinguishing version number. The Program
-(including Contributions) may always be distributed subject to the version of
-the Agreement under which it was received. In addition, after a new version of
-the Agreement is published, Contributor may elect to distribute the Program
-(including its Contributions) under the new version. Except as expressly stated
-in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
-the intellectual property of any Contributor under this Agreement, whether
-expressly, by implication, estoppel or otherwise. All rights in the Program not
-expressly granted under this Agreement are reserved.</span> </p>
-
-<p><span style='font-size:10.0pt'>This Agreement is governed by the laws of the
-State of New York and the intellectual property laws of the United States of
-America. No party to this Agreement will bring a legal action under this
-Agreement more than one year after the cause of action arose. Each party waives
-its rights to a jury trial in any resulting litigation.</span> </p>
-
-<p class=MsoNormal><![if !supportEmptyParas]>&nbsp;<![endif]><o:p></o:p></p>
-
-</div>
-
-</body>
-
-</html>
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/license.html b/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/license.html
deleted file mode 100644
index 5ad00ba719..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/license.html
+++ /dev/null
@@ -1,86 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
-<title>Eclipse.org Software User Agreement</title>
-</head>
-
-<body lang="EN-US" link=blue vlink=purple>
-<h2>Eclipse Foundation Software User Agreement</h2>
-<p>March 17, 2005</p>
-
-<h3>Usage Of Content</h3>
-
-<p>THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS
- (COLLECTIVELY &quot;CONTENT&quot;). USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS AGREEMENT AND/OR THE TERMS AND
- CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE
- OF THE CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR
- NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND
- CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT USE THE CONTENT.</p>
-
-<h3>Applicable Licenses</h3>
-
-<p>Unless otherwise indicated, all Content made available by the Eclipse Foundation is provided to you under the terms and conditions of the Eclipse Public License Version 1.0
- (&quot;EPL&quot;). A copy of the EPL is provided with this Content and is also available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
- For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
-
-<p>Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository (&quot;Repository&quot;) in CVS
- modules (&quot;Modules&quot;) and made available as downloadable archives (&quot;Downloads&quot;).</p>
-
-<ul>
- <li>Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins (&quot;Plug-ins&quot;), plug-in fragments (&quot;Fragments&quot;), and features (&quot;Features&quot;).</li>
-
- <li>Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java&trade; ARchive) in a directory named &quot;plugins&quot;.</li>
- <li>A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material. Each Feature may be packaged as a sub-directory in a directory named &quot;features&quot;. Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of the Plug-ins
- and/or Fragments associated with that Feature.</li>
- <li>Features may also include other Features (&quot;Included Features&quot;). Within a Feature, files named &quot;feature.xml&quot; may contain a list of the names and version numbers of Included Features.</li>
-
-</ul>
-
-<p>The terms and conditions governing Plug-ins and Fragments should be contained in files named &quot;about.html&quot; (&quot;Abouts&quot;). The terms and conditions governing Features and
-Included Features should be contained in files named &quot;license.html&quot; (&quot;Feature Licenses&quot;). Abouts and Feature Licenses may be located in any directory of a Download or Module
-including, but not limited to the following locations:</p>
-
-<ul>
- <li>The top-level (root) directory</li>
-
- <li>Plug-in and Fragment directories</li>
- <li>Inside Plug-ins and Fragments packaged as JARs</li>
- <li>Sub-directories of the directory named &quot;src&quot; of certain Plug-ins</li>
- <li>Feature directories</li>
-</ul>
-
-
-<p>Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license (&quot;Feature Update License&quot;) during the
-installation process. If the Feature contains Included Features, the Feature Update License should either provide you with the terms and conditions governing the Included Features or
-inform you where you can locate them. Feature Update Licenses may be found in the &quot;license&quot; property of files named &quot;feature.properties&quot; found within a Feature.
-Such Abouts, Feature Licenses, and Feature Update Licenses contain the terms and conditions (or references to such terms and conditions) that govern your use of the associated Content in
-that directory.</p>
-
-<p>THE ABOUTS, FEATURE LICENSES, AND FEATURE UPDATE LICENSES MAY REFER TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS. SOME OF THESE
-OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):</p>
-
-<ul>
- <li>Common Public License Version 1.0 (available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>)</li>
-
- <li>Apache Software License 1.1 (available at <a href="http://www.apache.org/licenses/LICENSE">http://www.apache.org/licenses/LICENSE</a>)</li>
- <li>Apache Software License 2.0 (available at <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
- <li>IBM Public License 1.0 (available at <a href="http://oss.software.ibm.com/developerworks/opensource/license10.html">http://oss.software.ibm.com/developerworks/opensource/license10.html</a>)</li>
- <li>Metro Link Public License 1.00 (available at <a href="http://www.opengroup.org/openmotif/supporters/metrolink/license.html">http://www.opengroup.org/openmotif/supporters/metrolink/license.html</a>)</li>
-
- <li>Mozilla Public License Version 1.1 (available at <a href="http://www.mozilla.org/MPL/MPL-1.1.html">http://www.mozilla.org/MPL/MPL-1.1.html</a>)</li>
-</ul>
-
-<p>IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR TO USE OF THE CONTENT. If no About, Feature License, or Feature Update License is provided, please
-contact the Eclipse Foundation to determine what terms and conditions govern that particular Content.</p>
-
-<h3>Cryptography</h3>
-
-<p>Content may contain encryption software. The country in which you are currently may have restrictions on the import, possession, and use, and/or re-export to
- another country, of encryption software. BEFORE using any encryption software, please check the country's laws, regulations and policies concerning the import,
- possession, or use, and re-export of encryption software, to see if this is permitted.</p>
-
-<small>Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.</small>
-
-</body>
-</html>
diff --git a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/plugin.properties b/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/plugin.properties
deleted file mode 100644
index 5d10675de1..0000000000
--- a/common/features/org.eclipse.jpt.common.feature/sourceTemplatePlugin/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-pluginName = Dali Java Persistence Tools - Common
-providerName = Eclipse Web Tools Platform
diff --git a/common/features/org.eclipse.jpt.common.tests.feature/.cvsignore b/common/features/org.eclipse.jpt.common.tests.feature/.cvsignore
deleted file mode 100644
index c14487ceac..0000000000
--- a/common/features/org.eclipse.jpt.common.tests.feature/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-build.xml
diff --git a/common/features/org.eclipse.jpt.common.tests.feature/.project b/common/features/org.eclipse.jpt.common.tests.feature/.project
deleted file mode 100644
index 89783a78c1..0000000000
--- a/common/features/org.eclipse.jpt.common.tests.feature/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.tests.feature</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/common/features/org.eclipse.jpt.common.tests.feature/build.properties b/common/features/org.eclipse.jpt.common.tests.feature/build.properties
deleted file mode 100644
index 34b9c1ac57..0000000000
--- a/common/features/org.eclipse.jpt.common.tests.feature/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = feature.xml,\
- eclipse_update_120.jpg,\
- feature.properties
-src.includes = \
- feature.xml,\
- eclipse_update_120.jpg,\
- build.properties
diff --git a/common/features/org.eclipse.jpt.common.tests.feature/eclipse_update_120.jpg b/common/features/org.eclipse.jpt.common.tests.feature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/common/features/org.eclipse.jpt.common.tests.feature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common.tests.feature/feature.properties b/common/features/org.eclipse.jpt.common.tests.feature/feature.properties
deleted file mode 100644
index 54ef2287a3..0000000000
--- a/common/features/org.eclipse.jpt.common.tests.feature/feature.properties
+++ /dev/null
@@ -1,51 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2010 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# feature.properties
-# contains externalized strings for feature.xml
-# "%foo" in feature.xml corresponds to the key "foo" in this file
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file should be translated.
-
-# "featureName" property - name of the feature
-featureName=Dali Java Persistence Tools - Common JUnit Tests
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse Web Tools Platform
-
-# "updateSiteName" property - label for the update site
-# TOREVIEW - updateSiteName
-updateSiteName=Web Tools Platform (WTP) Updates
-
-# "description" property - description of the feature
-description=Dali Java Persistence Tools Common JUnit Tests
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006, 2010 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-########### end of license property ##########################################
diff --git a/common/features/org.eclipse.jpt.common.tests.feature/feature.xml b/common/features/org.eclipse.jpt.common.tests.feature/feature.xml
deleted file mode 100644
index 02150807b4..0000000000
--- a/common/features/org.eclipse.jpt.common.tests.feature/feature.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.common.tests.feature"
- label="%featureName"
- version="1.2.0.qualifier"
- provider-name="%providerName"
- license-feature="org.eclipse.license"
- license-feature-version="1.0.0.qualifier">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <requires>
- <import feature="org.eclipse.jpt.common.feature" version="1.2.0"/>
- </requires>
-
- <plugin
- id="org.eclipse.jpt.common.utility.tests"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
-
- <plugin
- id="org.eclipse.jpt.common.core.tests"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
-
-</feature>
diff --git a/common/features/org.eclipse.jpt.common_sdk.feature/.cvsignore b/common/features/org.eclipse.jpt.common_sdk.feature/.cvsignore
deleted file mode 100644
index 9d0e114f67..0000000000
--- a/common/features/org.eclipse.jpt.common_sdk.feature/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-feature.temp.folder
-build.xml
diff --git a/common/features/org.eclipse.jpt.common_sdk.feature/.project b/common/features/org.eclipse.jpt.common_sdk.feature/.project
deleted file mode 100644
index 24b45742af..0000000000
--- a/common/features/org.eclipse.jpt.common_sdk.feature/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common_sdk.feature</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.FeatureBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.FeatureNature</nature>
- </natures>
-</projectDescription>
diff --git a/common/features/org.eclipse.jpt.common_sdk.feature/build.properties b/common/features/org.eclipse.jpt.common_sdk.feature/build.properties
deleted file mode 100644
index 1be2ea1e6a..0000000000
--- a/common/features/org.eclipse.jpt.common_sdk.feature/build.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = feature.xml,\
- feature.properties,\
- eclipse_update_120.jpg
-
-generate.feature@org.eclipse.jpt.common.feature.source=org.eclipse.jpt.common.feature
diff --git a/common/features/org.eclipse.jpt.common_sdk.feature/eclipse_update_120.jpg b/common/features/org.eclipse.jpt.common_sdk.feature/eclipse_update_120.jpg
deleted file mode 100644
index bfdf708ad6..0000000000
--- a/common/features/org.eclipse.jpt.common_sdk.feature/eclipse_update_120.jpg
+++ /dev/null
Binary files differ
diff --git a/common/features/org.eclipse.jpt.common_sdk.feature/feature.properties b/common/features/org.eclipse.jpt.common_sdk.feature/feature.properties
deleted file mode 100644
index 8578168b7a..0000000000
--- a/common/features/org.eclipse.jpt.common_sdk.feature/feature.properties
+++ /dev/null
@@ -1,43 +0,0 @@
-###############################################################################
-# Copyright (c) 2010, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-# "featureName" property - name of the feature
-featureName=Dali Java Persistence Tools - Common SDK
-
-# "providerName" property - name of the company that provides the feature
-providerName=Eclipse Web Tools Platform
-
-
-# "description" property - description of the feature
-description=Source code archives for Dali Java Persistence - Common
-
-# "copyright" property - text of the "Feature Update Copyright"
-copyright=\
-Copyright (c) 2006, 2011 Oracle Corporation.\n\
-All rights reserved. This program and the accompanying materials\n\
-are made available under the terms of the Eclipse Public License v1.0\n\
-which accompanies this distribution, and is available at\n\
-http://www.eclipse.org/legal/epl-v10.html\n\
-\n\
-Contributors:\n\
- Oracle - initial API and implementation\n
-################ end of copyright property ####################################
-
-# "licenseURL" property - URL of the "Feature License"
-# do not translate value - just change to point to a locale-specific HTML page
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-
-# "license" property - text of the "Feature Update License"
-# should be plain text version of license agreement pointed to be "licenseURL"
-# license and licenseURL properties were removed as a result to migrating to new PDE license support.
-# Those properties are now added at build time. See http://wiki.eclipse.org/Equinox/p2/License_Mechanism.
-########### end of license property ##########################################
diff --git a/common/features/org.eclipse.jpt.common_sdk.feature/feature.xml b/common/features/org.eclipse.jpt.common_sdk.feature/feature.xml
deleted file mode 100644
index 058f3ef776..0000000000
--- a/common/features/org.eclipse.jpt.common_sdk.feature/feature.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.common_sdk.feature"
- label="%featureName"
- version="1.2.0.qualifier"
- provider-name="%providerName"
- license-feature="org.eclipse.license"
- license-feature-version="1.0.0.qualifier">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <includes
- id="org.eclipse.jpt.common.feature"
- version="0.0.0"/>
-
- <includes
- id="org.eclipse.jpt.common.feature.source"
- version="0.0.0"/>
-
-</feature>
diff --git a/common/plugins/org.eclipse.jpt.common.branding/.cvsignore b/common/plugins/org.eclipse.jpt.common.branding/.cvsignore
deleted file mode 100644
index c14487ceac..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-build.xml
diff --git a/common/plugins/org.eclipse.jpt.common.branding/.project b/common/plugins/org.eclipse.jpt.common.branding/.project
deleted file mode 100644
index d794011572..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/.project
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.branding</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/common/plugins/org.eclipse.jpt.common.branding/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.branding/META-INF/MANIFEST.MF
deleted file mode 100644
index 5c65eca88d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,7 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jpt.common.branding;singleton:=true
-Bundle-Version: 1.2.0.qualifier
-Bundle-Localization: plugin
-Bundle-Vendor: %providerName
diff --git a/common/plugins/org.eclipse.jpt.common.branding/about.html b/common/plugins/org.eclipse.jpt.common.branding/about.html
deleted file mode 100644
index ca606b1bb5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June 06, 2007</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.branding/about.ini b/common/plugins/org.eclipse.jpt.common.branding/about.ini
deleted file mode 100644
index 6c107d466d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/about.ini
+++ /dev/null
@@ -1,44 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-# about.ini
-# contains information about a feature
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in about.properties
-# This file does not need to be translated.
-
-# Property "aboutText" contains blurb for "About" dialog (translated)
-aboutText=%blurb
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-
-# Property "featureImage" contains path to feature image (32x32)
-featureImage=icons/WTP_icon_x32_v2.png
-
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-
-# Property "appName" contains name of the application (translated)
-# needed for primary features only
-
-# Property "welcomePage" contains path to welcome page (special XML-based format)
-# optional
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional
-
-# Property "tipsAndTricksHref" contains the Help topic href to a tips and tricks page
-# optional
-tipsAndTricksHref=/org.eclipse.jpt.doc.user/tips_and_tricks.htm
-
-
diff --git a/common/plugins/org.eclipse.jpt.common.branding/about.mappings b/common/plugins/org.eclipse.jpt.common.branding/about.mappings
deleted file mode 100644
index bddaab4310..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/about.mappings
+++ /dev/null
@@ -1,6 +0,0 @@
-# about.mappings
-# contains fill-ins for about.properties
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file does not need to be translated.
-
-0=@build@ \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.branding/about.properties b/common/plugins/org.eclipse.jpt.common.branding/about.properties
deleted file mode 100644
index 5d9827f286..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/about.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-# about.properties
-# contains externalized strings for about.ini
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# fill-ins are supplied by about.mappings
-# This file should be translated.
-
-blurb=Dali Java Persistence Tools - Common\n\
-\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-(c) Copyright Oracle contributors and others 2011. All rights reserved.\n\
-Visit http://www.eclipse.org/webtools
diff --git a/common/plugins/org.eclipse.jpt.common.branding/build.properties b/common/plugins/org.eclipse.jpt.common.branding/build.properties
deleted file mode 100644
index 6c20e3b027..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2010, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- about.ini,\
- about.html,\
- about.mappings,\
- about.properties,\
- icons/,\
- plugin.properties
diff --git a/common/plugins/org.eclipse.jpt.common.branding/component.xml b/common/plugins/org.eclipse.jpt.common.branding/component.xml
deleted file mode 100644
index f437ec94d5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/component.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt.common.branding">
-<description url=""></description>
-<component-depends unrestricted="true"></component-depends>
-<plugin id="org.eclipse.jpt.common.branding" fragment="false"/>
-<plugin id="org.eclipse.jpt.common.utility" fragment="false"/>
-<plugin id="org.eclipse.jpt.common.core" fragment="false"/>
-<plugin id="org.eclipse.jpt.common.ui" fragment="false"/>
-</component> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.branding/icons/WTP_icon_x32_v2.png b/common/plugins/org.eclipse.jpt.common.branding/icons/WTP_icon_x32_v2.png
deleted file mode 100644
index 6f09c2a700..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/icons/WTP_icon_x32_v2.png
+++ /dev/null
Binary files differ
diff --git a/common/plugins/org.eclipse.jpt.common.branding/plugin.properties b/common/plugins/org.eclipse.jpt.common.branding/plugin.properties
deleted file mode 100644
index 58b4eea0ab..0000000000
--- a/common/plugins/org.eclipse.jpt.common.branding/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2010, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-pluginName = Dali Java Persistence Tools - Common
-providerName = Eclipse Web Tools Platform
diff --git a/common/plugins/org.eclipse.jpt.common.core/.classpath b/common/plugins/org.eclipse.jpt.common.core/.classpath
deleted file mode 100644
index 84e5b0b8a4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/.classpath
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="property_files"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/jst/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/wst/**"/>
- <accessrule kind="nonaccessible" pattern="org/eclipse/jpt/common/utility/model/value/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/common/plugins/org.eclipse.jpt.common.core/.cvsignore b/common/plugins/org.eclipse.jpt.common.core/.cvsignore
deleted file mode 100644
index ba077a4031..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/common/plugins/org.eclipse.jpt.common.core/.options b/common/plugins/org.eclipse.jpt.common.core/.options
deleted file mode 100644
index 987ec33b47..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/.options
+++ /dev/null
@@ -1,4 +0,0 @@
-# Debugging options for the org.eclipse.jpt.common.core plugin.
-
-# Turn on debugging for the org.eclipse.jpt.common.core plugin.
-org.eclipse.jpt.common.core/debug=true
diff --git a/common/plugins/org.eclipse.jpt.common.core/.project b/common/plugins/org.eclipse.jpt.common.core/.project
deleted file mode 100644
index 5513a1552d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/common/plugins/org.eclipse.jpt.common.core/.settings/org.eclipse.jdt.core.prefs b/common/plugins/org.eclipse.jpt.common.core/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index c84cdadbd2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Fri Apr 01 17:14:35 EDT 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
diff --git a/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF
deleted file mode 100644
index 2eafc6b611..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,83 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.common.core;singleton:=true
-Bundle-Version: 1.2.0.qualifier
-Bundle-Activator: org.eclipse.jpt.common.core.JptCommonCorePlugin
-Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: .
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.core.filebuffers;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.debug.core;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.emf.ecore.xmi;bundle-version="[2.4.0,3.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jdt.launching;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jpt.common.utility;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jst.common.project.facet.core;bundle-version="[1.3.100,2.0.0)",
- org.eclipse.jst.j2ee;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.pde.core;bundle-version="[3.6.0,4.0.0)";resolution:=optional,
- org.eclipse.text;bundle-version="[3.5.100,4.0.0)",
- org.eclipse.wst.common.emf;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.wst.common.frameworks;bundle-version="[1.1.200,2.0.0)",
- org.eclipse.wst.common.project.facet.core;bundle-version="[1.3.0,2.0.0)",
- org.eclipse.wst.validation;bundle-version="[1.2.0,2.0.0)"
-Dali-Comment: We friend 'utility' to all non-EclipseLink, non-test bundles
-Export-Package: org.eclipse.jpt.common.core,
- org.eclipse.jpt.common.core.internal;
- x-friends:="org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jaxb.core",
- org.eclipse.jpt.common.core.internal.gen;
- x-friends:="org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jaxb.core",
- org.eclipse.jpt.common.core.internal.libprov;
- x-friends:="org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jaxb.core",
- org.eclipse.jpt.common.core.internal.libval;
- x-friends:="org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jaxb.core",
- org.eclipse.jpt.common.core.internal.operations;
- x-friends:="org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jaxb.core",
- org.eclipse.jpt.common.core.internal.resource;
- x-friends:="org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jaxb.core",
- org.eclipse.jpt.common.core.internal.resource.java;
- x-friends:="org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jaxb.core",
- org.eclipse.jpt.common.core.internal.resource.java.binary;
- x-friends:="org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jaxb.core",
- org.eclipse.jpt.common.core.internal.resource.java.source;
- x-friends:="org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jaxb.core",
- org.eclipse.jpt.common.core.internal.utility;
- x-friends:="org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.core,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jpa.db,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.gen,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.core.internal.utility.command;
- x-friends:="org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jaxb.core",
- org.eclipse.jpt.common.core.internal.utility.jdt;
- x-friends:="org.eclipse.jpt.jaxb.core,
- org.eclipse.jpt.jpa.core",
- org.eclipse.jpt.common.core.internal.utility.translators;
- x-friends:="org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jaxb.core",
- org.eclipse.jpt.common.core.libprov,
- org.eclipse.jpt.common.core.libval,
- org.eclipse.jpt.common.core.resource,
- org.eclipse.jpt.common.core.resource.java,
- org.eclipse.jpt.common.core.utility,
- org.eclipse.jpt.common.core.utility.command,
- org.eclipse.jpt.common.core.utility.jdt
-Import-Package: com.ibm.icu.text;version="4.0.1"
diff --git a/common/plugins/org.eclipse.jpt.common.core/about.html b/common/plugins/org.eclipse.jpt.common.core/about.html
deleted file mode 100644
index be534ba44f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>May 02, 2008</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/common/plugins/org.eclipse.jpt.common.core/build.properties b/common/plugins/org.eclipse.jpt.common.core/build.properties
deleted file mode 100644
index 559c6fab57..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-################################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-source.. = src/,\
- property_files/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- about.html,\
- plugin.xml,\
- plugin.properties
-jars.compile.order = .
-src.includes = schema/
diff --git a/common/plugins/org.eclipse.jpt.common.core/plugin.properties b/common/plugins/org.eclipse.jpt.common.core/plugin.properties
deleted file mode 100644
index a38a4a43c3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/plugin.properties
+++ /dev/null
@@ -1,31 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = Dali Java Persistence Tools - Common Core
-providerName = Eclipse Web Tools Platform
-
-LIBRARY_VALIDATORS=Library Validators
-RESOURCE_LOCATORS=Resource Locators
-
-JAR_CONTENT = JAR Content
-JAVA_PACKAGE_INFO_CONTENT = package-info.java
-
-NO_OP_LIBRARY_PROVIDER_WARNING = Library configuration is disabled. The user may need to configure further classpath changes later.
diff --git a/common/plugins/org.eclipse.jpt.common.core/plugin.xml b/common/plugins/org.eclipse.jpt.common.core/plugin.xml
deleted file mode 100644
index 453e253726..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/plugin.xml
+++ /dev/null
@@ -1,173 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<!--
- Copyright (c) 2011, 2012 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0, which accompanies this distribution
- and is available at http://www.eclipse.org/legal/epl-v10.html.
-
- Contributors:
- Oracle - initial API and implementation
- -->
-
-<plugin>
-
- <!-- ***** extension points ***** -->
-
- <extension-point
- id="org.eclipse.jpt.common.core.libraryValidators"
- name="%LIBRARY_VALIDATORS"
- schema="schema/libraryValidators.exsd"/>
-
-
- <extension-point
- id="org.eclipse.jpt.common.core.resourceLocators"
- name="%RESOURCE_LOCATORS"
- schema="schema/resourceLocators.exsd"/>
-
-
- <!-- ***** adapters ***** -->
-
- <extension
- point="org.eclipse.core.runtime.adapters">
-
- <!-- IProject -> ProjectResourceLocator -->
- <factory
- adaptableType="org.eclipse.core.resources.IProject"
- class="org.eclipse.jpt.common.core.internal.resource.ProjectAdapterFactory">
- <adapter type="org.eclipse.jpt.common.core.resource.ProjectResourceLocator"/>
- </factory>
-
- </extension>
-
-
- <!-- ***** content types ***** -->
-
- <extension
- point="org.eclipse.core.contenttype.contentTypes">
-
- <!-- JAR content type -->
- <content-type
- id="org.eclipse.jpt.common.core.content.jar"
- name="%JAR_CONTENT"
- file-extensions="jar, zip">
- <describer
- class="org.eclipse.core.runtime.content.BinarySignatureDescriber">
- <parameter name="signature" value="50 4B 03 04"/>
- </describer>
- </content-type>
-
- <!-- package-info.java content type (for package annotations) -->
- <content-type
- id="org.eclipse.jpt.common.core.content.javaPackageInfo"
- name="%JAVA_PACKAGE_INFO_CONTENT"
- base-type="org.eclipse.jdt.core.javaSource"
- file-names="package-info.java"
- priority="normal">
- </content-type>
-
- </extension>
-
-
- <!-- ***** property testers ***** -->
-
- <extension
- point="org.eclipse.core.expressions.propertyTesters">
-
- <propertyTester
- id="org.eclipse.jpt.common.core.propertyTester.libraryProvider"
- type="org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider"
- namespace="org.eclipse.jpt.common.core"
- properties="id, extendsId"
- class="org.eclipse.jpt.common.core.internal.LibraryProviderPropertyTester"/>
-
- </extension>
-
-
- <!-- ***** Dali extensions (eat our own dogfood) ***** -->
-
- <extension
- point="org.eclipse.jpt.common.core.resourceLocators">
-
- <resourceLocator
- id="simpleJavaResourceLocator"
- class="org.eclipse.jpt.common.core.internal.resource.SimpleJavaResourceLocator"
- priority="lowest">
- <enablement>
- <with variable="project">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="java"
- forcePluginActivation="true"/>
- </with>
- </enablement>
- </resourceLocator>
-
- <resourceLocator
- id="moduleResourceLocator"
- class="org.eclipse.jpt.common.core.internal.resource.ModuleResourceLocator"
- priority="lower">
- <enablement>
- <with variable="project">
- <and>
- <test
- property="org.eclipse.core.resources.projectNature"
- value="org.eclipse.wst.common.modulecore.ModuleCoreNature"
- forcePluginActivation="true"/>
- <not>
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="wst.web"
- forcePluginActivation="true"/>
- </not>
- </and>
- </with>
- </enablement>
- </resourceLocator>
-
- <resourceLocator
- id="webModuleResourceLocator"
- class="org.eclipse.jpt.common.core.internal.resource.WebModuleResourceLocator"
- priority="low">
- <enablement>
- <with variable="project">
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jst.web"
- forcePluginActivation="true"/>
- </with>
- </enablement>
- </resourceLocator>
-
- <resourceLocator
- id="pluginResourceLocator"
- class="org.eclipse.jpt.common.core.internal.resource.PluginResourceLocator"
- priority="normal">
- <enablement>
- <with variable="project">
- <test
- property="org.eclipse.core.resources.projectNature"
- value="org.eclipse.pde.PluginNature"
- forcePluginActivation="true"/>
- </with>
- </enablement>
- </resourceLocator>
-
- </extension>
-
-
- <!-- ***** WTP Library Provider Framework Integration ***** -->
-
- <extension
- point="org.eclipse.jst.common.project.facet.core.libraryProviders">
-
- <provider
- id="jpt-no-op-library-provider"
- extends="no-op-library-provider"
- abstract="true">
- <param name="warning" value="%NO_OP_LIBRARY_PROVIDER_WARNING"/>
- </provider>
-
- </extension>
-
-</plugin>
diff --git a/common/plugins/org.eclipse.jpt.common.core/property_files/jpt_common_core.properties b/common/plugins/org.eclipse.jpt.common.core/property_files/jpt_common_core.properties
deleted file mode 100644
index a4eef57496..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/property_files/jpt_common_core.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-################################################################################
-# Copyright (c) 2012 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-DALI_JOB_NAME=Dali
-DALI_EVENT_HANDLER_THREAD_NAME=Dali Event Handler
-GENERATION_CREATING_LAUNCH_CONFIG_TASK=Creating launch configuration
-GENERATION_SAVING_LAUNCH_CONFIG_TASK=Saving launch configuration
-GENERATION_LAUNCHING_CONFIG_TASK=Launching configuration
-REGISTRY_MISSING_ATTRIBUTE=Missing required attribute ''{0}'' for element ''{1}'' in extension ''{1}'' from plug-in ''{2}''.
-REGISTRY_INVALID_VALUE=Invalid value ''{0}'' for ''{1}'' in extension ''{2}'' from plug-in ''{3}''.
-REGISTRY_DUPLICATE=An extension of ''{0}'' with the ''{1}'' value of ''{2}'' is already registered.
-REGISTRY_FAILED_CLASS_LOAD=Unable to load the class ''{0}'' declared for the extension point ''{1}'' in the plug-in ''{2}''.
-REGISTRY_FAILED_INTERFACE_ASSIGNMENT=Unable to assign the class ''{0}'' declared for the extension point ''{1}'' in the plug-in ''{2}'' to the interface ''{3}''.
-REGISTRY_FAILED_INSTANTIATION=Unable to instantiate the class ''{0}'' declared for the extension point ''{1}'' in the plug-in ''{2}''.
-USER_LIBRARY_VALIDATOR__CLASS_NOT_FOUND=The class ''{0}'' is required to be in the selected libraries.
-VALIDATE_CONTAINER_NOT_SPECIFIED=Parent folder must be specified
-VALIDATE_FILE_NAME_NOT_SPECIFIED=File name must be specified
-VALIDATE_FILE_ALREADY_EXISTS=File already exist \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.core/schema/libraryValidators.exsd b/common/plugins/org.eclipse.jpt.common.core/schema/libraryValidators.exsd
deleted file mode 100644
index 52dacbb094..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/schema/libraryValidators.exsd
+++ /dev/null
@@ -1,139 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.jpt.common.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.jpt.common.core" id="libraryValidators" name="Library Validators"/>
- </appinfo>
- <documentation>
- Used to provide custom library validation to JPT project configuration.
- </documentation>
- </annotation>
-
- <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="libraryValidator" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="libraryValidator">
- <annotation>
- <documentation>
- Declares a library validator. See &lt;samp&gt;org.eclipse.jpt.common.core.libval.LibraryValidator&lt;/samp&gt; for more information on library validators.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="enablement" minOccurs="0" maxOccurs="1"/>
- </sequence>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- A unique identifier for the declared library validator.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The implementation class, which implements &lt;samp&gt;org.eclipse.jpt.common.core.libval.LibraryValidator&lt;/samp&gt;.
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.jpt.core.libval.LibraryValidator"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- JPT 3.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- &lt;br&gt;
-&lt;p&gt;
-The following example is the included generic library validator, which is used for user library validation for projects of the generic JPA platform group.
-&lt;p&gt;
-&lt;pre&gt;
-&lt;extension
- point=&quot;org.eclipse.jpt.common.core.libraryValidators&quot;&gt;
- &lt;libraryValidator
- id=&quot;genericUserLibraryValidator&quot;
- class=&quot;org.eclipse.jpt.core.internal.libval.GenericJpaUserLibraryValidator&quot;&gt;
- &lt;enablement&gt;
- &lt;with variable=&quot;libraryProvider&quot;&gt;
- &lt;test property=&quot;org.eclipse.jpt.core.extendsId&quot; value=&quot;jpa-user-library-provider&quot;/&gt;
- &lt;/with&gt;
- &lt;/enablement&gt;
- &lt;/libraryValidator&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- &lt;p&gt;
-The enablement variables include:
-&lt;ul&gt;
-&lt;li&gt;&quot;libraryProvider&quot; which gives the current ILibraryProvider.&lt;/li&gt;
-&lt;li&gt;&quot;config&quot; which gives the current JptLibraryProviderInstallOperationConfig.&lt;/li&gt;
-&lt;/ul&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2010, 2011 Oracle. All rights reserved.
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0, which accompanies this distribution
-and is available at http://www.eclipse.org/legal/epl-v10.html.
-
-Contributors:
-Oracle - initial API and implementation
- </documentation>
- </annotation>
-
-</schema>
diff --git a/common/plugins/org.eclipse.jpt.common.core/schema/resourceLocators.exsd b/common/plugins/org.eclipse.jpt.common.core/schema/resourceLocators.exsd
deleted file mode 100644
index d82f686e66..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/schema/resourceLocators.exsd
+++ /dev/null
@@ -1,191 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.jpt.common.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.jpt.common.core" id="resourceLocators" name="Resource Locators"/>
- </appinfo>
- <documentation>
- Used to provide custom (non-Java) resource location logic to JPT projects.
- </documentation>
- </annotation>
-
- <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="resourceLocator" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="resourceLocator">
- <annotation>
- <documentation>
- Declares a resource locator. See &lt;samp&gt;org.eclipse.jpt.common.core.resource.ResourceLocator&lt;/samp&gt; for more information on resource locators.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="enablement" minOccurs="0" maxOccurs="1"/>
- </sequence>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- A unique identifier for the declared resource locator.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The implementation class, which implements &lt;samp&gt;org.eclipse.jpt.common.core.resource.ResourceLocator&lt;/samp&gt;.
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.jpt.common.core.resource.ResourceLocator"/>
- </appinfo>
- </annotation>
- </attribute>
- <attribute name="priority">
- <annotation>
- <documentation>
- Indicates the relative priority of this extension to other extensions. Used by the resource locator manager to determine which extension should be used in the case that multiple extensions apply to a given project. Defaults to &quot;normal&quot;.
- </documentation>
- </annotation>
- <simpleType>
- <restriction base="string">
- <enumeration value="lowest">
- </enumeration>
- <enumeration value="lower">
- </enumeration>
- <enumeration value="low">
- </enumeration>
- <enumeration value="normal">
- </enumeration>
- <enumeration value="high">
- </enumeration>
- <enumeration value="higher">
- </enumeration>
- <enumeration value="highest">
- </enumeration>
- </restriction>
- </simpleType>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- JPT 3.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- &lt;br&gt;
-&lt;p&gt;
-The following example is the included simple Java resource locator, which is used for simple Java projects. It is of &quot;lowest&quot; priority, since all JPT projects will at their roots be simple Java projects.
-&lt;p&gt;
-&lt;pre&gt;
-&lt;extension
- point=&quot;org.eclipse.jpt.common.core.resourceLocators&quot;&gt;
- &lt;resourceLocator
- id=&quot;simpleJavaResourceLocator&quot;
- class=&quot;org.eclipse.jpt.common.core.internal.resource.SimpleJavaResourceLocator&quot;
- priority=&quot;lowest&quot;
- &lt;enablement&gt;
- &lt;with variable=&quot;project&quot;&gt;
- &lt;test property=&quot;org.eclipse.wst.common.project.facet.core.projectFacet&quot; value=&quot;java&quot; forcePluginActivation=&quot;true&quot;/&gt;
- &lt;/with&gt;
- &lt;/enablement&gt;
- &lt;/resourceLocator&gt;
-&lt;/extension&gt;
-&lt;/pre&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="apiinfo"/>
- </appinfo>
- <documentation>
- &lt;p&gt;
-The contributed resource locator class must implement &lt;code&gt;org.eclipse.jpt.common.core.resource.ResourceLocator&lt;/code&gt;.
-&lt;p&gt;
-The enablement variables include:
-&lt;ul&gt;
-&lt;li&gt;&quot;project&quot; which gives the current &lt;code&gt;IProject&lt;/code&gt;.&lt;/li&gt;
-&lt;/ul&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- &lt;p&gt;The org.eclipse.jpt.common.core plug-in provides the following resource locators:
-&lt;ul&gt;
-&lt;li&gt;simpleJavaResourceLocator&lt;/li&gt;
-&lt;li&gt;moduleResourceLocator&lt;/li&gt;
-&lt;li&gt;webModuleResourceLocator&lt;/li&gt;
-&lt;li&gt;pluginResourceLocator&lt;/li&gt;
-&lt;/ul&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2011 Oracle. All rights reserved.
-This program and the accompanying materials are made available under the
-terms of the Eclipse Public License v1.0, which accompanies this distribution
-and is available at http://www.eclipse.org/legal/epl-v10.html.
-
-Contributors:
-Oracle - initial API and implementation
- </documentation>
- </annotation>
-
-</schema>
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/AnnotationProvider.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/AnnotationProvider.java
deleted file mode 100644
index 5551329f03..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/AnnotationProvider.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-
-/**
- * This is used to provide annotations and nestable annotations. An exception will
- * be thrown on an attempt to build an annotation that does not exist.
- *
- * This interface is not intended to be implemented.
- *
- * @version 3.0
- * @since 3.0
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface AnnotationProvider {
-
- /**
- * Return the names of the annotations.
- */
- Iterable<String> getAnnotationNames();
-
- Iterable<String> getContainerAnnotationNames();
-
- Iterable<String> getNestableAnnotationNames();
-
- String getNestableAnnotationName(String containerAnnotationName);
-
- String getContainerAnnotationName(String nestableAnnotationName);
-
- String getNestableElementName(String nestableAnnotationName);
-
- /**
- * Build an annotation with the specified name.
- * Throw an IllegalArgumentException if the specified name is unsupported.
- * @see #getAnnotationNames()
- */
- Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element, String annotationName);
-
- /**
- * Build a nestable annotation with the specified name and index.
- * Throw an IllegalArgumentException if the specified name is unsupported.
- * @see #getNestableAnnotationNames()
- */
- NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element, String annotationName, int index);
-
- /**
- * Build an annotation for the specified JDT annotation.
- * Throw an IllegalArgumentException if the specified annotation is unsupported.
- * @see #getAnnotationNames()
- */
- Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation);
-
- /**
- * Build a nestable annotation for the specified JDT annotation and index.
- * Throw an IllegalArgumentException if the specified annotation is unsupported.
- * @see #getNestableAnnotationNames()
- */
- NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation, int index);
-
- /**
- * Build a null annotation with the specified name.
- * Throw an IllegalArgumentException if the specified annotation is unsupported.
- * @see #getAnnotationNames()
- */
- Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent, String annotationName);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/GenericAnnotationProvider.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/GenericAnnotationProvider.java
deleted file mode 100644
index 3eee738f74..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/GenericAnnotationProvider.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
-import org.eclipse.jpt.common.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotationDefinition;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-
-/**
- * Delegate to annotation definition providers.
- * The platform factory will build an instance of this annotation provider,
- * passing in the appropriate array of annotation definition providers necessary
- * to build the annotations for the platform (vendor and/or version).
- */
-public final class GenericAnnotationProvider
- implements AnnotationProvider
-{
- private final AnnotationDefinition[] annotationDefinitions;
-
- private final NestableAnnotationDefinition[] nestableAnnotationDefinitions;
-
- public GenericAnnotationProvider(AnnotationDefinition[] annotationDefinitions, NestableAnnotationDefinition[] nestableAnnotationDefinitions) {
- super();
- this.annotationDefinitions = annotationDefinitions;
- this.nestableAnnotationDefinitions = nestableAnnotationDefinitions;
- }
-
-
- protected Iterable<AnnotationDefinition> getAnnotationDefinitions() {
- return new ArrayIterable<AnnotationDefinition>(this.annotationDefinitions);
- }
-
- protected AnnotationDefinition getAnnotationDefinition(String annotationName) {
- for (AnnotationDefinition annotationDefinition : this.annotationDefinitions) {
- if (annotationDefinition.getAnnotationName().equals(annotationName)) {
- return annotationDefinition;
- }
- }
- return null;
- }
-
- public Iterable<String> getAnnotationNames() {
- return new TransformationIterable<AnnotationDefinition, String>(getAnnotationDefinitions()) {
- @Override
- protected String transform(AnnotationDefinition annotationDefinition) {
- return annotationDefinition.getAnnotationName();
- }
- };
- }
-
- public Iterable<String> getContainerAnnotationNames() {
- return new TransformationIterable<NestableAnnotationDefinition, String>(getNestableAnnotationDefinitions()) {
- @Override
- protected String transform(NestableAnnotationDefinition annotationDefinition) {
- return annotationDefinition.getContainerAnnotationName();
- }
- };
- }
-
- public Iterable<String> getNestableAnnotationNames() {
- return new TransformationIterable<NestableAnnotationDefinition, String>(getNestableAnnotationDefinitions()) {
- @Override
- protected String transform(NestableAnnotationDefinition annotationDefinition) {
- return annotationDefinition.getNestableAnnotationName();
- }
- };
- }
-
- public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element, String annotationName) {
- return this.getAnnotationDefinition(annotationName).buildAnnotation(parent, element);
- }
-
- public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) {
- return this.getAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation);
- }
-
- public NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation, int index) {
- return this.getNestableAnnotationDefinition(jdtAnnotation.getElementName()).buildAnnotation(parent, jdtAnnotation, index);
- }
-
- public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent, String annotationName) {
- return this.getAnnotationDefinition(annotationName).buildNullAnnotation(parent);
- }
-
- protected Iterable<NestableAnnotationDefinition> getNestableAnnotationDefinitions() {
- return new ArrayIterable<NestableAnnotationDefinition>(this.nestableAnnotationDefinitions);
- }
-
- protected NestableAnnotationDefinition getNestableAnnotationDefinition(String annotationName) {
- for (NestableAnnotationDefinition annotationDefinition : this.nestableAnnotationDefinitions) {
- if (annotationDefinition.getNestableAnnotationName().equals(annotationName)) {
- return annotationDefinition;
- }
- }
- return null;
- }
-
- public NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement element, String annotationName, int index) {
- return this.getNestableAnnotationDefinition(annotationName).buildAnnotation(parent, element, index);
- }
-
- public String getNestableAnnotationName(String containerAnnotationName) {
- return getNestableAnnotationDefinitionForContainer(containerAnnotationName).getNestableAnnotationName();
- }
-
- public String getContainerAnnotationName(String nestableAnnotationName) {
- return getNestableAnnotationDefinition(nestableAnnotationName).getContainerAnnotationName();
- }
-
- public String getNestableElementName(String nestableAnnotationName) {
- return getNestableAnnotationDefinition(nestableAnnotationName).getElementName();
- }
-
- private NestableAnnotationDefinition getNestableAnnotationDefinitionForContainer(String containerAnnotationName) {
- for (NestableAnnotationDefinition nestableAnnotationDefinition : getNestableAnnotationDefinitions()) {
- if (nestableAnnotationDefinition.getContainerAnnotationName().equals(containerAnnotationName)) {
- return nestableAnnotationDefinition;
- }
- }
- return null;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptCommonCorePlugin.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptCommonCorePlugin.java
deleted file mode 100644
index f7e06e39bf..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptCommonCorePlugin.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jpt.common.core.internal.JptPlugin;
-import org.eclipse.jpt.common.core.internal.libval.LibraryValidatorManager;
-import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
-import org.eclipse.jpt.common.core.libval.LibraryValidator;
-import org.osgi.framework.BundleContext;
-
-// TODO bjv move to *private* internal package and move all public stuff to adapters etc.
-public class JptCommonCorePlugin
- extends JptPlugin
-{
-
- // ********** public constants **********
-
- /**
- * The plug-in identifier of the jpt common core support
- * (value <code>"org.eclipse.jpt.common.core"</code>).
- */
- public static final String PLUGIN_ID = "org.eclipse.jpt.common.core"; //$NON-NLS-1$
- public static final String PLUGIN_ID_ = PLUGIN_ID + '.';
-
-
- /**
- * The content type for Java source code files.
- */
- public static final IContentType JAVA_SOURCE_CONTENT_TYPE = getContentType(JavaCore.JAVA_SOURCE_CONTENT_TYPE);
-
- /**
- * The resource type for Java source code files
- */
- public static final JptResourceType JAVA_SOURCE_RESOURCE_TYPE = new JptResourceType(JAVA_SOURCE_CONTENT_TYPE);
-
- /**
- * The content type for Java archives (JARs).
- */
- public static final IContentType JAR_CONTENT_TYPE = getJptContentType("jar"); //$NON-NLS-1$
-
- /**
- * The resource type for Java archives (JARs).
- */
- public static final JptResourceType JAR_RESOURCE_TYPE = new JptResourceType(JptCommonCorePlugin.JAR_CONTENT_TYPE);
-
- /**
- * The content type for package-info Java code files.
- */
- public static final IContentType JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE = getJptContentType("javaPackageInfo"); //$NON-NLS-1$
-
- /**
- * The resource type for package-info Java code files
- */
- public static final JptResourceType JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE = new JptResourceType(JAVA_SOURCE_PACKAGE_INFO_CONTENT_TYPE);
-
-
- private static final String JPT_CONTENT_PREFIX = PLUGIN_ID_ + "content"; //$NON-NLS-1$
-
- private static final String JPT_CONTENT_PREFIX_ = JPT_CONTENT_PREFIX + '.';
-
- private static IContentType getJptContentType(String jptContentType) {
- return getContentType(JPT_CONTENT_PREFIX_ + jptContentType);
- }
-
- private static IContentType getContentType(String contentType) {
- return Platform.getContentTypeManager().getContentType(contentType);
- }
-
- public static Iterable<LibraryValidator> getLibraryValidators(
- JptLibraryProviderInstallOperationConfig config) {
- return LibraryValidatorManager.instance().getLibraryValidators(config);
- }
-
- // ********** singleton **********
-
- private static JptCommonCorePlugin INSTANCE;
-
- /**
- * Return the singleton Dali common core plug-in.
- */
- public static JptCommonCorePlugin instance() {
- return INSTANCE;
- }
-
-
- // ********** public static methods **********
-
- /**
- * Log the specified message.
- */
- public static void log(String msg) {
- INSTANCE.logError(msg);
- }
-
- /**
- * Log the specified exception or error.
- */
- public static void log(Throwable throwable) {
- INSTANCE.logError(throwable);
- }
-
- /**
- * Log the specified message and exception or error.
- */
- public static void log(String msg, Throwable throwable) {
- INSTANCE.logError(msg, throwable);
- }
-
-
- // ********** plug-in implementation **********
-
- public JptCommonCorePlugin() {
- super();
- if (INSTANCE != null) {
- throw new IllegalStateException();
- }
- // this convention is *wack*... ~bjv
- INSTANCE = this;
- }
-
- @Override
- public synchronized void start(BundleContext context) throws Exception {
- super.start(context);
- // nothing yet...
- }
-
- @Override
- public synchronized void stop(BundleContext context) throws Exception {
- try {
- // nothing yet...
- } finally {
- super.stop(context);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceModel.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceModel.java
deleted file mode 100644
index f183add042..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceModel.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core;
-
-import org.eclipse.core.resources.IFile;
-
-/**
- * Listeners are notified whenever anything in the JPT resource model changes.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 2.3
- * @since 2.2
- */
-public interface JptResourceModel {
- /**
- * Return the model's resource type. This can change.
- * Return <code>null</code> if the resource type cannot be determined,
- * the content type is <code>null</code> or the version is <code>null</code>.
- */
- JptResourceType getResourceType();
-
- /**
- * Return the model's file.
- */
- IFile getFile();
-
- /**
- * Changes to the resource model result in events.
- * In particular, the JPA project performs an "update" whenever a resource
- * model changes.
- */
- void addResourceModelListener(JptResourceModelListener listener);
-
- /**
- * @see #addResourceModelListener(JptResourceModelListener)
- */
- void removeResourceModelListener(JptResourceModelListener listener);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceModelListener.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceModelListener.java
deleted file mode 100644
index 5cca6fe240..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceModelListener.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core;
-
-import java.util.EventListener;
-import org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl;
-
-/**
- * The listener is notified whenever anything in the JPA resource model changes.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 2.3
- * @since 2.2
- */
-public interface JptResourceModelListener
- extends EventListener
-{
- void resourceModelChanged(JptResourceModel jpaResourceModel);
-
- /**
- * Modified resource is closed without saving
- * @see TranslatorResourceImpl#isReverting()
- */
- void resourceModelReverted(JptResourceModel jpaResourceModel);
-
- void resourceModelUnloaded(JptResourceModel jpaResourceModel);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceType.java
deleted file mode 100644
index e86355e266..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/JptResourceType.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core;
-
-import org.eclipse.core.runtime.content.IContentType;
-
-/**
- * Describes the file content type and version for JPA resources.
- * This is a value object that defines an {@link #equals(Object)} method.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 2.3
- * @since 2.3
- */
-public class JptResourceType
-{
- private final IContentType contentType;
-
- private final String version;
-
-
- /**
- * Version used when version can not be determined or when there is no
- * sense of version (e.g. Java).
- */
- public static final String UNDETERMINED_VERSION = "<undetermined>"; //$NON-NLS-1$
-
-
- public JptResourceType(IContentType contentType) {
- this(contentType, UNDETERMINED_VERSION);
- }
-
- public JptResourceType(IContentType contentType, String version) {
- super();
- if (contentType == null) {
- throw new NullPointerException("content type"); //$NON-NLS-1$
- }
- if (version == null) {
- throw new NullPointerException("version"); //$NON-NLS-1$
- }
- this.contentType = contentType;
- this.version = version;
- }
-
-
- public IContentType getContentType() {
- return this.contentType;
- }
-
- public String getVersion() {
- return this.version;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if ((obj == null) || (obj.getClass() != this.getClass())) {
- return false;
- }
- JptResourceType other = (JptResourceType) obj;
- return this.contentType.equals(other.contentType) && this.version.equals(other.version);
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int hash = 17;
- hash = hash * prime + this.contentType.hashCode();
- hash = hash * prime + this.version.hashCode();
- return hash;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(this.getClass().getSimpleName());
- sb.append("(content = "); //$NON-NLS-1$
- sb.append(this.contentType);
- sb.append(", "); //$NON-NLS-1$
- sb.append("version = "); //$NON-NLS-1$
- sb.append(this.version);
- sb.append(')');
- return sb.toString();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptCommonCoreMessages.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptCommonCoreMessages.java
deleted file mode 100644
index b9e6e40681..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptCommonCoreMessages.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Localized messages used by Dali common core.
- */
-public class JptCommonCoreMessages {
-
- public static String DALI_JOB_NAME;
- public static String DALI_EVENT_HANDLER_THREAD_NAME;
- public static String GENERATION_CREATING_LAUNCH_CONFIG_TASK;
- public static String GENERATION_SAVING_LAUNCH_CONFIG_TASK;
- public static String GENERATION_LAUNCHING_CONFIG_TASK;
- public static String REGISTRY_MISSING_ATTRIBUTE;
- public static String REGISTRY_INVALID_VALUE;
- public static String REGISTRY_DUPLICATE;
- public static String REGISTRY_FAILED_CLASS_LOAD;
- public static String REGISTRY_FAILED_INTERFACE_ASSIGNMENT;
- public static String REGISTRY_FAILED_INSTANTIATION;
- public static String USER_LIBRARY_VALIDATOR__CLASS_NOT_FOUND;
- public static String VALIDATE_CONTAINER_NOT_SPECIFIED;
- public static String VALIDATE_FILE_NAME_NOT_SPECIFIED;
- public static String VALIDATE_FILE_ALREADY_EXISTS;
-
- private static final String BUNDLE_NAME = "jpt_common_core"; //$NON-NLS-1$
- private static final Class<?> BUNDLE_CLASS = JptCommonCoreMessages.class;
- static {
- NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
- }
-
- private JptCommonCoreMessages() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptPlugin.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptPlugin.java
deleted file mode 100644
index 52be7123d1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/JptPlugin.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.osgi.service.debug.DebugOptions;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Common Dali plug-in behavior.
- */
-public abstract class JptPlugin
- extends Plugin
-{
- protected BundleContext bundleContext;
- protected ServiceTracker<DebugOptions, DebugOptions> debugOptionsServiceTracker;
-
-
- protected JptPlugin() {
- super();
- }
-
-
- // ********** logging **********
-
- /**
- * Log the specified message with a severity of
- * {@link IStatus#ERROR ERROR}.
- * @see #log(int, String)
- * @see IStatus
- */
- public void logError(String message) {
- this.log(IStatus.ERROR, message);
- }
-
- /**
- * Log the specified message with the specified severity.
- * @see IStatus#getSeverity()
- */
- public void log(int severity, String message) {
- this.log(severity, message, null);
- }
-
- /**
- * Log the specified exception or error with a severity of
- * {@link IStatus#ERROR ERROR}.
- * @see #log(int, Throwable)
- * @see IStatus
- */
- public void logError(Throwable throwable) {
- this.log(IStatus.ERROR, throwable);
- }
-
- /**
- * Log the specified exception or error with the specified severity.
- * @see IStatus#getSeverity()
- */
- public void log(int severity, Throwable throwable) {
- this.log(severity, throwable.getLocalizedMessage(), throwable);
- }
-
- /**
- * Log the specified message and exception or error with a severity of
- * {@link IStatus#ERROR ERROR}.
- * @see #log(int, String, Throwable)
- * @see IStatus
- */
- public void logError(String msg, Throwable throwable) {
- this.log(IStatus.ERROR, msg, throwable);
- }
-
- /**
- * Log the specified message and exception or error
- * with the specified severity.
- * @see IStatus#getSeverity()
- * @see IStatus#getCode()
- */
- public void log(int severity, String msg, Throwable throwable) {
- this.log(severity, IStatus.OK, msg, throwable);
- }
-
- /**
- * Log the specified message and exception or error
- * with the specified severity and code.
- * @see IStatus#getSeverity()
- * @see IStatus#getCode()
- */
- public void log(int severity, int code, String msg, Throwable throwable) {
- this.getLog().log(new Status(severity, this.getPluginID(), code, msg, throwable));
- }
-
-
- // ********** debug options **********
-
- /**
- * Return the specified debug option as a <code>boolean</code> value.
- * Return <code>false</code> if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public boolean getBooleanDebugOption(String option) {
- return this.getBooleanDebugOption(option, false);
- }
-
- /**
- * Return the specified debug option as a <code>boolean</code> value.
- * Return the specified default value if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public boolean getBooleanDebugOption(String option, boolean defaultValue) {
- String value = this.getDebugOption(option);
- return (value == null) ? defaultValue : Boolean.parseBoolean(value.trim());
- }
-
- /**
- * Return the specified debug option as an <code>int</code> value.
- * Return <code>-1</code> if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public int getIntegerDebugOption(String option) {
- return this.getIntegerDebugOption(option, -1);
- }
-
- /**
- * Return the specified debug option as an <code>int</code> value.
- * Return the specified default value if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public int getIntegerDebugOption(String option, int defaultValue) {
- String value = this.getDebugOption(option);
- return (value == null) ? defaultValue : Integer.parseInt(value.trim());
- }
-
- /**
- * Return the specified debug option.
- * Return <code>null</code> if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public String getDebugOption(String option) {
- return this.getDebugOption(option, null);
- }
-
- /**
- * Return the specified debug option.
- * Return the specified default value if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public String getDebugOption(String option, String defaultValue) {
- return this.isDebugging() ? this.getDebugOption_(option, defaultValue) : defaultValue;
- }
-
- protected String getDebugOption_(String option, String defaultValue) {
- if (StringTools.stringIsEmpty(option)) {
- throw new IllegalArgumentException("debug option cannot be blank"); //$NON-NLS-1$
- }
- String value = this.getDebugOption_(option);
- return (value != null) ? value : defaultValue;
- }
-
- protected String getDebugOption_(String option) {
- DebugOptions debugOptions = this.getDebugOptions();
- return (debugOptions == null) ? null : debugOptions.getOption(this.getPluginDebugOption() + option);
- }
-
- protected DebugOptions getDebugOptions() {
- ServiceTracker<DebugOptions, DebugOptions> tracker = this.getDebugOptionsServiceTracker();
- return (tracker == null) ? null : tracker.getService();
- }
-
- private synchronized ServiceTracker<DebugOptions, DebugOptions> getDebugOptionsServiceTracker() {
- if (this.isActive() && (this.debugOptionsServiceTracker == null)) {
- this.debugOptionsServiceTracker = this.buildDebugOptionsServiceTracker();
- this.debugOptionsServiceTracker.open();
- }
- return this.debugOptionsServiceTracker;
- }
-
- private ServiceTracker<DebugOptions, DebugOptions> buildDebugOptionsServiceTracker() {
- return new ServiceTracker<DebugOptions, DebugOptions>(this.bundleContext, DebugOptions.class, null);
- }
-
- /**
- * Return the plug-in's debug option path.
- */
- protected String getPluginDebugOption() {
- return this.getPluginID() + DEBUG_OPTION_SCOPE;
- }
- protected static final String DEBUG_OPTION_SCOPE = "/debug/"; //$NON-NLS-1$
-
-
- // ********** plug-in lifecycle **********
-
- @Override
- public synchronized void start(BundleContext context) throws Exception {
- super.start(context);
- this.bundleContext = context;
- }
-
- @Override
- public synchronized void stop(BundleContext context) throws Exception {
- try {
- this.stop_();
- } finally {
- this.bundleContext = null;
- super.stop(context);
- }
- }
-
- protected void stop_() throws Exception {
- if (this.debugOptionsServiceTracker != null) {
- this.debugOptionsServiceTracker.close();
- this.debugOptionsServiceTracker = null;
- }
- }
-
-
- // ********** misc **********
-
- public String getPluginID() {
- return this.getBundle().getSymbolicName();
- }
-
- /**
- * Return whether the plug-in is active; i.e. it has been
- * {@link #start(BundleContext) started}.
- */
- public synchronized boolean isActive() {
- return this.bundleContext != null;
- }
-
- /**
- * Return whether the plug-in is inactive; i.e. it has been
- * {@link #stop(BundleContext) stopped} or not yet
- * {@link #start(BundleContext) started}.
- */
- public boolean isInactive() {
- return ! this.isActive();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/LibraryProviderPropertyTester.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/LibraryProviderPropertyTester.java
deleted file mode 100644
index 0f3e21f034..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/LibraryProviderPropertyTester.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
-
-/**
- * Property tester for {@link ILibraryProvider}.
- * See <code>org.eclipse.jpt.common.core/plugin.xml</code>
- */
-public class LibraryProviderPropertyTester
- extends PropertyTester
-{
- public static final String ID = "id"; //$NON-NLS-1$
- public static final String EXTENDS_ID = "extendsId"; //$NON-NLS-1$
-
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if (receiver instanceof ILibraryProvider) {
- return this.test((ILibraryProvider) receiver, property, expectedValue);
- }
- return false;
- }
-
- private boolean test(ILibraryProvider libraryProvider, String property, Object expectedValue) {
- if (property.equals(ID)) {
- return libraryProvider.getId().equals(expectedValue);
- }
- if (property.equals(EXTENDS_ID)) {
- while (libraryProvider != null) {
- if (libraryProvider.getId().equals(expectedValue)) {
- return true;
- }
- libraryProvider = libraryProvider.getBaseProvider();
- }
- return false;
- }
- return false;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/gen/AbstractJptGenerator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/gen/AbstractJptGenerator.java
deleted file mode 100644
index 22dd3b8d85..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/gen/AbstractJptGenerator.java
+++ /dev/null
@@ -1,390 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2008, 2011 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.common.core.internal.gen;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.ILaunchesListener2;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
-import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.JptCommonCoreMessages;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.osgi.framework.Bundle;
-
-public abstract class AbstractJptGenerator
-{
- public static final String PLUGINS_DIR = "plugins/"; //$NON-NLS-1$
-
- private IVMInstall jre;
- protected ILaunchConfigurationWorkingCopy launchConfig;
- private ILaunch launch;
-
- protected final IJavaProject javaProject;
- protected final String projectLocation;
-
- private boolean isDebug = false;
-
- // ********** constructors **********
-
- protected AbstractJptGenerator(IJavaProject javaProject) {
- super();
- this.javaProject = javaProject;
- this.projectLocation = javaProject.getProject().getLocation().toString();
- this.initialize();
- }
-
- // ********** abstract methods **********
-
- protected abstract String getMainType();
-
- protected abstract String getLaunchConfigName();
-
- protected String getBootstrapJarPrefix() {
- throw new RuntimeException("Bootstrap JAR not specified."); //$NON-NLS-1$;
- }
-
- protected abstract void specifyProgramArguments();
-
- protected abstract List<String> buildClasspath() throws CoreException;
-
- // ********** behavior **********
-
- protected void initialize() {
- try {
- this.jre = this.getProjectJRE();
- if (this.jre == null) {
- String message = "Could not identify the VM."; //$NON-NLS-1$
- throw new RuntimeException(message);
- }
- this.launchConfig = this.buildLaunchConfiguration();
- }
- catch (CoreException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected void generate(IProgressMonitor monitor) {
- SubMonitor sm = SubMonitor.convert(monitor, 10);
- this.preGenerate(sm.newChild(2));
- if (sm.isCanceled()) {
- throw new OperationCanceledException();
- }
- sm.subTask(JptCommonCoreMessages.GENERATION_CREATING_LAUNCH_CONFIG_TASK);
- this.initializeLaunchConfiguration();
- sm.worked(1);
- if (sm.isCanceled()) {
- throw new OperationCanceledException();
- }
-
- this.addLaunchListener();
- sm.worked(1);
-
- if (sm.isCanceled()) {
- throw new OperationCanceledException();
- }
- this.launch = this.saveAndLaunchConfig(sm.newChild(6));
- }
-
- private void initializeLaunchConfiguration() {
- this.specifyJRE();
-
- this.specifyProject();
- this.specifyMainType();
-
- this.specifyProgramArguments();
- this.specifyWorkingDir();
-
- this.specifyClasspathProperties();
- }
-
- private void addLaunchListener() {
-
- this.getLaunchManager().addLaunchListener(this.buildLaunchListener());
- }
-
- protected abstract void preGenerate(IProgressMonitor monitor);
-
- protected void postGenerate() {
- try {
- if( ! this.isDebug) {
- this.removeLaunchConfiguration();
- }
- this.refreshProject();
- }
- catch(CoreException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected void refreshProject() throws CoreException {
- this.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- }
-
- private ILaunchesListener2 buildLaunchListener() {
- return new ILaunchesListener2() {
-
- public void launchesTerminated(ILaunch[] launches) {
- for(int i = 0; i < launches.length; i++) {
- ILaunch launch = launches[i];
- if (launch.equals(AbstractJptGenerator.this.getLaunch())) {
- try {
- AbstractJptGenerator.this.postGenerate();
- AbstractJptGenerator.this.launch = null;
- }
- finally {
- AbstractJptGenerator.this.getLaunchManager().removeLaunchListener(this);
- }
- return;
- }
- }
- }
-
- public void launchesAdded(ILaunch[] launches) {
- // not interested to this event
- }
-
- public void launchesChanged(ILaunch[] launches) {
- // not interested to this event
- }
-
- public void launchesRemoved(ILaunch[] launches) {
- // not interested to this event
- }
- };
- }
-
- // ********** Setting Launch Configuration **********
-
- protected void specifyJRE() {
- String jreName = this.jre.getName();
- String vmId = this.jre.getVMInstallType().getId();
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, jreName);
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, vmId);
- }
-
- private void specifyProject() {
- String projectName = this.getProject().getName();
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
- }
-
- protected IProject getProject() {
- return this.javaProject.getProject();
- }
-
- private void specifyMainType() {
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, this.getMainType());
- }
-
- protected void specifyClasspathProperties() {
- List<String> classpath;
- try {
- classpath = this.buildClasspath();
- }
- catch (CoreException e) {
- throw new RuntimeException("An error occured generating a memento", e); //$NON-NLS-1$
- }
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH, classpath);
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_DEFAULT_CLASSPATH, false);
- }
-
- // ********** ClasspathEntry **********
-
- protected IRuntimeClasspathEntry getSystemLibraryClasspathEntry() throws CoreException {
-
- IPath systemLibsPath = new Path(JavaRuntime.JRE_CONTAINER);
- return JavaRuntime.newRuntimeContainerClasspathEntry(systemLibsPath, IRuntimeClasspathEntry.STANDARD_CLASSES);
- }
-
- protected IRuntimeClasspathEntry getDefaultProjectClasspathEntry() {
-
- IRuntimeClasspathEntry projectEntry = JavaRuntime.newDefaultProjectClasspathEntry(this.javaProject);
- projectEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-
- return projectEntry;
- }
-
- protected static IRuntimeClasspathEntry getArchiveClasspathEntry(IPath archivePath) {
- IRuntimeClasspathEntry archiveEntry = JavaRuntime.newArchiveRuntimeClasspathEntry(archivePath);
- archiveEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-
- return archiveEntry;
- }
-
- protected static IRuntimeClasspathEntry getVariableRuntimeClasspathEntry(IPath path) {
- IRuntimeClasspathEntry varEntry = JavaRuntime.newVariableRuntimeClasspathEntry(path);
- varEntry.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
- return varEntry;
- }
-
- // ********** LaunchConfig **********
-
- private ILaunch saveAndLaunchConfig(IProgressMonitor monitor) {
- SubMonitor sm = SubMonitor.convert(monitor, 10);
- ILaunchConfiguration configuration = null;
- ILaunch result = null;
- try {
- sm.subTask(JptCommonCoreMessages.GENERATION_SAVING_LAUNCH_CONFIG_TASK);
- configuration = this.launchConfig.doSave();
- }
- catch (CoreException saveException) {
- throw new RuntimeException("Could not save LaunchConfig", saveException); //$NON-NLS-1$
- }
- sm.worked(1);
- if (sm.isCanceled()) {
- throw new OperationCanceledException();
- }
- try {
- sm.subTask(JptCommonCoreMessages.GENERATION_LAUNCHING_CONFIG_TASK);
- result = configuration.launch(ILaunchManager.RUN_MODE, sm.newChild(9));
- }
- catch (CoreException launchException) {
- throw new RuntimeException("An error occured during launch", launchException); //$NON-NLS-1$
- }
- return result;
- }
-
- // ********** Main arguments **********
-
- protected void appendDebugArgument(StringBuffer sb) {
- if (this.isDebug) {
- sb.append(" -debug"); //$NON-NLS-1$
- }
- }
-
- // ********** Queries **********
-
- protected ILaunch getLaunch() {
- return this.launch;
- }
-
- protected ILaunchManager getLaunchManager() {
- return DebugPlugin.getDefault().getLaunchManager();
- }
-
- private IVMInstall getProjectJRE() throws CoreException {
- return JavaRuntime.getVMInstall(this.javaProject);
- }
-
- // ********** Utilities **********
-
- protected IRuntimeClasspathEntry getBootstrapJarClasspathEntry() {
- return getArchiveClasspathEntry(this.buildBootstrapJarPath());
- }
-
- protected IPath buildBootstrapJarPath() {
- return this.findGenJarStartingWith(this.getBootstrapJarPrefix());
- }
-
- protected IPath findGenJarStartingWith(String genJarName) {
- try {
- File jarInstallDir = this.getBundleParentDir(JptCommonCorePlugin.PLUGIN_ID);
-
- List<File> result = new ArrayList<File>();
- this.findFileStartingWith(genJarName, jarInstallDir, result);
- if (result.isEmpty()) {
- throw new RuntimeException("Could not find: " + genJarName + "#.#.#v###.jar in: " + jarInstallDir); //$NON-NLS-1$ //$NON-NLS-2$
- }
- File genJarFile = result.get(0);
- String genJarPath = genJarFile.getCanonicalPath();
- return new Path(genJarPath);
- }
- catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- // ********** private methods **********
-
- private File getBundleParentDir(String bundleName) throws IOException {
-
- if (Platform.inDevelopmentMode()) {
- Location eclipseHomeLoc = Platform.getInstallLocation();
- String eclipseHome = eclipseHomeLoc.getURL().getPath();
- if ( ! eclipseHome.endsWith(PLUGINS_DIR)) {
- eclipseHome += PLUGINS_DIR;
- }
- return new File(eclipseHome);
- }
- Bundle bundle = Platform.getBundle(bundleName);
- return FileLocator.getBundleFile(bundle).getParentFile();
- }
-
- private ILaunchConfigurationWorkingCopy buildLaunchConfiguration() throws CoreException {
- this.removeLaunchConfiguration();
-
- ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
-
- return type.newInstance(null, this.getLaunchConfigName());
- }
-
- private void removeLaunchConfiguration() throws CoreException {
-
- ILaunchManager manager = this.getLaunchManager();
- ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
-
- ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
- for (int i = 0; i < configurations.length; i++) {
- ILaunchConfiguration configuration = configurations[i];
- if (configuration.getName().equals(this.getLaunchConfigName())) {
- configuration.delete();
- break;
- }
- }
- }
-
- private void findFileStartingWith(String fileName, File directory, List<? super File> list) {
- if(directory.listFiles() == null) {
- throw new RuntimeException("Could not find directory: " + directory); //$NON-NLS-1$
- }
- for (File file : directory.listFiles()) {
- if (file.getName().startsWith(fileName)) {
- list.add(file);
- }
- if (file.isDirectory()) {
- this.findFileStartingWith(fileName, file, list);
- }
- }
- }
-
- private void specifyWorkingDir() {
- File workingDir = new Path(this.projectLocation).toFile();
- this.launchConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, workingDir.getAbsolutePath());
- }
-
- protected void setDebug(boolean isDebug) {
- this.isDebug = isDebug;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libprov/JptOsgiBundlesLibraryProviderInstallOperationConfig.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libprov/JptOsgiBundlesLibraryProviderInstallOperationConfig.java
deleted file mode 100644
index b91c73b440..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libprov/JptOsgiBundlesLibraryProviderInstallOperationConfig.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.libprov;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
-import org.eclipse.jpt.common.core.libval.LibraryValidator;
-import org.eclipse.jst.j2ee.internal.common.classpath.WtpOsgiBundlesLibraryProviderInstallOperationConfig;
-
-
-public abstract class JptOsgiBundlesLibraryProviderInstallOperationConfig
- extends WtpOsgiBundlesLibraryProviderInstallOperationConfig
- implements JptLibraryProviderInstallOperationConfig {
-
- protected JptOsgiBundlesLibraryProviderInstallOperationConfig() {
- super();
- }
-
-
- @Override
- public synchronized IStatus validate() {
- IStatus status = super.validate();
- if (! status.isOK()) {
- return status;
- }
-
- for (LibraryValidator libraryValidator : JptCommonCorePlugin.getLibraryValidators(this)) {
- status = libraryValidator.validate(this);
- if (! status.isOK()) {
- return status;
- }
- }
-
- return Status.OK_STATUS;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libprov/JptUserLibraryProviderInstallOperationConfig.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libprov/JptUserLibraryProviderInstallOperationConfig.java
deleted file mode 100644
index 224f52afe2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libprov/JptUserLibraryProviderInstallOperationConfig.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.libprov;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
-import org.eclipse.jpt.common.core.libval.LibraryValidator;
-import org.eclipse.jst.j2ee.internal.common.classpath.WtpUserLibraryProviderInstallOperationConfig;
-
-
-public abstract class JptUserLibraryProviderInstallOperationConfig
- extends WtpUserLibraryProviderInstallOperationConfig
- implements JptLibraryProviderInstallOperationConfig {
-
- protected JptUserLibraryProviderInstallOperationConfig() {
- super();
- }
-
-
- @Override
- public synchronized IStatus validate() {
- IStatus status = super.validate();
- if (! status.isOK()) {
- return status;
- }
-
- for (LibraryValidator libraryValidator : JptCommonCorePlugin.getLibraryValidators(this)) {
- status = libraryValidator.validate(this);
- if (! status.isOK()) {
- return status;
- }
- }
-
- return Status.OK_STATUS;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibValUtil.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibValUtil.java
deleted file mode 100644
index 34afb0c83b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibValUtil.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.libval;
-
-import static org.eclipse.jst.common.project.facet.core.internal.FacetedProjectFrameworkJavaPlugin.PLUGIN_ID;
-import java.io.File;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.common.core.internal.JptCommonCoreMessages;
-import org.eclipse.osgi.util.NLS;
-
-
-public class LibValUtil {
-
- public static IStatus validate(Iterable<IPath> libraryPaths, Set<String> classNames) {
- Set<String> classFileNames = new HashSet<String>();
- Map<String,String> classFileNameToClassName = new HashMap<String,String>();
- for (String className : classNames) {
- String classFileName = className.replace('.', '/') + ".class"; //$NON-NLS-1$
- classFileNames.add(classFileName);
- classFileNameToClassName.put(classFileName, className);
- }
-
- final Map<String,Integer> classAppearanceCounts = new HashMap<String,Integer>();
-
- for (String classFileName : classFileNames) {
- classAppearanceCounts.put(classFileName, 0);
- }
-
- for (IPath libraryPath : libraryPaths) {
- final File file = libraryPath.toFile();
-
- if (file.exists()) {
- ZipFile zip = null;
-
- try {
- zip = new ZipFile(file);
-
- for (Enumeration<? extends ZipEntry> itr = zip.entries(); itr.hasMoreElements(); ) {
- final ZipEntry zipEntry = itr.nextElement();
- final String name = zipEntry.getName();
-
- Integer count = classAppearanceCounts.get(name);
-
- if (count != null) {
- classAppearanceCounts.put(name, count + 1);
- }
- }
- }
- catch (IOException e) {}
- finally {
- if (zip != null) {
- try {
- zip.close();
- }
- catch (IOException e) {}
- }
- }
- }
- }
-
- for (Map.Entry<String,Integer> entry : classAppearanceCounts.entrySet()) {
- final int count = entry.getValue();
-
- if (count == 0) {
- final String classFileName = entry.getKey();
- final String className = classFileNameToClassName.get(classFileName);
- final String message =
- NLS.bind(JptCommonCoreMessages.USER_LIBRARY_VALIDATOR__CLASS_NOT_FOUND, className);
- return new Status(IStatus.ERROR, PLUGIN_ID, message);
- }
- }
-
- return Status.OK_STATUS;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorConfig.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorConfig.java
deleted file mode 100644
index 27a84ae9ba..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorConfig.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.libval;
-
-import static org.eclipse.jst.common.project.facet.core.internal.FacetedProjectFrameworkJavaPlugin.log;
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jpt.common.core.internal.utility.XPointTools;
-import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
-import org.eclipse.jpt.common.core.libval.LibraryValidator;
-
-public class LibraryValidatorConfig {
-
- public static final String CONFIG_EXPR_VAR = "config"; //$NON-NLS-1$
- public static final String LIBRARY_PROVIDER_EXPR_VAR = "libraryProvider"; //$NON-NLS-1$
-
-
- private String id;
- private String pluginId;
- private String className;
- private Expression enablementCondition;
-
-
- LibraryValidatorConfig() {
- super();
- }
-
-
- public String getId() {
- return this.id;
- }
-
- void setId(String id) {
- this.id = id;
- }
-
- public String getPluginId() {
- return this.pluginId;
- }
-
- void setPluginId(String pluginId) {
- this.pluginId = pluginId;
- }
-
- public String getClassName() {
- return this.className;
- }
-
- void setClassName(String className) {
- this.className = className;
- }
-
- public Expression getEnablementCondition() {
- return this.enablementCondition;
- }
-
- void setEnablementCondition(Expression enablementCondition) {
- this.enablementCondition = enablementCondition;
- }
-
- public LibraryValidator getLibraryValidator() {
- return XPointTools.instantiate(
- this.pluginId, LibraryValidatorManager.QUALIFIED_EXTENSION_POINT_ID,
- this.className, LibraryValidator.class);
- }
-
- public boolean isEnabledFor(JptLibraryProviderInstallOperationConfig config) {
- EvaluationContext evalContext = new EvaluationContext(null, config);
- evalContext.setAllowPluginActivation(true);
- evalContext.addVariable(CONFIG_EXPR_VAR, config);
- evalContext.addVariable(LIBRARY_PROVIDER_EXPR_VAR, config.getLibraryProvider());
-
- if (this.enablementCondition != null) {
- try {
- EvaluationResult evalResult = this.enablementCondition.evaluate(evalContext);
-
- if (evalResult == EvaluationResult.FALSE) {
- return false;
- }
- }
- catch (CoreException e) {
- log(e);
- }
- }
-
- return true;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorManager.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorManager.java
deleted file mode 100644
index ce7c2eb179..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/libval/LibraryValidatorManager.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.libval;
-
-import static org.eclipse.jpt.common.core.internal.utility.XPointTools.*;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.ExpressionConverter;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.XPointTools.XPointException;
-import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
-import org.eclipse.jpt.common.core.libval.LibraryValidator;
-import org.eclipse.jpt.common.utility.internal.KeyedSet;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-
-public class LibraryValidatorManager {
-
- public static final String EXTENSION_POINT_ID = "libraryValidators"; //$NON-NLS-1$
- public static final String QUALIFIED_EXTENSION_POINT_ID = JptCommonCorePlugin.PLUGIN_ID_ + EXTENSION_POINT_ID;
- public static final String LIBRARY_VALIDATOR_ELEMENT = "libraryValidator"; //$NON-NLS-1$
- public static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$
- public static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
- public static final String ENABLEMENT_ELEMENT = "enablement"; //$NON-NLS-1$
-
-
- private static LibraryValidatorManager INSTANCE = new LibraryValidatorManager();
-
-
- public static LibraryValidatorManager instance() {
- return INSTANCE;
- }
-
-
- private KeyedSet<String, LibraryValidatorConfig> libraryValidatorConfigs;
-
-
- private LibraryValidatorManager() {
- this.libraryValidatorConfigs = new KeyedSet<String, LibraryValidatorConfig>();
- readExtensions();
- }
-
-
- /**
- * Return the {@link LibraryValidator}s
- */
- public Iterable<LibraryValidator> getLibraryValidators(final JptLibraryProviderInstallOperationConfig config) {
- return new FilteringIterable<LibraryValidator>(
- new TransformationIterable<LibraryValidatorConfig, LibraryValidator>(
- new FilteringIterable<LibraryValidatorConfig>(
- this.libraryValidatorConfigs.getItemSet()) {
- @Override
- protected boolean accept(LibraryValidatorConfig o) {
- return o.isEnabledFor(config);
- }
- }) {
- @Override
- protected LibraryValidator transform(LibraryValidatorConfig o) {
- return o.getLibraryValidator();
- }
- }) {
- @Override
- protected boolean accept(LibraryValidator o) {
- return o != null;
- }
- };
- }
-
- private void readExtensions() {
- final IExtensionRegistry registry = Platform.getExtensionRegistry();
-
- final IExtensionPoint xpoint
- = registry.getExtensionPoint(QUALIFIED_EXTENSION_POINT_ID);
-
- if (xpoint == null) {
- throw new IllegalStateException();
- }
-
- final List<IConfigurationElement> configs = new ArrayList<IConfigurationElement>();
-
- for (IExtension extension : xpoint.getExtensions()) {
- for (IConfigurationElement element : extension.getConfigurationElements()) {
- configs.add(element);
- }
- }
-
- for (IConfigurationElement element : configs) {
- if (element.getName().equals(LIBRARY_VALIDATOR_ELEMENT)) {
- readExtension(element);
- }
- }
- }
-
- private void readExtension(IConfigurationElement element) {
- try {
- final LibraryValidatorConfig lvConfig = new LibraryValidatorConfig();
-
- // plug-in id
- lvConfig.setPluginId(element.getContributor().getName());
-
- // resource locator id
- lvConfig.setId(findRequiredAttribute(element, ID_ATTRIBUTE));
-
- if (this.libraryValidatorConfigs.containsKey(lvConfig.getId())) {
- logDuplicateExtension(QUALIFIED_EXTENSION_POINT_ID, ID_ATTRIBUTE, lvConfig.getId());
- throw new XPointException();
- }
-
- // resource locator class name
- lvConfig.setClassName(findRequiredAttribute(element, CLASS_ATTRIBUTE));
-
- // enablement
- for (IConfigurationElement child : element.getChildren()) {
- String childName = child.getName();
- if (childName.equals(ENABLEMENT_ELEMENT)) {
- Expression expr;
- try {
- expr = ExpressionConverter.getDefault().perform(child);
- }
- catch (CoreException e) {
- log(e);
- throw new XPointException();
- }
- lvConfig.setEnablementCondition(expr);
- }
- }
-
- this.libraryValidatorConfigs.addItem(lvConfig.getId(), lvConfig);
- }
- catch (XPointException e) {
- // Ignore and continue. The problem has already been reported to the user
- // in the log.
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationDataModelProvider.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationDataModelProvider.java
deleted file mode 100644
index 1106f12032..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/AbstractJptFileCreationDataModelProvider.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.operations;
-
-import java.util.Set;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.JptCommonCoreMessages;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
-import org.eclipse.jpt.common.core.resource.ProjectResourceLocator;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelProvider;
-
-public abstract class AbstractJptFileCreationDataModelProvider
- extends AbstractDataModelProvider
- implements JptFileCreationDataModelProperties
-{
- protected AbstractJptFileCreationDataModelProvider() {
- super();
- }
-
-
- @Override
- public Set<String> getPropertyNames() {
- @SuppressWarnings("unchecked")
- Set<String> propertyNames = super.getPropertyNames();
- propertyNames.add(PROJECT);
- propertyNames.add(CONTAINER_PATH);
- propertyNames.add(FILE_NAME);
- return propertyNames;
- }
-
- @Override
- public Object getDefaultProperty(String propertyName) {
- if (propertyName.equals(CONTAINER_PATH)) {
- IContainer sourceLocation = getDefaultContainer();
- if (sourceLocation != null && sourceLocation.exists()) {
- return sourceLocation.getFullPath();
- }
- }
- else if (propertyName.equals(FILE_NAME)) {
- return getDefaultFileName();
- }
- return super.getDefaultProperty(propertyName);
- }
-
- protected abstract String getDefaultFileName();
-
-
- // **************** validation *********************************************
-
- @Override
- public IStatus validate(String propertyName) {
- IStatus status = Status.OK_STATUS;
- if (propertyName.equals(CONTAINER_PATH)
- || propertyName.equals(FILE_NAME)) {
- status = validateContainerPathAndFileName();
- }
- if (! status.isOK()) {
- return status;
- }
-
- return status;
- }
-
- protected IStatus validateContainerPathAndFileName() {
- IContainer container = getContainer();
- if (container == null) {
- // verifies container has been specified, but should be unnecessary in most cases.
- // there is almost always a default, and the new file wizard does this validation as well.
- return new Status(
- IStatus.ERROR, JptCommonCorePlugin.PLUGIN_ID,
- JptCommonCoreMessages.VALIDATE_CONTAINER_NOT_SPECIFIED);
- }
- String fileName = getStringProperty(FILE_NAME);
- if (StringTools.stringIsEmpty(fileName)) {
- // verifies file name has been specified, but should be unnecessary in most cases.
- // there is almost always a default, and the new file wizard does this validation as well.
- return new Status(
- IStatus.ERROR, JptCommonCorePlugin.PLUGIN_ID,
- JptCommonCoreMessages.VALIDATE_FILE_NAME_NOT_SPECIFIED);
- }
- if (container.getFile(new Path(fileName)).exists()) {
- // verifies file does not exist, but should be unnecessary in most cases.
- // the new file wizard does this validation as well.
- return new Status(
- IStatus.ERROR, JptCommonCorePlugin.PLUGIN_ID,
- JptCommonCoreMessages.VALIDATE_FILE_ALREADY_EXISTS);
- }
- return Status.OK_STATUS;
- }
-
-
- // **************** helper methods *****************************************
-
- protected IPath getContainerPath() {
- return (IPath) this.model.getProperty(CONTAINER_PATH);
- }
-
- protected IContainer getContainer() {
- IPath containerPath = getContainerPath();
- if (containerPath == null) {
- return null;
- }
- return PlatformTools.getContainer(containerPath);
- }
-
- protected IProject getProject() {
- return getProject(getContainer());
- }
-
- protected IProject getProject(IContainer container) {
- return (container == null) ? null : container.getProject();
- }
-
- /**
- * Return a best guess source location for the for the specified project
- */
- protected IContainer getDefaultContainer() {
- IProject project = (IProject) this.model.getProperty(PROJECT);
- if (project != null) {
- ProjectResourceLocator locator = (ProjectResourceLocator) project.getAdapter(ProjectResourceLocator.class);
- return locator.getDefaultResourceLocation();
- }
- return null;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/JptFileCreationDataModelProperties.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/JptFileCreationDataModelProperties.java
deleted file mode 100644
index 5c635c98c8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/operations/JptFileCreationDataModelProperties.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.operations;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-
-public interface JptFileCreationDataModelProperties
-{
- /**
- * Optional, type {@link IProject}, gives a clue as to the default container path
- */
- String PROJECT = "JptFileCreationDataModelProperties.PROJECT"; //$NON-NLS-1$
-
- /**
- * Required, type {@link IPath}, identifies the full path to the container in which
- * the file should be created
- */
- String CONTAINER_PATH = "JptFileCreationDataModelProperties.CONTAINER_PATH"; //$NON-NLS-1$
-
- /**
- * Required, type {@link String}, identifies the file name
- */
- String FILE_NAME = "JptFileCreationDataModelProperties.FILE_NAME"; //$NON-NLS-1$
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ModuleResourceLocator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ModuleResourceLocator.java
deleted file mode 100644
index d76318d249..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ModuleResourceLocator.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
-import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
-
-public class ModuleResourceLocator
- extends SimpleJavaResourceLocator
-{
- /**
- * Return the folder representing the <code>META-INF</code> runtime location.
- */
- @Override
- public IContainer getDefaultResourceLocation(IProject project) {
- return this.getRootFolder(project).getFolder(META_INF_PATH).getUnderlyingFolder();
- }
-
- @Override
- public IPath getResourcePath(IProject project, IPath runtimePath) {
- return this.getRootFolder(project).getFile(runtimePath).getWorkspaceRelativePath();
- }
-
- @Override
- public IPath getRuntimePath(IProject project, IPath resourcePath) {
- IVirtualFolder rootFolder = this.getRootFolder(project);
- IFile file = PlatformTools.getFile(resourcePath);
- IVirtualFile vFile = this.getVirtualFile(rootFolder, file);
- if (vFile != null) {
- return vFile.getRuntimePath().makeRelative();
- }
- // couldn't find it - try the super-case
- return super.getRuntimePath(project, resourcePath);
- }
-
- protected IVirtualFile getVirtualFile(IVirtualFolder vFolder, IFile file) {
- try {
- return this.getVirtualFile_(vFolder, file);
- } catch (CoreException ex) {
- JptCommonCorePlugin.log(ex);
- return null;
- }
- }
-
- protected IVirtualFile getVirtualFile_(IVirtualFolder vFolder, IFile file) throws CoreException {
- for (IVirtualResource vResource : vFolder.members()) {
- IVirtualFile vFile = this.getVirtualFile(vResource, file);
- if (vFile != null) {
- return vFile;
- }
- }
- return null;
- }
-
- protected IVirtualFile getVirtualFile(IVirtualResource vResource, IFile file) throws CoreException {
- switch (vResource.getType()) {
- case IVirtualResource.FILE:
- IVirtualFile vFile = (IVirtualFile) vResource;
- return file.equals(vFile.getUnderlyingResource()) ? vFile : null;
- case IVirtualResource.FOLDER:
- // recurse
- return this.getVirtualFile_((IVirtualFolder) vResource, file);
- default:
- return null;
- }
- }
-
- protected IVirtualFolder getRootFolder(IProject project) {
- return ComponentCore.createComponent(project).getRootFolder();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/PluginResourceLocator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/PluginResourceLocator.java
deleted file mode 100644
index 2e8f070000..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/PluginResourceLocator.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
-import org.eclipse.pde.core.project.IBundleProjectService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-public class PluginResourceLocator
- extends SimpleJavaResourceLocator
-{
- @Override
- public IContainer getDefaultResourceLocation(IProject project) {
- IContainer bundleRoot = this.getBundleRoot(project);
- return (bundleRoot != null) ?
- bundleRoot.getFolder(META_INF_PATH) :
- super.getDefaultResourceLocation(project);
- }
-
- @Override
- public IPath getResourcePath(IProject project, IPath runtimePath) {
- IContainer bundleRoot = this.getBundleRoot(project);
- if (bundleRoot != null) {
- IPath resourcePath = bundleRoot.getFullPath().append(runtimePath);
- if (project.getWorkspace().getRoot().getFile(resourcePath).exists()) {
- return resourcePath;
- }
- }
- return super.getResourcePath(project, runtimePath);
- }
-
- @Override
- public IPath getRuntimePath(IProject project, IPath resourcePath) {
- IContainer bundleRoot = this.getBundleRoot(project);
- if (bundleRoot != null) {
- IFile file = PlatformTools.getFile(resourcePath);
- if (bundleRoot.contains(file)) {
- return resourcePath.makeRelativeTo(bundleRoot.getFullPath());
- }
- }
- return super.getRuntimePath(project, resourcePath);
- }
-
- protected IContainer getBundleRoot(IProject project) {
- try {
- return this.getBundleRoot_(project);
- } catch (CoreException ex) {
- // problem creating description on an existing project
- JptCommonCorePlugin.log(ex);
- return null;
- }
- }
-
- protected IContainer getBundleRoot_(IProject project) throws CoreException {
- BundleContext bundleContext = JptCommonCorePlugin.instance().getBundle().getBundleContext();
- if (bundleContext == null) {
- return project;
- }
- ServiceReference<IBundleProjectService> serviceRef = bundleContext.getServiceReference(IBundleProjectService.class);
- if (serviceRef == null) {
- return project;
- }
- IBundleProjectService service = bundleContext.getService(serviceRef);
- if (service == null) {
- bundleContext.ungetService(serviceRef);
- return project;
- }
- IPath bundleRoot = service.getDescription(project).getBundleRoot();
- bundleContext.ungetService(serviceRef);
- return (bundleRoot == null) ? project : project.getFolder(bundleRoot);
- }
-
- protected IBundleProjectService getBundleProjectService() {
- BundleContext context = JptCommonCorePlugin.instance().getBundle().getBundleContext();
- ServiceReference<IBundleProjectService> reference = context.getServiceReference(IBundleProjectService.class);
- if (reference == null) {
- return null;
- }
- IBundleProjectService service = context.getService(reference);
- if (service != null) {
- context.ungetService(reference);
- }
- return service;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ProjectAdapterFactory.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ProjectAdapterFactory.java
deleted file mode 100644
index 1b0e356297..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ProjectAdapterFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.jpt.common.core.resource.ProjectResourceLocator;
-
-/**
- * Factory to build Dali adapters for an {@link IProject}:<ul>
- * <li>{@link org.eclipse.jpt.common.core.resource.ProjectResourceLocator}
- * </ul>
- * See <code>org.eclipse.jpt.common.core/plugin.xml</code>.
- */
-public class ProjectAdapterFactory
- implements IAdapterFactory
-{
- private static final Class<?>[] ADAPTER_LIST = new Class[] {
- ProjectResourceLocator.class
- };
-
- public Class<?>[] getAdapterList() {
- return ADAPTER_LIST;
- }
-
- public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes") Class adapterType) {
- if (adaptableObject instanceof IProject) {
- return this.getAdapter((IProject) adaptableObject, adapterType);
- }
- return null;
- }
-
- private Object getAdapter(IProject project, Class<?> adapterType) {
- if (adapterType == ProjectResourceLocator.class) {
- return this.getProjectResourceLocator(project);
- }
- return null;
- }
-
- private ProjectResourceLocator getProjectResourceLocator(IProject project) {
- return new SimpleProjectResourceLocator(project);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorConfig.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorConfig.java
deleted file mode 100644
index 22a1b192af..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorConfig.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource;
-
-import static org.eclipse.jst.common.project.facet.core.internal.FacetedProjectFrameworkJavaPlugin.log;
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jpt.common.core.internal.utility.XPointTools;
-import org.eclipse.jpt.common.core.resource.ResourceLocator;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-public class ResourceLocatorConfig
- implements Comparable<ResourceLocatorConfig> {
-
- public static final String PROJECT_ENABLEMENT_VARIABLE = "project"; //$NON-NLS-1$
-
- private String id;
- private String pluginId;
- private String className;
- private Priority priority;
- private Expression enablementCondition;
-
-
- ResourceLocatorConfig() {
- super();
- }
-
-
- public String getId() {
- return this.id;
- }
-
- void setId(String id) {
- this.id = id;
- }
-
- public String getPluginId() {
- return this.pluginId;
- }
-
- void setPluginId(String pluginId) {
- this.pluginId = pluginId;
- }
-
- public String getClassName() {
- return this.className;
- }
-
- void setClassName(String className) {
- this.className = className;
- }
-
- public Priority getPriority() {
- return this.priority;
- }
-
- void setPriority(Priority priority) {
- this.priority = priority;
- }
-
- public Expression getEnablementCondition() {
- return this.enablementCondition;
- }
-
- void setEnablementCondition(Expression enablementCondition) {
- this.enablementCondition = enablementCondition;
- }
-
- public ResourceLocator getResourceLocator() {
- return XPointTools.instantiate(
- this.pluginId, ResourceLocatorManager.QUALIFIED_EXTENSION_POINT_ID,
- this.className, ResourceLocator.class);
- }
-
- public boolean isEnabledFor(IProject project) {
- EvaluationContext evalContext = new EvaluationContext(null, project);
- evalContext.setAllowPluginActivation(true);
- evalContext.addVariable(PROJECT_ENABLEMENT_VARIABLE, project);
-
- if (this.enablementCondition != null) {
- try {
- EvaluationResult evalResult = this.enablementCondition.evaluate(evalContext);
-
- if (evalResult == EvaluationResult.FALSE) {
- return false;
- }
- }
- catch (CoreException e) {
- log(e);
- }
- }
-
- return true;
- }
-
- public int compareTo(ResourceLocatorConfig other) {
- return Priority.compare(this.priority, other.priority);
- }
-
-
- public static enum Priority {
-
- /* The lowest priority for a resource locator */
- LOWEST(6, "lowest"), //$NON-NLS-1$
-
- /* The second lowest priority for a resource locator */
- LOWER(5, "lower"), //$NON-NLS-1$
-
- /* The third lowest priority for a resource locator */
- LOW(4, "low"), //$NON-NLS-1$
-
- /* The default priority for a resource locator */
- NORMAL(3, "normal"), //$NON-NLS-1$
-
- /* The third highest priority for a resource locator */
- HIGH(2, "high"), //$NON-NLS-1$
-
- /* The second highest priority for a resource locator */
- HIGHER(1, "higher"), //$NON-NLS-1$
-
- /* The highest priority for a resource locator */
- HIGHEST(0, "highest"); //$NON-NLS-1$
-
-
- public static int compare(Priority priority1, Priority priority2) {
- return priority1.value.compareTo(priority2.value);
- }
-
- public static Priority get(String literal) {
- if (literal == null) {
- return NORMAL;
- }
- for (Priority priority : values()) {
- if (StringTools.stringsAreEqual(literal, priority.literal)) {
- return priority;
- }
- }
- return null;
- }
-
-
- private Integer value;
- private String literal;
-
-
- private Priority(int value, String literal) {
- this.value = Integer.valueOf(value);
- this.literal = literal;
- }
-
-
- @Override
- public String toString() {
- return this.literal;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorManager.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorManager.java
deleted file mode 100644
index ad71031646..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/ResourceLocatorManager.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource;
-
-import static org.eclipse.jpt.common.core.internal.utility.XPointTools.*;
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.ExpressionConverter;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.resource.ResourceLocatorConfig.Priority;
-import org.eclipse.jpt.common.core.internal.utility.XPointTools.XPointException;
-import org.eclipse.jpt.common.core.resource.ResourceLocator;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.KeyedSet;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-
-public class ResourceLocatorManager {
-
- public static final String EXTENSION_POINT_ID = "resourceLocators"; //$NON-NLS-1$
- public static final String QUALIFIED_EXTENSION_POINT_ID = JptCommonCorePlugin.PLUGIN_ID_ + EXTENSION_POINT_ID;
- public static final String RESOURCE_LOCATOR_ELEMENT = "resourceLocator"; //$NON-NLS-1$
- public static final String ID_ATTRIBUTE = "id"; //$NON-NLS-1$
- public static final String CLASS_ATTRIBUTE = "class"; //$NON-NLS-1$
- public static final String PRIORITY_ATTRIBUTE = "priority"; //$NON-NLS-1$
- public static final String ENABLEMENT_ELEMENT = "enablement"; //$NON-NLS-1$
-
-
- private static ResourceLocatorManager INSTANCE = new ResourceLocatorManager();
-
-
- public static ResourceLocatorManager instance() {
- return INSTANCE;
- }
-
-
- private KeyedSet<String, ResourceLocatorConfig> resourceLocatorConfigs;
-
-
- private ResourceLocatorManager() {
- this.resourceLocatorConfigs = new KeyedSet<String, ResourceLocatorConfig>();
- readExtensions();
- }
-
-
- /**
- * Return the {@link ResourceLocator} of highest priority that is acceptable
- * for the given project
- */
- public ResourceLocator getResourceLocator(final IProject project) {
- Iterable<ResourceLocatorConfig> sortedConfigs =
- //make ResourceLocatorConfig with higher priority go first
- CollectionTools.sort(
- new FilteringIterable<ResourceLocatorConfig>(
- this.resourceLocatorConfigs.getItemSet()) {
- @Override
- protected boolean accept(ResourceLocatorConfig o) {
- return o.isEnabledFor(project)
- && o.getResourceLocator() != null;
- }
- });
- for (ResourceLocatorConfig config : sortedConfigs) {
- ResourceLocator locator = config.getResourceLocator();
- if (locator != null) {
- return locator;
- }
- }
- return null;
- }
-
- private void readExtensions() {
- final IExtensionRegistry registry = Platform.getExtensionRegistry();
-
- final IExtensionPoint xpoint
- = registry.getExtensionPoint(QUALIFIED_EXTENSION_POINT_ID);
-
- if (xpoint == null) {
- throw new IllegalStateException();
- }
-
- final List<IConfigurationElement> configs = new ArrayList<IConfigurationElement>();
-
- for (IExtension extension : xpoint.getExtensions()) {
- for (IConfigurationElement element : extension.getConfigurationElements()) {
- configs.add(element);
- }
- }
-
- for (IConfigurationElement element : configs) {
- if (element.getName().equals(RESOURCE_LOCATOR_ELEMENT)) {
- readExtension(element);
- }
- }
- }
-
- private void readExtension(IConfigurationElement element) {
- try {
- final ResourceLocatorConfig rlConfig = new ResourceLocatorConfig();
-
- // plug-in id
- rlConfig.setPluginId(element.getContributor().getName());
-
- // resource locator id
- rlConfig.setId(findRequiredAttribute(element, ID_ATTRIBUTE));
-
- if (this.resourceLocatorConfigs.containsKey(rlConfig.getId())) {
- logDuplicateExtension(QUALIFIED_EXTENSION_POINT_ID, ID_ATTRIBUTE, rlConfig.getId());
- throw new XPointException();
- }
-
- // resource locator class name
- rlConfig.setClassName(findRequiredAttribute(element, CLASS_ATTRIBUTE));
-
- // priority
- String priorityString = element.getAttribute(PRIORITY_ATTRIBUTE).trim();
- Priority priority = Priority.get(priorityString);
- if (priority == null) {
- logInvalidValue(element, PRIORITY_ATTRIBUTE, priorityString);
- throw new XPointException();
- }
- rlConfig.setPriority(priority);
-
- // enablement
- for (IConfigurationElement child : element.getChildren()) {
- String childName = child.getName();
- if (childName.equals(ENABLEMENT_ELEMENT)) {
- Expression expr;
- try {
- expr = ExpressionConverter.getDefault().perform(child);
- }
- catch (CoreException e) {
- log(e);
- throw new XPointException();
- }
- rlConfig.setEnablementCondition(expr);
- }
- }
-
- this.resourceLocatorConfigs.addItem(rlConfig.getId(), rlConfig);
- }
- catch (XPointException e) {
- // Ignore and continue. The problem has already been reported to the user
- // in the log.
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleJavaResourceLocator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleJavaResourceLocator.java
deleted file mode 100644
index 58712b543c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleJavaResourceLocator.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
-import org.eclipse.jpt.common.core.resource.ResourceLocator;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-
-public class SimpleJavaResourceLocator
- implements ResourceLocator
-{
- protected static final IPath META_INF_PATH = new Path(J2EEConstants.META_INF);
-
- /**
- * Return whether the specified container is either:<ul>
- * <li>on the corresponding Java project's classpath; or
- * <li>in the non-Java resources, but not in the project output location
- * </ul>
- */
- public boolean resourceLocationIsValid(IProject project, IContainer container) {
- try {
- return this.resourceLocationIsValid_(project, container);
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- // happens if the Java project does not exist
- return false;
- }
- }
-
- protected boolean resourceLocationIsValid_(IProject project, IContainer container) throws JavaModelException {
- IJavaProject javaProject = this.getJavaProject(project);
- if (javaProject.isOnClasspath(container)) {
- return true;
- }
-
- IPath outputPath = javaProject.getOutputLocation();
- IPath containerPath = container.getFullPath();
- if (container.equals(project) && outputPath.isPrefixOf(containerPath)) {
- return true;
- }
-
- if (outputPath.isPrefixOf(containerPath)) {
- return false;
- }
- for (Object resource : javaProject.getNonJavaResources()) {
- if (resource instanceof IFolder) {
- IFolder folder = (IFolder) resource;
- if (folder.getFullPath().isPrefixOf(containerPath)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- /**
- * Return the default resource location for the specified project:<ul>
- * <li>the first package fragment root (source folder) <code>META-INF</code>
- * folder if it exists; or
- * <li>the project rooted <code>META-INF</code> folder if it exists; or
- * <li>the non-existent <code>META-INF</code> folder in the first package
- * fragment root (source folder)
- * </ul>
- */
- public IContainer getDefaultResourceLocation(IProject project) {
- try {
- return this.getDefaultResourceLocation_(project);
- } catch (Exception ex) {
- JptCommonCorePlugin.log(ex);
- // happens if the Java project does not exist or there is a problem with the
- // Java resources
- return null;
- }
- }
-
- protected IContainer getDefaultResourceLocation_(IProject project) throws JavaModelException {
- IContainer defaultLocation = null;
- for (IContainer sourceFolder : this.getSourceFolders(project)) {
- IFolder metaInfFolder = sourceFolder.getFolder(META_INF_PATH);
- if (metaInfFolder.exists()) {
- return metaInfFolder;
- }
- if (defaultLocation == null) {
- // save the first one, to use if none found
- defaultLocation = metaInfFolder;
- }
- }
- IFolder metaInfFolder = project.getFolder(META_INF_PATH);
- if (metaInfFolder.exists()) {
- return metaInfFolder;
- }
- return defaultLocation;
- }
-
- public IPath getResourcePath(IProject project, IPath runtimePath) {
- try {
- return this.getResourcePath_(project, runtimePath);
- } catch (Exception ex) {
- JptCommonCorePlugin.log(ex);
- return null;
- }
- }
-
- protected IPath getResourcePath_(IProject project, IPath runtimePath) throws JavaModelException {
- IPath defaultResourcePath = null;
- for (IContainer sourceFolder : this.getSourceFolders(project)) {
- IPath resourcePath = sourceFolder.getFullPath().append(runtimePath);
- IFile file = project.getWorkspace().getRoot().getFile(resourcePath);
- if (file.exists()) {
- return file.getFullPath();
- }
- if (defaultResourcePath == null) {
- // save the first one, to use if none found
- defaultResourcePath = resourcePath;
- }
- }
- return defaultResourcePath;
- }
-
- public IPath getRuntimePath(IProject project, IPath resourcePath) {
- try {
- return this.getRuntimePath_(project, resourcePath);
- } catch (Exception ex) {
- JptCommonCorePlugin.log(ex);
- return resourcePath.makeRelativeTo(project.getFullPath());
- }
- }
-
- protected IPath getRuntimePath_(IProject project, IPath resourcePath) throws JavaModelException {
- IFile file = PlatformTools.getFile(resourcePath);
- for (IContainer sourceFolder : this.getSourceFolders(project)) {
- if (sourceFolder.contains(file)) {
- return resourcePath.makeRelativeTo(sourceFolder.getFullPath());
- }
- }
- return resourcePath.makeRelativeTo(project.getFullPath());
- }
-
- protected Iterable<IContainer> getSourceFolders(IProject project) throws JavaModelException {
- return new TransformationIterable<IPackageFragmentRoot, IContainer>(this.getSourcePackageFragmentRoots(project), ROOT_CONTAINER_TRANSFORMER);
- }
-
- protected static final Transformer<IPackageFragmentRoot, IContainer> ROOT_CONTAINER_TRANSFORMER = new RootContainerTransformer();
-
- protected static class RootContainerTransformer
- implements Transformer<IPackageFragmentRoot, IContainer>
- {
- public IContainer transform(IPackageFragmentRoot pfr) {
- try {
- return this.transform_(pfr);
- } catch (JavaModelException ex) {
- throw new RuntimeException(ex);
- }
- }
- protected IContainer transform_(IPackageFragmentRoot pfr) throws JavaModelException {
- return (IContainer) pfr.getUnderlyingResource();
- }
- }
-
- protected Iterable<IPackageFragmentRoot> getSourcePackageFragmentRoots(IProject project) throws JavaModelException {
- return new FilteringIterable<IPackageFragmentRoot>(this.getPackageFragmentRoots(project), SOURCE_ROOT_FILTER);
- }
-
- protected static final Filter<IPackageFragmentRoot> SOURCE_ROOT_FILTER = new SourceRootFilter();
-
- protected static class SourceRootFilter
- implements Filter<IPackageFragmentRoot>
- {
- public boolean accept(IPackageFragmentRoot pfr) {
- try {
- return this.accept_(pfr);
- } catch (JavaModelException ex) {
- throw new RuntimeException(ex);
- }
- }
- protected boolean accept_(IPackageFragmentRoot pfr) throws JavaModelException {
- // accept both source folders and *class* folders (xml files may exist there as well)
- IResource resource = pfr.getUnderlyingResource();
- return resource != null && resource.getType() == IResource.FOLDER;
- }
- }
-
- protected Iterable<IPackageFragmentRoot> getPackageFragmentRoots(IProject project) throws JavaModelException {
- return new ArrayIterable<IPackageFragmentRoot>(this.getPackageFragmentRootsArray(project));
- }
-
- protected IPackageFragmentRoot[] getPackageFragmentRootsArray(IProject project) throws JavaModelException {
- return this.getJavaProject(project).getPackageFragmentRoots();
- }
-
- protected IJavaProject getJavaProject(IProject project) {
- return JavaCore.create(project);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleProjectResourceLocator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleProjectResourceLocator.java
deleted file mode 100644
index 71b1d522ef..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/SimpleProjectResourceLocator.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jpt.common.core.resource.ProjectResourceLocator;
-import org.eclipse.jpt.common.core.resource.ResourceLocator;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * @see org.eclipse.jpt.common.core.internal.resource.ProjectAdapterFactory
- * @see ResourceLocatorManager
- */
-public class SimpleProjectResourceLocator
- implements ProjectResourceLocator
-{
- protected final IProject project;
-
-
- public SimpleProjectResourceLocator(IProject project) {
- super();
- this.project = project;
- }
-
- public boolean resourceLocationIsValid(IContainer container) {
- ResourceLocator resourceLocator = this.getResourceLocator();
- return (resourceLocator != null) && resourceLocator.resourceLocationIsValid(this.project, container);
- }
-
- public IContainer getDefaultResourceLocation() {
- ResourceLocator resourceLocator = this.getResourceLocator();
- return (resourceLocator == null) ? null : resourceLocator.getDefaultResourceLocation(this.project);
- }
-
- public IPath getResourcePath(IPath runtimePath) {
- ResourceLocator resourceLocator = this.getResourceLocator();
- return (resourceLocator == null) ? null : resourceLocator.getResourcePath(this.project, runtimePath);
- }
-
- public IPath getRuntimePath(IPath resourcePath) {
- ResourceLocator resourceLocator = this.getResourceLocator();
- return (resourceLocator == null) ? null : resourceLocator.getRuntimePath(this.project, resourcePath);
- }
-
- public IFile getPlatformFile(IPath runtimePath) {
- IPath sourcePath = this.getResourcePath(runtimePath);
- return (sourcePath == null) ? null : this.project.getWorkspace().getRoot().getFile(sourcePath);
- }
-
- protected ResourceLocator getResourceLocator() {
- return ResourceLocatorManager.instance().getResourceLocator(this.project);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.project);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/WebModuleResourceLocator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/WebModuleResourceLocator.java
deleted file mode 100644
index 7d1cb6bfb4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/WebModuleResourceLocator.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.j2ee.internal.J2EEConstants;
-
-public class WebModuleResourceLocator
- extends ModuleResourceLocator
-{
- protected static final IPath WEB_INF_CLASSES_PATH = new Path(J2EEConstants.WEB_INF_CLASSES);
- protected static final IPath WEB_META_INF_PATH = WEB_INF_CLASSES_PATH.append(META_INF_PATH);
-
- /**
- * Return the folder representing the <code>WEB-INF/classes/META-INF</code>
- * location.
- */
- @Override
- public IContainer getDefaultResourceLocation(IProject project) {
- return this.getRootFolder(project).getFolder(WEB_META_INF_PATH).getUnderlyingFolder();
- }
-
- /**
- * Return the full resource path representing the specified runtime location
- * appended to the <code>WEB-INF/classes</code> location.
- */
- @Override
- public IPath getResourcePath(IProject project, IPath runtimePath) {
- return super.getResourcePath(project, WEB_INF_CLASSES_PATH.append(runtimePath));
- }
-
- /**
- *
- */
- @Override
- public IPath getRuntimePath(IProject project, IPath resourcePath) {
- IPath runtimePath = super.getRuntimePath(project, resourcePath);
- return WEB_INF_CLASSES_PATH.isPrefixOf(runtimePath) ?
- runtimePath.makeRelativeTo(WEB_INF_CLASSES_PATH) :
- runtimePath;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/AbstractJavaResourceNode.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/AbstractJavaResourceNode.java
deleted file mode 100644
index 79b621d8b5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/AbstractJavaResourceNode.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.AspectChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-
-/**
- * Java resource containment hierarchy
- */
-public abstract class AbstractJavaResourceNode
- extends AbstractModel
- implements JavaResourceNode
-{
- protected final JavaResourceNode parent;
-
-
- // ********** constructor **********
-
- protected AbstractJavaResourceNode(JavaResourceNode parent) {
- super();
- this.checkParent(parent);
- this.parent = parent;
- }
-
- public JavaResourceNode getParent() {
- return this.parent;
- }
-
- // ********** parent **********
-
- protected void checkParent(JavaResourceNode p) {
- if (p == null) {
- if (this.requiresParent()) {
- throw new IllegalArgumentException("'parent' cannot be null"); //$NON-NLS-1$
- }
- } else {
- if (this.forbidsParent()) {
- throw new IllegalArgumentException("'parent' must be null"); //$NON-NLS-1$
- }
- }
- }
-
- protected boolean requiresParent() {
- return true;
- }
-
- protected boolean forbidsParent() {
- return ! this.requiresParent(); // assume 'parent' is not optional
- }
-
-
- // ********** change support callback hook **********
-
- @Override
- protected final ChangeSupport buildChangeSupport() {
- return new AspectChangeSupport(this, this.buildChangeSupportListener());
- }
-
- private AspectChangeSupport.Listener buildChangeSupportListener() {
- return new AspectChangeSupport.Listener() {
- public void aspectChanged(String aspectName) {
- AbstractJavaResourceNode.this.aspectChanged(aspectName);
- }
- };
- }
-
- /**
- * ignore the aspect name, we notify listeners of *every* change
- */
- protected void aspectChanged(@SuppressWarnings("unused") String aspectName) {
- this.getRoot().resourceModelChanged();
- }
-
-
- // ********** JavaResourceNode implementation **********
-
- /**
- * @see org.eclipse.jpt.common.core.internal.resource.java.binary.RootBinaryNode#getRoot()
- * @see org.eclipse.jpt.common.core.internal.resource.java.source.SourceCompilationUnit#getRoot()
- */
- public Root getRoot() {
- return this.parent.getRoot();
- }
-
- public IFile getFile() {
- return this.getRoot().getFile();
- }
-
-
- // ********** convenience methods **********
-
- protected AnnotationProvider getAnnotationProvider() {
- return this.getRoot().getAnnotationProvider();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/NullAnnotation.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/NullAnnotation.java
deleted file mode 100644
index 5a7e7b775e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/NullAnnotation.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.core.utility.TextRange;
-
-/**
- * Simplify null annotation classes
- */
-public abstract class NullAnnotation<A extends Annotation>
- extends AbstractJavaResourceNode
- implements Annotation
-{
-
- protected NullAnnotation(JavaResourceNode parent) {
- super(parent);
- }
-
- public void initialize(CompilationUnit astRoot) {
- // do nothing
- }
-
- public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) {
- return null;
- }
-
- public JavaResourceCompilationUnit getJavaResourceCompilationUnit() {
- throw new UnsupportedOperationException();
- }
-
- public boolean isMappingAnnotation() {
- return false;
- }
-
- public void newAnnotation() {
- throw new UnsupportedOperationException();
- }
-
- public void removeAnnotation() {
- throw new UnsupportedOperationException();
- }
-
- public void moveAnnotation(int index) {
- throw new UnsupportedOperationException();
- }
-
- public boolean isUnset() {
- throw new UnsupportedOperationException();
- }
-
- public TextRange getTextRange(CompilationUnit astRoot) {
- return null;
- }
-
- public void synchronizeWith(CompilationUnit astRoot) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Convenience method: Cast the annotation's parent to a
- * persistent member.
- */
- protected JavaResourceAnnotatedElement getAnnotatedElement() {
- return (JavaResourceAnnotatedElement) this.parent;
- }
-
- /**
- * Convenience method: Add the type or attribute's annotation
- * and return it.
- * Pre-condition: The annotation's parent must be a persistent member
- * (type or attribute).
- */
- protected A addAnnotation() {
- return this.addAnnotation_();
- }
-
- @SuppressWarnings("unchecked")
- protected A addAnnotation_() {
- return (A) this.getAnnotatedElement().addAnnotation(this.getAnnotationName());
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAbstractType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAbstractType.java
deleted file mode 100644
index 82dad91135..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAbstractType.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeParameter;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-
-/**
- * binary persistent type
- */
-abstract class BinaryAbstractType
- extends BinaryMember
- implements JavaResourceAbstractType
-{
- private String name;
-
- private String qualifiedName;
-
- private String packageName;
-
- private String declaringTypeName;
-
- private boolean memberType;
-
-
- // ********** construction/initialization **********
-
- protected BinaryAbstractType(JavaResourceNode parent, IType type) {
- super(parent, new TypeAdapter(type));
- this.name = this.buildName(type);
- this.qualifiedName = this.buildQualifiedName(type);
- this.packageName = this.buildPackageName(type);
- this.declaringTypeName = this.buildDeclaringTypeName(type);
- this.memberType = this.buildMemberType(type);
- }
-
-
- // ********** overrides **********
-
- @Override
- protected void update(IMember member) {
- super.update(member);
- this.setName(this.buildName((IType) member));
- this.setQualifiedName(this.buildQualifiedName((IType) member));
- this.setPackageName(this.buildPackageName((IType) member));
- this.setDeclaringTypeName(this.buildDeclaringTypeName((IType) member));
- this.setMemberType(this.buildMemberType((IType) member));
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
-
- // ********** JavaResourceAbstractType implementation **********
-
- // ***** name
- public String getName() {
- return this.name;
- }
-
- private void setName(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- private String buildName(IType type) {
- return type.getElementName();
- }
-
- // ***** qualified name
- public String getQualifiedName() {
- return this.qualifiedName;
- }
-
- private void setQualifiedName(String qualifiedName) {
- String old = this.qualifiedName;
- this.qualifiedName = qualifiedName;
- this.firePropertyChanged(QUALIFIED_NAME_PROPERTY, old, qualifiedName);
- }
-
- private String buildQualifiedName(IType type) {
- return type.getFullyQualifiedName('.'); // no parameters are included here
- }
-
- // ***** package
- public String getPackageName() {
- return this.packageName;
- }
-
- private void setPackageName(String packageName) {
- String old = this.packageName;
- this.packageName = packageName;
- this.firePropertyChanged(PACKAGE_NAME_PROPERTY, old, packageName);
- }
-
- private String buildPackageName(IType type) {
- return type.getPackageFragment().getElementName();
- }
-
- public boolean isIn(IPackageFragment packageFragment) {
- return StringTools.stringsAreEqual(packageFragment.getElementName(), this.packageName);
- }
-
- // ***** source folder
- public boolean isIn(IPackageFragmentRoot sourceFolder) {
- return getSourceFolder().equals(sourceFolder);
- }
-
- private IPackageFragmentRoot getSourceFolder() {
- return (IPackageFragmentRoot) this.getMember().getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
- }
-
- // ***** declaring type name
- public String getDeclaringTypeName() {
- return this.declaringTypeName;
- }
-
- private void setDeclaringTypeName(String declaringTypeName) {
- String old = this.declaringTypeName;
- this.declaringTypeName = declaringTypeName;
- this.firePropertyChanged(DECLARING_TYPE_NAME_PROPERTY, old, declaringTypeName);
- }
-
- private String buildDeclaringTypeName(IType type) {
- IType declaringType = type.getDeclaringType();
- return (declaringType == null) ? null : declaringType.getFullyQualifiedName('.'); // no parameters are included here
- }
-
-
- // ***** member
- public boolean isMemberType() {
- return this.memberType;
- }
-
- private void setMemberType(boolean memberType) {
- boolean old = this.memberType;
- this.memberType = memberType;
- this.firePropertyChanged(MEMBER_TYPE_PROPERTY, old, memberType);
- }
-
- private boolean buildMemberType(IType type) {
- try {
- return type.isMember();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
-
- // ********** misc **********
-
- @Override
- public IType getMember() {
- return (IType) super.getMember();
- }
-
- public Iterable<JavaResourceType> getTypes() {
- throw new UnsupportedOperationException();
- }
-
- public Iterable<JavaResourceEnum> getEnums() {
- throw new UnsupportedOperationException();
- }
-
- public Iterable<JavaResourceType> getAllTypes() {
- throw new UnsupportedOperationException();
- }
-
- public Iterable<JavaResourceEnum> getAllEnums() {
- throw new UnsupportedOperationException();
- }
-
- // ********** IType adapter **********
-
- static class TypeAdapter
- implements Adapter {
-
- private final IType type;
-
- TypeAdapter(IType type) {
- super();
- this.type = type;
- }
-
- public IType getElement() {
- return this.type;
- }
-
- public Iterable<ITypeParameter> getTypeParameters() {
- try {
- return new ArrayIterable<ITypeParameter>(this.type.getTypeParameters());
- }
- catch (JavaModelException jme) {
- JptCommonCorePlugin.log(jme);
- }
- return EmptyIterable.instance();
- }
-
- public IAnnotation[] getAnnotations() throws JavaModelException {
- return this.type.getAnnotations();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAnnotatedElement.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAnnotatedElement.java
deleted file mode 100644
index dfb509060d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAnnotatedElement.java
+++ /dev/null
@@ -1,391 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import java.util.Hashtable;
-import java.util.Vector;
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IMemberValuePair;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.TransformerAdapter;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-
-/**
- * Java binary annotated element
- */
-abstract class BinaryAnnotatedElement
- extends BinaryNode
- implements JavaResourceAnnotatedElement
-{
- /** JDT annotated element adapter */
- final Adapter adapter;
-
- /**
- * Annotations keyed by annotation name;
- * no duplicates (the Java compiler does not allow duplicate annotations).
- */
- private final Hashtable<String, Annotation> annotations = new Hashtable<String, Annotation>();
-
- /**
- * Annotation containers keyed by <em>nestable</em> annotation name.
- * This is used to store annotations that can be both standalone and nested
- * and are moved back and forth between the two.
- */
- private final Hashtable<String, AnnotationContainer> annotationContainers = new Hashtable<String, AnnotationContainer>();
-
- /**
- * These are built as needed.
- */
- private final Hashtable<String, Annotation> nullAnnotationsCache = new Hashtable<String, Annotation>();
-
-
- // ********** construction/initialization **********
-
- BinaryAnnotatedElement(JavaResourceNode parent, Adapter adapter) {
- super(parent);
- this.adapter = adapter;
- this.initializeAnnotations();
- }
-
- private void initializeAnnotations() {
- for (IAnnotation annotation : this.getJdtAnnotations()) {
- this.addAnnotation(annotation);
- }
- }
-
- private void addAnnotation(IAnnotation jdtAnnotation) {
- String jdtAnnotationName = jdtAnnotation.getElementName();
- // check whether the annotation is a valid container annotation first
- // because container validations are also valid annotations
- // TODO remove container annotations from list of annotations???
- if (this.annotationIsValidContainer(jdtAnnotationName)) {
- String nestableAnnotationName = this.getAnnotationProvider().getNestableAnnotationName(jdtAnnotationName);
- AnnotationContainer container = new AnnotationContainer();
- container.initializeFromContainerAnnotation(jdtAnnotation);
- this.annotationContainers.put(nestableAnnotationName, container);
- }
- else if (this.annotationIsValid(jdtAnnotationName)) {
- this.annotations.put(jdtAnnotationName, this.buildAnnotation(jdtAnnotation));
- }
- else if (this.annotationIsValidNestable(jdtAnnotationName)) {
- // if we already have an annotation container (because there was a container annotation)
- // ignore the standalone nestable annotation
- if (this.annotationContainers.get(jdtAnnotationName) == null) {
- AnnotationContainer container = new AnnotationContainer();
- container.initializeFromStandaloneAnnotation(jdtAnnotation);
- this.annotationContainers.put(jdtAnnotationName, container);
- }
- }
- }
-
- private boolean annotationIsValid(String annotationName) {
- return CollectionTools.contains(this.getAnnotationProvider().getAnnotationNames(), annotationName);
- }
-
- private boolean annotationIsValidContainer(String annotationName) {
- return CollectionTools.contains(this.getAnnotationProvider().getContainerAnnotationNames(), annotationName);
- }
-
- private boolean annotationIsValidNestable(String annotationName) {
- return CollectionTools.contains(this.getAnnotationProvider().getNestableAnnotationNames(), annotationName);
- }
-
-
- // ********** updating **********
-
- @Override
- public void update() {
- super.update();
- this.updateAnnotations();
- }
-
- // TODO
- private void updateAnnotations() {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** annotations **********
-
- public Iterable<Annotation> getAnnotations() {
- return new LiveCloneIterable<Annotation>(this.annotations.values());
- }
-
- public int getAnnotationsSize() {
- return this.annotations.size();
- }
-
- public Annotation getAnnotation(String annotationName) {
- return this.annotations.get(annotationName);
- }
-
- public Annotation getNonNullAnnotation(String annotationName) {
- Annotation annotation = this.getAnnotation(annotationName);
- return (annotation != null) ? annotation : this.getNullAnnotation(annotationName);
- }
-
- private Annotation getNullAnnotation(String annotationName) {
- synchronized (this.nullAnnotationsCache) {
- Annotation annotation = this.nullAnnotationsCache.get(annotationName);
- if (annotation == null) {
- annotation = this.buildNullAnnotation(annotationName);
- this.nullAnnotationsCache.put(annotationName, annotation);
- }
- return annotation;
- }
- }
-
- private Annotation buildNullAnnotation(String annotationName) {
- return this.getAnnotationProvider().buildNullAnnotation(this, annotationName);
- }
-
- /* CU private */ Annotation buildAnnotation(IAnnotation jdtAnnotation) {
- return this.getAnnotationProvider().buildAnnotation(this, jdtAnnotation);
- }
-
-
- // ********** combination annotations **********
-
- private Iterable<NestableAnnotation> getNestableAnnotations() {
- return new CompositeIterable<NestableAnnotation>(this.getNestableAnnotationLists());
- }
-
- private Iterable<Iterable<NestableAnnotation>> getNestableAnnotationLists() {
- return new TransformationIterable<AnnotationContainer, Iterable<NestableAnnotation>>(this.getAnnotationContainers(), ANNOTATION_CONTAINER_NESTED_ANNOTATIONS_TRANSFORMER);
- }
-
- private static final Transformer<AnnotationContainer, Iterable<NestableAnnotation>> ANNOTATION_CONTAINER_NESTED_ANNOTATIONS_TRANSFORMER = new AnnotationContainerNestedAnnotationsTransformer();
- static final class AnnotationContainerNestedAnnotationsTransformer
- extends TransformerAdapter<AnnotationContainer, Iterable<NestableAnnotation>>
- {
- @Override
- public Iterable<NestableAnnotation> transform(AnnotationContainer container) {
- return container.getNestedAnnotations();
- }
- }
-
- private Iterable<AnnotationContainer> getAnnotationContainers() {
- return new LiveCloneIterable<AnnotationContainer>(this.annotationContainers.values());
- }
-
- public ListIterable<NestableAnnotation> getAnnotations(String nestableAnnotationName) {
- AnnotationContainer container = this.annotationContainers.get(nestableAnnotationName);
- return (container != null) ? container.getNestedAnnotations() : EmptyListIterable.<NestableAnnotation> instance();
- }
-
-
- public int getAnnotationsSize(String nestableAnnotationName) {
- AnnotationContainer container = this.annotationContainers.get(nestableAnnotationName);
- return (container == null) ? 0 : container.getNestedAnnotationsSize();
- }
-
- public NestableAnnotation getAnnotation(int index, String nestableAnnotationName) {
- AnnotationContainer container = this.annotationContainers.get(nestableAnnotationName);
- return (container == null) ? null : container.getNestedAnnotation(index);
- }
-
- private Iterable<Annotation> getContainerOrStandaloneNestableAnnotations() {
- return new TransformationIterable<AnnotationContainer, Annotation>(this.getAnnotationContainers(), TOP_LEVEL_ANNOTATION_CONTAINER_TRANSFORMER);
- }
-
- private static final Transformer<AnnotationContainer, Annotation> TOP_LEVEL_ANNOTATION_CONTAINER_TRANSFORMER = new TopLevelAnnotationContainerTransformer();
- /* CU private */ static final class TopLevelAnnotationContainerTransformer
- extends TransformerAdapter<AnnotationContainer, Annotation>
- {
- @Override
- public Annotation transform(AnnotationContainer container) {
- Annotation containerAnnotation = container.getContainerAnnotation();
- return (containerAnnotation != null) ? containerAnnotation : container.getNestedAnnotation(0);
- }
- }
-
- /* CU private */ NestableAnnotation buildAnnotation(IAnnotation jdtAnnotation, int index) {
- return this.getAnnotationProvider().buildAnnotation(this, jdtAnnotation, index);
- }
-
-
- // ***** all annotations *****
-
- @SuppressWarnings("unchecked")
- public Iterable<Annotation> getTopLevelAnnotations() {
- return new CompositeIterable<Annotation>(
- this.getAnnotations(),
- this.getContainerOrStandaloneNestableAnnotations()
- );
- }
-
- public boolean isAnnotated() {
- return ! this.isUnannotated();
- }
-
- private boolean isUnannotated() {
- return this.annotations.isEmpty() && this.annotationContainers.isEmpty();
- }
-
- public boolean isAnnotatedWithAnyOf(Iterable<String> annotationNames) {
- for (Annotation annotation : this.getSignificantAnnotations()) {
- if (CollectionTools.contains(annotationNames, annotation.getAnnotationName())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return the "significant" annotations;
- * i.e. ignore the container annotations (they have no semantics).
- */
- @SuppressWarnings("unchecked")
- private Iterable<Annotation> getSignificantAnnotations() {
- return new CompositeIterable<Annotation>(
- this.getAnnotations(),
- this.getNestableAnnotations()
- );
- }
-
-
- // ********** misc **********
-
- @Override
- protected AnnotationProvider getAnnotationProvider() {
- return super.getAnnotationProvider();
- }
-
- private IAnnotation[] getJdtAnnotations() {
- try {
- return this.adapter.getAnnotations();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return EMPTY_JDT_ANNOTATION_ARRAY;
- }
- }
- private static final IAnnotation[] EMPTY_JDT_ANNOTATION_ARRAY = new IAnnotation[0];
-
-
- // ********** IJavaElement adapter **********
-
- interface Adapter {
- /**
- * Return the adapter's JDT element (IPackageFragment, IType, IField, IMethod).
- */
- IJavaElement getElement();
-
- /**
- * Return the adapter's element's JDT annotations.
- */
- IAnnotation[] getAnnotations() throws JavaModelException;
- }
-
-
- // ********** unsupported JavaResourcePersistentMember implementation **********
-
- public Annotation addAnnotation(String annotationName) {
- throw new UnsupportedOperationException();
- }
-
- public NestableAnnotation addAnnotation(int index, String nestableAnnotationName) {
- throw new UnsupportedOperationException();
- }
-
- public void moveAnnotation(int targetIndex, int sourceIndex, String nestableAnnotationName) {
- throw new UnsupportedOperationException();
- }
-
- public void removeAnnotation(String annotationName) {
- throw new UnsupportedOperationException();
- }
-
- public void removeAnnotation(int index, String nestableAnnotationName) {
- throw new UnsupportedOperationException();
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- throw new UnsupportedOperationException();
- }
-
- public TextRange getTextRange(String nestableAnnotationName, CompilationUnit astRoot) {
- throw new UnsupportedOperationException();
- }
-
- /* CU private */ static final IMemberValuePair[] EMPTY_MEMBER_VALUE_PAIR_ARRAY = new IMemberValuePair[0];
- /* CU private */ static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
-
-
- // ********** annotation container **********
-
- /* CU private */ class AnnotationContainer {
-
- private Annotation containerAnnotation;
-
- private final Vector<NestableAnnotation> nestedAnnotations = new Vector<NestableAnnotation>();
-
- AnnotationContainer() {
- super();
- }
-
- void initializeFromContainerAnnotation(IAnnotation jdtContainerAnnotation) {
- this.initializeNestedAnnotations(jdtContainerAnnotation);
- this.containerAnnotation = BinaryAnnotatedElement.this.buildAnnotation(jdtContainerAnnotation);
- }
-
- void initializeNestedAnnotations(IAnnotation jdtContainerAnnotation) {
- Object[] jdtNestedAnnotations = this.getJdtNestedAnnotations(jdtContainerAnnotation);
- int len = jdtNestedAnnotations.length;
- for (int i = 0; i < len; i++) {
- IAnnotation jdtNestedAnnotation = (IAnnotation) jdtNestedAnnotations[i];
- this.addAnnotation(jdtNestedAnnotation, i);
- }
- }
-
- private Object[] getJdtNestedAnnotations(IAnnotation jdtContainerAnnotation) {
- return BinaryAnnotatedElement.this.getJdtMemberValues(jdtContainerAnnotation, "value"); //$NON-NLS-1$
- }
-
- void initializeFromStandaloneAnnotation(IAnnotation jdtNestableAnnotation) {
- this.addAnnotation(jdtNestableAnnotation, 0);
- }
-
- private void addAnnotation(IAnnotation jdtNestableAnnotation, int index) {
- this.nestedAnnotations.add(BinaryAnnotatedElement.this.buildAnnotation(jdtNestableAnnotation, index));
- }
-
- Annotation getContainerAnnotation() {
- return this.containerAnnotation;
- }
-
- ListIterable<NestableAnnotation> getNestedAnnotations() {
- return new LiveCloneListIterable<NestableAnnotation>(this.nestedAnnotations);
- }
-
- int getNestedAnnotationsSize() {
- return this.nestedAnnotations.size();
- }
-
- NestableAnnotation getNestedAnnotation(int index) {
- return this.nestedAnnotations.get(index);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAnnotation.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAnnotation.java
deleted file mode 100644
index 813453ccab..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAnnotation.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-
-/**
- * JAR annotation
- */
-public abstract class BinaryAnnotation
- extends BinaryNode
- implements Annotation
-{
- final IAnnotation jdtAnnotation;
-
- protected BinaryAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation) {
- super(parent);
- this.jdtAnnotation = jdtAnnotation;
- }
-
- // ********** convenience methods **********
-
- /**
- * Return the values of the JDT annotation's member with the specified name.
- */
- protected Object[] getJdtMemberValues(String memberName) {
- return this.getJdtMemberValues(this.jdtAnnotation, memberName);
- }
-
- /**
- * Return the value of the JDT annotation's member with the specified name.
- */
- protected Object getJdtMemberValue(String memberName) {
- return this.getJdtMemberValue(this.jdtAnnotation, memberName);
- }
-
-
- // ********** Annotation implementation **********
-
- public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) {
- throw new UnsupportedOperationException();
- }
- public void newAnnotation() {
- throw new UnsupportedOperationException();
- }
- public void removeAnnotation() {
- throw new UnsupportedOperationException();
- }
- public boolean isUnset() {
- throw new UnsupportedOperationException();
- }
-
- // ********** NestableAnnotation implementation **********
- public void moveAnnotation(@SuppressWarnings("unused") int index) {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAttribute.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAttribute.java
deleted file mode 100644
index d3deae8981..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryAttribute.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.ITypeParameter;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.utility.internal.ClassName;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-
-/**
- * binary attribute (field or property)
- */
-abstract class BinaryAttribute
- extends BinaryMember
- implements JavaResourceAttribute
-{
- private int modifiers;
-
- private String typeName;
-
- private boolean typeIsInterface;
-
- private boolean typeIsEnum;
-
- private boolean typeIsArray;
-
- private int typeArrayDimensionality;
-
- private String typeArrayComponentTypeName;
-
- private final Vector<String> typeSuperclassNames = new Vector<String>();
-
- private final Vector<String> typeInterfaceNames = new Vector<String>();
-
- private final Vector<String> typeTypeArgumentNames = new Vector<String>();
-
-
- protected BinaryAttribute(JavaResourceType parent, Adapter adapter) {
- super(parent, adapter);
- IMember member = adapter.getElement();
- this.modifiers = this.buildModifiers(member);
-
- String typeSignature = getTypeSignature();
- Iterable<ITypeParameter> typeParameters = getAdapter().getTypeParameters();
- this.typeName = buildTypeName(typeSignature, typeParameters);
- this.typeIsArray = buildTypeIsArray(typeSignature);
- this.typeArrayDimensionality = buildTypeArrayDimensionality(typeSignature);
- this.typeArrayComponentTypeName = buildTypeArrayComponentTypeName(typeSignature, typeParameters);
- this.typeTypeArgumentNames.addAll(buildTypeTypeArgumentNames(typeSignature, typeParameters));
-
- IType type = this.getType(member.getJavaProject());
- // if the type is an array, then the following will be false or empty
- this.typeIsInterface = this.buildTypeIsInterface(type);
- this.typeIsEnum = this.buildTypeIsEnum(type);
- this.typeSuperclassNames.addAll(this.buildTypeSuperclassNames(type));
- this.typeInterfaceNames.addAll(this.buildTypeInterfaceNames(type));
- }
-
- // ******** overrides ********
-
- @Override
- public void update() {
- super.update();
-
- String typeSignature = getTypeSignature();
- Iterable<ITypeParameter> typeParameters = getAdapter().getTypeParameters();
- setTypeName(buildTypeName(typeSignature, typeParameters));
- setTypeIsArray(buildTypeIsArray(typeSignature));
- setTypeArrayDimensionality(buildTypeArrayDimensionality(typeSignature));
- setTypeArrayComponentTypeName(buildTypeArrayComponentTypeName(typeSignature, typeParameters));
- setTypeTypeArgumentNames(buildTypeTypeArgumentNames(typeSignature, typeParameters));
- }
-
-
- @Override
- protected void update(IMember member) {
- super.update(member);
- this.setModifiers(this.buildModifiers(member));
-
- IType type = this.getType(member.getJavaProject()); // if the type is an array, then the following will be false or empty
- this.setTypeIsInterface(this.buildTypeIsInterface(type));
- this.setTypeIsEnum(this.buildTypeIsEnum(type));
- this.setTypeSuperclassNames(this.buildTypeSuperclassNames(type));
- this.setTypeInterfaceNames(this.buildTypeInterfaceNames(type));
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ********** BinaryPersistentMember implementation **********
-
- private Adapter getAdapter() {
- return (Adapter) this.adapter;
- }
-
-
- // ********** JavaResourceAttribute implementation **********
-
- @Override
- public JavaResourceType getParent() {
- return (JavaResourceType) super.getParent();
- }
-
- public JavaResourceType getResourceType() {
- return this.getParent();
- }
-
- public String getName() {
- return this.getAdapter().getAttributeName();
- }
-
- public boolean typeIsSubTypeOf(String tn) {
- return ((this.typeName != null) && this.typeName.equals(tn))
- || this.typeInterfaceNames.contains(tn)
- || this.typeSuperclassNames.contains(tn);
- }
-
- public boolean typeIsVariablePrimitive() {
- return (this.typeName != null) && ClassName.isVariablePrimitive(this.typeName);
- }
-
- // ***** modifiers
- public int getModifiers() {
- return this.modifiers;
- }
-
- private void setModifiers(int modifiers) {
- int old = this.modifiers;
- this.modifiers = modifiers;
- this.firePropertyChanged(MODIFIERS_PROPERTY, old, modifiers);
- }
-
- /**
- * zero seems like a reasonable default...
- */
- private int buildModifiers(IMember member) {
- try {
- return member.getFlags();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return 0;
- }
- }
-
- // ***** type name
- public String getTypeName() {
- return this.typeName;
- }
-
- private void setTypeName(String typeName) {
- String old = this.typeName;
- this.typeName = typeName;
- this.firePropertyChanged(TYPE_NAME_PROPERTY, old, typeName);
- }
-
- private String buildTypeName(String typeSignature, Iterable<ITypeParameter> typeParameters) {
- return convertTypeSignatureToTypeName(typeSignature, typeParameters);
- }
-
- // ***** type is interface
- public boolean typeIsInterface() {
- return this.typeIsInterface;
- }
-
- private void setTypeIsInterface(boolean typeIsInterface) {
- boolean old = this.typeIsInterface;
- this.typeIsInterface = typeIsInterface;
- this.firePropertyChanged(TYPE_IS_INTERFACE_PROPERTY, old, typeIsInterface);
- }
-
- private boolean buildTypeIsInterface(IType type) {
- try {
- return (type != null) && type.isInterface();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- // ***** type is enum
- public boolean typeIsEnum() {
- return this.typeIsEnum;
- }
-
- private void setTypeIsEnum(boolean typeIsEnum) {
- boolean old = this.typeIsEnum;
- this.typeIsEnum = typeIsEnum;
- this.firePropertyChanged(TYPE_IS_ENUM_PROPERTY, old, typeIsEnum);
- }
-
- private boolean buildTypeIsEnum(IType type) {
- try {
- return (type != null) && type.isEnum();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- // ***** type is array
- public boolean typeIsArray() {
- return this.typeIsArray;
- }
-
- private void setTypeIsArray(boolean typeIsArray) {
- boolean old = this.typeIsArray;
- this.typeIsArray = typeIsArray;
- this.firePropertyChanged(TYPE_IS_ARRAY_PROPERTY, old, typeIsArray);
- }
-
- private boolean buildTypeIsArray(String typeSignature) {
- return convertTypeSignatureToTypeIsArray(typeSignature);
- }
-
- // ***** type array dimensionality
- public int getTypeArrayDimensionality() {
- return this.typeArrayDimensionality;
- }
-
- private void setTypeArrayDimensionality(int typeArrayDimensionality) {
- int old = this.typeArrayDimensionality;
- this.typeArrayDimensionality = typeArrayDimensionality;
- firePropertyChanged(TYPE_ARRAY_DIMENSIONALITY_PROPERTY, old, typeArrayDimensionality);
- }
-
- private int buildTypeArrayDimensionality(String typeSignature) {
- return convertTypeSignatureToTypeArrayDimensionality(typeSignature);
- }
-
- // ***** type array component type name
- public String getTypeArrayComponentTypeName() {
- return this.typeArrayComponentTypeName;
- }
-
- private void setTypeArrayComponentTypeName(String typeArrayComponentTypeName) {
- String old = this.typeArrayComponentTypeName;
- this.typeArrayComponentTypeName = typeArrayComponentTypeName;
- firePropertyChanged(TYPE_ARRAY_COMPONENT_TYPE_NAME_PROPERTY, old, typeArrayComponentTypeName);
- }
-
- private String buildTypeArrayComponentTypeName(String typeSignature, Iterable<ITypeParameter> typeParameters) {
- int arrayDimensionality = convertTypeSignatureToTypeArrayDimensionality(typeSignature);
- return (arrayDimensionality == 0) ? null : convertTypeSignatureToTypeArrayComponentTypeName(typeSignature, typeParameters);
- }
-
- // ***** type superclass hierarchy
- public ListIterable<String> getTypeSuperclassNames() {
- return new LiveCloneListIterable<String>(this.typeSuperclassNames);
- }
-
- public boolean typeSuperclassNamesContains(String superclassName) {
- return this.typeSuperclassNames.contains(superclassName);
- }
-
- private void setTypeSuperclassNames(List<String> typeSuperclassNames) {
- this.synchronizeList(typeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_LIST);
- }
-
- private List<String> buildTypeSuperclassNames(IType type) {
- if (type == null) {
- return Collections.emptyList();
- }
-
- ArrayList<String> names = new ArrayList<String>();
- type = this.findSuperclass(type);
- while (type != null) {
- names.add(type.getFullyQualifiedName('.')); // no parameters are included here
- type = this.findSuperclass(type);
- }
- return names;
- }
-
- // ***** type interface hierarchy
- public Iterable<String> getTypeInterfaceNames() {
- return new LiveCloneIterable<String>(this.typeInterfaceNames);
- }
-
- public boolean typeInterfaceNamesContains(String interfaceName) {
- return this.typeInterfaceNames.contains(interfaceName);
- }
-
- private void setTypeInterfaceNames(Collection<String> typeInterfaceNames) {
- this.synchronizeCollection(typeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION);
- }
-
- private Collection<String> buildTypeInterfaceNames(IType type) {
- if (type == null) {
- return Collections.emptySet();
- }
-
- HashSet<String> names = new HashSet<String>();
- while (type != null) {
- this.addInterfaceNamesTo(type, names);
- type = this.findSuperclass(type);
- }
- return names;
- }
-
- private void addInterfaceNamesTo(IType type, HashSet<String> names) {
- for (String interfaceSignature : this.getSuperInterfaceTypeSignatures(type)) {
- String interfaceName = convertTypeSignatureToTypeName(interfaceSignature);
- names.add(interfaceName);
- IType interfaceType = this.findType(interfaceName, type.getJavaProject());
- if (interfaceType != null) {
- this.addInterfaceNamesTo(interfaceType, names); // recurse
- }
- }
- }
-
- // ***** type type argument names
- public ListIterable<String> getTypeTypeArgumentNames() {
- return new LiveCloneListIterable<String>(this.typeTypeArgumentNames);
- }
-
- public int getTypeTypeArgumentNamesSize() {
- return this.typeTypeArgumentNames.size();
- }
-
- public String getTypeTypeArgumentName(int index) {
- return this.typeTypeArgumentNames.get(index);
- }
-
- private void setTypeTypeArgumentNames(List<String> typeTypeArgumentNames) {
- this.synchronizeList(typeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_LIST);
- }
-
- private List<String> buildTypeTypeArgumentNames(String typeSignature, Iterable<ITypeParameter> typeParameters) {
- int arrayDimensionality = convertTypeSignatureToTypeArrayDimensionality(typeSignature);
- return (arrayDimensionality != 0) ? Collections.<String>emptyList() : convertTypeSignatureToTypeTypeArgumentNames(typeSignature, typeParameters);
- }
-
-
- // ********** convenience methods **********
-
- private String getTypeSignature() {
- try {
- return this.getAdapter().getTypeSignature();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return null;
- }
- }
-
- private IType findSuperclass(IType type) {
- return this.findTypeBySignature(this.getSuperclassSignature(type), type.getJavaProject());
- }
-
- private String getSuperclassSignature(IType type) {
- try {
- return type.getSuperclassTypeSignature();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return null;
- }
- }
-
- private String[] getSuperInterfaceTypeSignatures(IType type) {
- try {
- return type.getSuperInterfaceTypeSignatures();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return StringTools.EMPTY_STRING_ARRAY;
- }
- }
-
- private IType findTypeBySignature(String typeSignature, IJavaProject javaProject) {
- return (typeSignature == null) ? null : findType(convertTypeSignatureToTypeName_(typeSignature), javaProject);
- }
-
- private IType getType(IJavaProject javaProject) {
- return (this.typeName == null) ? null : findType(this.typeName, javaProject);
- }
-
- private static IType findType(String fullyQualifiedName, IJavaProject javaProject) {
- try {
- return javaProject.findType(fullyQualifiedName);
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return null;
- }
- }
-
-
-
- // ********** adapters **********
-
- /**
- * Adapt an IField or IMethod.
- */
- interface Adapter
- extends BinaryMember.Adapter {
-
- /**
- * Return the field or getter method's "attribute" name
- * (e.g. field "foo" -> "foo"; method "getFoo" -> "foo").
- */
- String getAttributeName();
-
- /**
- * Return the attribute's type signature.
- */
- String getTypeSignature() throws JavaModelException;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryClassFile.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryClassFile.java
deleted file mode 100644
index 3c4d009ad6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryClassFile.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceClassFile;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageFragment;
-
-/**
- * binary class file
- */
-final class BinaryClassFile
- extends BinaryNode
- implements JavaResourceClassFile
-{
- /** JDT class file */
- private final IClassFile classFile;
-
- /** class file's type */
- private final JavaResourceAbstractType type;
-
-
- // ********** construction/initialization **********
-
- /**
- * The JDT type gets passed in because the package fragment inspects it
- * beforehand to determine whether it exists and is relevant.
- */
- BinaryClassFile(JavaResourcePackageFragment parent, IClassFile classFile, IType jdtType) {
- super(parent);
- this.classFile = classFile;
- this.type = this.buildType(jdtType);
- }
-
- private JavaResourceAbstractType buildType(IType jdtType) {
- try {
- if (jdtType.isEnum()) {
- return new BinaryEnum(this, jdtType);
- }
- }
- catch (JavaModelException e) {
- JptCommonCorePlugin.log(e);
- }
- return new BinaryType(this, jdtType);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.classFile.getElementName());
- }
-
-
- // ********** JavaResourceClassFile implementation **********
-
- public JavaResourceAbstractType getType() {
- return this.type;
- }
-
- // TODO
- @Override
- public void update() {
- super.update();
-// type(this.classFile.getType());
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryEnum.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryEnum.java
deleted file mode 100644
index c41524bbd3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryEnum.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import java.util.Collection;
-import java.util.Vector;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnumConstant;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-
-/**
- * binary enum
- */
-final class BinaryEnum
- extends BinaryAbstractType
- implements JavaResourceEnum
-{
- private final Vector<JavaResourceEnumConstant> enumConstants;
-
-
- // ********** construction/initialization **********
-
- BinaryEnum(JavaResourceNode parent, IType type) {
- super(parent, type);
- this.enumConstants = this.buildEnumConstants();
- }
-
- public Kind getKind() {
- return JavaResourceAnnotatedElement.Kind.ENUM;
- }
- // ********** overrides **********
-
- @Override
- public void update() {
- super.update();
- this.updateEnumConstants();
- }
-
- // TODO
- private void updateEnumConstants() {
- throw new UnsupportedOperationException();
- }
-
-
-
- // ********** JavaResourceEnum implementation **********
-
-
-
- // ********** enum constants **********
-
- public Iterable<JavaResourceEnumConstant> getEnumConstants() {
- return new LiveCloneIterable<JavaResourceEnumConstant>(this.enumConstants);
- }
-
- private void addEnumConstant(JavaResourceEnumConstant enumConstants) {
- this.addItemToCollection(enumConstants, this.enumConstants, ENUMS_COLLECTION);
- }
-
- private JavaResourceEnumConstant getEnumConstant(String enumConstantName, int occurrence) {
- for (JavaResourceEnumConstant enumConstant : this.getEnumConstants()) {
- if (enumConstant.isFor(enumConstantName, occurrence)) {
- return enumConstant;
- }
- }
- return null;
- }
-
- private void removeEnumConstants(Collection<JavaResourceEnumConstant> remove) {
- this.removeItemsFromCollection(remove, this.enumConstants, ENUMS_COLLECTION);
- }
-
- private Vector<JavaResourceEnumConstant> buildEnumConstants() {
- Iterable<IField> jdtEnumConstants = this.getEnumConstants(this.getMember());
- Vector<JavaResourceEnumConstant> result = new Vector<JavaResourceEnumConstant>(CollectionTools.size(jdtEnumConstants));
- for (IField jdtEnumConstant : jdtEnumConstants) {
- result.add(this.buildEnumConstant(jdtEnumConstant));
- }
- return result;
- }
-
- private Iterable<IField> getEnumConstants(IType type) {
- return new FilteringIterable<IField>(CollectionTools.iterable(this.getFields(type))) {
- @Override
- protected boolean accept(IField jdtField) {
- return isEnumConstant(jdtField);
- }
- };
- }
-
- private IField[] getFields(IType type) {
- try {
- return type.getFields();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return EMPTY_FIELD_ARRAY;
- }
- }
- private static final IField[] EMPTY_FIELD_ARRAY = new IField[0];
-
- private boolean isEnumConstant(IField field) {
- try {
- return field.isEnumConstant();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- private JavaResourceEnumConstant buildEnumConstant(IField jdtEnumConstant) {
- return new BinaryEnumConstant(this, jdtEnumConstant);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryEnumConstant.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryEnumConstant.java
deleted file mode 100644
index eae0c24578..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryEnumConstant.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.ITypeParameter;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnumConstant;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-
-/**
- * Java binary enum constant, IField that returns true to isEnumConstant
- */
-final class BinaryEnumConstant
- extends BinaryMember
- implements JavaResourceEnumConstant {
-
-
-
- BinaryEnumConstant(JavaResourceEnum parent, IField enumConstant){
- super(parent, new EnumConstantAdapter(enumConstant));
- }
-
- @Override
- IField getMember() {
- return (IField) super.getMember();
- }
-
- // ******** JavaResourceAnnotatedElement implementation ********
-
- public Kind getKind() {
- return Kind.ENUM_CONSTANT;
- }
-
-
- // ******** JavaResourceEnumConstant implementation ********
-
- public String getName() {
- return this.getMember().getElementName();
- }
-
-
- // ********** IField adapter **********
-
- static class EnumConstantAdapter
- implements Adapter {
-
- private final IField enumConstant;
-
- EnumConstantAdapter(IField enumConstant) {
- super();
- this.enumConstant = enumConstant;
- }
-
- public IField getElement() {
- return this.enumConstant;
- }
-
- public Iterable<ITypeParameter> getTypeParameters() {
- try {
- return new ArrayIterable<ITypeParameter>(this.enumConstant.getDeclaringType().getTypeParameters());
- }
- catch (JavaModelException jme) {
- JptCommonCorePlugin.log(jme);
- }
- return EmptyIterable.instance();
- }
-
- public IAnnotation[] getAnnotations() throws JavaModelException {
- return this.enumConstant.getAnnotations();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryField.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryField.java
deleted file mode 100644
index ea20715065..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryField.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.ITypeParameter;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-
-/**
- * binary field
- */
-final class BinaryField
- extends BinaryAttribute
- implements JavaResourceField
-{
-
- BinaryField(JavaResourceType parent, IField field) {
- super(parent, new FieldAdapter(field));
- }
-
-
- // ******** JavaResourceAnnotatedElement implementation ********
-
- public Kind getKind() {
- return Kind.FIELD;
- }
-
- // ********** adapters **********
-
- /**
- * IField adapter
- */
- static class FieldAdapter
- implements BinaryAttribute.Adapter {
-
- final IField field;
-
- FieldAdapter(IField field) {
- super();
- this.field = field;
- }
-
- public IField getElement() {
- return this.field;
- }
-
- public Iterable<ITypeParameter> getTypeParameters() {
- try {
- return new ArrayIterable<ITypeParameter>(this.field.getDeclaringType().getTypeParameters());
- }
- catch (JavaModelException jme) {
- JptCommonCorePlugin.log(jme);
- }
- return EmptyIterable.instance();
- }
-
- public IAnnotation[] getAnnotations() throws JavaModelException {
- return this.field.getAnnotations();
- }
-
- public String getAttributeName() {
- return this.field.getElementName();
- }
-
- public String getTypeSignature() throws JavaModelException {
- return this.field.getTypeSignature();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMember.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMember.java
deleted file mode 100644
index c7b38f8529..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMember.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.ITypeParameter;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceMember;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-
-/**
- * binary persistent member
- */
-abstract class BinaryMember
- extends BinaryAnnotatedElement
- implements JavaResourceMember
-{
-
- private boolean final_; // 'final' is a reserved word
- private boolean transient_; // 'transient' is a reserved word
- private boolean public_; // 'public' is a reserved word
- private boolean static_; // 'static' is a reserved word
- private boolean protected_; // 'protected' is a reserved word
-
-
- // ********** construction/initialization **********
-
- public BinaryMember(JavaResourceNode parent, Adapter adapter) {
- super(parent, adapter);
- IMember member = adapter.getElement();
- this.final_ = this.buildFinal(member);
- this.transient_ = this.buildTransient(member);
- this.public_ = this.buildPublic(member);
- this.static_ = this.buildStatic(member);
- this.protected_ = this.buildProtected(member);
- }
-
- // ********** updating **********
-
- @Override
- public void update() {
- super.update();
- this.update(this.getMember());
- }
-
- protected void update(IMember member) {
- this.setFinal(this.buildFinal(member));
- this.setTransient(this.buildTransient(member));
- this.setPublic(this.buildPublic(member));
- this.setStatic(this.buildStatic(member));
- this.setProtected(this.buildProtected(member));
- }
-
- // ********** simple state **********
-
- // ***** final
- public boolean isFinal() {
- return this.final_;
- }
-
- private void setFinal(boolean final_) {
- boolean old = this.final_;
- this.final_ = final_;
- this.firePropertyChanged(FINAL_PROPERTY, old, final_);
- }
-
- private boolean buildFinal(IMember member) {
- try {
- return Flags.isFinal(member.getFlags());
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- // ***** transient
- public boolean isTransient() {
- return this.transient_;
- }
-
- private void setTransient(boolean transient_) {
- boolean old = this.transient_;
- this.transient_ = transient_;
- this.firePropertyChanged(TRANSIENT_PROPERTY, old, transient_);
- }
-
- private boolean buildTransient(IMember member) {
- try {
- return Flags.isTransient(member.getFlags());
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- // ***** public
- public boolean isPublic() {
- return this.public_;
- }
-
- private void setPublic(boolean public_) {
- boolean old = this.public_;
- this.public_ = public_;
- this.firePropertyChanged(PUBLIC_PROPERTY, old, public_);
- }
-
- private boolean buildPublic(IMember member) {
- try {
- return Flags.isPublic(member.getFlags());
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- // ***** static
- public boolean isStatic() {
- return this.static_;
- }
-
- private void setStatic(boolean static_) {
- boolean old = this.static_;
- this.static_ = static_;
- this.firePropertyChanged(STATIC_PROPERTY, old, static_);
- }
-
- private boolean buildStatic(IMember member) {
- try {
- return Flags.isStatic(member.getFlags());
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- // ***** protected
- public boolean isProtected() {
- return this.protected_;
- }
-
- private void setProtected(boolean protected_) {
- boolean old = this.protected_;
- this.protected_ = protected_;
- this.firePropertyChanged(PROTECTED_PROPERTY, old, protected_);
- }
-
- private boolean buildProtected(IMember member) {
- try {
- return Flags.isProtected(member.getFlags());
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- // ********** miscellaneous **********
-
- IMember getMember() {
- return this.getAdapter().getElement();
- }
-
- private Adapter getAdapter() {
- return (Adapter) this.adapter;
- }
-
- /**
- * Strip off the type signature's parameters if present.
- * Convert to a readable string.
- */
- static String convertTypeSignatureToTypeName(String typeSignature) {
- return convertTypeSignatureToTypeName(typeSignature, EmptyIterable.<ITypeParameter>instance());
- }
-
- /**
- * Strip off the type signature's parameters if present.
- * Convert to a readable string.
- */
- static String convertTypeSignatureToTypeName(String typeSignature, Iterable<ITypeParameter> typeParameters) {
- return (typeSignature == null) ? null : convertTypeSignatureToTypeName_(typeSignature, typeParameters);
- }
-
- /**
- * no null check
- */
- static String convertTypeSignatureToTypeName_(String typeSignature) {
- return convertTypeSignatureToTypeName(typeSignature, EmptyIterable.<ITypeParameter>instance());
- }
-
- /**
- * no null check
- */
- static String convertTypeSignatureToTypeName_(String typeSignature, Iterable<ITypeParameter> typeParameters) {
- String erasureSignature = Signature.getTypeErasure(typeSignature);
- if (Signature.getTypeSignatureKind(erasureSignature) == Signature.TYPE_VARIABLE_SIGNATURE) {
- try {
- String typeParameterName = Signature.toString(erasureSignature);
- for (ITypeParameter typeParameter : typeParameters) {
- if (typeParameterName.equals(typeParameter.getElementName())) {
- String[] bounds = typeParameter.getBoundsSignatures();
- if (bounds.length > 0) {
- return convertTypeSignatureToTypeName_(bounds[0], typeParameters);
- }
- }
- }
- }
- catch (JavaModelException jme) {
- JptCommonCorePlugin.log(jme);
- }
- }
- else if (Signature.getTypeSignatureKind(erasureSignature) == Signature.ARRAY_TYPE_SIGNATURE) {
- int dim = Signature.getArrayCount(erasureSignature);
- String arrayTypeName = convertTypeSignatureToTypeName(Signature.getElementType(erasureSignature), typeParameters);
- return Signature.toString(Signature.createArraySignature(Signature.createTypeSignature(arrayTypeName, true), dim));
- }
- else if (Signature.getTypeSignatureKind(erasureSignature) == Signature.WILDCARD_TYPE_SIGNATURE) {
- // if signature is ? (wildcard) or ? super X (bottom bounded), return top bound, which is Object
- if (String.valueOf(Signature.C_STAR).equals(erasureSignature) || erasureSignature.startsWith(String.valueOf(Signature.C_SUPER))) {
- return Object.class.getName();
- }
- // return top bound
- return Signature.toString(erasureSignature.substring(1));
- }
- return Signature.toString(erasureSignature);
- }
-
- static boolean convertTypeSignatureToTypeIsArray(String typeSignature) {
- return (typeSignature == null) ? false : Signature.getTypeSignatureKind(typeSignature) == Signature.ARRAY_TYPE_SIGNATURE;
- }
-
- static int convertTypeSignatureToTypeArrayDimensionality(String typeSignature) {
- return (typeSignature == null) ? 0 : Signature.getArrayCount(typeSignature);
- }
-
- static String convertTypeSignatureToTypeArrayComponentTypeName(String typeSignature, Iterable<ITypeParameter> typeParameters) {
- return (typeSignature == null) ? null : convertTypeSignatureToTypeName(Signature.getElementType(typeSignature), typeParameters);
- }
-
- /**
- * these types can be arrays (e.g. "java.lang.String[]");
- * but they won't have any further nested generic type arguments
- * (e.g. "java.util.Collection<java.lang.String>")
- */
- static List<String> convertTypeSignatureToTypeTypeArgumentNames(String typeSignature, Iterable<ITypeParameter> typeParameters) {
- if (typeSignature == null) {
- return Collections.emptyList();
- }
-
- String[] typeArgumentSignatures = Signature.getTypeArguments(typeSignature);
- if (typeArgumentSignatures.length == 0) {
- return Collections.emptyList();
- }
-
- ArrayList<String> names = new ArrayList<String>(typeArgumentSignatures.length);
- for (String typeArgumentSignature : typeArgumentSignatures) {
- names.add(convertTypeSignatureToTypeName(typeArgumentSignature, typeParameters));
- }
- return names;
- }
-
- public boolean isPublicOrProtected() {
- return this.isPublic() || this.isProtected();
- }
-
- // ********** IMember adapter **********
-
- interface Adapter extends BinaryAnnotatedElement.Adapter {
- /**
- * Return the adapter's JDT member (IType, IField, IMethod).
- */
- IMember getElement();
-
- Iterable<ITypeParameter> getTypeParameters();
- }
-
-
- // ********** unsupported JavaResourceMember implementation **********
-
- public Annotation setPrimaryAnnotation(String primaryAnnotationName, Iterable<String> supportingAnnotationNames) {
- throw new UnsupportedOperationException();
- }
-
- public void resolveTypes(CompilationUnit astRoot) {
- throw new UnsupportedOperationException();
- }
-
- public boolean isFor(String memberName, int occurrence) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMethod.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMethod.java
deleted file mode 100644
index fbdd9bea91..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryMethod.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.ILocalVariable;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.ITypeParameter;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.utility.MethodSignature;
-import org.eclipse.jpt.common.utility.internal.NameTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-
-/**
- * binary method
- */
-final class BinaryMethod
- extends BinaryAttribute
- implements JavaResourceMethod {
-
- private boolean constructor;
-
- private final Vector<String> parameterTypeNames = new Vector<String>();
-
-
- BinaryMethod(JavaResourceType parent, IMethod method) {
- super(parent, new MethodAdapter(method));
- }
-
- public Kind getKind() {
- return JavaResourceAnnotatedElement.Kind.METHOD;
- }
-
- // ***** overrides *****
-
- @Override
- protected void update(IMember member) {
- super.update(member);
- this.setConstructor(this.buildConstructor((IMethod) member));
- this.setParameterTypeNames(this.buildParameterTypeNames((IMethod) member));
- }
-
- public void initialize(MethodDeclaration methodDeclaration) {
- throw new UnsupportedOperationException();
- }
-
- public void synchronizeWith(MethodDeclaration methodDeclaration) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- IMethod getMember() {
- return (IMethod) super.getMember();
- }
-
-
- // ***** method name *****
-
- public String getMethodName() {
- return getMember().getElementName();
- }
-
-
- // ***** parameter type names *****
-
- public ListIterable<String> getParameterTypeNames() {
- return new LiveCloneListIterable<String>(this.parameterTypeNames);
- }
-
- public String getParameterTypeName(int index) {
- return this.parameterTypeNames.get(index);
- }
-
- public int getParametersSize() {
- return this.parameterTypeNames.size();
- }
-
- private List<String> buildParameterTypeNames(IMethod method) {
- ArrayList<String> names = new ArrayList<String>();
- for (ILocalVariable parameter : this.getParameters(method)) {
- names.add(parameter.getElementName());//TODO is this right?
- }
- return names;
- }
-
- private ILocalVariable[] getParameters(IMethod jdtMethod) {
- try {
- return jdtMethod.getParameters();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return null;
- }
- }
-
- private void setParameterTypeNames(List<String> parameterTypeNames) {
- this.synchronizeList(parameterTypeNames, this.parameterTypeNames, PARAMETER_TYPE_NAMES_LIST);
- }
-
-
- // ***** constructor *****
-
- public boolean isConstructor() {
- return this.constructor;
- }
-
- private void setConstructor(boolean isConstructor) {
- boolean old = this.constructor;
- this.constructor = isConstructor;
- this.firePropertyChanged(CONSTRUCTOR_PROPERTY, old, isConstructor);
- }
-
- private boolean buildConstructor(IMethod method) {
- try {
- return method.isConstructor();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
-
- // ***** misc *****
-
- public boolean isFor(MethodSignature methodSignature, int occurrence) {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** adapters **********
-
- /**
- * IMethod adapter
- */
- static class MethodAdapter
- implements BinaryAttribute.Adapter {
-
- final IMethod method;
- static final IMethod[] EMPTY_METHOD_ARRAY = new IMethod[0];
-
- MethodAdapter(IMethod method) {
- super();
- this.method = method;
- }
-
- public IMethod getElement() {
- return this.method;
- }
-
- public Iterable<ITypeParameter> getTypeParameters() {
- try {
- return new CompositeIterable<ITypeParameter>(
- new ArrayIterable<ITypeParameter>(this.method.getTypeParameters()),
- new ArrayIterable<ITypeParameter>(this.method.getDeclaringType().getTypeParameters()));
- }
- catch (JavaModelException jme) {
- JptCommonCorePlugin.log(jme);
- }
- return EmptyIterable.instance();
- }
-
- public IAnnotation[] getAnnotations() throws JavaModelException {
- return this.method.getAnnotations();
- }
-
- public String getAttributeName() {
- return NameTools.convertGetterSetterMethodNameToPropertyName(this.method.getElementName());
- }
-
- public String getTypeSignature() throws JavaModelException {
- return this.method.getReturnType();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryNamedAnnotation.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryNamedAnnotation.java
deleted file mode 100644
index 3e3b3f8cc0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryNamedAnnotation.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-
-/**
- * Used for annotations that have no behavior, just a name
- */
-public final class BinaryNamedAnnotation
- extends BinaryAnnotation
-{
-
- private final String annotationName;
-
- public BinaryNamedAnnotation(JavaResourceNode parent, IAnnotation jdtAnnotation, String annotationName) {
- super(parent, jdtAnnotation);
- this.annotationName = annotationName;
- }
-
- public String getAnnotationName() {
- return this.annotationName;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryNode.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryNode.java
deleted file mode 100644
index 76a1eecf52..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryNode.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.IMemberValuePair;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.resource.java.AbstractJavaResourceNode;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.core.utility.TextRange;
-
-/**
- * Binary convenience methods
- */
-// TODO hopefully this class can go away with some sort of refactoring of the
-// source and binary hierarchies...
-public abstract class BinaryNode
- extends AbstractJavaResourceNode
-{
- protected BinaryNode(JavaResourceNode parent) {
- super(parent);
- }
-
-
- // ********** JavaResourceNode implementation **********
-
- @Override
- public IFile getFile() {
- return null; // only BinaryPackageFragmentRoot has a file...
- }
-
- public void update() {
- // nothing by default
- }
-
- public JavaResourceCompilationUnit getJavaResourceCompilationUnit() {
- throw new UnsupportedOperationException();
- }
-
- public TextRange getTextRange(CompilationUnit astRoot) {
- throw new UnsupportedOperationException();
- }
-
- public void initialize(CompilationUnit astRoot) {
- throw new UnsupportedOperationException();
- }
-
- public void synchronizeWith(CompilationUnit astRoot) {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** member value-pairs **********
-
- /**
- * Return the <em>values</em> of the specified JDT annotation's member with
- * the specified name.
- */
- public Object[] getJdtMemberValues(IAnnotation jdtContainerAnnotation, String memberName) {
- Object[] values = (Object[]) this.getJdtMemberValue(jdtContainerAnnotation, memberName);
- return (values != null) ? values : EMPTY_OBJECT_ARRAY;
- }
- private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
-
- /**
- * Return the value of the specified JDT annotation's member with
- * the specified name.
- */
- public Object getJdtMemberValue(IAnnotation jdtContainerAnnotation, String memberName) {
- IMemberValuePair pair = this.getJdtMemberValuePair(jdtContainerAnnotation, memberName);
- return (pair == null) ? null : pair.getValue();
- }
-
- /**
- * Return the specified JDT annotation's member-value pair with
- * the specified name.
- */
- public IMemberValuePair getJdtMemberValuePair(IAnnotation jdtContainerAnnotation, String memberName) {
- for (IMemberValuePair pair : this.getJdtMemberValuePairs(jdtContainerAnnotation)) {
- if (pair.getMemberName().equals(memberName)) {
- return pair;
- }
- }
- return null;
- }
-
- public IMemberValuePair[] getJdtMemberValuePairs(IAnnotation jdtContainerAnnotation) {
- try {
- return jdtContainerAnnotation.getMemberValuePairs();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return EMPTY_MEMBER_VALUE_PAIR_ARRAY;
- }
- }
- private static final IMemberValuePair[] EMPTY_MEMBER_VALUE_PAIR_ARRAY = new IMemberValuePair[0];
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryPackageFragment.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryPackageFragment.java
deleted file mode 100644
index bbfdf84c37..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryPackageFragment.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Vector;
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.IClassFile;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceClassFile;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageFragment;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageFragmentRoot;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-
-/**
- * binary package fragment
- */
-final class BinaryPackageFragment
- extends BinaryNode
- implements JavaResourcePackageFragment
-{
- /** JDT package fragment */
- private final IPackageFragment packageFragment;
-
- /**
- * class files in the package fragment;
- * we only hold class files/types that are actually annotated;
- * if the unannotated types are needed (e.g. for orm.xml or an
- * inheritance tree) they can be discovered on the classpath as needed
- */
- private final Vector<JavaResourceClassFile> classFiles = new Vector<JavaResourceClassFile>();
-
-
- // ********** construction/initialization **********
-
- BinaryPackageFragment(JavaResourcePackageFragmentRoot parent, IPackageFragment packageFragment) {
- super(parent);
- this.packageFragment = packageFragment;
- this.classFiles.addAll(this.buildClassFiles());
- }
-
- private Collection<JavaResourceClassFile> buildClassFiles() {
- IJavaElement[] children = this.getJDTChildren();
- ArrayList<JavaResourceClassFile> result = new ArrayList<JavaResourceClassFile>(children.length);
- Collection<String> annotationNames = CollectionTools.collection(this.getAnnotationProvider().getAnnotationNames());
- for (IJavaElement child : children) {
- IClassFile jdtClassFile = (IClassFile) child;
- IType jdtType = jdtClassFile.getType();
- if (typeIsRelevant(jdtType, annotationNames)) {
- result.add(new BinaryClassFile(this, jdtClassFile, jdtType));
- }
- }
- return result;
- }
-
- //we will limit to classes, interfaces, and enums. Annotation types will be ignored.
- static boolean typeIsRelevant(IType type, Collection<String> annotationNames) {
- try {
- return (type != null)
- && type.exists()
- && (type.isClass() || type.isInterface() || type.isEnum())
- && typeHasAnnotations(type, annotationNames); // we only hold annotated types
- }
- catch (JavaModelException e) {
- return false;
- }
- }
-
- static boolean typeHasAnnotations(IType type, Collection<String> annotationNames) {
- IAnnotation[] annotations;
- try {
- annotations = type.getAnnotations();
- }
- catch (JavaModelException e) {
- return false;
- }
- for (IAnnotation annotation : annotations) {
- if (annotationNames.contains(annotation.getElementName())) {
- return true;
- }
- }
- return false;
- }
-
- // ********** JarResourceNode implementation **********
-
- @Override
- public void update() {
- super.update();
- this.updateClassFiles();
- }
-
- // TODO
- private void updateClassFiles() {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** JavaResourcePackageFragment implementation **********
-
- public ListIterable<JavaResourceClassFile> getClassFiles() {
- return new LiveCloneListIterable<JavaResourceClassFile>(this.classFiles);
- }
-
- public int getClassFilesSize() {
- return this.classFiles.size();
- }
-
- public Iterable<JavaResourceAbstractType> getTypes() {
- return new TransformationIterable<JavaResourceClassFile, JavaResourceAbstractType>(this.getClassFiles()) {
- @Override
- protected JavaResourceAbstractType transform(JavaResourceClassFile classFile) {
- return classFile.getType(); // we only hold annotated types
- }
- };
- }
-
-
- // ********** misc **********
-
- private IJavaElement[] getJDTChildren() {
- try {
- return this.packageFragment.getChildren();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return EMPTY_JAVA_ELEMENT_ARRAY;
- }
- }
- protected static final IJavaElement[] EMPTY_JAVA_ELEMENT_ARRAY = new IJavaElement[0];
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.packageFragment.getElementName());
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java
deleted file mode 100644
index 42865f3267..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryPackageFragmentRoot.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Vector;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.internal.utility.JDTTools;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageFragment;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageFragmentRoot;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-
-/**
- * binary package fragment root
- */
-public final class BinaryPackageFragmentRoot
- extends RootBinaryNode
- implements JavaResourcePackageFragmentRoot
-{
- /** JDT package fragment root */
- private final IPackageFragmentRoot packageFragmentRoot;
-
- /** package fragments in the JAR */
- private final Vector<JavaResourcePackageFragment> packageFragments = new Vector<JavaResourcePackageFragment>();
-
-
- // ********** construction/initialization **********
-
- public BinaryPackageFragmentRoot(IPackageFragmentRoot packageFragmentRoot, AnnotationProvider annotationProvider) {
- super(null, annotationProvider); // the package fragment root is the root of its sub-tree
- this.packageFragmentRoot = packageFragmentRoot;
- this.packageFragments.addAll(this.buildPackageFragments());
- }
-
- private Collection<JavaResourcePackageFragment> buildPackageFragments() {
- IJavaElement[] jdtChildren = this.getJDTChildren();
- ArrayList<JavaResourcePackageFragment> result = new ArrayList<JavaResourcePackageFragment>(jdtChildren.length);
- for (IJavaElement child : jdtChildren) {
- result.add(new BinaryPackageFragment(this, (IPackageFragment) child));
- }
- return result;
- }
-
-
- // ********** overrides **********
-
- @Override
- public IFile getFile() {
- return (IFile) this.packageFragmentRoot.getResource();
- }
-
- @Override
- public void update() {
- super.update();
- this.updatePackageFragments();
- }
-
- // TODO
- private void updatePackageFragments() {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** JavaResourceNode.Root implementation **********
-
- /**
- * NB: we hold only annotated types
- */
- public Iterable<JavaResourceAbstractType> getTypes() {
- return new CompositeIterable<JavaResourceAbstractType>(this.persistedTypesLists());
- }
-
- private Iterable<Iterable<JavaResourceAbstractType>> persistedTypesLists() {
- return new TransformationIterable<JavaResourcePackageFragment, Iterable<JavaResourceAbstractType>>(this.getPackageFragments()) {
- @Override
- protected Iterable<JavaResourceAbstractType> transform(JavaResourcePackageFragment fragment) {
- return fragment.getTypes();
- }
- };
- }
-
-
- // ********** JavaResourcePackageFragmentRoot implementation **********
-
- public Iterable<JavaResourcePackageFragment> getPackageFragments() {
- return new LiveCloneIterable<JavaResourcePackageFragment>(this.packageFragments);
- }
-
- public int getPackageFragmentsSize() {
- return this.packageFragments.size();
- }
-
-
- // ********** misc **********
-
- private IJavaElement[] getJDTChildren() {
- return JDTTools.getChildren(this.packageFragmentRoot);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryType.java
deleted file mode 100644
index 2ae0b6d0c0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryType.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import java.util.Collection;
-import java.util.Vector;
-import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.Modifier;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.utility.MethodSignature;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-
-/**
- * binary type
- */
-final class BinaryType
- extends BinaryAbstractType
- implements JavaResourceType
-{
- private String superclassQualifiedName;
-
- private boolean abstract_; // 'abstract' is a reserved word
-
- private boolean hasNoArgConstructor;
-
- private boolean hasPrivateNoArgConstructor;
-
- private final Vector<JavaResourceField> fields;
-
- private final Vector<JavaResourceMethod> methods;
-
-
- // ********** construction/initialization **********
-
- BinaryType(JavaResourceNode parent, IType type) {
- super(parent, type);
- this.superclassQualifiedName = this.buildSuperclassQualifiedName(type);
- this.abstract_ = this.buildAbstract(type);
- this.hasNoArgConstructor = this.buildHasNoArgConstructor(type);
- this.hasPrivateNoArgConstructor = this.buildHasPrivateNoArgConstructor(type);
- this.fields = this.buildFields(type);
- this.methods = this.buildMethods(type);
- }
-
- public Kind getKind() {
- return JavaResourceAnnotatedElement.Kind.TYPE;
- }
-
-
- // ********** overrides **********
-
- @Override
- protected void update(IMember member) {
- super.update(member);
- this.setSuperclassQualifiedName(this.buildSuperclassQualifiedName((IType) member));
- this.setAbstract(this.buildAbstract((IType) member));
- this.setHasNoArgConstructor(this.buildHasNoArgConstructor((IType) member));
- this.setHasPrivateNoArgConstructor(this.buildHasPrivateNoArgConstructor((IType) member));
- this.updateFields((IType) member);
- this.updateMethods((IType) member);
- }
-
- // TODO
- private void updateFields(IType type) {
- throw new UnsupportedOperationException();
- }
-
- // TODO
- private void updateMethods(IType type) {
- throw new UnsupportedOperationException();
- }
-
-
-
- // ********** JavaResourceType implementation **********
-
- // ***** superclass qualified name
- public String getSuperclassQualifiedName() {
- return this.superclassQualifiedName;
- }
-
- private void setSuperclassQualifiedName(String superclassQualifiedName) {
- String old = this.superclassQualifiedName;
- this.superclassQualifiedName = superclassQualifiedName;
- this.firePropertyChanged(SUPERCLASS_QUALIFIED_NAME_PROPERTY, old, superclassQualifiedName);
- }
-
- private String buildSuperclassQualifiedName(IType type) {
- return convertTypeSignatureToTypeName(this.getSuperclassTypeSignature(type));
- }
-
- private String getSuperclassTypeSignature(IType type) {
- try {
- return type.getSuperclassTypeSignature();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return null;
- }
- }
-
-
- // ***** abstract
- public boolean isAbstract() {
- return this.abstract_;
- }
-
- private void setAbstract(boolean abstract_) {
- boolean old = this.abstract_;
- this.abstract_ = abstract_;
- this.firePropertyChanged(ABSTRACT_PROPERTY, old, abstract_);
- }
-
- private boolean buildAbstract(IType type) {
- try {
- return Flags.isAbstract(type.getFlags());
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- // ***** no-arg constructor
- public boolean hasNoArgConstructor() {
- return this.hasNoArgConstructor;
- }
-
- private void setHasNoArgConstructor(boolean hasNoArgConstructor) {
- boolean old = this.hasNoArgConstructor;
- this.hasNoArgConstructor = hasNoArgConstructor;
- this.firePropertyChanged(NO_ARG_CONSTRUCTOR_PROPERTY, old, hasNoArgConstructor);
- }
-
- private boolean buildHasNoArgConstructor(IType type) {
- return this.findNoArgConstructor(type) != null;
- }
-
- private IMethod findNoArgConstructor(IType type) {
- try {
- for (IMethod method : type.getMethods()) {
- if (method.isConstructor()) {
- return method;
- }
- }
- }
- catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- }
- return null;
- }
-
- // ***** private no-arg constructor
- public boolean hasPrivateNoArgConstructor() {
- return this.hasPrivateNoArgConstructor;
- }
-
- private void setHasPrivateNoArgConstructor(boolean hasPrivateNoArgConstructor) {
- boolean old = this.hasPrivateNoArgConstructor;
- this.hasPrivateNoArgConstructor = hasPrivateNoArgConstructor;
- this.firePropertyChanged(PRIVATE_NO_ARG_CONSTRUCTOR_PROPERTY, old, hasPrivateNoArgConstructor);
- }
-
- private boolean buildHasPrivateNoArgConstructor(IType type) {
- IMethod method = this.findNoArgConstructor(type);
- try {
- return method != null && Flags.isPrivate(method.getFlags());
- }
- catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
-
- // ***** public/protected no-arg constructor *****
-
- public boolean hasPublicOrProtectedNoArgConstructor() {
- Iterable<JavaResourceMethod> constructors = this.getConstructors();
- if (CollectionTools.size(constructors) == 0) {
- return true;
- }
- for (JavaResourceMethod constructor : constructors) {
- if (constructor.getParametersSize() == 0) {
- return Modifier.isPublic(constructor.getModifiers())
- || Modifier.isProtected(constructor.getModifiers());
- }
- }
- return false;
- }
-
- public boolean hasPublicNoArgConstructor() {
- Iterable<JavaResourceMethod> constructors = this.getConstructors();
- if (CollectionTools.size(constructors) == 0) {
- return true;
- }
- for (JavaResourceMethod constructor : constructors) {
- if (constructor.getParametersSize() == 0) {
- return Modifier.isPublic(constructor.getModifiers());
- }
- }
- return false;
- }
-
- protected Iterable<JavaResourceMethod> getConstructors() {
- return new FilteringIterable<JavaResourceMethod>(this.getMethods()) {
- @Override
- protected boolean accept(JavaResourceMethod method) {
- return method.isConstructor();
- }
- };
- }
-
-
- // ********** misc **********
-
- public boolean hasAnyAnnotatedFields() {
- for (JavaResourceField field : this.getFields()) {
- if (field.isAnnotated()) {
- return true;
- }
- }
- return false;
- }
-
- public boolean hasAnyAnnotatedMethods() {
- for (JavaResourceMethod method : this.getMethods()) {
- if (method.isAnnotated()) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public IType getMember() {
- return super.getMember();
- }
-
- // Two more requirements for a valid equals() method:
- // 1. It should be public
- // 2. The return type should be boolean
- // Both requirements are validated by the compiler so they are excluded here
- public boolean hasEqualsMethod() {
- for (JavaResourceMethod method : this.getMethods()) {
- if (StringTools.stringsAreEqual(method.getMethodName(), "equals") //$NON-NLS-1$
- && method.getParametersSize() == 1
- && StringTools.stringsAreEqual(method.getParameterTypeName(0), Object.class.getName())) {
- return true;
- }
- }
- return false;
- }
-
- // Two more requirements for a valid hashCode() method:
- // 1. It should be public
- // 2. The return type should be int
- // Both requirements are validated by the compiler so they are excluded here
- public boolean hasHashCodeMethod() {
- for (JavaResourceMethod method : this.getMethods()) {
- if (StringTools.stringsAreEqual(method.getMethodName(), "hashCode") //$NON-NLS-1$
- && method.getParametersSize() == 0) {
- return true;
- }
- }
- return false;
- }
-
- public JavaResourceMethod getMethod(String propertyName) {
- for (JavaResourceMethod method : this.getMethods()) {
- if (StringTools.stringsAreEqual(method.getMethodName(), propertyName)) {
- return method;
- }
- }
- return null;
- }
-
- // ********** fields **********
-
- public Iterable<JavaResourceField> getFields() {
- return new LiveCloneIterable<JavaResourceField>(this.fields);
- }
-
- private void addField(JavaResourceField field) {
- this.addItemToCollection(field, this.fields, FIELDS_COLLECTION);
- }
-
- private JavaResourceField getField(String fieldName, int occurrence) {
- for (JavaResourceField field : this.getFields()) {
- if (field.isFor(fieldName, occurrence)) {
- return field;
- }
- }
- return null;
- }
-
- private void removeFields(Collection<JavaResourceField> remove) {
- this.removeItemsFromCollection(remove, this.fields, FIELDS_COLLECTION);
- }
-
- private Vector<JavaResourceField> buildFields(IType type) {
- IField[] jdtFields = this.getFields(type);
- Vector<JavaResourceField> result = new Vector<JavaResourceField>(jdtFields.length);
- for (IField jdtField : jdtFields) {
- result.add(this.buildField(jdtField));
- }
- return result;
- }
-
- private IField[] getFields(IType type) {
- try {
- return type.getFields();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return EMPTY_FIELD_ARRAY;
- }
- }
- private static final IField[] EMPTY_FIELD_ARRAY = new IField[0];
-
- private JavaResourceField buildField(IField jdtField) {
- return new BinaryField(this, jdtField);
- }
-
-
- // ********** methods **********
-
- public Iterable<JavaResourceMethod> getMethods() {
- return new LiveCloneIterable<JavaResourceMethod>(this.methods);
- }
-
- private JavaResourceMethod getMethod(MethodSignature signature, int occurrence) {
- for (JavaResourceMethod method : this.getMethods()) {
- if (method.isFor(signature, occurrence)) {
- return method;
- }
- }
- return null;
- }
-
- private void addMethod(JavaResourceMethod method) {
- this.addItemToCollection(method, this.methods, METHODS_COLLECTION);
- }
-
- private void removeMethods(Collection<JavaResourceMethod> remove) {
- this.removeItemsFromCollection(remove, this.methods, METHODS_COLLECTION);
- }
-
- private Vector<JavaResourceMethod> buildMethods(IType type) {
- IMethod[] jdtMethods = this.getMethods(type);
- Vector<JavaResourceMethod> result = new Vector<JavaResourceMethod>(jdtMethods.length);
- for (IMethod jdtMethod : jdtMethods) {
- result.add(this.buildMethod(jdtMethod));
- }
- return result;
- }
-
- private IMethod[] getMethods(IType type) {
- try {
- return type.getMethods();
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return EMPTY_METHOD_ARRAY;
- }
- }
- private static final IMethod[] EMPTY_METHOD_ARRAY = new IMethod[0];
-
- private JavaResourceMethod buildMethod(IMethod jdtMethod) {
- return new BinaryMethod(this, jdtMethod);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryTypeCache.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryTypeCache.java
deleted file mode 100644
index fdc5684ba7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/BinaryTypeCache.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import java.util.Vector;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceTypeCache;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-
-/**
- * cache used to hold binary "external" Java resource types
- * (typically derived from JARs on the project's build path)
- */
-public final class BinaryTypeCache
- extends RootBinaryNode
- implements JavaResourceTypeCache
-{
- /** populated on-demand */
- private final Vector<Entry> entries = new Vector<Entry>();
-
-
- // ********** construction **********
-
- public BinaryTypeCache(AnnotationProvider annotationProvider) {
- super(null, annotationProvider);
- }
-
-
- // ********** JavaResourceNode.Root implementation **********
-
- public Iterable<JavaResourceAbstractType> getTypes() {
- return new TransformationIterable<Entry, JavaResourceAbstractType>(this.getEntries()) {
- @Override
- protected JavaResourceAbstractType transform(Entry entry) {
- return entry.type;
- }
- };
- }
-
- private Iterable<Entry> getEntries() {
- return new LiveCloneIterable<Entry>(this.entries);
- }
-
-
- // ********** JavaResourcePersistentTypeCache implementation **********
-
- public int getTypesSize() {
- return this.entries.size();
- }
-
- public JavaResourceAbstractType addType(IType jdtType) {
- Entry entry = this.buildEntry(jdtType);
- this.entries.add(entry);
- this.fireItemAdded(TYPES_COLLECTION, entry.type);
- return entry.type;
- }
-
- private Entry buildEntry(IType jdtType) {
- return new Entry(this.buildType(jdtType), jdtType.getResource());
- }
-
- //ignore annotations
- private JavaResourceAbstractType buildType(IType jdtType) {
- try {
- if (jdtType.isClass() || jdtType.isInterface()) {
- return new BinaryType(this, jdtType);
- }
- if (jdtType.isEnum()) {
- return new BinaryEnum(this, jdtType);
- }
- }
- catch(JavaModelException e) {
- JptCommonCorePlugin.log(e);
- }
- return null;
- }
-
- public boolean removeTypes(IFile jarFile) {
- boolean modified = false;
- for (Entry entry : this.getEntries()) {
- IResource resource = entry.resource;
- if ((resource != null) && resource.equals(jarFile)) {
- this.removeEntry(entry);
- modified = true;
- }
- }
- return modified;
- }
-
- private void removeEntry(Entry entry) {
- this.entries.remove(entry);
- this.fireItemRemoved(TYPES_COLLECTION, entry.type);
- }
-
-
- // ********** overrides **********
-
- /**
- * Ignore changes to this collection. Adds can be ignored since they are triggered
- * by requests that will, themselves, trigger updates (typically during the
- * update of an object that calls a setter with the newly-created resource
- * type). Deletes will be accompanied by manual updates.
- */
- @Override
- protected void aspectChanged(String aspectName) {
- if ((aspectName != null) && ! aspectName.equals(TYPES_COLLECTION)) {
- super.aspectChanged(aspectName);
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.entries);
- }
-
-
- // ********** cache entry **********
-
- /**
- * Associate a type with its resource.
- * This will be a JAR in the case of a type loaded from a JAR that is in
- * the Eclipse workspace. The resource will be null for a type loaded
- * from a JAR or class directory outside of the workspace.
- */
- static class Entry {
- final JavaResourceAbstractType type;
- final IResource resource;
-
- Entry(JavaResourceAbstractType type, IResource resource) {
- super();
- this.type = type;
- this.resource = resource;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.type);
- }
-
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/RootBinaryNode.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/RootBinaryNode.java
deleted file mode 100644
index 3afcf608da..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/binary/RootBinaryNode.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.binary;
-
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.JptResourceModelListener;
-import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-
-/**
- * JAR and external types
- */
-abstract class RootBinaryNode
- extends BinaryNode
- implements JavaResourceNode.Root
-{
- /** pluggable annotation provider */
- private final AnnotationProvider annotationProvider;
-
- /** listeners notified whenever the resource model changes */
- private final ListenerList<JptResourceModelListener> resourceModelListenerList = new ListenerList<JptResourceModelListener>(JptResourceModelListener.class);
-
-
- // ********** construction **********
-
- RootBinaryNode(JavaResourceNode parent, AnnotationProvider annotationProvider) {
- super(parent);
- this.annotationProvider = annotationProvider;
- }
-
-
- // ********** overrides **********
-
- @Override
- protected boolean requiresParent() {
- return false;
- }
-
- @Override
- public Root getRoot() {
- return this;
- }
-
- @Override
- public AnnotationProvider getAnnotationProvider() {
- return this.annotationProvider;
- }
-
-
- // ********** JavaResourceNode.Root implementation **********
-
- public void resourceModelChanged() {
- for (JptResourceModelListener listener : this.resourceModelListenerList.getListeners()) {
- listener.resourceModelChanged(this);
- }
- }
-
-
- // ********** JptResourceModel implementation **********
-
- public JptResourceType getResourceType() {
- return JptCommonCorePlugin.JAR_RESOURCE_TYPE;
- }
-
- public void addResourceModelListener(JptResourceModelListener listener) {
- this.resourceModelListenerList.add(listener);
- }
-
- public void removeResourceModelListener(JptResourceModelListener listener) {
- this.resourceModelListenerList.remove(listener);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAbstractType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAbstractType.java
deleted file mode 100644
index 16a42f37d3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAbstractType.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import java.util.HashMap;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.utility.jdt.AbstractType;
-import org.eclipse.jpt.common.utility.internal.SimpleIntReference;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Java source type
- */
-abstract class SourceAbstractType<A extends AbstractType>
- extends SourceMember<A>
- implements JavaResourceAbstractType
-{
- private String name;
-
- private String qualifiedName;
-
- private String packageName;
-
- private String declaringTypeName;
-
- private boolean memberType;
-
-
- // ********** construction/initialization **********
-
- protected SourceAbstractType(JavaResourceCompilationUnit javaResourceCompilationUnit, A type) {
- super(javaResourceCompilationUnit, type);
- }
-
- @Override
- protected void initialize(IBinding binding) {
- super.initialize(binding);
- this.name = this.buildName((ITypeBinding) binding);
- this.qualifiedName = this.buildQualifiedName((ITypeBinding) binding);
- this.packageName = this.buildPackageName((ITypeBinding) binding);
- this.declaringTypeName = this.buildDeclaringTypeName((ITypeBinding) binding);
- this.memberType = this.buildMemberType((ITypeBinding) binding);
- }
-
-
- // ********** update **********
-
- @Override
- protected void synchronizeWith(IBinding binding) {
- super.synchronizeWith(binding);
- this.syncName(this.buildName((ITypeBinding) binding));
- this.syncQualifiedName(this.buildQualifiedName((ITypeBinding) binding));
- this.syncPackageName(this.buildPackageName((ITypeBinding) binding));
- this.syncDeclaringTypeName(this.buildDeclaringTypeName((ITypeBinding) binding));
- this.syncMemberType(this.buildMemberType((ITypeBinding) binding));
- }
-
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
-
- // ******** JavaResourceAbstractType implementation ********
-
- // ***** name
- public String getName() {
- return this.name;
- }
-
- private void syncName(String astName) {
- String old = this.name;
- this.name = astName;
- this.firePropertyChanged(NAME_PROPERTY, old, astName);
- }
-
- private String buildName(ITypeBinding binding) {
- return (binding == null) ? null : binding.getName();
- }
-
- // ***** qualified name
- public String getQualifiedName() {
- return this.qualifiedName;
- }
-
- private void syncQualifiedName(String astQualifiedName) {
- String old = this.qualifiedName;
- this.qualifiedName = astQualifiedName;
- this.firePropertyChanged(QUALIFIED_NAME_PROPERTY, old, astQualifiedName);
- }
-
- private String buildQualifiedName(ITypeBinding binding) {
- return (binding == null) ? null : binding.getQualifiedName();
- }
-
- // ***** package name
- public String getPackageName() {
- return this.packageName;
- }
-
- private void syncPackageName(String astPackageName) {
- String old = this.packageName;
- this.packageName = astPackageName;
- this.firePropertyChanged(PACKAGE_NAME_PROPERTY, old, astPackageName);
- }
-
- private String buildPackageName(ITypeBinding binding) {
- return (binding == null) ? null : binding.getPackage().getName();
- }
-
- // ***** package
- public boolean isIn(IPackageFragment packageFragment) {
- return StringTools.stringsAreEqual(packageFragment.getElementName(), this.packageName);
- }
-
- // ***** source folder
- public boolean isIn(IPackageFragmentRoot sourceFolder) {
- return getSourceFolder().equals(sourceFolder);
- }
-
- private IPackageFragmentRoot getSourceFolder() {
- return (IPackageFragmentRoot) this.getJavaResourceCompilationUnit().getCompilationUnit().getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
- }
-
- // ***** declaring type name
- public String getDeclaringTypeName() {
- return this.declaringTypeName;
- }
-
- private void syncDeclaringTypeName(String astDeclaringTypeName) {
- String old = this.declaringTypeName;
- this.declaringTypeName = astDeclaringTypeName;
- this.firePropertyChanged(DECLARING_TYPE_NAME_PROPERTY, old, astDeclaringTypeName);
- }
-
- private String buildDeclaringTypeName(ITypeBinding binding) {
- if (binding == null) {
- return null;
- }
- ITypeBinding declaringClass = binding.getDeclaringClass();
- return (declaringClass == null) ? null : declaringClass.getTypeDeclaration().getQualifiedName();
- }
-
- // ***** member type
- public boolean isMemberType() {
- return this.memberType;
- }
-
- private void syncMemberType(boolean astMemberType) {
- boolean old = this.memberType;
- this.memberType = astMemberType;
- this.firePropertyChanged(MEMBER_TYPE_PROPERTY, old, astMemberType);
- }
-
- private boolean buildMemberType(ITypeBinding binding) {
- return (binding == null) ? false : binding.isMember();
- }
-
-
- // ********** CounterMap **********
-
- protected static class CounterMap {
- private final HashMap<Object, SimpleIntReference> counters;
-
- protected CounterMap(int initialCapacity) {
- super();
- this.counters = new HashMap<Object, SimpleIntReference>(initialCapacity);
- }
-
- /**
- * Return the incremented count for the specified object.
- */
- int increment(Object o) {
- SimpleIntReference counter = this.counters.get(o);
- if (counter == null) {
- counter = new SimpleIntReference();
- this.counters.put(o, counter);
- }
- counter.increment();
- return counter.getValue();
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotatedElement.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotatedElement.java
deleted file mode 100644
index d5d80754fd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotatedElement.java
+++ /dev/null
@@ -1,834 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ASTVisitor;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IAnnotationBinding;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.TransformerAdapter;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-
-/**
- * Java source annotated element
- */
-abstract class SourceAnnotatedElement<E extends AnnotatedElement>
- extends SourceNode
- implements JavaResourceAnnotatedElement
-{
- final E annotatedElement;
-
- /**
- * Annotations keyed by annotation name;
- * no duplicates (the Java compiler does not allow duplicate annotations).
- */
- private final Hashtable<String, Annotation> annotations = new Hashtable<String, Annotation>();
-
- /**
- * Cache the null annotation objects or they will be rebuilt on every access.
- * Make this a HashMap for performance, not concerned with duplicate creation and
- * unlikely that multiple threads will access this.
- */
- private final HashMap<String, Annotation> nullAnnotationCache = new HashMap<String, Annotation>();
-
- /**
- * Annotation containers keyed by <em>nestable</em> annotation name.
- * This is used to store annotations that can be both standalone and nested
- * and are moved back and forth between the two.
- */
- private final Hashtable<String, CombinationAnnotationContainer> annotationContainers = new Hashtable<String, CombinationAnnotationContainer>();
-
-
- // ********** construction/initialization **********
-
- SourceAnnotatedElement(JavaResourceNode parent, E annotatedElement) {
- super(parent);
- this.annotatedElement = annotatedElement;
- }
-
- /**
- * There are 2 initialize calls, 1 for ASTNode and one for IBinding.
- * This is a performance enhancement because finding a MethodDeclaration
- * for a SourceMethod is very non-performant. SourceMethod actually overrides
- * this as unsupported and instead uses initialize(MethodDeclaration).
- * TODO continue the pattern in SourceMethod with the other classes in this hierarchy
- * trying not to change much API in 3.2M7
- *
- * This is also to handle multiple fields declared in a single statement:
- * private int foo, bar;
- * JDTFieldAttribute.getBodyDeclaration(CompilationUnit) returns the FieldDeclaration
- * in the call to getBodyDeclaration, this is the ASTNode for a field and
- * has the annotations on it.
- * JDTFieldAttribute.getBinding(CompiltationUnit) returns the IVariableBinding of the
- * VariableDeclarationFragment which is the ASTNode for the particular field.
- */
- public void initialize(CompilationUnit astRoot) {
- this.initialize(this.annotatedElement.getBodyDeclaration(astRoot));
- this.initialize(this.annotatedElement.getBinding(astRoot));
- }
-
- protected void initialize(IBinding binding) {
- //do nothing
- }
-
- /**
- * Gather up all the significant AST annotations
- * and build the corresponding Dali annotations.
- */
- protected void initialize(ASTNode node) {
- AnnotationVisitor visitor = new AnnotationVisitor(node);
- node.accept(visitor);
- this.initializeAnnotations(visitor.astAnnotations);
- // container annotations take precedence over...
- this.initializeContainerAnnotations(visitor.astContainerAnnotations);
- // ...standalone nestable annotations
- this.initializeStandaloneNestableAnnotations(visitor.astStandaloneNestableAnnotations);
- }
-
- private void initializeAnnotations(HashMap<String, org.eclipse.jdt.core.dom.Annotation> astAnnotations) {
- for (Map.Entry<String, org.eclipse.jdt.core.dom.Annotation> entry : astAnnotations.entrySet()) {
- String annotationName = entry.getKey();
- org.eclipse.jdt.core.dom.Annotation astAnnotation = entry.getValue();
- Annotation annotation = this.buildAnnotation(annotationName);
- annotation.initialize((CompilationUnit) astAnnotation.getRoot()); // TODO pass the AST annotation!
- this.annotations.put(annotationName, annotation);
- }
- }
-
- private void initializeContainerAnnotations(HashMap<String, org.eclipse.jdt.core.dom.Annotation> astContainerAnnotations) {
- for (Map.Entry<String, org.eclipse.jdt.core.dom.Annotation> entry : astContainerAnnotations.entrySet()) {
- String containerAnnotationName = entry.getKey();
- org.eclipse.jdt.core.dom.Annotation astAnnotation = entry.getValue();
- String nestableAnnotationName = this.getNestableAnnotationName(containerAnnotationName);
- CombinationAnnotationContainer container = new CombinationAnnotationContainer(nestableAnnotationName, containerAnnotationName);
- container.initializeFromContainerAnnotation(astAnnotation);
- this.annotationContainers.put(nestableAnnotationName, container);
- }
- }
-
- private void initializeStandaloneNestableAnnotations(HashMap<String, org.eclipse.jdt.core.dom.Annotation> astStandaloneNestableAnnotations) {
- for (Map.Entry<String, org.eclipse.jdt.core.dom.Annotation> entry : astStandaloneNestableAnnotations.entrySet()) {
- String nestableAnnotationName = entry.getKey();
- org.eclipse.jdt.core.dom.Annotation astAnnotation = entry.getValue();
- // if we already have an annotation container (because there was a container annotation)
- // ignore the standalone nestable annotation
- if (this.annotationContainers.get(nestableAnnotationName) == null) {
- CombinationAnnotationContainer container = new CombinationAnnotationContainer(nestableAnnotationName);
- container.initializeFromStandaloneAnnotation(astAnnotation);
- this.annotationContainers.put(nestableAnnotationName, container);
- }
- }
- }
-
- /**
- * @see #initialize(CompilationUnit)
- */
- public void synchronizeWith(CompilationUnit astRoot) {
- this.synchronizeWith(this.annotatedElement.getBodyDeclaration(astRoot));
- this.synchronizeWith(this.annotatedElement.getBinding(astRoot));
- }
-
- protected void synchronizeWith(ASTNode bodyDeclaration) {
- this.syncAnnotations(bodyDeclaration);
- }
-
- protected void synchronizeWith(IBinding binding) {
- //do nothing
- }
-
-
- // ********** annotations **********
-
- public Iterable<Annotation> getAnnotations() {
- return new LiveCloneIterable<Annotation>(this.annotations.values());
- }
-
- public int getAnnotationsSize() {
- return this.annotations.size();
- }
-
- public Annotation getAnnotation(String annotationName) {
- // TODO one reason we search the containers is validation, we need to have separate API for getting the container annotation.
- //The validation in org.eclipse.jpt.jaxb.core.internal.context.java.GenericJavaXmlAnyElementMapping is an example
- if (this.annotationIsValidContainer(annotationName)) {
- CombinationAnnotationContainer container = this.annotationContainers.get(this.getAnnotationProvider().getNestableAnnotationName(annotationName));
- return (container == null) ? null : container.getContainerAnnotation();
- }
- return this.annotations.get(annotationName);
- }
-
- public Annotation getNonNullAnnotation(String annotationName) {
- Annotation annotation = this.performantGetAnnotation(annotationName);
- return (annotation != null) ? annotation : this.getNullAnnotation(annotationName);
- }
-
- /**
- * TODO performance - hack for performance so we don't have to break API in M7.
- * Our calls to getNonNullAnnotation are never used for container annotations, so
- * I can use this method to avoid the expensive {@link #annotationIsValidContainer(String)} check
- * in {@link #getAnnotation(String)}. In the next release I think we need
- * to change the genAnnotation api to not check for container annotations and instead have
- * separate API.
- */
- protected Annotation performantGetAnnotation(String annotationName) {
- return this.annotations.get(annotationName);
- }
-
- private Annotation getNullAnnotation(String annotationName) {
- Annotation annotation = this.nullAnnotationCache.get(annotationName);
- if (annotation == null) {
- annotation = this.buildNullAnnotation(annotationName);
- this.nullAnnotationCache.put(annotationName, annotation);
- }
- return annotation;
- }
-
- private Annotation buildNullAnnotation(String annotationName) {
- return this.getAnnotationProvider().buildNullAnnotation(this, annotationName);
- }
-
- public Annotation addAnnotation(String annotationName) {
- Annotation annotation = this.buildAnnotation(annotationName);
- this.annotations.put(annotationName, annotation);
- annotation.newAnnotation();
- return annotation;
- }
-
- public void removeAnnotation(String annotationName) {
- Annotation annotation = this.annotations.remove(annotationName);
- if (annotation != null) {
- annotation.removeAnnotation();
- }
- }
-
- /* CU private */ boolean annotationIsValid(String annotationName) {
- return CollectionTools.contains(this.getAnnotationProvider().getAnnotationNames(), annotationName);
- }
-
- /* CU private */ Annotation buildAnnotation(String annotationName) {
- return this.getAnnotationProvider().buildAnnotation(this, this.annotatedElement, annotationName);
- }
-
-
- // ********** combination annotations **********
-
- private Iterable<NestableAnnotation> getNestableAnnotations() {
- return new CompositeIterable<NestableAnnotation>(this.getNestableAnnotationLists());
- }
-
- private Iterable<Iterable<NestableAnnotation>> getNestableAnnotationLists() {
- return new TransformationIterable<CombinationAnnotationContainer_, Iterable<NestableAnnotation>>(this.getAnnotationContainers(), ANNOTATION_CONTAINER_NESTED_ANNOTATIONS_TRANSFORMER);
- }
-
- private static final Transformer<CombinationAnnotationContainer_, Iterable<NestableAnnotation>> ANNOTATION_CONTAINER_NESTED_ANNOTATIONS_TRANSFORMER = new AnnotationContainerNestedAnnotationsTransformer();
- /* CU private */ static final class AnnotationContainerNestedAnnotationsTransformer
- extends TransformerAdapter<CombinationAnnotationContainer_, Iterable<NestableAnnotation>>
- {
- @Override
- public Iterable<NestableAnnotation> transform(CombinationAnnotationContainer_ container) {
- return container.getNestedAnnotations();
- }
- }
-
- private Iterable<CombinationAnnotationContainer> getAnnotationContainers() {
- return new LiveCloneIterable<CombinationAnnotationContainer>(this.annotationContainers.values());
- }
-
- public ListIterable<NestableAnnotation> getAnnotations(String nestableAnnotationName) {
- CombinationAnnotationContainer container = this.annotationContainers.get(nestableAnnotationName);
- return (container != null) ? container.getNestedAnnotations() : EmptyListIterable.<NestableAnnotation> instance();
- }
-
- public int getAnnotationsSize(String nestableAnnotationName) {
- CombinationAnnotationContainer container = this.annotationContainers.get(nestableAnnotationName);
- return (container == null) ? 0 : container.getNestedAnnotationsSize();
- }
-
- public NestableAnnotation getAnnotation(int index, String nestableAnnotationName) {
- CombinationAnnotationContainer container = this.annotationContainers.get(nestableAnnotationName);
- if (container == null) {
- throw new ArrayIndexOutOfBoundsException("size: 0 index: " + index); //$NON-NLS-1$
- }
- return container.getNestedAnnotation(index);
- }
-
- private String getNestableAnnotationName(String containerAnnotationName) {
- return this.getAnnotationProvider().getNestableAnnotationName(containerAnnotationName);
- }
-
- /* CU private */ String getContainerAnnotationName(String nestableAnnotationName) {
- return this.getAnnotationProvider().getContainerAnnotationName(nestableAnnotationName);
- }
-
- /* CU private */ String getNestableElementName(String nestableAnnotationName) {
- return this.getAnnotationProvider().getNestableElementName(nestableAnnotationName);
- }
-
- public NestableAnnotation addAnnotation(int index, String nestableAnnotationName) {
- CombinationAnnotationContainer container = this.annotationContainers.get(nestableAnnotationName);
- if (container == null) {
- container = new CombinationAnnotationContainer(nestableAnnotationName);
- this.annotationContainers.put(nestableAnnotationName, container);
- }
- return container.addNestedAnnotation(index);
- }
-
- public void moveAnnotation(int targetIndex, int sourceIndex, String nestableAnnotationName) {
- this.annotationContainers.get(nestableAnnotationName).moveNestedAnnotation(targetIndex, sourceIndex);
- }
-
- public void removeAnnotation(int index, String nestableAnnotationName) {
- CombinationAnnotationContainer container = this.annotationContainers.get(nestableAnnotationName);
- container.removeNestedAnnotation(index);
- if (container.isEmpty()) {
- this.annotationContainers.remove(nestableAnnotationName);
- }
- }
-
- /* CU private */ boolean annotationIsValidContainer(String annotationName) {
- return CollectionTools.contains(this.getAnnotationProvider().getContainerAnnotationNames(), annotationName);
- }
-
- /* CU private */ boolean annotationIsValidNestable(String annotationName) {
- return CollectionTools.contains(this.getAnnotationProvider().getNestableAnnotationNames(), annotationName);
- }
-
- /* CU private */ NestableAnnotation buildNestableAnnotation(String annotationName, int index) {
- return this.getAnnotationProvider().buildAnnotation(this, this.annotatedElement, annotationName, index);
- }
-
- /* CU private */ void nestedAnnotationAdded(String collectionName, NestableAnnotation addedAnnotation) {
- this.fireItemAdded(collectionName, addedAnnotation);
- }
-
- /* CU private */ void nestedAnnotationsRemoved(String collectionName, Collection<? extends NestableAnnotation> removedAnnotations) {
- this.fireItemsRemoved(collectionName, removedAnnotations);
- }
-
-
- // ***** all annotations *****
-
- Annotation setPrimaryAnnotation(String primaryAnnotationName, Iterable<String> supportingAnnotationNames) {
- // clear out extraneous annotations
- HashSet<String> annotationNames = new HashSet<String>();
- CollectionTools.addAll(annotationNames, supportingAnnotationNames);
- if (primaryAnnotationName != null) {
- annotationNames.add(primaryAnnotationName);
- }
- this.retainAnnotations(annotationNames);
- this.retainAnnotationContainers(annotationNames);
-
- // add the primary annotation
- if (primaryAnnotationName == null) {
- return null;
- }
- Annotation primaryAnnotation = this.getAnnotation(primaryAnnotationName);
- if (primaryAnnotation == null) {
- primaryAnnotation = this.buildAnnotation(primaryAnnotationName);
- this.annotations.put(primaryAnnotationName, primaryAnnotation);
- primaryAnnotation.newAnnotation();
- }
- return primaryAnnotation;
- }
-
- private void retainAnnotations(HashSet<String> annotationNames) {
- synchronized (this.annotations) {
- for (Iterator<Map.Entry<String, Annotation>> stream = this.annotations.entrySet().iterator(); stream.hasNext(); ) {
- Map.Entry<String, Annotation> entry = stream.next();
- String annotationName = entry.getKey();
- Annotation annotation = entry.getValue();
- if ( ! annotationNames.contains(annotationName)) {
- stream.remove();
- annotation.removeAnnotation();
- }
- }
- }
- }
-
- private void retainAnnotationContainers(HashSet<String> annotationNames) {
- synchronized (this.annotationContainers) {
- for (Iterator<Map.Entry<String, CombinationAnnotationContainer>> stream = this.annotationContainers.entrySet().iterator(); stream.hasNext(); ) {
- Map.Entry<String, CombinationAnnotationContainer> entry = stream.next();
- String nestableAnnotationName = entry.getKey();
- CombinationAnnotationContainer container = entry.getValue();
- Annotation containerAnnotation = container.getContainerAnnotation();
- if (containerAnnotation != null) {
- if ( ! annotationNames.contains(container.getContainerAnnotationName())) {
- stream.remove();
- containerAnnotation.removeAnnotation();
- }
- } else {
- // standalone "nestable" annotation
- if ( ! annotationNames.contains(nestableAnnotationName)) {
- stream.remove();
- container.getNestedAnnotation(0).removeAnnotation();
- }
- }
- }
- }
- }
-
- /**
- * Gather up all the significant AST annotations
- * and add or sync the corresponding Dali annotations.
- */
- private void syncAnnotations(ASTNode node) {
- AnnotationVisitor visitor = new AnnotationVisitor(node);
- node.accept(visitor);
- this.syncAnnotations(visitor.astAnnotations);
- this.syncAnnotationContainers(visitor.astContainerAnnotations, visitor.astStandaloneNestableAnnotations);
- }
-
- private void syncAnnotations(HashMap<String, org.eclipse.jdt.core.dom.Annotation> astAnnotations) {
- HashMap<String, Annotation> annotationsToRemove = new HashMap<String, Annotation>(this.annotations);
- HashMap<String, Annotation> annotationsToAdd = new HashMap<String, Annotation>();
- for (Map.Entry<String, org.eclipse.jdt.core.dom.Annotation> entry : astAnnotations.entrySet()) {
- String annotationName = entry.getKey();
- org.eclipse.jdt.core.dom.Annotation astAnnotation = entry.getValue();
- Annotation annotation = annotationsToRemove.remove(annotationName);
- if (annotation == null) {
- annotation = this.buildAnnotation(annotationName);
- annotation.initialize((CompilationUnit) astAnnotation.getRoot()); // TODO pass the AST annotation!
- annotationsToAdd.put(annotationName, annotation);
- } else {
- annotation.synchronizeWith((CompilationUnit) astAnnotation.getRoot()); // TODO pass the AST annotation!
- }
- }
-
- for (String annotationName : annotationsToRemove.keySet()) {
- this.annotations.remove(annotationName);
- }
- this.fireItemsRemoved(ANNOTATIONS_COLLECTION, annotationsToRemove.values());
-
- this.annotations.putAll(annotationsToAdd);
- this.fireItemsAdded(ANNOTATIONS_COLLECTION, annotationsToAdd.values());
- }
-
- private void syncAnnotationContainers(HashMap<String, org.eclipse.jdt.core.dom.Annotation> astContainerAnnotations, HashMap<String, org.eclipse.jdt.core.dom.Annotation> astStandaloneNestableAnnotations) {
- HashMap<String, CombinationAnnotationContainer> containersToRemove = new HashMap<String, CombinationAnnotationContainer>(this.annotationContainers);
- HashMap<String, CombinationAnnotationContainer> containersToAdd = new HashMap<String, CombinationAnnotationContainer>();
-
- for (Map.Entry<String, org.eclipse.jdt.core.dom.Annotation> entry : astContainerAnnotations.entrySet()) {
- String containerAnnotationName = entry.getKey();
- org.eclipse.jdt.core.dom.Annotation astContainerAnnotation = entry.getValue();
- String nestableAnnotationName = this.getNestableAnnotationName(containerAnnotationName);
- CombinationAnnotationContainer container = containersToRemove.remove(nestableAnnotationName);
- if (container == null) {
- container = new CombinationAnnotationContainer(nestableAnnotationName, containerAnnotationName);
- container.initializeFromContainerAnnotation(astContainerAnnotation);
- containersToAdd.put(nestableAnnotationName, container);
- } else {
- container.synchronize(astContainerAnnotation);
- }
- // if it exists, strip out the standalone annotation
- // corresponding to the current container annotation
- astStandaloneNestableAnnotations.remove(nestableAnnotationName);
- }
-
- for (Map.Entry<String, org.eclipse.jdt.core.dom.Annotation> entry : astStandaloneNestableAnnotations.entrySet()) {
- String nestableAnnotationName = entry.getKey();
- org.eclipse.jdt.core.dom.Annotation astNestableAnnotation = entry.getValue();
- CombinationAnnotationContainer container = containersToRemove.remove(nestableAnnotationName);
- if (container == null) {
- container = new CombinationAnnotationContainer(nestableAnnotationName);
- container.initializeFromStandaloneAnnotation(astNestableAnnotation);
- containersToAdd.put(nestableAnnotationName, container);
- } else {
- container.synchronizeNestableAnnotation(astNestableAnnotation);
- }
- }
-
- ArrayList<NestableAnnotation> removedNestableAnnotations = new ArrayList<NestableAnnotation>();
- for (String nestableAnnotationName : containersToRemove.keySet()) {
- CombinationAnnotationContainer container = this.annotationContainers.remove(nestableAnnotationName);
- CollectionTools.addAll(removedNestableAnnotations, container.getNestedAnnotations());
- }
- this.fireItemsRemoved(NESTABLE_ANNOTATIONS_COLLECTION, removedNestableAnnotations);
-
- ArrayList<NestableAnnotation> addedNestableAnnotations = new ArrayList<NestableAnnotation>();
- for (Map.Entry<String, CombinationAnnotationContainer> entry : containersToAdd.entrySet()) {
- String nestableAnnotationName = entry.getKey();
- CombinationAnnotationContainer container = entry.getValue();
- this.annotationContainers.put(nestableAnnotationName, container);
- CollectionTools.addAll(addedNestableAnnotations, container.getNestedAnnotations());
- }
- this.fireItemsAdded(NESTABLE_ANNOTATIONS_COLLECTION, addedNestableAnnotations);
- }
-
- @SuppressWarnings("unchecked")
- public Iterable<Annotation> getTopLevelAnnotations() {
- return new CompositeIterable<Annotation>(
- this.getAnnotations(),
- this.getContainerOrStandaloneNestableAnnotations()
- );
- }
-
- private Iterable<Annotation> getContainerOrStandaloneNestableAnnotations() {
- return new TransformationIterable<CombinationAnnotationContainer_, Annotation>(this.getAnnotationContainers(), TOP_LEVEL_ANNOTATION_CONTAINER_TRANSFORMER);
- }
-
- private static final Transformer<CombinationAnnotationContainer_, Annotation> TOP_LEVEL_ANNOTATION_CONTAINER_TRANSFORMER = new TopLevelAnnotationContainerTransformer();
- static final class TopLevelAnnotationContainerTransformer
- extends TransformerAdapter<CombinationAnnotationContainer_, Annotation>
- {
- @Override
- public Annotation transform(CombinationAnnotationContainer_ container) {
- Annotation containerAnnotation = container.getContainerAnnotation();
- return (containerAnnotation != null) ? containerAnnotation : container.getNestedAnnotation(0);
- }
- }
-
- public boolean isAnnotated() {
- return ! this.isUnannotated();
- }
-
- public boolean isUnannotated() {
- return this.annotations.isEmpty() && this.annotationContainers.isEmpty();
- }
-
- public boolean isAnnotatedWithAnyOf(Iterable<String> annotationNames) {
- for (Annotation annotation : this.getSignificantAnnotations()) {
- if (CollectionTools.contains(annotationNames, annotation.getAnnotationName())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return the "significant" annotations;
- * i.e. ignore the container annotations (they have no semantics).
- */
- @SuppressWarnings("unchecked")
- private Iterable<Annotation> getSignificantAnnotations() {
- return new CompositeIterable<Annotation>(
- this.getAnnotations(),
- this.getNestableAnnotations()
- );
- }
-
-
- // ********** misc **********
-
- public TextRange getTextRange(CompilationUnit astRoot) {
- // the AST is null for virtual Java attributes
- // TODO remove the AST null check once we start storing text ranges
- // in the resource model
- return (astRoot == null) ? null : this.buildTextRange(this.annotatedElement.getBodyDeclaration(astRoot));
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- // the AST is null for virtual Java attributes
- // TODO remove the AST null check once we start storing text ranges
- // in the resource model
- return (astRoot == null) ? null : this.annotatedElement.getNameTextRange(astRoot);
- }
-
- public TextRange getTextRange(String nestableAnnotationName, CompilationUnit astRoot) {
- CombinationAnnotationContainer container = this.annotationContainers.get(nestableAnnotationName);
- if (container == null) {
- return null;
- }
- Annotation annotation = container.getContainerAnnotation();
- if (annotation == null) {
- annotation = container.getNestedAnnotation(0);
- }
- return annotation.getTextRange(astRoot);
- }
-
- private TextRange buildTextRange(ASTNode astNode) {
- return (astNode == null) ? null : ASTTools.buildTextRange(astNode);
- }
-
-
- // ********** AST visitor **********
-
- /**
- * This annotation visitor gathers up all the <em>significant</em>
- * (i.e. non-duplicate with a valid name) AST annotations
- * container annotations and standalone nestable annotations for its
- * {@link #node}.
- */
- /* CU private */ class AnnotationVisitor
- extends ASTVisitor
- {
- private final ASTNode node;
- final HashMap<String, org.eclipse.jdt.core.dom.Annotation> astAnnotations = new HashMap<String, org.eclipse.jdt.core.dom.Annotation>();
- final HashMap<String, org.eclipse.jdt.core.dom.Annotation> astContainerAnnotations = new HashMap<String, org.eclipse.jdt.core.dom.Annotation>();
- final HashMap<String, org.eclipse.jdt.core.dom.Annotation> astStandaloneNestableAnnotations = new HashMap<String, org.eclipse.jdt.core.dom.Annotation>();
-
- AnnotationVisitor(ASTNode node) {
- super();
- this.node = node;
- }
-
- @Override
- public boolean visit(SingleMemberAnnotation annotation) {
- return this.visit_(annotation);
- }
-
- @Override
- public boolean visit(NormalAnnotation annotation) {
- return this.visit_(annotation);
- }
-
- @Override
- public boolean visit(MarkerAnnotation annotation) {
- return this.visit_(annotation);
- }
-
- /**
- * Process only the annotations for the {@link #node}; ignore any children.
- */
- private boolean visit_(org.eclipse.jdt.core.dom.Annotation astAnnotation) {
- if (astAnnotation.getParent() == this.node) {
- this.visitChildAnnotation(astAnnotation);
- }
- return false; // => do *not* visit children
- }
-
- /**
- * For each annotation name we save only the first one
- * and ignore duplicates.
- */
- private void visitChildAnnotation(org.eclipse.jdt.core.dom.Annotation astAnnotation) {
- String astAnnotationName = this.resolveAnnotationName(astAnnotation);
- if (astAnnotationName == null) {
- return;
- }
- // check whether the annotation is a valid container annotation first
- // because container validations are also valid annotations
- // TODO remove container annotations from list of annotations???
- if (SourceAnnotatedElement.this.annotationIsValidContainer(astAnnotationName)) {
- if (this.astContainerAnnotations.get(astAnnotationName) == null) {
- this.astContainerAnnotations.put(astAnnotationName, astAnnotation);
- }
- }
- else if (SourceAnnotatedElement.this.annotationIsValid(astAnnotationName)) {
- if (this.astAnnotations.get(astAnnotationName) == null) {
- this.astAnnotations.put(astAnnotationName, astAnnotation);
- }
- }
- else if (SourceAnnotatedElement.this.annotationIsValidNestable(astAnnotationName)) {
- if (this.astStandaloneNestableAnnotations.get(astAnnotationName) == null) {
- this.astStandaloneNestableAnnotations.put(astAnnotationName, astAnnotation);
- }
- }
- }
-
- /**
- * Return the specified annotation's (fully-qualified) class name.
- */
- private String resolveAnnotationName(org.eclipse.jdt.core.dom.Annotation astAnnotation) {
- IAnnotationBinding annotationBinding = astAnnotation.resolveAnnotationBinding();
- if (annotationBinding == null) {
- return null;
- }
- ITypeBinding annotationTypeBinding = annotationBinding.getAnnotationType();
- return (annotationTypeBinding == null) ? null : annotationTypeBinding.getQualifiedName();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, node);
- }
- }
-
-
- // ********** annotation container **********
-
- /**
- * Use this interface to make static references to the annotation container.
- * Sort of a hack....
- * @see AnnotationContainerNestedAnnotationsTransformer
- * @see TopLevelAnnotationContainerTransformer
- */
- private interface CombinationAnnotationContainer_ {
- Annotation getContainerAnnotation();
- ListIterable<NestableAnnotation> getNestedAnnotations();
- NestableAnnotation getNestedAnnotation(int index);
- }
-
-
- /**
- * Annotation container for top-level "combination" annotations that allow
- * a single nestable annotation to stand alone, outside of its standard
- * container annotation, and represent a single-element array.
- */
- /* CU private */ class CombinationAnnotationContainer
- extends AnnotationContainer<NestableAnnotation>
- implements CombinationAnnotationContainer_
- {
- /**
- * The name of the nestable annotation that be either a top-level
- * standalone annotation or nested within the container annotation.
- */
- private final String nestableAnnotationName;
-
- /**
- * The name of the container annotation, used to build the
- * {@link #containerAnnotation container annotation} as necessary.
- */
- private final String containerAnnotationName;
-
- /**
- * This is <code>null</code> if the container annotation does not exist
- * but the standalone nestable annotation does.
- */
- private Annotation containerAnnotation;
-
-
- CombinationAnnotationContainer(String nestableAnnotationName) {
- this(nestableAnnotationName, SourceAnnotatedElement.this.getContainerAnnotationName(nestableAnnotationName));
- }
-
- CombinationAnnotationContainer(String nestableAnnotationName, String containerAnnotationName) {
- super();
- if ((nestableAnnotationName == null) || (containerAnnotationName == null)) {
- throw new NullPointerException();
- }
- this.nestableAnnotationName = nestableAnnotationName;
- this.containerAnnotationName = containerAnnotationName;
- }
-
- @Override
- public void initializeFromContainerAnnotation(org.eclipse.jdt.core.dom.Annotation astContainerAnnotation) {
- super.initializeFromContainerAnnotation(astContainerAnnotation);
- this.containerAnnotation = this.buildContainerAnnotation(this.containerAnnotationName);
- }
-
- private Annotation buildContainerAnnotation(String name) {
- return SourceAnnotatedElement.this.buildAnnotation(name);
- }
-
- public Annotation getContainerAnnotation() {
- return this.containerAnnotation;
- }
-
- String getContainerAnnotationName() {
- return this.containerAnnotationName;
- }
-
- /**
- * Return the element name of the nested annotations
- */
- @Override
- protected String getElementName() {
- return SourceAnnotatedElement.this.getNestableElementName(this.nestableAnnotationName);
- }
-
- /**
- * Return the nested annotation name
- */
- @Override
- protected String getNestedAnnotationName() {
- return this.nestableAnnotationName;
- }
-
- /**
- * Return a new nested annotation at the given index
- */
- @Override
- protected NestableAnnotation buildNestedAnnotation(int index) {
- return SourceAnnotatedElement.this.buildNestableAnnotation(this.nestableAnnotationName, index);
- }
-
- void initializeFromStandaloneAnnotation(org.eclipse.jdt.core.dom.Annotation astStandaloneNestableAnnotation) {
- NestableAnnotation nestedAnnotation = this.buildNestedAnnotation(0);
- this.nestedAnnotations.add(nestedAnnotation);
- nestedAnnotation.initialize((CompilationUnit) astStandaloneNestableAnnotation.getRoot()); // TODO pass the AST annotation!
- }
-
- /**
- * If we get here, the container annotation is either empty or does
- * <em>not</em> exist but the standalone nestable annotation does.
- */
- void synchronizeNestableAnnotation(org.eclipse.jdt.core.dom.Annotation astStandaloneNestableAnnotation) {
- this.containerAnnotation = null;
- if (this.nestedAnnotations.size() == 0) {
- // container annotation is present but empty
- this.syncAddNestedAnnotation(astStandaloneNestableAnnotation);
- } else {
- this.nestedAnnotations.get(0).synchronizeWith((CompilationUnit) astStandaloneNestableAnnotation.getRoot()); // TODO pass the AST annotation!
- // remove any remaining nested annotations
- this.syncRemoveNestedAnnotations(1);
- }
- }
-
- @Override
- public NestableAnnotation addNestedAnnotation(int index) {
- if ((this.nestedAnnotations.size() == 1) && (this.containerAnnotation == null)) {
- this.containerAnnotation = this.buildContainerAnnotation(this.containerAnnotationName);
- }
- return super.addNestedAnnotation(index);
- }
-
- @Override
- public NestableAnnotation removeNestedAnnotation(int index) {
- if (this.nestedAnnotations.size() == 2) {
- this.containerAnnotation = null;
- }
- return super.removeNestedAnnotation(index);
- }
-
- /**
- * <strong>NB:</strong> This is a <em>collection</em> name.
- * @see #nestedAnnotationAdded(int, NestableAnnotation)
- * @see #nestedAnnotationsRemoved(int, List)
- */
- @Override
- protected String getNestedAnnotationsListName() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * <strong>NB:</strong> Convert to a <em>collection</em> change.
- */
- @Override
- void nestedAnnotationAdded(int index, NestableAnnotation addedAnnotation) {
- SourceAnnotatedElement.this.nestedAnnotationAdded(NESTABLE_ANNOTATIONS_COLLECTION, addedAnnotation);
- }
-
- /**
- * <strong>NB:</strong> Convert to a <em>collection</em> change.
- */
- @Override
- void nestedAnnotationsRemoved(int index, List<NestableAnnotation> removedAnnotations) {
- SourceAnnotatedElement.this.nestedAnnotationsRemoved(NESTABLE_ANNOTATIONS_COLLECTION, removedAnnotations);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotation.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotation.java
deleted file mode 100644
index a7eaef1f9e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAnnotation.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools;
-import org.eclipse.jpt.common.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ElementAnnotationAdapter;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationElementAdapter;
-
-/**
- * some common state and behavior for Java source annotations;
- * and lots of convenience methods
- */
-public abstract class SourceAnnotation
- extends SourceNode
- implements Annotation
-{
- protected final AnnotatedElement annotatedElement;
-
- protected final DeclarationAnnotationAdapter daa;
-
- protected final AnnotationAdapter annotationAdapter;
-
-
- /**
- * constructor for straight member annotation
- */
- protected SourceAnnotation(JavaResourceNode parent, AnnotatedElement element, DeclarationAnnotationAdapter daa) {
- this(parent, element, daa, new ElementAnnotationAdapter(element, daa));
- }
-
- /**
- * constructor for nested annotation (typically)
- */
- protected SourceAnnotation(JavaResourceNode parent, AnnotatedElement element, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) {
- super(parent);
- this.annotatedElement = element;
- this.daa = daa;
- this.annotationAdapter = annotationAdapter;
- }
-
-
- // ********** JavaResourceNode implementation **********
-
- public TextRange getTextRange(CompilationUnit astRoot) {
- return this.getAnnotationTextRange(astRoot);
- }
-
-
- // ********** Annotation implementation **********
-
- public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) {
- return this.annotationAdapter.getAnnotation(astRoot);
- }
-
- public void newAnnotation() {
- this.annotationAdapter.newMarkerAnnotation();
- }
-
- public void removeAnnotation() {
- this.annotationAdapter.removeAnnotation();
- }
-
- public boolean isUnset() {
- return true;
- }
-
-
- // ********** convenience methods **********
-
- protected DeclarationAnnotationElementAdapter<String> buildStringElementAdapter(String elementName) {
- return ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, elementName);
- }
-
- protected DeclarationAnnotationElementAdapter<Boolean> buildBooleanElementAdapter(String elementName) {
- return ConversionDeclarationAnnotationElementAdapter.forBooleans(this.daa, elementName);
- }
-
- protected DeclarationAnnotationElementAdapter<Integer> buildIntegerElementAdapter(String elementName) {
- return ConversionDeclarationAnnotationElementAdapter.forNumbers(this.daa, elementName);
- }
-
- protected AnnotationElementAdapter<String> buildStringElementAdapter(DeclarationAnnotationElementAdapter<String> daea) {
- return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea);
- }
-
- protected AnnotationElementAdapter<Boolean> buildBooleanElementAdapter(DeclarationAnnotationElementAdapter<Boolean> daea) {
- return new AnnotatedElementAnnotationElementAdapter<Boolean>(this.annotatedElement, daea);
- }
-
- protected AnnotationElementAdapter<Integer> buildIntegerElementAdapter(DeclarationAnnotationElementAdapter<Integer> daea) {
- return new AnnotatedElementAnnotationElementAdapter<Integer>(this.annotatedElement, daea);
- }
-
- /**
- /**
- * Return the text range corresponding to the annotation.
- * If the annotation is missing, return <code>null</code>.
- */
- protected TextRange getAnnotationTextRange(CompilationUnit astRoot) {
- // the AST is null for virtual Java attributes
- // TODO remove the AST null check once we start storing text ranges
- // in the resource model
- return (astRoot == null) ? null : this.buildTextRange(this.getAstAnnotation(astRoot));
- }
-
- /**
- * Convenience method.
- * Return the text range corresponding to the specified element.
- * If the specified element is missing, return the annotation's text range instead.
- */
- protected TextRange getElementTextRange(DeclarationAnnotationElementAdapter<?> elementAdapter, CompilationUnit astRoot) {
- return this.getElementTextRange(this.getAnnotationElementTextRange(elementAdapter, astRoot), astRoot);
- }
-
- /**
- * Convenience method. If the specified element text range is null
- * return the member's text range instead.
- */
- protected TextRange getElementTextRange(TextRange elementTextRange, CompilationUnit astRoot) {
- return (elementTextRange != null) ? elementTextRange : this.getAnnotationTextRange(astRoot);
- }
-
- /**
- * Convenience method. Return whether the specified position exists and
- * touches the specified element.
- */
- protected boolean elementTouches(DeclarationAnnotationElementAdapter<?> elementAdapter, int pos, CompilationUnit astRoot) {
- return this.textRangeTouches(this.getAnnotationElementTextRange(elementAdapter, astRoot), pos);
- }
-
- /**
- * Convenience method. Return whether the specified text range is not
- * null (meaning the corresponding AST node exists) and the specified position touches it.
- */
- protected boolean textRangeTouches(TextRange textRange, int pos) {
- return (textRange != null) && textRange.touches(pos);
- }
-
- /**
- * Return the text range corresponding to the specified element.
- * If the element is missing, return null.
- */
- protected TextRange getAnnotationElementTextRange(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) {
- // the AST is null for virtual Java attributes
- // TODO remove the AST null check once we start storing text ranges
- // in the resource model
- return (astRoot == null) ? null : this.buildTextRange(this.getAnnotationElementExpression(adapter, astRoot));
- }
-
- /**
- * Return the specified AST DOM element.
- */
- protected Expression getAnnotationElementExpression(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) {
- return adapter.getExpression(this.annotatedElement.getModifiedDeclaration(astRoot));
- }
-
- /**
- * Return the text range corresponding to the expression at the specified
- * index of the element's array.
- * @exception ArrayIndexOutOfBoundsException if the index is out of range
- */
- protected TextRange selectAnnotationElementTextRange(IndexedDeclarationAnnotationElementAdapter<?> adapter, int index, CompilationUnit astRoot) {
- // the AST is null for virtual Java attributes
- // TODO remove the AST null check once we start storing text ranges
- // in the resource model
- return (astRoot == null) ? null : this.buildTextRange(this.selectAnnotationElementExpression(adapter, index, astRoot));
- }
-
- /**
- * Return the expression at the specified index of the element's array.
- */
- protected Expression selectAnnotationElementExpression(IndexedDeclarationAnnotationElementAdapter<?> adapter, int index, CompilationUnit astRoot) {
- return adapter.selectExpression(this.annotatedElement.getModifiedDeclaration(astRoot), index);
- }
-
- /**
- * Return the text range corresponding to the specified AST node.
- * Return <code>null</code> if the AST node is <code>null</code>.
- */
- protected TextRange buildTextRange(ASTNode astNode) {
- return (astNode == null) ? null : ASTTools.buildTextRange(astNode);
- }
-
-
- // ********** NestableAnnotation implementation **********
-
- /**
- * Convenience implementation of method from {@link NestableAnnotation} interface
- * for subclasses.
- */
- public void moveAnnotation(int newIndex) {
- this.getIndexedAnnotationAdapter().moveAnnotation(newIndex);
- }
-
- private IndexedAnnotationAdapter getIndexedAnnotationAdapter() {
- return (IndexedAnnotationAdapter) this.annotationAdapter;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAttribute.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAttribute.java
deleted file mode 100644
index 4802d09239..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceAttribute.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.utility.jdt.Attribute;
-import org.eclipse.jpt.common.utility.internal.ClassName;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-
-/**
- * Java source attribute (field or method)
- */
-abstract class SourceAttribute<A extends Attribute>
- extends SourceMember<A>
- implements JavaResourceAttribute
-{
- private int modifiers;
-
- private String typeName;
-
- private boolean typeIsInterface;
-
- private boolean typeIsEnum;
-
- private boolean typeIsArray;
-
- private int typeArrayDimensionality;
-
- private String typeArrayComponentTypeName;
-
- private final Vector<String> typeSuperclassNames = new Vector<String>();
-
- private final Vector<String> typeInterfaceNames = new Vector<String>();
-
- private final Vector<String> typeTypeArgumentNames = new Vector<String>();
-
-
- protected SourceAttribute(JavaResourceType parent, A attribute){
- super(parent, attribute);
- }
-
- @Override
- protected void initialize(IBinding binding) {
- super.initialize(binding);
- this.modifiers = this.buildModifiers(binding);
- }
-
- /**
- * subclasses need to call this method
- */
- protected void initialize(ITypeBinding attributeTypeBinding) {
- this.typeName = this.buildTypeName(attributeTypeBinding);
- this.typeIsInterface = this.buildTypeIsInterface(attributeTypeBinding);
- this.typeIsEnum = this.buildTypeIsEnum(attributeTypeBinding);
- this.typeIsArray = this.buildTypeIsArray(attributeTypeBinding);
- this.typeArrayDimensionality = buildTypeArrayDimensionality(attributeTypeBinding);
- this.typeArrayComponentTypeName = buildTypeArrayComponentTypeName(attributeTypeBinding);
- this.typeSuperclassNames.addAll(this.buildTypeSuperclassNames(attributeTypeBinding));
- this.typeInterfaceNames.addAll(this.buildTypeInterfaceNames(attributeTypeBinding));
- this.typeTypeArgumentNames.addAll(this.buildTypeTypeArgumentNames(attributeTypeBinding));
- }
-
-
- // ******** overrides ********
-
- @Override
- public void resolveTypes(CompilationUnit astRoot) {
- super.resolveTypes(astRoot);
- this.resolveTypes(this.getTypeBinding(astRoot));//build once, minor performance tweak for major benefit
- }
-
- protected void resolveTypes(ITypeBinding typeBinding) {
- this.syncTypeName(this.buildTypeName(typeBinding));
- this.syncTypeArrayComponentTypeName(this.buildTypeArrayComponentTypeName(typeBinding));
- this.syncTypeSuperclassNames(this.buildTypeSuperclassNames(typeBinding));
- this.syncTypeInterfaceNames(this.buildTypeInterfaceNames(typeBinding));
- this.syncTypeTypeArgumentNames(this.buildTypeTypeArgumentNames(typeBinding));
- }
-
- /**
- * subclasses need to call this method
- */
- protected void synchronizeWith(ITypeBinding attributeTypeBinding) {
- this.syncTypeName(this.buildTypeName(attributeTypeBinding));
- this.syncTypeIsInterface(this.buildTypeIsInterface(attributeTypeBinding));
- this.syncTypeIsEnum(this.buildTypeIsEnum(attributeTypeBinding));
- this.syncTypeIsArray(this.buildTypeIsArray(attributeTypeBinding));
- this.syncTypeArrayDimensionality(this.buildTypeArrayDimensionality(attributeTypeBinding));
- this.syncTypeArrayComponentTypeName(this.buildTypeArrayComponentTypeName(attributeTypeBinding));
- this.syncTypeSuperclassNames(this.buildTypeSuperclassNames(attributeTypeBinding));
- this.syncTypeInterfaceNames(this.buildTypeInterfaceNames(attributeTypeBinding));
- this.syncTypeTypeArgumentNames(this.buildTypeTypeArgumentNames(attributeTypeBinding));
- }
-
- @Override
- protected void synchronizeWith(IBinding binding) {
- super.synchronizeWith(binding);
- this.syncModifiers(this.buildModifiers(binding));
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ******** JavaResourceAttribute implementation ********
-
- @Override
- public JavaResourceType getParent() {
- return (JavaResourceType) super.getParent();
- }
-
- public JavaResourceType getResourceType() {
- return this.getParent();
- }
-
- public String getName() {
- return this.annotatedElement.getAttributeName();
- }
-
- public boolean typeIsSubTypeOf(String tn) {
- if (this.typeName == null) {
- return false;
- }
- return this.typeName.equals(tn)
- || this.typeInterfaceNames.contains(tn)
- || this.typeSuperclassNames.contains(tn);
- }
-
- public boolean typeIsVariablePrimitive() {
- return (this.typeName != null) && ClassName.isVariablePrimitive(this.typeName);
- }
-
- protected ITypeBinding getTypeBinding(CompilationUnit astRoot) {
- return this.annotatedElement.getTypeBinding(astRoot);
- }
-
-
- // ***** modifiers
- public int getModifiers() {
- return this.modifiers;
- }
-
- private void syncModifiers(int astModifiers) {
- int old = this.modifiers;
- this.modifiers = astModifiers;
- this.firePropertyChanged(MODIFIERS_PROPERTY, old, astModifiers);
- }
-
- /**
- * zero seems like a reasonable default...
- */
- private int buildModifiers(IBinding binding) {
- return (binding == null) ? 0 : binding.getModifiers();
- }
-
- // ***** type name
- public String getTypeName() {
- return this.typeName;
- }
-
- private void syncTypeName(String astTypeName) {
- String old = this.typeName;
- this.typeName = astTypeName;
- this.firePropertyChanged(TYPE_NAME_PROPERTY, old, astTypeName);
- }
-
- /**
- * this can be an array (e.g. "java.lang.String[]");
- * but no generic type arguments
- */
- private String buildTypeName(ITypeBinding typeBinding) {
- if (typeBinding == null) {
- return null;
- }
-
- typeBinding = typeBinding.getErasure();
- String tbName = typeBinding.getTypeDeclaration().getQualifiedName();
- return (tbName.length() == 0) ? null : tbName;
- }
-
- // ***** type is interface
- public boolean typeIsInterface() {
- return this.typeIsInterface;
- }
-
- private void syncTypeIsInterface(boolean astTypeIsInterface) {
- boolean old = this.typeIsInterface;
- this.typeIsInterface = astTypeIsInterface;
- this.firePropertyChanged(TYPE_IS_INTERFACE_PROPERTY, old, astTypeIsInterface);
- }
-
- private boolean buildTypeIsInterface(ITypeBinding typeBinding) {
- return (typeBinding != null) && ( ! typeBinding.isArray()) && typeBinding.isInterface();
- }
-
- // ***** type is enum
- public boolean typeIsEnum() {
- return this.typeIsEnum;
- }
-
- private void syncTypeIsEnum(boolean astTypeIsEnum) {
- boolean old = this.typeIsEnum;
- this.typeIsEnum = astTypeIsEnum;
- this.firePropertyChanged(TYPE_IS_ENUM_PROPERTY, old, astTypeIsEnum);
- }
-
- private boolean buildTypeIsEnum(ITypeBinding typeBinding) {
- return (typeBinding != null) && ( ! typeBinding.isArray()) && typeBinding.isEnum();
- }
-
- // ***** type is array
- public boolean typeIsArray() {
- return this.typeIsArray;
- }
-
- private void syncTypeIsArray(boolean astTypeIsArray) {
- boolean old = this.typeIsArray;
- this.typeIsArray = astTypeIsArray;
- this.firePropertyChanged(TYPE_IS_ARRAY_PROPERTY, old, astTypeIsArray);
- }
-
- private boolean buildTypeIsArray(ITypeBinding typeBinding) {
- return (typeBinding != null) && typeBinding.isArray();
- }
-
- // ***** type array dimensionality
- public int getTypeArrayDimensionality() {
- return this.typeArrayDimensionality;
- }
-
- private void syncTypeArrayDimensionality(int astTypeArrayDimensionality) {
- int old = this.typeArrayDimensionality;
- this.typeArrayDimensionality = astTypeArrayDimensionality;
- firePropertyChanged(TYPE_ARRAY_DIMENSIONALITY_PROPERTY, old, astTypeArrayDimensionality);
- }
-
- private int buildTypeArrayDimensionality(ITypeBinding typeBinding) {
- return (typeBinding == null) ? 0 : typeBinding.getDimensions();
- }
-
- // ***** type array component type name
- public String getTypeArrayComponentTypeName() {
- return this.typeArrayComponentTypeName;
- }
-
- private void syncTypeArrayComponentTypeName(String astTypeArrayComponentTypeName) {
- String old = this.typeArrayComponentTypeName;
- this.typeArrayComponentTypeName = astTypeArrayComponentTypeName;
- firePropertyChanged(TYPE_ARRAY_COMPONENT_TYPE_NAME_PROPERTY, old, astTypeArrayComponentTypeName);
- }
-
- private String buildTypeArrayComponentTypeName(ITypeBinding typeBinding) {
- if (typeBinding == null || ! typeBinding.isArray()) {
- return null;
- }
-
- // the component type of String[][] is actually String[], whereas we want String
- while (typeBinding.isArray()) {
- typeBinding = typeBinding.getComponentType();
-
- if (typeBinding == null) {
- return null;
- }
- }
-
- // a type variable is what is declared by a generic type;
- // e.g. "E" is a type variable declared by the generic type "Collection" in
- // public interface Collection<E>
- if (typeBinding.isTypeVariable()) {
- // e.g. "E extends Number" has an erasure of "Number"
- typeBinding = typeBinding.getErasure();
- }
- String tbName = typeBinding.getTypeDeclaration().getQualifiedName();
- return (tbName.length() == 0) ? null : tbName;
- }
-
- // ***** type superclass hierarchy
- public ListIterable<String> getTypeSuperclassNames() {
- return new LiveCloneListIterable<String>(this.typeSuperclassNames);
- }
-
- private void syncTypeSuperclassNames(List<String> astTypeSuperclassNames) {
- this.synchronizeList(astTypeSuperclassNames, this.typeSuperclassNames, TYPE_SUPERCLASS_NAMES_LIST);
- }
-
- private List<String> buildTypeSuperclassNames(ITypeBinding typeBinding) {
- if (typeBinding == null) {
- return Collections.emptyList();
- }
- ArrayList<String> names = new ArrayList<String>();
- typeBinding = typeBinding.getSuperclass();
- while (typeBinding != null) {
- names.add(typeBinding.getErasure().getQualifiedName());
- typeBinding = typeBinding.getSuperclass();
- }
- return names;
- }
-
- // ***** type interface hierarchy
- public Iterable<String> getTypeInterfaceNames() {
- return new LiveCloneIterable<String>(this.typeInterfaceNames);
- }
-
-// private boolean typeInterfaceNamesContains(String interfaceName) {
-// return this.typeInterfaceNames.contains(interfaceName);
-// }
-//
- private void syncTypeInterfaceNames(Collection<String> astTypeInterfaceNames) {
- this.synchronizeCollection(astTypeInterfaceNames, this.typeInterfaceNames, TYPE_INTERFACE_NAMES_COLLECTION);
- }
-
- private Collection<String> buildTypeInterfaceNames(ITypeBinding typeBinding) {
- if (typeBinding == null) {
- return Collections.emptySet();
- }
- HashSet<String> names = new HashSet<String>();
- while (typeBinding != null) {
- this.addInterfaceNamesTo(typeBinding, names);
- typeBinding = typeBinding.getSuperclass();
- }
- return names;
- }
-
- private void addInterfaceNamesTo(ITypeBinding typeBinding, HashSet<String> names) {
- for (ITypeBinding interfaceBinding : typeBinding.getInterfaces()) {
- names.add(interfaceBinding.getTypeDeclaration().getErasure().getQualifiedName());
- this.addInterfaceNamesTo(interfaceBinding, names); // recurse
- }
- }
-
- // ***** type type argument names
- public ListIterable<String> getTypeTypeArgumentNames() {
- return new LiveCloneListIterable<String>(this.typeTypeArgumentNames);
- }
-
- public int getTypeTypeArgumentNamesSize() {
- return this.typeTypeArgumentNames.size();
- }
-
- public String getTypeTypeArgumentName(int index) {
- return this.typeTypeArgumentNames.get(index);
- }
-
- private void syncTypeTypeArgumentNames(List<String> astTypeTypeArgumentNames) {
- this.synchronizeList(astTypeTypeArgumentNames, this.typeTypeArgumentNames, TYPE_TYPE_ARGUMENT_NAMES_LIST);
- }
-
- /**
- * these types can be arrays (e.g. "java.lang.String[]");
- * but they won't have any further nested generic type arguments
- * (e.g. "java.util.Collection<java.lang.String>")
- */
- private List<String> buildTypeTypeArgumentNames(ITypeBinding typeBinding) {
- if (typeBinding == null) {
- return Collections.emptyList();
- }
-
- ITypeBinding[] typeArguments = typeBinding.getTypeArguments();
- if (typeArguments.length == 0) {
- return Collections.emptyList();
- }
-
- ArrayList<String> names = new ArrayList<String>(typeArguments.length);
- for (ITypeBinding typeArgument : typeArguments) {
- if (typeArgument == null) {
- names.add(null);
- } else {
- // e.g. "? extends Number" has an erasure of "Number"
- ITypeBinding erasure = typeArgument.getErasure();
- names.add(erasure.getTypeDeclaration().getQualifiedName());
- }
- }
- return names;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceCompilationUnit.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceCompilationUnit.java
deleted file mode 100644
index bf69665e48..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceCompilationUnit.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.JptResourceModelListener;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-
-/**
- * Java compilation unit (source file)
- */
-public abstract class SourceCompilationUnit
- extends SourceNode
- implements JavaResourceCompilationUnit
-{
- /** JDT compilation unit */
- final ICompilationUnit compilationUnit;
-
- /** pluggable annotation provider */
- private final AnnotationProvider annotationProvider;
-
- /** improved annotation formatting */
- private final AnnotationEditFormatter annotationEditFormatter;
-
- /** pluggable executor that allows the document to be modified on another thread */
- private final CommandExecutor modifySharedDocumentCommandExecutor;
-
- /** listeners notified whenever the resource model changes */
- private final ListenerList<JptResourceModelListener> resourceModelListenerList;
-
-
- // ********** construction **********
-
- protected SourceCompilationUnit(
- ICompilationUnit compilationUnit,
- AnnotationProvider annotationProvider,
- AnnotationEditFormatter annotationEditFormatter,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- super(null); // the JPA compilation unit is the root of its sub-tree
- this.compilationUnit = compilationUnit;
- this.annotationProvider = annotationProvider;
- this.annotationEditFormatter = annotationEditFormatter;
- this.modifySharedDocumentCommandExecutor = modifySharedDocumentCommandExecutor;
- this.resourceModelListenerList = new ListenerList<JptResourceModelListener>(JptResourceModelListener.class);
- }
-
- public void initialize(CompilationUnit astRoot) {
- // never called?
- }
-
- void openCompilationUnit() {
- try {
- this.compilationUnit.open(null);
- } catch (JavaModelException ex) {
- // do nothing - we just won't have a primary type in this case
- }
- }
-
- void closeCompilationUnit() {
- try {
- this.compilationUnit.close();
- } catch (JavaModelException ex) {
- // hmmm
- }
- }
-
-
- // ********** AbstractJavaResourceNode overrides **********
-
- @Override
- protected boolean requiresParent() {
- return false;
- }
-
- @Override
- public JavaResourceCompilationUnit getRoot() {
- return this;
- }
-
- @Override
- public IFile getFile() {
- return (IFile) this.compilationUnit.getResource();
- }
-
- @Override
- public AnnotationProvider getAnnotationProvider() {
- return this.annotationProvider;
- }
-
-
- // ********** JavaResourceNode implementation **********
-
- public TextRange getTextRange(CompilationUnit astRoot) {
- return null;
- }
-
-
- // ********** JavaResourceNode.Root implementation **********
-
- public void resourceModelChanged() {
- for (JptResourceModelListener listener : this.resourceModelListenerList.getListeners()) {
- listener.resourceModelChanged(this);
- }
- }
-
-
- // ********** JavaResourceCompilationUnit implementation **********
-
- public ICompilationUnit getCompilationUnit() {
- return this.compilationUnit;
- }
-
- public CommandExecutor getModifySharedDocumentCommandExecutor() {
- return this.modifySharedDocumentCommandExecutor;
- }
-
- public AnnotationEditFormatter getAnnotationEditFormatter() {
- return this.annotationEditFormatter;
- }
-
- @Override
- public CompilationUnit buildASTRoot() {
- return ASTTools.buildASTRoot(this.compilationUnit);
- }
-
-
- // ********** JpaResourceModel implementation **********
-
- public void addResourceModelListener(JptResourceModelListener listener) {
- this.resourceModelListenerList.add(listener);
- }
-
- public void removeResourceModelListener(JptResourceModelListener listener) {
- this.resourceModelListenerList.remove(listener);
- }
-
-
- // ********** Java changes **********
-
- public void synchronizeWithJavaSource() {
- this.synchronizeWith(this.buildASTRoot());
- }
-
-
- // ********** internal **********
-
- String getCompilationUnitName() {
- return this.removeJavaExtension(this.compilationUnit.getElementName());
- }
-
- private String removeJavaExtension(String fileName) {
- int index = fileName.lastIndexOf(".java"); //$NON-NLS-1$
- return (index == -1) ? fileName : fileName.substring(0, index);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getCompilationUnitName());
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceEnum.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceEnum.java
deleted file mode 100644
index edc6b44065..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceEnum.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jpt.common.core.internal.utility.jdt.JDTEnum;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnumConstant;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.utility.jdt.Enum;
-import org.eclipse.jpt.common.core.utility.jdt.Type;
-import org.eclipse.jpt.common.utility.internal.SimpleIntReference;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-
-/**
- * Java source type
- */
-final class SourceEnum
- extends SourceAbstractType<Enum>
- implements JavaResourceEnum
-{
-
- private final Vector<JavaResourceEnumConstant> enumConstants;
-
-
-
- // ********** construction/initialization **********
-
- /**
- * build top-level type
- */
- static JavaResourceEnum newInstance(
- JavaResourceCompilationUnit javaResourceCompilationUnit,
- EnumDeclaration enumDeclaration,
- CompilationUnit astRoot) {
- Enum _enum = new JDTEnum(
- enumDeclaration,
- javaResourceCompilationUnit.getCompilationUnit(),
- javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
- javaResourceCompilationUnit.getAnnotationEditFormatter());
- JavaResourceEnum jre = new SourceEnum(javaResourceCompilationUnit, _enum);
- jre.initialize(astRoot);
- return jre;
- }
-
- /**
- * build nested type
- */
- protected static JavaResourceEnum newInstance(
- JavaResourceCompilationUnit javaResourceCompilationUnit,
- Type declaringType,
- EnumDeclaration enumDeclaration,
- int occurrence,
- CompilationUnit astRoot) {
- Enum _enum = new JDTEnum(
- declaringType,
- enumDeclaration,
- occurrence,
- javaResourceCompilationUnit.getCompilationUnit(),
- javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
- javaResourceCompilationUnit.getAnnotationEditFormatter());
- JavaResourceEnum jre = new SourceEnum(javaResourceCompilationUnit, _enum);
- jre.initialize(astRoot);
- return jre;
- }
-
- private SourceEnum(JavaResourceCompilationUnit javaResourceCompilationUnit, Enum _enum) {
- super(javaResourceCompilationUnit, _enum);
- this.enumConstants = new Vector<JavaResourceEnumConstant>();
- }
-
- @Override
- public void initialize(CompilationUnit astRoot) {
- super.initialize(astRoot);
- this.initializeEnumConstants(astRoot);
- }
-
-
- // ********** update **********
-
- @Override
- public void synchronizeWith(CompilationUnit astRoot) {
- super.synchronizeWith(astRoot);
- this.syncEnumConstants(astRoot);
- }
-
-
- // ********** SourceAnnotatedElement implementation **********
-
- @Override
- public void resolveTypes(CompilationUnit astRoot) {
- super.resolveTypes(astRoot);
-
- for (JavaResourceEnumConstant enumConstant : this.getEnumConstants()) {
- enumConstant.resolveTypes(astRoot);
- }
- }
-
-
- // ******** JavaResourceAnnotatedElement implementation ********
-
- public Kind getKind() {
- return Kind.ENUM;
- }
-
-
- // ********** enum constants **********
-
- public Iterable<JavaResourceEnumConstant> getEnumConstants() {
- return new LiveCloneIterable<JavaResourceEnumConstant>(this.enumConstants);
- }
-
- private void addEnumConstant(JavaResourceEnumConstant enumConstant) {
- this.addItemToCollection(enumConstant, this.enumConstants, ENUM_CONSTANTS_COLLECTION);
- }
-
- private JavaResourceEnumConstant getEnumConstant(String fieldName, int occurrence) {
- for (JavaResourceEnumConstant enumConstant : this.getEnumConstants()) {
- if (enumConstant.isFor(fieldName, occurrence)) {
- return enumConstant;
- }
- }
- return null;
- }
-
- private void removeEnumConstants(Collection<JavaResourceEnumConstant> remove) {
- this.removeItemsFromCollection(remove, this.enumConstants, ENUM_CONSTANTS_COLLECTION);
- }
-
- private void initializeEnumConstants(CompilationUnit astRoot) {
- EnumConstantDeclaration[] enumConstantDeclarations = this.annotatedElement.getEnumConstants(astRoot);
- CounterMap counters = new CounterMap(enumConstantDeclarations.length);
- for (EnumConstantDeclaration enumConstantDeclaration : enumConstantDeclarations) {
- String constantName = enumConstantDeclaration.getName().getFullyQualifiedName();
- int occurrence = counters.increment(constantName);
- this.enumConstants.add(this.buildEnumConstant(constantName, occurrence, astRoot));
- }
- }
-
- private void syncEnumConstants(CompilationUnit astRoot) {
- EnumConstantDeclaration[] enumConstantDeclarations = this.annotatedElement.getEnumConstants(astRoot);
- CounterMap counters = new CounterMap(enumConstantDeclarations.length);
- HashSet<JavaResourceEnumConstant> enumConstantsToRemove = new HashSet<JavaResourceEnumConstant>(this.enumConstants);
- for (EnumConstantDeclaration enumConstantDeclaration : enumConstantDeclarations) {
- String constantName = enumConstantDeclaration.getName().getFullyQualifiedName();
- int occurrence = counters.increment(constantName);
-
- JavaResourceEnumConstant enumConstant = this.getEnumConstant(constantName, occurrence);
- if (enumConstant == null) {
- this.addEnumConstant(this.buildEnumConstant(constantName, occurrence, astRoot));
- } else {
- enumConstantsToRemove.remove(enumConstant);
- enumConstant.synchronizeWith(astRoot);
- }
- }
- this.removeEnumConstants(enumConstantsToRemove);
- }
-
- private JavaResourceEnumConstant buildEnumConstant(String fieldName, int occurrence, CompilationUnit astRoot) {
- return SourceEnumConstant.newInstance(this, this.annotatedElement, fieldName, occurrence, this.getJavaResourceCompilationUnit(), astRoot);
- }
-
-
- public Iterable<JavaResourceType> getTypes() {
- return EmptyIterable.instance();
- }
-
- public Iterable<JavaResourceType> getAllTypes() {
- return EmptyIterable.instance();
- }
-
- public Iterable<JavaResourceEnum> getEnums() {
- return EmptyIterable.instance();
- }
-
- public Iterable<JavaResourceEnum> getAllEnums() {
- return new SingleElementIterable<JavaResourceEnum>(this);
- }
-
- // ********** CounterMap **********
-
- private static class CounterMap {
- private final HashMap<Object, SimpleIntReference> counters;
-
- protected CounterMap(int initialCapacity) {
- super();
- this.counters = new HashMap<Object, SimpleIntReference>(initialCapacity);
- }
-
- /**
- * Return the incremented count for the specified object.
- */
- int increment(Object o) {
- SimpleIntReference counter = this.counters.get(o);
- if (counter == null) {
- counter = new SimpleIntReference();
- this.counters.put(o, counter);
- }
- counter.increment();
- return counter.getValue();
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceEnumConstant.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceEnumConstant.java
deleted file mode 100644
index 939a08f374..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceEnumConstant.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.internal.utility.jdt.JDTEnumConstant;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnumConstant;
-import org.eclipse.jpt.common.core.utility.jdt.Enum;
-import org.eclipse.jpt.common.core.utility.jdt.EnumConstant;
-
-/**
- * Java source enum constant
- */
-final class SourceEnumConstant
- extends SourceMember<EnumConstant>
- implements JavaResourceEnumConstant
-{
-
- /**
- * construct enum constant
- */
- static JavaResourceEnumConstant newInstance(
- JavaResourceEnum parent,
- Enum declaringEnum,
- String name,
- int occurrence,
- JavaResourceCompilationUnit javaResourceCompilationUnit,
- CompilationUnit astRoot) {
-
- EnumConstant enumConstant = new JDTEnumConstant(
- declaringEnum,
- name,
- occurrence,
- javaResourceCompilationUnit.getCompilationUnit(),
- javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
- javaResourceCompilationUnit.getAnnotationEditFormatter());
- JavaResourceEnumConstant jrec = new SourceEnumConstant(parent, enumConstant);
- jrec.initialize(astRoot);
- return jrec;
- }
-
-
- private SourceEnumConstant(JavaResourceEnum parent, EnumConstant enumConstant){
- super(parent, enumConstant);
- }
-
-
- @Override
- public void initialize(CompilationUnit astRoot) {
- super.initialize(astRoot);
- }
-
-
- // ******** JavaResourceAnnotatedElement implementation ********
-
- public Kind getKind() {
- return Kind.ENUM_CONSTANT;
- }
-
-
- // ******** overrides ********
-
- @Override
- public void resolveTypes(CompilationUnit astRoot) {
- super.resolveTypes(astRoot);
- }
-
- @Override
- public void synchronizeWith(CompilationUnit astRoot) {
- super.synchronizeWith(astRoot);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ******** JavaResourceEnumConstant implementation ********
-
- public String getName() {
- return this.annotatedElement.getName();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceField.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceField.java
deleted file mode 100644
index fc4e4ab95f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceField.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.eclipse.jpt.common.core.internal.utility.jdt.JDTFieldAttribute;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.utility.jdt.FieldAttribute;
-import org.eclipse.jpt.common.core.utility.jdt.Type;
-
-/**
- * Java source field
- */
-final class SourceField
- extends SourceAttribute<FieldAttribute>
- implements JavaResourceField
-{
-
- /**
- * construct field attribute
- */
- static JavaResourceField newInstance(
- JavaResourceType parent,
- Type declaringType,
- String name,
- int occurrence,
- JavaResourceCompilationUnit javaResourceCompilationUnit,
- CompilationUnit astRoot) {
-
- FieldAttribute field = new JDTFieldAttribute(
- declaringType,
- name,
- occurrence,
- javaResourceCompilationUnit.getCompilationUnit(),
- javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
- javaResourceCompilationUnit.getAnnotationEditFormatter());
- JavaResourceField jrpa = new SourceField(parent, field);
- jrpa.initialize(astRoot);
- return jrpa;
- }
-
-
- private SourceField(JavaResourceType parent, FieldAttribute field){
- super(parent, field);
- }
-
- // ******** JavaResourceAnnotatedElement implementation ********
-
- public Kind getKind() {
- return Kind.FIELD;
- }
-
- @Override
- protected void initialize(ASTNode node) {
- super.initialize(node);
- this.initialize(((FieldDeclaration) node).getType().resolveBinding());
- }
-
- @Override
- public void synchronizeWith(ASTNode node) {
- super.synchronizeWith(node);
- this.synchronizeWith(((FieldDeclaration) node).getType().resolveBinding());
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMember.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMember.java
deleted file mode 100644
index 380f175fcf..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMember.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.Modifier;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceMember;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
-
-/**
- * Java source member (annotations, "persistable")
- */
-abstract class SourceMember<M extends Member>
- extends SourceAnnotatedElement<M>
- implements JavaResourceMember
-{
- boolean final_; // 'final' is a reserved word
-
- boolean transient_; // 'transient' is a reserved word
-
- boolean public_; // 'public' is a reserved word
-
- boolean static_; // 'static' is a reserved word
-
- boolean protected_; // 'protected' is a reserved word
-
- // ********** construction/initialization **********
-
- SourceMember(JavaResourceNode parent, M member) {
- super(parent, member);
- }
-
- @Override
- protected void initialize(IBinding binding) {
- super.initialize(binding);
- this.final_ = this.buildFinal(binding);
- this.transient_ = this.buildTransient(binding);
- this.public_ = this.buildPublic(binding);
- this.static_ = this.buildStatic(binding);
- this.protected_ = this.buildProtected(binding);
- }
-
- @Override
- protected void synchronizeWith(IBinding binding) {
- super.synchronizeWith(binding);
- this.syncFinal(this.buildFinal(binding));
- this.syncTransient(this.buildTransient(binding));
- this.syncPublic(this.buildPublic(binding));
- this.syncStatic(this.buildStatic(binding));
- this.syncProtected(this.buildProtected(binding));
- }
-
- // ***** final
- public boolean isFinal() {
- return this.final_;
- }
-
- private void syncFinal(boolean astFinal) {
- boolean old = this.final_;
- this.final_ = astFinal;
- this.firePropertyChanged(FINAL_PROPERTY, old, astFinal);
- }
-
- private boolean buildFinal(IBinding binding) {
- return (binding == null) ? false : Modifier.isFinal(binding.getModifiers());
- }
-
- // ***** transient
- public boolean isTransient() {
- return this.transient_;
- }
-
- private void syncTransient(boolean astTransient) {
- boolean old = this.transient_;
- this.transient_ = astTransient;
- this.firePropertyChanged(TRANSIENT_PROPERTY, old, astTransient);
- }
-
- private boolean buildTransient(IBinding binding) {
- return (binding == null) ? false : Modifier.isTransient(binding.getModifiers());
- }
-
- // ***** public
- public boolean isPublic() {
- return this.public_;
- }
-
- private void syncPublic(boolean astPublic) {
- boolean old = this.public_;
- this.public_ = astPublic;
- this.firePropertyChanged(PUBLIC_PROPERTY, old, astPublic);
- }
-
- private boolean buildPublic(IBinding binding) {
- return (binding == null) ? false : Modifier.isPublic(binding.getModifiers());
- }
-
- // ***** static
- public boolean isStatic() {
- return this.static_;
- }
-
- private void syncStatic(boolean astStatic) {
- boolean old = this.static_;
- this.static_ = astStatic;
- this.firePropertyChanged(STATIC_PROPERTY, old, astStatic);
- }
-
- private boolean buildStatic(IBinding binding) {
- return (binding == null) ? false : Modifier.isStatic(binding.getModifiers());
- }
-
- // ***** protected
- public boolean isProtected() {
- return this.protected_;
- }
-
- private void syncProtected(boolean astProtected) {
- boolean old = this.protected_;
- this.protected_ = astProtected;
- this.firePropertyChanged(PROTECTED_PROPERTY, old, astProtected);
- }
-
- private boolean buildProtected(IBinding binding) {
- return (binding == null) ? false : Modifier.isProtected(binding.getModifiers());
- }
-
- // ********** miscellaneous **********
-
- public boolean isFor(String memberName, int occurrence) {
- return this.annotatedElement.matches(memberName, occurrence);
- }
-
- @Override
- public Annotation setPrimaryAnnotation(String primaryAnnotationName, Iterable<String> supportingAnnotationNames) {
- return super.setPrimaryAnnotation(primaryAnnotationName, supportingAnnotationNames);
- }
-
- public void resolveTypes(CompilationUnit astRoot) {
- // do nothing?
- }
-
- public boolean isPublicOrProtected() {
- return this.isPublic() || this.isProtected();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMethod.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMethod.java
deleted file mode 100644
index d92d2d7dcb..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceMethod.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jpt.common.core.internal.utility.jdt.JDTMethodAttribute;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.utility.jdt.MethodAttribute;
-import org.eclipse.jpt.common.core.utility.jdt.Type;
-import org.eclipse.jpt.common.utility.MethodSignature;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-
-/**
- * Java source method
- */
-final class SourceMethod
- extends SourceAttribute<MethodAttribute>
- implements JavaResourceMethod {
-
- boolean constructor;
-
- private final Vector<String> parameterTypeNames = new Vector<String>();
-
-
- /**
- * construct method
- */
- static JavaResourceMethod newInstance(
- JavaResourceType parent,
- Type declaringType,
- MethodSignature signature,
- int occurrence,
- JavaResourceCompilationUnit javaResourceCompilationUnit,
- MethodDeclaration methodDeclaration) {
-
- MethodAttribute method = JDTMethodAttribute.newInstance(
- declaringType,
- signature,
- occurrence,
- javaResourceCompilationUnit.getCompilationUnit(),
- javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
- javaResourceCompilationUnit.getAnnotationEditFormatter());
- JavaResourceMethod jrm = new SourceMethod(parent, method);
- jrm.initialize(methodDeclaration);
- return jrm;
- }
-
-
- private SourceMethod(JavaResourceType parent, MethodAttribute method){
- super(parent, method);
- }
-
- //call initialize(MethodDeclaration) now for performance
- //trying to minimize API changes, this should be removed from the interface
- //TODO other members of this hierarchy should have similar initialize methods
- @Override
- public void initialize(CompilationUnit astRoot) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void initialize(IBinding binding) {
- super.initialize(binding);
- this.constructor = this.buildConstructor((IMethodBinding) binding);
- this.parameterTypeNames.addAll(this.buildParameterTypeNames((IMethodBinding) binding));
- }
-
- public void initialize(MethodDeclaration methodDeclaration) {
- super.initialize(methodDeclaration);
- IMethodBinding binding = methodDeclaration.resolveBinding();
- this.initialize(binding.getReturnType());
- this.initialize(binding);
-
- }
-
-
- // ******** JavaResourceAnnotatedElement implementation ********
-
- public Kind getKind() {
- return Kind.METHOD;
- }
-
-
- // ******** overrides ********
-
- @Override
- public void resolveTypes(CompilationUnit astRoot) {
- super.resolveTypes(astRoot);
- }
-
- //call synchronizeWith(MethodDeclaration) now for performance
- //trying to minimize API changes, this should be removed from the interface
- //TODO other members of this hierarchy should have similar synchronizeWith methods
- @Override
- public void synchronizeWith(CompilationUnit astRoot) {
- throw new UnsupportedOperationException();
- }
-
- public void synchronizeWith(MethodDeclaration methodDeclaration) {
- super.synchronizeWith(methodDeclaration);
- IMethodBinding binding = methodDeclaration.resolveBinding();
- this.synchronizeWith(binding.getReturnType());
- this.synchronizeWith(binding);
- }
-
- @Override
- public void synchronizeWith(IBinding binding) {
- super.synchronizeWith(binding);
- this.syncConstructor(this.buildConstructor((IMethodBinding) binding));
- this.syncParameterTypeNames(this.buildParameterTypeNames((IMethodBinding) binding));
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getMethodName());
- }
-
-
- // ***** method name *****
-
- public String getMethodName() {
- return this.annotatedElement.getName();
- }
-
-
- // ***** parameter type names *****
-
- public ListIterable<String> getParameterTypeNames() {
- return new LiveCloneListIterable<String>(this.parameterTypeNames);
- }
-
- public String getParameterTypeName(int index) {
- return this.parameterTypeNames.get(index);
- }
-
- public int getParametersSize() {
- return this.parameterTypeNames.size();
- }
-
- private void syncParameterTypeNames(List<String> astParameterTypeNames) {
- this.synchronizeList(astParameterTypeNames, this.parameterTypeNames, PARAMETER_TYPE_NAMES_LIST);
- }
-
- private List<String> buildParameterTypeNames(IMethodBinding methodBinding) {
- if (methodBinding == null) {
- return Collections.emptyList();
- }
- ArrayList<String> names = new ArrayList<String>();
- for (ITypeBinding parameterType : methodBinding.getParameterTypes()) {
- if (parameterType.isTypeVariable()) {
- // e.g. "E extends Number" has an erasure of "Number"
- parameterType = parameterType.getErasure();
- }
- String ptName = parameterType.getTypeDeclaration().getQualifiedName();
- names.add(ptName);
- }
- return names;
- }
-
-
- // ***** constructor *****
-
- public boolean isConstructor() {
- return this.constructor;
- }
-
- private void syncConstructor(boolean astConstructor) {
- boolean old = this.constructor;
- this.constructor = astConstructor;
- this.firePropertyChanged(CONSTRUCTOR_PROPERTY, old, astConstructor);
- }
-
- private boolean buildConstructor(IMethodBinding methodBinding) {
- return methodBinding == null ? false : methodBinding.isConstructor();
- }
-
-
- // ***** misc *****
-
- public boolean isFor(MethodSignature signature, int occurrence) {
- return this.annotatedElement.matches(signature, occurrence);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceNamedAnnotation.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceNamedAnnotation.java
deleted file mode 100644
index 84c17f3df1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceNamedAnnotation.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.internal.resource.java.source.SourceAnnotation;
-import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-
-/**
- * Used for annotations that have no behavior, just a name
- */
-public final class SourceNamedAnnotation
- extends SourceAnnotation
-{
- private final String annotationName;
-
- public SourceNamedAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, String annotationName) {
- super(parent, annotatedElement, new SimpleDeclarationAnnotationAdapter(annotationName));
- this.annotationName = annotationName;
- }
-
- public String getAnnotationName() {
- return this.annotationName;
- }
-
- public void initialize(CompilationUnit astRoot) {
- //nothing
- }
-
- public void synchronizeWith(CompilationUnit astRoot) {
- //nothing
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.annotationName);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceNode.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceNode.java
deleted file mode 100644
index 2a46bc62b1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceNode.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ArrayInitializer;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.internal.resource.java.AbstractJavaResourceNode;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-
-
-/**
- * Source convenience methods
- */
-public abstract class SourceNode
- extends AbstractJavaResourceNode
-{
-
- protected SourceNode(JavaResourceNode parent) {
- super(parent);
- }
-
- public JavaResourceCompilationUnit getJavaResourceCompilationUnit() {
- return (JavaResourceCompilationUnit) this.getRoot();
- }
-
- protected CompilationUnit buildASTRoot() {
- return this.getJavaResourceCompilationUnit().buildASTRoot();
- }
-
- protected void nestedAnnotationAdded(String listName, int index, NestableAnnotation addedAnnotation) {
- this.fireItemAdded(listName, index, addedAnnotation);
- }
-
- protected void nestedAnnotationsRemoved(String listName, int index, List<? extends NestableAnnotation> removedAnnotations) {
- this.fireItemsRemoved(listName, index, removedAnnotations);
- }
-
- @Override
- protected AnnotationProvider getAnnotationProvider() {
- return super.getAnnotationProvider();
- }
-
-
- // ********** annotation container **********
-
- /**
- * A container for nested annotations. The owner of the AnnotationContainer
- * needs to call
- * {@link #initializeFromContainerAnnotation(org.eclipse.jdt.core.dom.Annotation)}
- * on it.
- * @param <A> the type of the resource nestable annotations
- */
- protected abstract class AnnotationContainer<A extends NestableAnnotation> {
- protected final Vector<A> nestedAnnotations = new Vector<A>();
-
- protected AnnotationContainer() {
- super();
- }
-
- /**
- * Return the element name of the nested annotations
- */
- protected abstract String getElementName();
-
- /**
- * Return the nested annotation name
- */
- protected abstract String getNestedAnnotationName();
-
- /**
- * Return a new nested annotation at the given index
- */
- protected abstract A buildNestedAnnotation(int index);
-
- public void initializeFromContainerAnnotation(org.eclipse.jdt.core.dom.Annotation astContainerAnnotation) {
- // ignore the nested AST annotations themselves
- // TODO (maybe someday we can use them during initialization...)
- int size = this.getNestedAstAnnotations(astContainerAnnotation).size();
- for (int i = 0; i < size; i++) {
- A nestedAnnotation = this.buildNestedAnnotation(i);
- this.nestedAnnotations.add(i, nestedAnnotation);
- nestedAnnotation.initialize((CompilationUnit) astContainerAnnotation.getRoot());
- }
- }
-
- /**
- * Synchronize the resource model annotations with those in the specified AST.
- * Trigger the appropriate change notification.
- */
- public void synchronize(org.eclipse.jdt.core.dom.Annotation astContainerAnnotation) {
- ArrayList<org.eclipse.jdt.core.dom.Annotation> astAnnotations = this.getNestedAstAnnotations(astContainerAnnotation);
- Iterator<org.eclipse.jdt.core.dom.Annotation> astAnnotationStream = astAnnotations.iterator();
-
- for (A nestedAnnotation : this.getNestedAnnotations()) {
- if (astAnnotationStream.hasNext()) {
- // matching AST annotation is present - synchronize the nested annotation
- astAnnotationStream.next(); // TODO pass this to the update
- nestedAnnotation.synchronizeWith((CompilationUnit) astContainerAnnotation.getRoot());
- } else {
- // no more AST annotations - remove the remaining nested annotations and exit
- this.syncRemoveNestedAnnotations(astAnnotations.size());
- return;
- }
- }
-
- // add nested annotations for any remaining AST annotations
- while (astAnnotationStream.hasNext()) {
- this.syncAddNestedAnnotation(astAnnotationStream.next());
- }
- }
-
- public ListIterable<A> getNestedAnnotations() {
- return new LiveCloneListIterable<A>(this.nestedAnnotations);
- }
-
- public int getNestedAnnotationsSize() {
- return this.nestedAnnotations.size();
- }
-
- public A getNestedAnnotation(int index) {
- return this.nestedAnnotations.get(index);
- }
-
- public A addNestedAnnotation(int index) {
- // add a new annotation to the end of the list...
- int sourceIndex = this.nestedAnnotations.size();
- A nestedAnnotation = this.buildNestedAnnotation(sourceIndex);
- this.nestedAnnotations.add(sourceIndex, nestedAnnotation);
- nestedAnnotation.newAnnotation();
- nestedAnnotation.initialize(nestedAnnotation.getJavaResourceCompilationUnit().buildASTRoot());
- // ...then move it to the specified index
- this.moveNestedAnnotation(index, sourceIndex);
- return nestedAnnotation;
- }
-
- public A moveNestedAnnotation(int targetIndex, int sourceIndex) {
- if (targetIndex != sourceIndex) {
- return this.moveNestedAnnotation_(targetIndex, sourceIndex);
- }
- return null;
- }
-
- public A removeNestedAnnotation(int index) {
- A nestedAnnotation = this.nestedAnnotations.remove(index);
- nestedAnnotation.removeAnnotation();
- this.syncAstAnnotationsAfterRemove(index);
- return nestedAnnotation;
- }
-
- private A moveNestedAnnotation_(int targetIndex, int sourceIndex) {
- A nestedAnnotation = CollectionTools.move(this.nestedAnnotations, targetIndex, sourceIndex).get(targetIndex);
- this.syncAstAnnotationsAfterMove(targetIndex, sourceIndex, nestedAnnotation);
- return nestedAnnotation;
- }
-
- /**
- * Return a list of the nested AST annotations.
- */
- private ArrayList<org.eclipse.jdt.core.dom.Annotation> getNestedAstAnnotations(org.eclipse.jdt.core.dom.Annotation astContainerAnnotation) {
- ArrayList<org.eclipse.jdt.core.dom.Annotation> result = new ArrayList<org.eclipse.jdt.core.dom.Annotation>();
- if (astContainerAnnotation == null || astContainerAnnotation.isMarkerAnnotation()) {
- // no nested annotations
- }
- else if (astContainerAnnotation.isSingleMemberAnnotation()) {
- if (this.getElementName().equals("value")) { //$NON-NLS-1$
- Expression ex = ((SingleMemberAnnotation) astContainerAnnotation).getValue();
- this.addAstAnnotationsTo(ex, result);
- } else {
- // no nested annotations
- }
- }
- else if (astContainerAnnotation.isNormalAnnotation()) {
- MemberValuePair pair = this.getMemberValuePair((NormalAnnotation) astContainerAnnotation);
- if (pair == null) {
- // no nested annotations
- } else {
- this.addAstAnnotationsTo(pair.getValue(), result);
- }
- }
- return result;
- }
-
- /**
- * Add whatever annotations are represented by the specified expression to
- * the specified list. Do not add null to the list for any non-annotation expression.
- */
- private void addAstAnnotationsTo(Expression expression, ArrayList<org.eclipse.jdt.core.dom.Annotation> astAnnotations) {
- if (expression == null) {
- //do not add null to the list, not sure how we would get here...
- }
- else if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
- this.addAstAnnotationsTo((ArrayInitializer) expression, astAnnotations);
- }
- else {
- org.eclipse.jdt.core.dom.Annotation astAnnotation = this.getAstAnnotation_(expression);
- if (astAnnotation != null) {
- astAnnotations.add(astAnnotation);
- }
- }
- }
-
- private void addAstAnnotationsTo(ArrayInitializer arrayInitializer, ArrayList<org.eclipse.jdt.core.dom.Annotation> astAnnotations) {
- List<Expression> expressions = this.expressions(arrayInitializer);
- for (Expression expression : expressions) {
- org.eclipse.jdt.core.dom.Annotation astAnnotation = getAstAnnotation(expression);
- if (astAnnotation != null) {
- astAnnotations.add(astAnnotation);
- }
- }
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private List<Expression> expressions(ArrayInitializer arrayInitializer) {
- return arrayInitializer.expressions();
- }
-
- /**
- * If the specified expression is an annotation with the specified name, return it;
- * otherwise return null.
- */
- private org.eclipse.jdt.core.dom.Annotation getAstAnnotation(Expression expression) {
- // not sure how the expression could be null...
- return (expression == null) ? null : getAstAnnotation_(expression);
- }
-
- /**
- * pre-condition: expression is not null
- */
- private org.eclipse.jdt.core.dom.Annotation getAstAnnotation_(Expression expression) {
- switch (expression.getNodeType()) {
- case ASTNode.NORMAL_ANNOTATION:
- case ASTNode.SINGLE_MEMBER_ANNOTATION:
- case ASTNode.MARKER_ANNOTATION:
- org.eclipse.jdt.core.dom.Annotation astAnnotation = (org.eclipse.jdt.core.dom.Annotation) expression;
- if (this.getQualifiedName(astAnnotation).equals(this.getNestedAnnotationName())) {
- return astAnnotation;
- }
- return null;
- default:
- return null;
- }
- }
-
- private String getQualifiedName(org.eclipse.jdt.core.dom.Annotation astAnnotation) {
- ITypeBinding typeBinding = astAnnotation.resolveTypeBinding();
- if (typeBinding != null) {
- String resolvedName = typeBinding.getQualifiedName();
- if (resolvedName != null) {
- return resolvedName;
- }
- }
- return astAnnotation.getTypeName().getFullyQualifiedName();
- }
-
- private MemberValuePair getMemberValuePair(NormalAnnotation annotation) {
- List<MemberValuePair> pairs = this.values(annotation);
- for (MemberValuePair pair : pairs) {
- if (pair.getName().getFullyQualifiedName().equals(this.getElementName())) {
- return pair;
- }
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- private List<MemberValuePair> values(NormalAnnotation na) {
- return na.values();
- }
-
- /**
- * An annotation was moved within the specified annotation container from
- * the specified source index to the specified target index.
- * Synchronize the AST annotations with the resource model annotation container,
- * starting with the lower index to prevent overlap.
- */
- private void syncAstAnnotationsAfterMove(int targetIndex, int sourceIndex, A nestedAnnotation) {
- // move the Java annotation to the end of the list...
- nestedAnnotation.moveAnnotation(this.nestedAnnotations.size());
- // ...then shift the other AST annotations over one slot...
- if (sourceIndex < targetIndex) {
- for (int i = sourceIndex; i < targetIndex; i++) {
- this.nestedAnnotations.get(i).moveAnnotation(i);
- }
- } else {
- for (int i = sourceIndex; i > targetIndex; i-- ) {
- this.nestedAnnotations.get(i).moveAnnotation(i);
- }
- }
- // ...then move the AST annotation to the now empty slot at the target index
- nestedAnnotation.moveAnnotation(targetIndex);
- }
-
- /**
- * An annotation was removed from the specified annotation container at the
- * specified index.
- * Synchronize the AST annotations with the resource model annotation container,
- * starting at the specified index to prevent overlap.
- */
- private void syncAstAnnotationsAfterRemove(int index) {
- for (int i = index; i < this.nestedAnnotations.size(); i++) {
- // the indices are the same because the model annotations are
- // already in the proper locations - it's the AST annotations that
- // need to be moved to the matching location
- this.nestedAnnotations.get(i).moveAnnotation(i);
- }
- }
-
- void syncAddNestedAnnotation(org.eclipse.jdt.core.dom.Annotation astAnnotation) {
- int index = this.nestedAnnotations.size();
- A nestedAnnotation = this.buildNestedAnnotation(index);
- nestedAnnotation.initialize((CompilationUnit) astAnnotation.getRoot());
- this.nestedAnnotations.add(index, nestedAnnotation);
- this.nestedAnnotationAdded(index, nestedAnnotation);
- }
-
- void nestedAnnotationAdded(int index, A addedAnnotation) {
- SourceNode.this.nestedAnnotationAdded(this.getNestedAnnotationsListName(), index, addedAnnotation);
- }
-
- /**
- * Remove the nested annotations from the specified index to the end of
- * the list.
- */
- void syncRemoveNestedAnnotations(int index) {
- List<A> subList = this.nestedAnnotations.subList(index, this.nestedAnnotations.size());
- List<A> removedAnnotations = new ArrayList<A>(subList);
- subList.clear();
- this.nestedAnnotationsRemoved(index, removedAnnotations);
- }
-
- void nestedAnnotationsRemoved(int index, List<A> removedAnnotations) {
- SourceNode.this.nestedAnnotationsRemoved(this.getNestedAnnotationsListName(), index, removedAnnotations);
- }
-
- /**
- * Return the nested annotations list name for firing property change
- * notification.
- */
- protected abstract String getNestedAnnotationsListName();
-
- public boolean isEmpty() {
- return this.nestedAnnotations.isEmpty();
- }
-
- AnnotationProvider getAnnotationProvider() {
- return SourceNode.this.getAnnotationProvider();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.nestedAnnotations);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackage.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackage.java
deleted file mode 100644
index b2fbc06fff..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackage.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- * Oracle
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.IPackageBinding;
-import org.eclipse.jdt.core.dom.PackageDeclaration;
-import org.eclipse.jpt.common.core.internal.utility.jdt.JDTPackage;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedPackage;
-
-/**
- * @author Dmitry Geraskov
- * Source package-info.java
- *
- */
-public final class SourcePackage
- extends SourceAnnotatedElement<AnnotatedPackage>
- implements JavaResourcePackage
-{
-
- private String name;
-
- /**
- * construct package info
- */
- public static JavaResourcePackage newInstance(
- JavaResourceCompilationUnit parent,
- PackageDeclaration declaringPackage,
- CompilationUnit astRoot) {
- AnnotatedPackage pack = new JDTPackage(
- declaringPackage,
- parent.getCompilationUnit(),
- parent.getModifySharedDocumentCommandExecutor(),
- parent.getAnnotationEditFormatter());
- JavaResourcePackage jrpp = new SourcePackage(parent, pack);
- jrpp.initialize(astRoot);
- return jrpp;
- }
-
- private SourcePackage(
- JavaResourceCompilationUnit parent,
- AnnotatedPackage pack){
- super(parent, pack);
- }
-
-
- @Override
- protected void initialize(IBinding binding) {
- super.initialize(binding);
- this.name = this.buildName((IPackageBinding) binding);
- }
-
- // ******** JavaResourceAnnotatedElement implementation ********
-
- public Kind getKind() {
- return Kind.PACKAGE;
- }
-
-
- // ********** JavaResourcePackageInfo implementation **********
-
- // ***** name
- public String getName() {
- return this.name;
- }
-
- private void syncName(String astName) {
- if (valuesAreDifferent(astName, this.name)){
- String old = this.name;
- this.name = astName;
- this.firePropertyChanged(NAME_PROPERTY, old, astName);
- }
- }
-
- private String buildName(IPackageBinding binding) {
- return (binding == null) ? null : binding.getName();
- }
-
-
- // ********** Java changes **********
-
- @Override
- protected void synchronizeWith(IBinding binding) {
- super.synchronizeWith(binding);
- this.syncName(this.buildName((IPackageBinding) binding));
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java
deleted file mode 100644
index 0ee2aae4a1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourcePackageInfoCompilationUnit.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Red Hat, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.PackageDeclaration;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageInfoCompilationUnit;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-
-/**
- * @author Dmitry Geraskov
- * Source package-info.java
- *
- */
-public final class SourcePackageInfoCompilationUnit
- extends SourceCompilationUnit
- implements JavaResourcePackageInfoCompilationUnit {
-
- private JavaResourcePackage package_;
-
- public SourcePackageInfoCompilationUnit(
- ICompilationUnit compilationUnit,
- AnnotationProvider annotationProvider,
- AnnotationEditFormatter annotationEditFormatter,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- super(compilationUnit, annotationProvider, annotationEditFormatter, modifySharedDocumentCommandExecutor); // the JPA compilation unit is the root of its sub-tree
- this.package_ = this.buildPackage();
- }
-
-
- private JavaResourcePackage buildPackage() {
- this.openCompilationUnit();
- CompilationUnit astRoot = this.buildASTRoot();
- this.closeCompilationUnit();
- return this.buildPackage(astRoot);
- }
-
-
- // ********** JavaResourceNode.Root implementation **********
-
- public Iterable<JavaResourceAbstractType> getTypes() {
- return EmptyIterable.instance();
- }
-
- public JavaResourceAbstractType getPrimaryType() {
- return null;
- }
-
- // ********** JptResourceModel implementation **********
-
- public JptResourceType getResourceType() {
- return JptCommonCorePlugin.JAVA_SOURCE_PACKAGE_INFO_RESOURCE_TYPE;
- }
-
-
- // ********** Java changes **********
-
- public void synchronizeWith(CompilationUnit astRoot) {
- this.syncPackage(astRoot);
- }
-
-
- // ********** JavaResourceCompilationUnit implementation **********
-
- public void resolveTypes() {
- //no-op
- }
-
- // ********** package-info **********
-
- public JavaResourcePackage getPackage() {
- return this.package_;
- }
-
- private JavaResourcePackage buildPackage(CompilationUnit astRoot) {
- return this.buildPackage(astRoot, this.getPackageDeclaration(astRoot));
- }
-
- private void syncPackage(CompilationUnit astRoot) {
- PackageDeclaration pd = this.getPackageDeclaration(astRoot);
- if (pd == null) {
- this.syncPackage_(null);
- } else {
- if (this.package_ == null) {
- this.syncPackage_(this.buildPackage(astRoot, pd));
- } else {
- this.package_.synchronizeWith(astRoot);
- }
- }
- }
-
- private PackageDeclaration getPackageDeclaration(CompilationUnit astRoot) {
- return astRoot.getPackage();
- }
-
- private void syncPackage_(JavaResourcePackage astPackage) {
- JavaResourcePackage old = this.package_;
- this.package_ = astPackage;
- this.firePropertyChanged(PACKAGE, old, astPackage);
- }
-
- private JavaResourcePackage buildPackage(CompilationUnit astRoot, PackageDeclaration packageDeclaration) {
- return SourcePackage.newInstance(this, packageDeclaration, astRoot);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java
deleted file mode 100644
index 1108105280..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceType.java
+++ /dev/null
@@ -1,622 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.Modifier;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools;
-import org.eclipse.jpt.common.core.internal.utility.jdt.JDTType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.utility.jdt.Type;
-import org.eclipse.jpt.common.utility.MethodSignature;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TreeIterable;
-
-/**
- * Java source type (type or interface)
- */
-final class SourceType
- extends SourceAbstractType<Type>
- implements JavaResourceType
-{
-
- private String superclassQualifiedName;
-
- private boolean abstract_; // 'abstract' is a reserved word
-
- private boolean hasNoArgConstructor;
-
- private boolean hasPrivateNoArgConstructor;
-
- private final Vector<JavaResourceType> types;
-
- private final Vector<JavaResourceEnum> enums;
-
- private final Vector<JavaResourceField> fields;
-
- private final Vector<JavaResourceMethod> methods;
-
-
- // ********** construction/initialization **********
-
- /**
- * build top-level type
- */
- static JavaResourceType newInstance(
- JavaResourceCompilationUnit javaResourceCompilationUnit,
- TypeDeclaration typeDeclaration,
- CompilationUnit astRoot) {
- Type type = new JDTType(
- typeDeclaration,
- javaResourceCompilationUnit.getCompilationUnit(),
- javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
- javaResourceCompilationUnit.getAnnotationEditFormatter());
- JavaResourceType jrpt = new SourceType(javaResourceCompilationUnit, type);
- jrpt.initialize(astRoot);
- return jrpt;
- }
-
- /**
- * build nested type
- */
- private static JavaResourceType newInstance(
- JavaResourceCompilationUnit javaResourceCompilationUnit,
- Type declaringType,
- TypeDeclaration typeDeclaration,
- int occurrence,
- CompilationUnit astRoot) {
- Type type = new JDTType(
- declaringType,
- typeDeclaration,
- occurrence,
- javaResourceCompilationUnit.getCompilationUnit(),
- javaResourceCompilationUnit.getModifySharedDocumentCommandExecutor(),
- javaResourceCompilationUnit.getAnnotationEditFormatter());
- JavaResourceType jrpt = new SourceType(javaResourceCompilationUnit, type);
- jrpt.initialize(astRoot);
- return jrpt;
- }
-
- private SourceType(JavaResourceCompilationUnit javaResourceCompilationUnit, Type type) {
- super(javaResourceCompilationUnit, type);
- this.types = new Vector<JavaResourceType>();
- this.enums = new Vector<JavaResourceEnum>();
- this.fields = new Vector<JavaResourceField>();
- this.methods = new Vector<JavaResourceMethod>();
- }
-
- @Override
- public void initialize(CompilationUnit astRoot) {
- super.initialize(astRoot);
- this.initializeTypes(astRoot);
- this.initializeEnums(astRoot);
- this.initializeFields(astRoot);
- this.initializeMethods(astRoot);
- }
-
- @Override
- protected void initialize(IBinding binding) {
- super.initialize(binding);
- this.superclassQualifiedName = this.buildSuperclassQualifiedName((ITypeBinding) binding);
- this.abstract_ = this.buildAbstract((ITypeBinding) binding);
- this.hasNoArgConstructor = this.buildHasNoArgConstructor((ITypeBinding) binding);
- this.hasPrivateNoArgConstructor = this.buildHasPrivateNoArgConstructor((ITypeBinding) binding);
- }
-
-
- // ********** update **********
-
- @Override
- public void synchronizeWith(CompilationUnit astRoot) {
- super.synchronizeWith(astRoot);
- this.syncTypes(astRoot);
- this.syncEnums(astRoot);
- this.syncFields(astRoot);
- this.syncMethods(astRoot);
- }
-
- @Override
- protected void synchronizeWith(IBinding binding) {
- super.synchronizeWith(binding);
- this.syncSuperclassQualifiedName(this.buildSuperclassQualifiedName((ITypeBinding) binding));
- this.syncAbstract(this.buildAbstract((ITypeBinding) binding));
- this.syncHasNoArgConstructor(this.buildHasNoArgConstructor((ITypeBinding) binding));
- this.syncHasPrivateNoArgConstructor(this.buildHasPrivateNoArgConstructor((ITypeBinding) binding));
- }
-
-
- // ********** SourceAnnotatedElement implementation **********
-
- @Override
- public void resolveTypes(CompilationUnit astRoot) {
- super.resolveTypes(astRoot);
-
- this.syncSuperclassQualifiedName(this.buildSuperclassQualifiedName(this.annotatedElement.getBinding(astRoot)));
-
- for (JavaResourceField field : this.getFields()) {
- field.resolveTypes(astRoot);
- }
-
- // a new type can trigger a method parameter type to be a resolved,
- // fully-qualified name, so we need to rebuild our list of methods:
- // "setFoo(Foo)" is not the same as "setFoo(com.bar.Foo)"
- // and, vice-versa, a removed type can "unresolve" a parameter type
- this.syncMethods(astRoot);
-
- // this is commented out because the above syncMethods() calls
- // JavaResourceMethod.sysynchronizeWith(MethodDeclaration)
- // on all the methods. resolveTypes() is a subset of synchronizeWith()
- // so it is redundant and expensive to do both of these.
- //for (JavaResourceMethod method : this.getMethods()) {
- // method.resolveTypes(astRoot);
- //}
- for (JavaResourceType type : this.getTypes()) {
- type.resolveTypes(astRoot);
- }
- for (JavaResourceEnum enum_ : this.getEnums()) {
- enum_.resolveTypes(astRoot);
- }
- }
-
-
- // ******** JavaResourceType implementation ********
-
- public Kind getKind() {
- return Kind.TYPE;
- }
-
- // ***** superclass qualified name
- public String getSuperclassQualifiedName() {
- return this.superclassQualifiedName;
- }
-
- private void syncSuperclassQualifiedName(String astSuperclassQualifiedName) {
- String old = this.superclassQualifiedName;
- this.superclassQualifiedName = astSuperclassQualifiedName;
- this.firePropertyChanged(SUPERCLASS_QUALIFIED_NAME_PROPERTY, old, astSuperclassQualifiedName);
- }
-
- private String buildSuperclassQualifiedName(ITypeBinding binding) {
- ITypeBinding superclass = binding == null ? null : binding.getSuperclass();
- return (superclass == null) ? null : superclass.getTypeDeclaration().getQualifiedName();
- }
-
- // ***** abstract
- public boolean isAbstract() {
- return this.abstract_;
- }
-
- private void syncAbstract(boolean astAbstract) {
- boolean old = this.abstract_;
- this.abstract_ = astAbstract;
- this.firePropertyChanged(ABSTRACT_PROPERTY, old, astAbstract);
- }
-
- private boolean buildAbstract(ITypeBinding binding) {
- return (binding == null) ? false : Modifier.isAbstract(binding.getModifiers());
- }
-
- // ***** no-arg constructor
- public boolean hasNoArgConstructor() {
- return this.hasNoArgConstructor;
- }
-
- private void syncHasNoArgConstructor(boolean astHasNoArgConstructor) {
- boolean old = this.hasNoArgConstructor;
- this.hasNoArgConstructor = astHasNoArgConstructor;
- this.firePropertyChanged(NO_ARG_CONSTRUCTOR_PROPERTY, old, astHasNoArgConstructor);
- }
-
- private boolean buildHasNoArgConstructor(ITypeBinding binding) {
- return (binding == null) ? false : typeHasNoArgConstructor(binding);
- }
-
- protected static boolean typeHasNoArgConstructor(ITypeBinding binding) {
- return findNoArgConstructor(binding) != null;
- }
-
- protected static IMethodBinding findNoArgConstructor(ITypeBinding binding) {
- for (IMethodBinding method : binding.getDeclaredMethods()) {
- if (method.isConstructor()) {
- if (method.getParameterTypes().length == 0) {
- return method;
- }
- }
- }
- return null;
- }
-
- // ***** private no-arg constructor
- public boolean hasPrivateNoArgConstructor() {
- return this.hasPrivateNoArgConstructor;
- }
-
- private void syncHasPrivateNoArgConstructor(boolean astHasPrivateNoArgConstructor) {
- boolean old = this.hasPrivateNoArgConstructor;
- this.hasPrivateNoArgConstructor = astHasPrivateNoArgConstructor;
- this.firePropertyChanged(PRIVATE_NO_ARG_CONSTRUCTOR_PROPERTY, old, astHasPrivateNoArgConstructor);
- }
-
- private boolean buildHasPrivateNoArgConstructor(ITypeBinding binding) {
- return (binding == null) ? false : typeHasPrivateNoArgConstructor(binding);
- }
-
- protected static boolean typeHasPrivateNoArgConstructor(ITypeBinding binding) {
- IMethodBinding method = findNoArgConstructor(binding);
- return (method != null) && Modifier.isPrivate(method.getModifiers());
- }
-
-
- // ***** public/protected no-arg constructor *****
-
- public boolean hasPublicOrProtectedNoArgConstructor() {
- Iterable<JavaResourceMethod> constructors = getConstructors();
- if (CollectionTools.size(constructors) == 0) {
- return true;
- }
- for (JavaResourceMethod constructor : constructors) {
- if (constructor.getParametersSize() == 0) {
- return Modifier.isPublic(constructor.getModifiers())
- || Modifier.isProtected(constructor.getModifiers());
- }
- }
- return false;
- }
-
- public boolean hasPublicNoArgConstructor() {
- Iterable<JavaResourceMethod> constructors = this.getConstructors();
- if (CollectionTools.size(constructors) == 0) {
- return true;
- }
- for (JavaResourceMethod constructor : constructors) {
- if (constructor.getParametersSize() == 0) {
- return Modifier.isPublic(constructor.getModifiers());
- }
- }
- return false;
- }
-
- protected Iterable<JavaResourceMethod> getConstructors() {
- return new FilteringIterable<JavaResourceMethod>(this.getMethods()) {
- @Override
- protected boolean accept(JavaResourceMethod method) {
- return method.isConstructor();
- }
- };
- }
-
-
- // ********** types **********
-
- public Iterable<JavaResourceType> getTypes() {
- return new LiveCloneIterable<JavaResourceType>(this.types); // read-only
- }
-
- public Iterable<JavaResourceType> getAllTypes() {
- return new TreeIterable<JavaResourceType>(this) {
- @Override
- protected Iterator<? extends JavaResourceType> children(JavaResourceType type) {
- return type.getTypes().iterator();
- }
- };
- }
-
- private JavaResourceType getType(String typeName, int occurrence) {
- for (JavaResourceType type : this.getTypes()) {
- if (type.isFor(typeName, occurrence)) {
- return type;
- }
- }
- return null;
- }
-
- private void addType(JavaResourceType type) {
- this.addItemToCollection(type, this.types, TYPES_COLLECTION);
- }
-
- private void removeTypes(Collection<JavaResourceType> remove) {
- this.removeItemsFromCollection(remove, this.types, TYPES_COLLECTION);
- }
-
- private void initializeTypes(CompilationUnit astRoot) {
- TypeDeclaration[] typeDeclarations = this.annotatedElement.getTypes(astRoot);
- CounterMap counters = new CounterMap(typeDeclarations.length);
- for (TypeDeclaration td : typeDeclarations) {
- String tdName = td.getName().getFullyQualifiedName();
- int occurrence = counters.increment(tdName);
- this.types.add(this.buildType(td, occurrence, astRoot));
- }
- }
-
- private void syncTypes(CompilationUnit astRoot) {
- TypeDeclaration[] typeDeclarations = this.annotatedElement.getTypes(astRoot);
- CounterMap counters = new CounterMap(typeDeclarations.length);
- HashSet<JavaResourceType> typesToRemove = new HashSet<JavaResourceType>(this.types);
- for (TypeDeclaration typeDeclaration : typeDeclarations) {
- String tdName = typeDeclaration.getName().getFullyQualifiedName();
- int occurrence = counters.increment(tdName);
-
- JavaResourceType type = this.getType(tdName, occurrence);
- if (type == null) {
- this.addType(this.buildType(typeDeclaration, occurrence, astRoot));
- } else {
- typesToRemove.remove(type);
- type.synchronizeWith(astRoot);
- }
- }
- this.removeTypes(typesToRemove);
- }
-
- private JavaResourceType buildType(TypeDeclaration nestedTypeDeclaration, int occurrence, CompilationUnit astRoot) {
- return newInstance(this.getJavaResourceCompilationUnit(), this.annotatedElement, nestedTypeDeclaration, occurrence, astRoot);
- }
-
-
- // ********** enums **********
-
- public Iterable<JavaResourceEnum> getEnums() {
- return new LiveCloneIterable<JavaResourceEnum>(this.enums); // read-only
- }
-
- public Iterable<JavaResourceEnum> getAllEnums() {
- return this.getEnums();
- }
-
- private JavaResourceEnum getEnum(String enumName, int occurrence) {
- for (JavaResourceEnum enum_ : this.getEnums()) {
- if (enum_.isFor(enumName, occurrence)) {
- return enum_;
- }
- }
- return null;
- }
-
- private void addEnum(JavaResourceEnum enum_) {
- this.addItemToCollection(enum_, this.enums, ENUMS_COLLECTION);
- }
-
- private void removeEnums(Collection<JavaResourceEnum> remove) {
- this.removeItemsFromCollection(remove, this.enums, ENUMS_COLLECTION);
- }
-
- private void initializeEnums(CompilationUnit astRoot) {
- EnumDeclaration[] enumDeclarations = this.annotatedElement.getEnums(astRoot);
- CounterMap counters = new CounterMap(enumDeclarations.length);
- for (EnumDeclaration ed : enumDeclarations) {
- String tdName = ed.getName().getFullyQualifiedName();
- int occurrence = counters.increment(tdName);
- this.enums.add(this.buildEnum(ed, occurrence, astRoot));
- }
- }
-
- private void syncEnums(CompilationUnit astRoot) {
- EnumDeclaration[] enumDeclarations = this.annotatedElement.getEnums(astRoot);
- CounterMap counters = new CounterMap(enumDeclarations.length);
- HashSet<JavaResourceEnum> enumsToRemove = new HashSet<JavaResourceEnum>(this.enums);
- for (EnumDeclaration enumDeclaration : enumDeclarations) {
- String tdName = enumDeclaration.getName().getFullyQualifiedName();
- int occurrence = counters.increment(tdName);
-
- JavaResourceEnum enum_ = this.getEnum(tdName, occurrence);
- if (enum_ == null) {
- this.addEnum(this.buildEnum(enumDeclaration, occurrence, astRoot));
- } else {
- enumsToRemove.remove(enum_);
- enum_.synchronizeWith(astRoot);
- }
- }
- this.removeEnums(enumsToRemove);
- }
-
- private JavaResourceEnum buildEnum(EnumDeclaration nestedEnumDeclaration, int occurrence, CompilationUnit astRoot) {
- return SourceEnum.newInstance(this.getJavaResourceCompilationUnit(), this.annotatedElement, nestedEnumDeclaration, occurrence, astRoot);
- }
-
-
- // ********** fields **********
-
- public Iterable<JavaResourceField> getFields() {
- return new LiveCloneIterable<JavaResourceField>(this.fields);
- }
-
- private void addField(JavaResourceField field) {
- this.addItemToCollection(field, this.fields, FIELDS_COLLECTION);
- }
-
- private JavaResourceField getField(String fieldName, int occurrence) {
- for (JavaResourceField field : this.getFields()) {
- if (field.isFor(fieldName, occurrence)) {
- return field;
- }
- }
- return null;
- }
-
- private void removeFields(Collection<JavaResourceField> remove) {
- this.removeItemsFromCollection(remove, this.fields, FIELDS_COLLECTION);
- }
-
- private void initializeFields(CompilationUnit astRoot) {
- FieldDeclaration[] fieldDeclarations = this.annotatedElement.getFields(astRoot);
- CounterMap counters = new CounterMap(fieldDeclarations.length);
- for (FieldDeclaration fieldDeclaration : fieldDeclarations) {
- for (VariableDeclarationFragment fragment : fragments(fieldDeclaration)) {
- String fieldName = fragment.getName().getFullyQualifiedName();
- int occurrence = counters.increment(fieldName);
- this.fields.add(this.buildField(fieldName, occurrence, astRoot));
- }
- }
- }
-
- private void syncFields(CompilationUnit astRoot) {
- FieldDeclaration[] fieldDeclarations = this.annotatedElement.getFields(astRoot);
- CounterMap counters = new CounterMap(fieldDeclarations.length);
- HashSet<JavaResourceField> fieldsToRemove = new HashSet<JavaResourceField>(this.fields);
- for (FieldDeclaration fieldDeclaration : fieldDeclarations) {
- for (VariableDeclarationFragment fragment : fragments(fieldDeclaration)) {
- String fieldName = fragment.getName().getFullyQualifiedName();
- int occurrence = counters.increment(fieldName);
-
- JavaResourceField field = this.getField(fieldName, occurrence);
- if (field == null) {
- this.addField(this.buildField(fieldName, occurrence, astRoot));
- } else {
- fieldsToRemove.remove(field);
- field.synchronizeWith(astRoot);
- }
- }
- }
- this.removeFields(fieldsToRemove);
- }
-
- private JavaResourceField buildField(String fieldName, int occurrence, CompilationUnit astRoot) {
- return SourceField.newInstance(this, this.annotatedElement, fieldName, occurrence, this.getJavaResourceCompilationUnit(), astRoot);
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private static List<VariableDeclarationFragment> fragments(FieldDeclaration fd) {
- return fd.fragments();
- }
-
-
- // ********** methods **********
-
- public Iterable<JavaResourceMethod> getMethods() {
- return new LiveCloneIterable<JavaResourceMethod>(this.methods);
- }
-
- private static JavaResourceMethod getMethod(Collection<JavaResourceMethod> methods, MethodSignature signature, int occurrence) {
- for (JavaResourceMethod method : methods) {
- if (method.isFor(signature, occurrence)) {
- return method;
- }
- }
- return null;
- }
-
- private void addMethod(JavaResourceMethod method) {
- this.addItemToCollection(method, this.methods, METHODS_COLLECTION);
- }
-
- private void removeMethods(Collection<JavaResourceMethod> remove) {
- this.removeItemsFromCollection(remove, this.methods, METHODS_COLLECTION);
- }
-
- private void initializeMethods(CompilationUnit astRoot) {
- MethodDeclaration[] methodDeclarations = this.annotatedElement.getMethods(astRoot);
- CounterMap counters = new CounterMap(methodDeclarations.length);
- for (MethodDeclaration methodDeclaration : methodDeclarations) {
- MethodSignature signature = ASTTools.buildMethodSignature(methodDeclaration);
- int occurrence = counters.increment(signature);
- this.methods.add(this.buildMethod(signature, occurrence, methodDeclaration));
- }
- }
-
- private void syncMethods(CompilationUnit astRoot) {
- MethodDeclaration[] methodDeclarations = this.annotatedElement.getMethods(astRoot);
- CounterMap counters = new CounterMap(methodDeclarations.length);
- HashSet<JavaResourceMethod> methodsToRemove = new HashSet<JavaResourceMethod>(this.methods);
- for (MethodDeclaration methodDeclaration : methodDeclarations) {
- MethodSignature signature = ASTTools.buildMethodSignature(methodDeclaration);
- int occurrence = counters.increment(signature);
-
- JavaResourceMethod method = getMethod(methodsToRemove, signature, occurrence);
- if (method == null) {
- this.addMethod(this.buildMethod(signature, occurrence, methodDeclaration));
- } else {
- methodsToRemove.remove(method);
- method.synchronizeWith(methodDeclaration);
- }
- }
- this.removeMethods(methodsToRemove);
- }
-
- private JavaResourceMethod buildMethod(MethodSignature signature, int occurrence, MethodDeclaration methodDeclaration) {
- return SourceMethod.newInstance(this, this.annotatedElement, signature, occurrence, this.getJavaResourceCompilationUnit(), methodDeclaration);
- }
-
-
- public boolean hasAnyAnnotatedFields() {
- for (JavaResourceField field : this.getFields()) {
- if (field.isAnnotated()) {
- return true;
- }
- }
- return false;
- }
-
- public boolean hasAnyAnnotatedMethods() {
- for (JavaResourceMethod method : this.getMethods()) {
- if (method.isAnnotated()) {
- return true;
- }
- }
- return false;
- }
-
- // Two more requirements for a valid equals() method:
- // 1. It should be public
- // 2. The return type should be boolean
- // Both requirements are validated by the compiler so they are excluded here
- public boolean hasEqualsMethod() {
- for (JavaResourceMethod method : this.getMethods()) {
- if (StringTools.stringsAreEqual(method.getMethodName(), "equals") //$NON-NLS-1$
- && method.getParametersSize() == 1
- && StringTools.stringsAreEqual(method.getParameterTypeName(0), Object.class.getName())) {
- return true;
- }
- }
- return false;
- }
-
- // Two more requirements for a valid hashCode() method:
- // 1. It should be public
- // 2. The return type should be int
- // Both requirements are validated by the compiler so they are excluded here
- public boolean hasHashCodeMethod() {
- for (JavaResourceMethod method : this.getMethods()) {
- if (StringTools.stringsAreEqual(method.getMethodName(), "hashCode") //$NON-NLS-1$
- && method.getParametersSize() == 0) {
- return true;
- }
- }
- return false;
- }
-
- public JavaResourceMethod getMethod(String propertyName) {
- for (JavaResourceMethod method : this.getMethods()) {
- if (StringTools.stringsAreEqual(method.getMethodName(), propertyName)) {
- return method;
- }
- }
- return null;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceTypeCompilationUnit.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceTypeCompilationUnit.java
deleted file mode 100644
index bf5333f91d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/resource/java/source/SourceTypeCompilationUnit.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.resource.java.source;
-
-import java.util.List;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-
-/**
- * Java compilation unit (source file)
- * non package-info.java file
- */
-public final class SourceTypeCompilationUnit
- extends SourceCompilationUnit
-{
-
- /**
- * The primary type of the AST compilation unit. We are not going to handle
- * multiple types defined in a single compilation unit. Entities must have
- * a public/protected no-arg constructor, and there is no way to access
- * the constructor in a package class (which is what all top-level,
- * non-primary classes must be).
- */
- private JavaResourceAbstractType primaryType;
-
-
- // ********** construction **********
-
- public SourceTypeCompilationUnit(
- ICompilationUnit compilationUnit,
- AnnotationProvider annotationProvider,
- AnnotationEditFormatter annotationEditFormatter,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- super(compilationUnit, annotationProvider, annotationEditFormatter, modifySharedDocumentCommandExecutor); // the compilation unit is the root of its sub-tree
- this.primaryType = this.buildPrimaryType();
- }
-
- private JavaResourceAbstractType buildPrimaryType() {
- this.openCompilationUnit();
- CompilationUnit astRoot = this.buildASTRoot();
- this.closeCompilationUnit();
- return this.buildPrimaryType(astRoot);
- }
-
-
- // ********** JavaResourceNode implementation **********
-
- public void synchronizeWith(CompilationUnit astRoot) {
- this.syncPrimaryType(astRoot);
- }
-
-
- // ********** JavaResourceNode.Root implementation **********
-
- /**
- * NB: return *all* the types since we build them all
- */
- public Iterable<JavaResourceAbstractType> getTypes() {
- return (this.primaryType == null) ?
- EmptyIterable.<JavaResourceAbstractType>instance() :
- new CompositeIterable<JavaResourceAbstractType>(this.primaryType.getAllTypes(), this.primaryType.getAllEnums());
- }
-
-
- // ********** JpaResourceModel implementation **********
-
- public JptResourceType getResourceType() {
- return JptCommonCorePlugin.JAVA_SOURCE_RESOURCE_TYPE;
- }
-
-
- // ********** JavaResourceCompilationUnit implementation **********
-
- public void resolveTypes() {
- if (this.primaryType != null) {
- this.primaryType.resolveTypes(this.buildASTRoot());
- }
- }
-
-
- // ********** type **********
-
- public JavaResourceAbstractType getPrimaryType() {
- return this.primaryType;
- }
-
- private JavaResourceAbstractType buildPrimaryType(CompilationUnit astRoot) {
- AbstractTypeDeclaration td = this.getPrimaryTypeOrEnumDeclaration(astRoot);
- return (td == null) ? null : this.buildPrimaryType(astRoot, td);
- }
-
-
- private void syncPrimaryType(CompilationUnit astRoot) {
- AbstractTypeDeclaration td = this.getPrimaryTypeOrEnumDeclaration(astRoot);
- if (td == null) {
- this.syncPrimaryType_(null);
- } else {
- if (this.primaryType == null || (!typeMatchesASTNodeType(this.primaryType, td))) {
- this.syncPrimaryType_(this.buildPrimaryType(astRoot, td));
- } else {
- this.primaryType.synchronizeWith(astRoot);
- }
- }
- }
-
- /**
- * Must be non-null JavaResourceAbstractType and AbstractTypeDeclaration
- */
- protected static boolean typeMatchesASTNodeType(JavaResourceAbstractType type, AbstractTypeDeclaration astType) {
- return type.getKind().getAstNodeType() == astType.getNodeType();
- }
-
- private void syncPrimaryType_(JavaResourceAbstractType astType) {
- JavaResourceAbstractType old = this.primaryType;
- this.primaryType = astType;
- this.firePropertyChanged(TYPES_COLLECTION, old, astType);
- }
-
-
- // ********** internal **********
-
- private JavaResourceAbstractType buildPrimaryType(CompilationUnit astRoot, AbstractTypeDeclaration typeDeclaration) {
- if (typeDeclaration.getNodeType() == ASTNode.TYPE_DECLARATION) {
- return SourceType.newInstance(this, (TypeDeclaration) typeDeclaration, astRoot);
- }
- else if (typeDeclaration.getNodeType() == ASTNode.ENUM_DECLARATION) {
- return SourceEnum.newInstance(this, (EnumDeclaration) typeDeclaration, astRoot);
- }
- throw new IllegalArgumentException();
- }
-
- /**
- * i.e. the type with the same name as the compilation unit;
- * return the first class, interface or enum (ignore annotations) with
- * the same name as the compilation unit (file);
- * NB: this type could be in error if there is an annotation
- * with the same name preceding it in the compilation unit
- *
- * Return null if the parser did not resolve the type declaration's binding.
- * This can occur if the project JRE is removed (bug 225332).
- */
- private AbstractTypeDeclaration getPrimaryTypeOrEnumDeclaration(CompilationUnit astRoot) {
- String primaryTypeName = this.getPrimaryTypeName();
- for (AbstractTypeDeclaration atd : this.types(astRoot)) {
- if (this.nodeIsPrimaryTypeOrEnumDeclaration(atd, primaryTypeName)) {
- return (atd.resolveBinding() == null) ? null : atd;
- }
- }
- return null;
- }
-
- private boolean nodeIsPrimaryTypeOrEnumDeclaration(AbstractTypeDeclaration atd, String primaryTypeName) {
- return this.nodeIsTypeOrEnumDeclaration(atd) &&
- (atd.getName().getFullyQualifiedName().equals(primaryTypeName));
- }
-
- private boolean nodeIsTypeOrEnumDeclaration(AbstractTypeDeclaration atd) {
- return atd.getNodeType() == ASTNode.TYPE_DECLARATION ||
- atd.getNodeType() == ASTNode.ENUM_DECLARATION;
- }
-
- private String getPrimaryTypeName() {
- return this.getCompilationUnitName();
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private List<AbstractTypeDeclaration> types(CompilationUnit astRoot) {
- return astRoot.types();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/CallbackJobSynchronizer.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/CallbackJobSynchronizer.java
deleted file mode 100644
index 947d027e5e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/CallbackJobSynchronizer.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jpt.common.core.utility.command.JobCommand;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-import org.eclipse.jpt.common.utility.synchronizers.CallbackSynchronizer;
-
-/**
- * Extend the job synchronizer to notify listeners
- * when a synchronization "cycle" is complete; i.e. the synchronization has,
- * for the moment, handled every "synchronize" request and quiesced.
- * This notification is <em>not</em> guaranteed to occur with <em>every</em>
- * synchronization "cycle";
- * since other, unrelated, synchronizations can be triggered concurrently;
- * preventing the synchronization from quiescing.
- */
-public class CallbackJobSynchronizer
- extends JobSynchronizer
- implements CallbackSynchronizer
-{
- private final ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
-
-
- // ********** construction **********
-
- /**
- * Construct a callback job synchronizer that uses the specified job command to
- * perform the synchronization. Assign the generated Eclipse job the
- * specified name.
- */
- public CallbackJobSynchronizer(String jobName, JobCommand command) {
- super(jobName, command);
- }
-
- /**
- * Construct a callback job synchronizer that uses the specified job command to
- * perform the synchronization. Assign the generated Eclipse job the
- * specified name and scheduling rule.
- */
- public CallbackJobSynchronizer(String jobName, JobCommand command, ISchedulingRule schedulingRule) {
- super(jobName, command, schedulingRule);
- }
-
- /**
- * Build a job that will let us know when the synchronization has
- * quiesced.
- */
- @Override
- SynchronizationJob buildJob(String jobName, JobCommand command, ISchedulingRule schedulingRule) {
- return new CallbackSynchronizationJob(jobName, command, schedulingRule);
- }
-
-
- // ********** CallbackSynchronizer implementation **********
-
- public void addListener(Listener listener) {
- this.listenerList.add(listener);
- }
-
- public void removeListener(Listener listener) {
- this.listenerList.remove(listener);
- }
-
- /**
- * Notify our listeners.
- */
- void synchronizationQuiesced() {
- for (Listener listener : this.listenerList.getListeners()) {
- listener.synchronizationQuiesced(this);
- }
- }
-
-
- // ********** synchronization job **********
-
- /**
- * Extend {@link JobSynchronizer.SynchronizationJob}
- * to notify the synchronizer when the synchronization has quiesced
- * (i.e. the command has finished executing and there are no further
- * requests for synchronization).
- * Because synchronization occurs during the job's execution,
- * no other thread will be able to
- * initiate another synchronization until the synchronizer's listeners have been
- * notified. Note also, the synchronizer's listeners can, themselves,
- * trigger another synchronization (by directly or indirectly calling
- * {@link org.eclipse.jpt.common.utility.synchronizers.Synchronizer#synchronize()});
- * but this synchronization will not occur until <em>after</em> all the
- * listeners have been notified.
- */
- class CallbackSynchronizationJob
- extends SynchronizationJob
- {
- /**
- * When this flag is set to true, the job has been scheduled to run.
- * We need this because {@link org.eclipse.core.runtime.jobs.Job Job}
- * has no public API for discovering whether a job is "scheduled".
- */
- // use 'volatile' because synchronization isn't really required
- private volatile boolean scheduled;
-
-
- CallbackSynchronizationJob(String jobName, JobCommand command, ISchedulingRule schedulingRule) {
- super(jobName, command, schedulingRule);
- this.scheduled = false;
- }
-
- /**
- * If we are allowing the job to be scheduled (i.e. {@link #start()}
- * was called), set the "scheduled" flag.
- */
- @Override
- void synchronize() {
- if (this.shouldSchedule) {
- this.scheduled = true;
- }
- super.synchronize();
- }
-
- /**
- * Clear the "scheduled" flag; perform the synchronization; and,
- * if the "scheduled" flag is still clear (i.e. there have been no
- * further calls to {@link #synchronize()}), notify our listeners.
- */
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- this.scheduled = false;
- IStatus status = super.run(monitor);
- // hmmm - we will notify listeners even when we our job is "stopped";
- // that seems ok... ~bjv
- if ( ! this.scheduled) {
- CallbackJobSynchronizer.this.synchronizationQuiesced();
- }
- return status;
- }
-
- @Override
- void stop() {
- this.scheduled = false;
- super.stop();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ICUStringCollator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ICUStringCollator.java
deleted file mode 100644
index 555fa43caf..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/ICUStringCollator.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility;
-
-import java.util.Comparator;
-import java.util.Locale;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import com.ibm.icu.text.Collator;
-
-/**
- * This collator simply wraps an ICU4J collator and implements a
- * {@link String} {@link Comparator} (instead of an {@link Object}
- * {@link Comparator}, which is what {@link Collator} does, mimicking the
- * JDK(?)).
- *
- * @see Collator
- */
-public class ICUStringCollator
- implements Comparator<String>
-{
- private final Collator collator;
-
-
- /**
- * Wrap the default collator.
- * @see Collator#getInstance()
- */
- public ICUStringCollator() {
- this(Collator.getInstance());
- }
-
- /**
- * Wrap the collator for the specified locale.
- * @see Collator#getInstance(Locale)
- */
- public ICUStringCollator(Locale locale) {
- this(Collator.getInstance(locale));
- }
-
- /**
- * Wrap the specified collator.
- */
- public ICUStringCollator(Collator collator) {
- super();
- this.collator = collator;
- }
-
- public int compare(String string1, String string2) {
- return this.collator.compare(string1, string2);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.collator);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java
deleted file mode 100644
index 024853c8cd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility;
-
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IParent;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.NotNullFilter;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-
-/**
- * Convenience methods for dealing with JDT core
- */
-public final class JDTTools {
-
- /**
- * Wrap checked exception.
- */
- public static boolean packageFragmentRootIsSourceFolder(IPackageFragmentRoot pfr) {
- try {
- return packageFragmentRootIsSourceFolder_(pfr);
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- static boolean packageFragmentRootIsSourceFolder_(IPackageFragmentRoot pfr) throws JavaModelException {
- return pfr.exists() && (pfr.getKind() == IPackageFragmentRoot.K_SOURCE);
- }
-
- /**
- * Wrap checked exception and check for out of sync workspace.
- */
- public static IJavaElement[] getChildren(IParent parent) {
- try {
- return parent.getChildren();
- } catch (JavaModelException ex) {
- // ignore FNFE - which can happen when the workspace is out of sync with O/S file system
- if ( ! (ex.getCause() instanceof FileNotFoundException)) {
- JptCommonCorePlugin.log(ex);
- }
- return EMPTY_JAVA_ELEMENT_ARRAY;
- }
- }
-
- private static final IJavaElement[] EMPTY_JAVA_ELEMENT_ARRAY = new IJavaElement[0];
-
- /**
- * Climb the specified type's inheritance hierarchy looking for the specified interface.
- */
- public static boolean typeIsSubType(IJavaProject javaProject, String potentialSubType, String potentialSuperType) {
- try {
- return typeIsSubType(javaProject, javaProject.findType(potentialSubType), javaProject.findType(potentialSuperType));
- }
- catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- public static boolean typeIsSubType(IJavaProject javaProject, IType potentialSubType, String potentialSuperType) {
- try {
- return typeIsSubType_(javaProject, potentialSubType, potentialSuperType);
- }
- catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return false;
- }
- }
-
- private static boolean typeIsSubType_(IJavaProject javaProject, IType potentialSubType, String potentialSuperType) throws JavaModelException {
- return typeIsSubType(javaProject, potentialSubType, javaProject.findType(potentialSuperType));
- }
-
- private static boolean typeIsSubType(IJavaProject javaProject, IType potentialSubType, IType potentialSuperType) throws JavaModelException {
- if ((potentialSubType == null) || (potentialSuperType == null)) {
- return false;
- }
-
- // short cut if types are the same
- if (potentialSubType.equals(potentialSuperType)) {
- return true;
- }
-
- // short cut if potential supertype is java.lang.Object
- if (javaProject.findType(Object.class.getName()).equals(potentialSuperType)) {
- return true;
- }
-
- String potentialSuperTypeName = potentialSuperType.getFullyQualifiedName();
-
- for (String superTypeName : getResolvedSuperTypeNames(potentialSubType)) {
- if (superTypeName.equals(potentialSuperTypeName)) {
- return true;
- }
-
- // recurse into super type
- if (typeIsSubType(javaProject, javaProject.findType(superTypeName), potentialSuperType)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Return the names of the specified type's supertypes (class and interfaces).
- * This is necessary because, for whatever reason, { @link IType#getSuperInterfaceNames()}
- * {@link IType#getSuperclassName()} return unqualified names when the type is from Java source.
- */
- private static Iterable<String> getResolvedSuperTypeNames(IType type) throws JavaModelException {
- Iterable<String> nonResolvedSuperTypeNames = getNonResolvedSuperTypeNames(type);
- if (type.isBinary()) {
- // if type is binary, the types are already resolved
- return nonResolvedSuperTypeNames;
- }
- ArrayList<String> resolvedSuperTypeNames = new ArrayList<String>();
- for (String superTypeName : nonResolvedSuperTypeNames) {
- resolvedSuperTypeNames.add(resolveType(type, superTypeName));
- }
- return resolvedSuperTypeNames;
- }
-
- /**
- * Return the (potentially) non-resolved names of the specified type's supertypes (class and interfaces).
- * This is necessary because, for whatever reason, { @link IType#getSuperInterfaceNames()} and
- * {@link IType#getSuperclassName()} return unqualified names when the type is from Java source.
- */
- private static Iterable<String> getNonResolvedSuperTypeNames(IType type) throws JavaModelException {
- return new CompositeIterable<String>(
- new FilteringIterable<String>(
- new SingleElementIterable<String>(type.getSuperclassName()),
- NotNullFilter.<String>instance()),
- new ArrayIterable<String>(type.getSuperInterfaceNames()));
- }
-
- /**
- * Just grab the first candidate type.
- */
- private static String resolveType(IType type, String className) throws JavaModelException {
- String[][] resolvedClassNames = type.resolveType(className);
- if (resolvedClassNames == null) {
- return null;
- }
- String pkg = resolvedClassNames[0][0];
- String cls = resolvedClassNames[0][1];
- // check for default package
- return (pkg.length() == 0) ? cls : (pkg + '.' + cls);
- }
-
- public static IType findType(IJavaProject javaProject, String fullyQualifiedName) {
- try {
- return javaProject.findType(fullyQualifiedName);
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return null;
- }
- }
-
- public static Iterable<IPackageFragmentRoot> getJavaSourceFolders(IJavaProject javaProject) {
- return new FilteringIterable<IPackageFragmentRoot>(
- getPackageFragmentRoots(javaProject),
- SOURCE_PACKAGE_FRAGMENT_ROOT_FILTER
- );
- }
-
- private static final Filter<IPackageFragmentRoot> SOURCE_PACKAGE_FRAGMENT_ROOT_FILTER =
- new Filter<IPackageFragmentRoot>() {
- public boolean accept(IPackageFragmentRoot pfr) {
- return packageFragmentRootIsSourceFolder(pfr);
- }
- };
-
- private static Iterable<IPackageFragmentRoot> getPackageFragmentRoots(IJavaProject javaProject) {
- try {
- return getPackageFragmentRoots_(javaProject);
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- return EmptyIterable.instance();
- }
- }
-
- private static Iterable<IPackageFragmentRoot> getPackageFragmentRoots_(IJavaProject javaProject) throws JavaModelException {
- return new ArrayIterable<IPackageFragmentRoot>(javaProject.getPackageFragmentRoots());
- }
-
- public static boolean typeIsEnum(IType type) {
- try {
- if (type.isEnum()) {
- return true;
- }
- }
- catch (JavaModelException e) {
- JptCommonCorePlugin.log(e);
- }
- return false;
- }
-
- public static boolean typeIsSerializable(IJavaProject javaProject, IType type) {
- return typeIsSubType(javaProject, type, SERIALIZABLE_CLASS_NAME);
- }
-
- public static final String SERIALIZABLE_CLASS_NAME = java.io.Serializable.class.getName();
-
- public static boolean classHasPublicZeroArgConstructor(IJavaProject javaProject, String className) {
- if (javaProject != null && className != null) {
- IType type = findType(javaProject, className);
- if (type != null) {
- return typeHasPublicZeroArgConstructor(type);
- }
- }
- return false;
- }
-
- public static boolean typeHasPublicZeroArgConstructor(IType type) {
- boolean hasDefinedConstructor = false;
- try {
- for (IMethod method : type.getMethods()) {
- if (method.isConstructor()) {
- if ((method.getNumberOfParameters() == 0) && (Flags.isPublic(method.getFlags()))) {
- return true;
- }
- hasDefinedConstructor = true;
- }
- }
- //When there's no defined constructor, the default constructor is in place.
- if (!hasDefinedConstructor) {
- return true;
- }
- } catch (JavaModelException ex) {
- JptCommonCorePlugin.log(ex);
- }
- return false;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JobSynchronizer.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JobSynchronizer.java
deleted file mode 100644
index 768e8e01e6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JobSynchronizer.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jpt.common.core.utility.command.JobCommand;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.synchronizers.Synchronizer;
-
-/**
- * This synchronizer will perform synchronizations in an Eclipse job on a
- * separate thread, allowing calls to {@link Synchronizer#synchronize()}
- * to return immediately.
- * <p>
- * If necessary, the client-supplied job command should handle any
- * exceptions appropriately. Although, the default exception-handling provided
- * by the Eclipse Job Framework is probably adequate in most cases:<ul>
- * <li>An {@link org.eclipse.core.runtime.OperationCanceledException OperationCanceledException}
- * results in a {@link org.eclipse.core.runtime.Status#CANCEL_STATUS CANCEL_STATUS}.
- * <li>Any non-{@link ThreadDeath} {@link Throwable}
- * results in a {@link org.eclipse.core.runtime.IStatus#ERROR ERROR}
- * {@link org.eclipse.core.runtime.IStatus IStatus}
- * </ul>
- * @see org.eclipse.core.internal.jobs.Worker#run()
- */
-public class JobSynchronizer
- implements Synchronizer
-{
- /**
- * The synchronization is performed by this job. The same job is used
- * for every start/stop cycle (since a job can be re-started).
- */
- private final SynchronizationJob job;
-
-
- // ********** construction **********
-
- /**
- * Construct a job synchronizer that uses the specified job command to
- * perform the synchronization. Assign the generated Eclipse job the
- * specified name.
- */
- public JobSynchronizer(String jobName, JobCommand command) {
- this(jobName, command, null);
- }
-
- /**
- * Construct a job synchronizer that uses the specified job command to
- * perform the synchronization. Assign the generated Eclipse job the
- * specified name and scheduling rule.
- */
- public JobSynchronizer(String jobName, JobCommand command, ISchedulingRule schedulingRule) {
- super();
- this.job = this.buildJob(jobName, command, schedulingRule);
- }
-
- SynchronizationJob buildJob(String jobName, JobCommand command, ISchedulingRule schedulingRule) {
- return new SynchronizationJob(jobName, command, schedulingRule);
- }
-
-
- // ********** Synchronizer implementation **********
-
- /**
- * Allow the job to be scheduled, but postpone the first synchronization
- * until requested, via {@link #synchronize()}.
- */
- public void start() {
- this.job.start();
- }
-
- /**
- * "Schedule" the job.
- */
- public void synchronize() {
- this.job.synchronize();
- }
-
- /**
- * Wait for the current job execution to complete.
- */
- public void stop() {
- this.job.stop();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.job);
- }
-
-
- // ********** synchronization job **********
-
- /**
- * This is the job that gets scheduled by the job synchronizer.
- * When the job is run it executes the client-supplied job command.
- */
- static class SynchronizationJob
- extends Job
- {
- /**
- * The client-supplied job command that executes every time the job
- * runs.
- */
- private final JobCommand command;
-
- /**
- * When this flag is set to false, the job does not stop immediately;
- * but it will not be scheduled to run again.
- */
- // use 'volatile' because synchronization isn't really required
- volatile boolean shouldSchedule;
-
-
- SynchronizationJob(String jobName, JobCommand command, ISchedulingRule schedulingRule) {
- super(jobName);
- if (command == null) {
- throw new NullPointerException();
- }
- this.command = command;
- this.shouldSchedule = false;
- this.setRule(schedulingRule);
- }
-
- /**
- * Just set the "should schedule" flag so the job <em>can</em> be
- * scheduled; but don't actually schedule it.
- */
- void start() {
- if (this.shouldSchedule) {
- throw new IllegalStateException("The Synchronizer was not stopped."); //$NON-NLS-1$
- }
- this.shouldSchedule = true;
- }
-
- /**
- * Simply re-schedule the job, allowing the current execution
- * to run to completion (i.e. do not try to cancel it prematurely).
- * This should minimize the number of times the job is re-executed
- * (recursively and otherwise).
- */
- void synchronize() {
- this.schedule();
- }
-
- /**
- * Any uncaught exceptions thrown by the command will be reasonably
- * handled by the Job Framework.
- * @see org.eclipse.core.internal.jobs.Worker#run()
- */
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- return this.command.execute(monitor);
- }
-
- /**
- * Prevent the job from running again and wait for the current
- * execution, if there is any, to end before returning.
- */
- void stop() {
- if ( ! this.shouldSchedule) {
- throw new IllegalStateException("The Synchronizer was not started."); //$NON-NLS-1$
- }
- // this will prevent the job from being scheduled to run again
- this.shouldSchedule = false;
- // this will cancel the job if it has already been scheduled, but is currently WAITING
- this.cancel();
- try {
- // if the job is currently RUNNING, wait until it is done before returning
- this.join();
- } catch (InterruptedException ex) {
- // the thread that called #stop() was interrupted while waiting to
- // join the synchronization job - ignore;
- // 'shouldSchedule' is still set to 'false', so the job loop will still stop - we
- // just won't wait around for it...
- }
- }
-
- /**
- * This is part of the normal {@link Job} behavior. By default, it is
- * not used (i.e. it always returns <code>true</code>).
- * We implement it here.
- */
- @Override
- public boolean shouldSchedule() {
- return this.shouldSchedule;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PlatformTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PlatformTools.java
deleted file mode 100644
index 462ccd18c3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/PlatformTools.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility;
-
-import java.io.IOException;
-import java.io.InputStream;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeManager;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-
-/**
- * A collection of utilities for dealing with the Eclipse platform API.
- */
-public class PlatformTools {
- /**
- * Add some Generic Goodness to the method signature.
- * @see org.eclipse.core.runtime.IAdapterManager#getAdapter(Object, Class)
- */
- @SuppressWarnings("unchecked")
- public static <A> A getAdapter(Object o, Class<A> adapterType) {
- return (A) Platform.getAdapterManager().getAdapter(o, adapterType);
- }
-
- /**
- * Return the {@link IContainer} with the workspace relative "full" path
- */
- public static IContainer getContainer(IPath fullContainerPath) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- // changed to handle non-workspace projects
- String projectName = fullContainerPath.segment(0).toString();
- IPath projectRelativePath = fullContainerPath.removeFirstSegments(1);
- IProject project = root.getProject(projectName);
- if (projectRelativePath.isEmpty()) {
- return project;
- }
- return project.getFolder(projectRelativePath);
- }
-
- /**
- * Return the {@link IFile} with the workspace relative "full" path
- */
- public static IFile getFile(IPath fullFilePath) {
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- // changed to handle non-workspace projects
- String projectName = fullFilePath.segment(0).toString();
- IPath projectRelativePath = fullFilePath.removeFirstSegments(1);
- IProject project = root.getProject(projectName);
- return project.getFile(projectRelativePath);
- }
-
- /**
- * Return the specified file's content type,
- * using the Eclipse platform's content type manager.
- */
- public static IContentType getContentType(IFile file) {
- String fileName = file.getName();
- InputStream fileContents = null;
- try {
- fileContents = file.getContents();
- } catch (CoreException ex) {
- // seems like we can ignore any exception that might occur here;
- // e.g. we get a FNFE if the workspace is out of sync with the O/S file system
- // JptCorePlugin.log(ex);
-
- // look for content type based on the file name only(?)
- return findContentTypeFor(fileName);
- }
-
- IContentType contentType = null;
- try {
- contentType = findContentTypeFor(fileContents, fileName);
- } catch (IOException ex) {
- JptCommonCorePlugin.log(ex);
- } finally {
- try {
- fileContents.close();
- } catch (IOException ex) {
- JptCommonCorePlugin.log(ex);
- }
- }
- return contentType;
- }
-
- private static IContentType findContentTypeFor(InputStream fileContents, String fileName) throws IOException {
- return getContentTypeManager().findContentTypeFor(fileContents, fileName);
- }
-
- private static IContentType findContentTypeFor(String fileName) {
- return getContentTypeManager().findContentTypeFor(fileName);
- }
-
- private static IContentTypeManager getContentTypeManager() {
- return Platform.getContentTypeManager();
- }
-
- private PlatformTools() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/SimpleSchedulingRule.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/SimpleSchedulingRule.java
deleted file mode 100644
index ca5915ac96..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/SimpleSchedulingRule.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility;
-
-import java.io.Serializable;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A job scheduling rule that conflicts only with itself.
- */
-public final class SimpleSchedulingRule
- implements ISchedulingRule, Serializable
-{
- private static final long serialVersionUID = 1L;
-
- public SimpleSchedulingRule() {
- super();
- }
-
- public boolean contains(ISchedulingRule rule) {
- return rule == this;
- }
-
- public boolean isConflicting(ISchedulingRule rule) {
- return rule == this;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/SimpleTextRange.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/SimpleTextRange.java
deleted file mode 100644
index 2164e3348e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/SimpleTextRange.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility;
-
-import org.eclipse.jpt.common.core.utility.AbstractTextRange;
-
-/**
- * Straightforward implementation of
- * {@link org.eclipse.jpt.common.core.utility.TextRange TextRange}.
- */
-public class SimpleTextRange
- extends AbstractTextRange
-{
- private final int offset;
- private final int length;
- private final int lineNumber;
-
-
- public SimpleTextRange(int offset, int length, int lineNumber) {
- super();
- this.offset = offset;
- this.length = length;
- this.lineNumber = lineNumber;
- }
-
- public int getOffset() {
- return this.offset;
- }
-
- public int getLength() {
- return this.length;
- }
-
- public int getLineNumber() {
- return this.lineNumber;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/WorkspaceRunnableAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/WorkspaceRunnableAdapter.java
deleted file mode 100644
index 2958fe42aa..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/WorkspaceRunnableAdapter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility;
-
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Convenience implementation of {@link IWorkspaceRunnable}.
- */
-public class WorkspaceRunnableAdapter
- implements IWorkspaceRunnable
-{
- public void run(IProgressMonitor monitor) throws CoreException {
- // NOP
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/XPointTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/XPointTools.java
deleted file mode 100644
index 5942fb531f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/XPointTools.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.internal.JptCommonCoreMessages;
-import org.eclipse.osgi.util.NLS;
-import org.osgi.framework.Bundle;
-
-/**
- * Utilities for extension point management, validation, etc.
- */
-public class XPointTools {
-
- public static String findRequiredAttribute(
- IConfigurationElement configElement, String attributeName)
- throws XPointException {
-
- String val = configElement.getAttribute(attributeName);
- if (val == null) {
- logMissingAttribute(configElement, attributeName);
- throw new XPointException();
- }
- return val;
- }
-
- public static <T> T instantiate(String pluginId, String extensionPoint, String className, Class<T> interfaze) {
- Class<T> clazz = loadClass(pluginId, extensionPoint, className, interfaze);
- return (clazz == null) ? null : instantiate(pluginId, extensionPoint, clazz);
- }
-
- /**
- * Instantiate the specified class.
- */
- public static <T> T instantiate(String pluginId, String extensionPoint, Class<T> clazz) {
- try {
- return clazz.newInstance();
- } catch (Exception ex) {
- logFailedInstantiation(ex, pluginId, extensionPoint, clazz.getName());
- return null;
- }
- }
-
- /**
- * Load the specified class and cast it to the specified interface.
- */
- private static <T> Class<T> loadClass(String pluginId, String extensionPoint, String className, Class<T> interfaze) {
- Bundle bundle = Platform.getBundle(pluginId);
-
- Class<?> clazz;
- try {
- clazz = bundle.loadClass(className);
- } catch (Exception ex) {
- logFailedClassLoad(ex, pluginId, extensionPoint, className);
- return null;
- }
-
- if (interfaze.isAssignableFrom(clazz)) {
- @SuppressWarnings("unchecked")
- Class<T> clazzT = (Class<T>) clazz;
- return clazzT;
- }
-
- logFailedInterfaceAssignment(pluginId, extensionPoint, className, interfaze.getName());
- return null;
- }
-
- public static void logDuplicateExtension(String extensionPoint, String nodeName, String value) {
- log(JptCommonCoreMessages.REGISTRY_DUPLICATE, extensionPoint, nodeName, value);
- }
-
- public static void logMissingAttribute(IConfigurationElement configElement, String attributeName) {
- log(JptCommonCoreMessages.REGISTRY_MISSING_ATTRIBUTE,
- attributeName,
- configElement.getName(),
- configElement.getDeclaringExtension().getExtensionPointUniqueIdentifier(),
- configElement.getContributor().getName());
- }
-
- public static void logInvalidValue(
- IConfigurationElement configElement, String nodeName, String invalidValue) {
-
- log(JptCommonCoreMessages.REGISTRY_INVALID_VALUE,
- invalidValue,
- nodeName,
- configElement.getDeclaringExtension().getExtensionPointUniqueIdentifier(),
- configElement.getContributor().getName());
- }
-
- private static void logFailedClassLoad(Exception ex, String pluginId, String extensionPoint, String className) {
- log(ex, JptCommonCoreMessages.REGISTRY_FAILED_CLASS_LOAD,
- className,
- extensionPoint,
- pluginId);
- }
-
- private static void logFailedInterfaceAssignment(
- String pluginId, String extensionPoint, String className, String interfaceName) {
-
- log(JptCommonCoreMessages.REGISTRY_FAILED_INTERFACE_ASSIGNMENT,
- className,
- extensionPoint,
- pluginId,
- interfaceName);
- }
-
- private static void logFailedInstantiation(Exception ex, String pluginId, String extensionPoint, String className) {
- log(ex, JptCommonCoreMessages.REGISTRY_FAILED_INSTANTIATION,
- className,
- extensionPoint,
- pluginId);
- }
-
- public static void log(String msg, String... bindings) {
- JptCommonCorePlugin.log(NLS.bind(msg, bindings));
- }
-
- public static void log(Throwable ex, String msg, String... bindings) {
- JptCommonCorePlugin.log(NLS.bind(msg, bindings), ex);
- }
-
- public static void log(Throwable ex) {
- JptCommonCorePlugin.log(ex);
- }
-
-
- public static final class XPointException extends Exception {
- private static final long serialVersionUID = 1L;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/AbstractSingleUseQueueingJobCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/AbstractSingleUseQueueingJobCommandExecutor.java
deleted file mode 100644
index ef298557aa..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/AbstractSingleUseQueueingJobCommandExecutor.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.command;
-
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jpt.common.core.utility.command.CombinedCommandExecutor;
-import org.eclipse.jpt.common.core.utility.command.JobCommand;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.command.AbstractSingleUseQueueingCommandExecutor;
-
-/**
- * This job command executor wraps and extends an
- * {@link AbstractSingleUseQueueingCommandExecutor},
- * adding support for executing {@link JobCommand}s.
- * <p>
- * <strong>NB:</strong> This executor <em>ignores</em> any
- * {@link ISchedulingRule scheduling rules}.
- */
-public abstract class AbstractSingleUseQueueingJobCommandExecutor<E1 extends AbstractSingleUseQueueingCommandExecutor<E2>, E2 extends StatefulCommandExecutor>
- implements CombinedCommandExecutor, StatefulCommandExecutor
-{
- /**
- * Since the {@link JobCommand}s are simply converted into {@link Command}s,
- * we can delegate to an {@link AbstractSingleUseQueueingCommandExecutor}.
- */
- protected final E1 commandExecutor;
-
-
- protected AbstractSingleUseQueueingJobCommandExecutor(E1 commandExecutor) {
- super();
- this.commandExecutor = commandExecutor;
- }
-
- /**
- * @see AbstractSingleUseQueueingCommandExecutor#start()
- */
- public void start() {
- this.commandExecutor.start();
- }
-
- /**
- * @see AbstractSingleUseQueueingCommandExecutor#execute(Command)
- */
- public void execute(Command command) {
- this.commandExecutor.execute(command);
- }
-
- /**
- * @see AbstractSingleUseQueueingCommandExecutor#execute(Command)
- */
- public void execute(JobCommand command) {
- this.commandExecutor.execute(new JobCommandCommandAdapter(command));
- }
-
- /**
- * @see AbstractSingleUseQueueingCommandExecutor#execute(Command)
- */
- public void execute(JobCommand command, String jobName) {
- // ignore 'jobName'
- this.commandExecutor.execute(new JobCommandCommandAdapter(command));
- }
-
- /**
- * @see AbstractSingleUseQueueingCommandExecutor#execute(Command)
- */
- public void execute(JobCommand command, String jobName, ISchedulingRule rule) {
- // ignore 'jobName' and 'rule'
- this.commandExecutor.execute(new JobCommandCommandAdapter(command));
- }
-
- /**
- * @see AbstractSingleUseQueueingCommandExecutor#suspend()
- */
- public void suspend() {
- this.commandExecutor.suspend();
- }
-
- /**
- * @see AbstractSingleUseQueueingCommandExecutor#resume()
- */
- public void resume() {
- this.commandExecutor.resume();
- }
-
- /**
- * @see AbstractSingleUseQueueingCommandExecutor#stop()
- */
- public void stop() throws InterruptedException {
- this.commandExecutor.stop();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.commandExecutor);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/CommandJobCommandAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/CommandJobCommandAdapter.java
deleted file mode 100644
index 97c52316e3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/CommandJobCommandAdapter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.command;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.common.core.utility.command.JobCommand;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Adapt a {@link Command} to the {@link JobCommand} interface.
- * Necessarily, the progress monitor is ignored and a status of
- * OK is returned.
- */
-public class CommandJobCommandAdapter
- implements JobCommand
-{
- private final Command command;
-
-
- public CommandJobCommandAdapter(Command command) {
- super();
- if (command == null) {
- throw new NullPointerException();
- }
- this.command = command;
- }
-
- public IStatus execute(IProgressMonitor monitor) {
- this.command.execute();
- return Status.OK_STATUS;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.command);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/JobCommandCommandAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/JobCommandCommandAdapter.java
deleted file mode 100644
index ac69a5b03b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/JobCommandCommandAdapter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.command;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jpt.common.core.utility.command.JobCommand;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Adapt a {@link JobCommand} to the {@link Command} interface.
- * Necessarily passing in a <em>null</em> progress monitor
- * and ignoring the returned status.
- */
-public class JobCommandCommandAdapter
- implements Command
-{
- private final JobCommand jobCommand;
-
-
- public JobCommandCommandAdapter(JobCommand jobCommand) {
- super();
- if (jobCommand == null) {
- throw new NullPointerException();
- }
- this.jobCommand = jobCommand;
- }
-
- public void execute() {
- this.jobCommand.execute(new NullProgressMonitor());
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.jobCommand);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/JobCommandJob.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/JobCommandJob.java
deleted file mode 100644
index 70318e1df2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/JobCommandJob.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.command;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jpt.common.core.utility.command.JobCommand;
-import org.eclipse.jpt.common.utility.command.Command;
-
-/**
- * A job that executes a {@link JobCommand job command} or
- * {@link Command command}.
- */
-public class JobCommandJob
- extends Job
-{
- private final JobCommand command;
-
-
- public JobCommandJob(String name, Command command) {
- this(name, new CommandJobCommandAdapter(command));
- }
-
- public JobCommandJob(String name, JobCommand command) {
- super(name);
- if (command == null) {
- throw new NullPointerException();
- }
- this.command = command;
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- return this.command.execute(monitor);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/NotifyingRepeatingJobCommandWrapper.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/NotifyingRepeatingJobCommandWrapper.java
deleted file mode 100644
index 1e49f6b18f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/NotifyingRepeatingJobCommandWrapper.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.command;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jpt.common.core.utility.command.NotifyingRepeatingJobCommand;
-import org.eclipse.jpt.common.core.utility.command.JobCommand;
-import org.eclipse.jpt.common.core.utility.command.JobCommandExecutor;
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-
-/**
- * @see org.eclipse.jpt.common.utility.internal.command.NotifyingRepeatingCommandWrapper
- */
-public class NotifyingRepeatingJobCommandWrapper
- extends RepeatingJobCommandWrapper
- implements NotifyingRepeatingJobCommand
-{
- private final ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
-
-
- // ********** construction **********
-
- /**
- * Construct a notifying repeating command wrapper that executes the
- * specified command. Any exceptions thrown by the command or listener
- * will be handled by the specified exception handler.
- */
- public NotifyingRepeatingJobCommandWrapper(JobCommand command, ExceptionHandler exceptionHandler) {
- super(command, exceptionHandler);
- }
-
- /**
- * Construct a notifying repeating command wrapper that executes the
- * specified command and uses the specified command executor to execute the
- * wrapped command whenever it is not already executing.
- * Any exceptions thrown by the command or listener will be handled by the
- * specified exception handler.
- */
- public NotifyingRepeatingJobCommandWrapper(JobCommand command, JobCommandExecutor startCommandExecutor, ExceptionHandler exceptionHandler) {
- super(command, startCommandExecutor, exceptionHandler);
- }
-
-
- // ********** listeners **********
-
- public void addListener(Listener listener) {
- this.listenerList.add(listener);
- }
-
- public void removeListener(Listener listener) {
- this.listenerList.remove(listener);
- }
-
-
- // ********** override **********
-
- @Override
- /* private protected */ IStatus executeCommand(IProgressMonitor monitor) {
- IStatus status = super.executeCommand(monitor);
- if (this.state.isQuiesced()) {
- // hmmm - we will notify listeners even when we are "stopped"; that seems OK...
- this.executionQuiesced(monitor);
- }
- return status;
- }
-
- /**
- * Notify our listeners.
- */
- private void executionQuiesced(IProgressMonitor monitor) {
- for (Listener listener : this.listenerList.getListeners()) {
- this.notifyListener(listener, monitor);
- }
- }
-
- private void notifyListener(Listener listener, IProgressMonitor monitor) {
- try {
- listener.executionQuiesced(this, monitor);
- } catch (OperationCanceledException ex) {
- throw ex; // seems reasonable...
- } catch (Throwable ex) {
- this.exceptionHandler.handleException(ex);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/RepeatingJobCommandWrapper.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/RepeatingJobCommandWrapper.java
deleted file mode 100644
index ce34a4765c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/RepeatingJobCommandWrapper.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.command;
-
-import java.util.ArrayList;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.utility.command.JobCommand;
-import org.eclipse.jpt.common.core.utility.command.JobCommandExecutor;
-import org.eclipse.jpt.common.core.utility.command.RepeatingJobCommand;
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.internal.StackTrace;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.command.RepeatingCommandState;
-
-/**
- * Wrap a repeating {@link JobCommand}.
- * <p>
- * <strong>NB:</strong> The {@link IProgressMonitor progress monitor} passed to
- * the job command wrapper is <em>ignored</em>. The {@link IProgressMonitor
- * progress monitor} passed to the <em>wrapped</em> job command is determined by
- * the {@link #startCommandExecutor start command executor}. That same
- * {@link IProgressMonitor progress monitor} is passed to the <em>wrapped</em>
- * job command for every execution during an execution "cycle". It is
- * <em>not</em> reset with each execution; so several
- * executions may take place before a new progress monitor is passed to the
- * command.
- * @see org.eclipse.jpt.common.utility.internal.command.RepeatingCommandWrapper
- */
-public class RepeatingJobCommandWrapper
- implements RepeatingJobCommand
-{
- /**
- * The client-supplied command that performs the execution. It may
- * trigger further calls to {@link #execute(IProgressMonitor)}
- * (i.e. the <em>wrapped</em>
- * command's execution may recurse back to the client code that executes the
- * <em>wrapper</em> command).
- */
- /* CU private */ final JobCommand command;
-
- /**
- * The command executed whenever the wrapped {@link #command} must be
- * executed and it is not already executing. If the wrapped {@link #command}
- * is already executing, it will simply be re-executed directly (once it has
- * completed its current execution), as opposed to calling the start
- * command.
- */
- private final JobCommand startCommand;
-
- /**
- * The client-supplied command executor that provides the context for the
- * {@link #startCommand start command}. By default, the start command is
- * executed directly; but this executor provides a hook for executing the
- * {@link #startCommand start command} asynchronously; after which,
- * subsequent overlapping executions are executed synchronously.
- */
- private final JobCommandExecutor startCommandExecutor;
-
- /**
- * This handles the exceptions thrown by the <em>wrapped</em> command.
- */
- final ExceptionHandler exceptionHandler;
-
- /**
- * The command wrapper's state.
- */
- final RepeatingCommandState state;
-
- /**
- * List of stack traces for each (repeating) invocation of the command,
- * starting with the initial invocation. The list is cleared with each
- * initial invocation of the command.
- */
- private final ArrayList<StackTrace> stackTraces = debug() ? new ArrayList<StackTrace>() : null;
-
- private static boolean debug() {
- return JptCommonCorePlugin.instance().isDebugging();
- }
-
-
- // ********** construction **********
-
- /**
- * Construct a repeating command wrapper that executes the specified
- * command. Any exceptions thrown by the command will be handled by the
- * specified exception handler.
- */
- public RepeatingJobCommandWrapper(JobCommand command, ExceptionHandler exceptionHandler) {
- this(command, JobCommandExecutor.Default.instance(), exceptionHandler);
- }
-
- /**
- * Construct a repeating command wrapper that executes the specified
- * command and uses the specified command executor to execute the wrapped
- * command whenever it is not already executing.
- * Any exceptions thrown by the command will be handled by the
- * specified exception handler.
- */
- public RepeatingJobCommandWrapper(JobCommand command, JobCommandExecutor startCommandExecutor, ExceptionHandler exceptionHandler) {
- super();
- if ((command == null) || (startCommandExecutor == null) || (exceptionHandler == null)) {
- throw new NullPointerException();
- }
- this.command = command;
- this.startCommandExecutor = startCommandExecutor;
- this.startCommand = this.buildStartJobCommand();
- this.exceptionHandler = exceptionHandler;
- this.state = this.buildState();
- }
-
- private JobCommand buildStartJobCommand() {
- return new StartJobCommand();
- }
-
- private RepeatingCommandState buildState() {
- return new RepeatingCommandState();
- }
-
-
- // ********** RepeatingJobCommand implementation **********
-
- public void start() {
- this.state.start();
- }
-
- /**
- * It is possible to come back here if the wrapped command recurses
- * to the client and triggers another execution.
- */
- public synchronized IStatus execute(IProgressMonitor monitor) {
- if (this.state.isReadyToStartExecutionCycle()) {
- if (debug()) {
- this.stackTraces.clear();
- this.stackTraces.add(new StackTrace());
- }
- this.executeStartCommand();
- } else {
- if (debug()) {
- this.stackTraces.add(new StackTrace());
- }
- }
- return Status.OK_STATUS;
- }
-
- /* private protected */ void executeStartCommand() {
- this.startCommandExecutor.execute(this.startCommand);
- }
-
- public void stop() throws InterruptedException {
- this.state.stop();
- }
-
- /**
- * The start command.
- * @see #startCommandExecutor
- */
- /* CU private */ class StartJobCommand
- implements JobCommand
- {
- public IStatus execute(IProgressMonitor monitor) {
- return RepeatingJobCommandWrapper.this.execute_(monitor);
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, RepeatingJobCommandWrapper.this.command);
- }
- }
-
- /**
- * This method will be called only once per execution cycle.
- * Any further calls to {@link #execute(IProgressMonitor)} will
- * simply set the {@link #state} to "repeat",
- * causing the command to execute again.
- */
- /* CU private */ IStatus execute_(IProgressMonitor monitor) {
- if (this.state.wasStoppedBeforeFirstExecutionCouldStart()) {
- return Status.OK_STATUS;
- }
-
- do {
- IStatus status = this.executeCommand(monitor);
- if (status.getSeverity() == IStatus.CANCEL) {
- return status; // seems reasonable...
- }
- } while (this.state.isRepeat());
- return Status.OK_STATUS;
- }
-
- /**
- * Execute the client-supplied command. Do not allow any unhandled
- * exceptions to kill the wrapper. Pass to the exception handler.
- * @see NotifyingRepeatingJobCommandWrapper
- */
- /* private protected */ IStatus executeCommand(IProgressMonitor monitor) {
- try {
- return this.command.execute(monitor);
- } catch (OperationCanceledException ex) {
- return Status.CANCEL_STATUS; // seems reasonable...
- } catch (Throwable ex) {
- this.exceptionHandler.handleException(ex);
- return Status.OK_STATUS;
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.command);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SimpleJobCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SimpleJobCommandExecutor.java
deleted file mode 100644
index 96c858b752..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SimpleJobCommandExecutor.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.command;
-
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.JobChangeAdapter;
-import org.eclipse.jpt.common.core.utility.command.CombinedExtendedCommandExecutor;
-import org.eclipse.jpt.common.core.utility.command.JobCommand;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean;
-
-/**
- * A command executor that schedules a {@link org.eclipse.core.runtime.jobs.Job
- * job} to [asynchronously] execute each {@link JobCommand job command} or
- * {@link Command command}.
- * Synchronous command executions are coordinated with the job via a
- * {@link LocalJobChangeListener job listener}.
- */
-public class SimpleJobCommandExecutor
- implements CombinedExtendedCommandExecutor
-{
- private final String defaultJobName;
- private final ISchedulingRule defaultJobSchedulingRule;
-
-
- /**
- * Construct a job command executor with no default job name and no
- * default scheduling rule.
- */
- public SimpleJobCommandExecutor() {
- this(null);
- }
-
- /**
- * Construct a job command executor with the specified default job name and
- * no default scheduling rule.
- */
- public SimpleJobCommandExecutor(String defaultJobName) {
- this(defaultJobName, null);
- }
-
- /**
- * Construct a job command executor with the specified default job name and
- * default scheduling rule.
- */
- public SimpleJobCommandExecutor(String defaultJobName, ISchedulingRule defaultJobSchedulingRule) {
- super();
- this.defaultJobName = defaultJobName;
- this.defaultJobSchedulingRule = defaultJobSchedulingRule;
- }
-
- public void execute(Command command) {
- this.execute(new CommandJobCommandAdapter(command));
- }
-
- public void waitToExecute(Command command) throws InterruptedException {
- this.waitToExecute(new CommandJobCommandAdapter(command));
- }
-
- public boolean waitToExecute(Command command, long timeout) throws InterruptedException {
- return this.waitToExecute(new CommandJobCommandAdapter(command), timeout);
- }
-
- /**
- * Assign the resulting {@link Job} the default name and scheduling rule.
- */
- public void execute(JobCommand command) {
- this.execute(command, null);
- }
-
- /**
- * Assign the resulting {@link Job} the default scheduling rule.
- */
- public void execute(JobCommand command, String jobName) {
- this.execute(command, jobName, this.defaultJobSchedulingRule);
- }
-
- public void execute(JobCommand command, String jobName, ISchedulingRule rule) {
- this.execute_(command, this.buildJobName(jobName, command), rule);
- }
-
- /**
- * Pre-condition: the job name must not be <code>null</code>.
- */
- private void execute_(JobCommand command, String jobName, ISchedulingRule rule) {
- Job job = new JobCommandJob(jobName, command);
- job.setRule(rule);
- job.schedule();
- }
-
- /**
- * Assign the resulting {@link Job} the default name and scheduling rule.
- */
- public void waitToExecute(JobCommand command) throws InterruptedException {
- this.waitToExecute(command, null);
- }
-
- /**
- * Assign the resulting {@link Job} the default name and scheduling rule.
- */
- public boolean waitToExecute(JobCommand command, long timeout) throws InterruptedException {
- return this.waitToExecute(command, null, timeout);
- }
-
- /**
- * Assign the resulting {@link Job} the specified name and the default
- * scheduling rule.
- */
- public void waitToExecute(JobCommand command, String jobName) throws InterruptedException {
- this.waitToExecute(command, jobName, this.defaultJobSchedulingRule);
- }
-
- /**
- * Assign the resulting {@link Job} the specified name and the default
- * scheduling rule.
- */
- public boolean waitToExecute(JobCommand command, String jobName, long timeout) throws InterruptedException {
- return this.waitToExecute(command, jobName, this.defaultJobSchedulingRule, timeout);
- }
-
- /**
- * Assign the resulting {@link Job} the specified name and scheduling rule.
- */
- public void waitToExecute(JobCommand command, String jobName, ISchedulingRule rule) throws InterruptedException {
- this.waitToExecute_(command, this.buildJobName(jobName, command), rule, 0);
- }
-
- /**
- * Assign the resulting {@link Job} the specified name and scheduling rule.
- */
- public boolean waitToExecute(JobCommand command, String jobName, ISchedulingRule rule, long timeout) throws InterruptedException {
- return this.waitToExecute_(command, this.buildJobName(jobName, command), rule, timeout);
- }
-
- /**
- * Pre-condition: the job name must not be <code>null</code>.
- * <p>
- * Schedule a job that will notify us when it is finished.
- * The current thread will suspend until the job is finished.
- */
- private boolean waitToExecute_(JobCommand command, String jobName, ISchedulingRule rule, long timeout) throws InterruptedException {
- if ((timeout == 0L) && Job.getJobManager().isSuspended()) {
- // the job manager is suspended during workbench start-up;
- // so this method will lock up accordingly, which is not a Good Thing
- // if it is called from the Eclipse Main thread during start-up
- // (i.e. deadlock!)
- return false;
- }
-
- Job job = new JobCommandJob(jobName, command);
- LocalJobChangeListener listener = new LocalJobChangeListener();
- job.addJobChangeListener(listener);
- job.setRule(rule);
- job.schedule();
- try {
- return listener.waitUntilDone(timeout);
- } finally {
- job.removeJobChangeListener(listener);
- }
- }
-
- private String buildJobName(String jobName, Object command) {
- if (jobName != null) {
- return jobName;
- }
- if (this.defaultJobName != null) {
- return this.defaultJobName;
- }
- return StringTools.buildToStringClassName(command.getClass());
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-
- // ********** job listener **********
-
- /**
- * This job listener notifies any interested threads when the
- * {@link Job job} is done.
- */
- /* CU private */ class LocalJobChangeListener
- extends JobChangeAdapter
- {
- private final SynchronizedBoolean done = new SynchronizedBoolean(false);
-
- @Override
- public void done(IJobChangeEvent event) {
- super.done(event);
- this.done.setTrue();
- }
-
- boolean waitUntilDone(long timeout) throws InterruptedException {
- return this.done.waitUntilTrue(timeout);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SingleUseQueueingExtendedJobCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SingleUseQueueingExtendedJobCommandExecutor.java
deleted file mode 100644
index 5957e3e4b4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SingleUseQueueingExtendedJobCommandExecutor.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.command;
-
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jpt.common.core.utility.command.CombinedExtendedCommandExecutor;
-import org.eclipse.jpt.common.core.utility.command.JobCommand;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.command.StatefulExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.command.SingleUseQueueingExtendedCommandExecutor;
-
-/**
- * This command executor wraps and extends a {@link SingleUseQueueingExtendedCommandExecutor},
- * adding support for executing {@link JobCommand}s.
- */
-public class SingleUseQueueingExtendedJobCommandExecutor
- extends AbstractSingleUseQueueingJobCommandExecutor<SingleUseQueueingExtendedCommandExecutor, StatefulExtendedCommandExecutor>
- implements CombinedExtendedCommandExecutor, StatefulExtendedCommandExecutor
-{
- public SingleUseQueueingExtendedJobCommandExecutor() {
- this(new SingleUseQueueingExtendedCommandExecutor());
- }
-
- public SingleUseQueueingExtendedJobCommandExecutor(ExtendedCommandExecutor commandExecutor) {
- this(new SingleUseQueueingExtendedCommandExecutor(commandExecutor));
- }
-
- public SingleUseQueueingExtendedJobCommandExecutor(StatefulExtendedCommandExecutor commandExecutor) {
- this(new SingleUseQueueingExtendedCommandExecutor(commandExecutor));
- }
-
- public SingleUseQueueingExtendedJobCommandExecutor(SingleUseQueueingExtendedCommandExecutor commandExecutor) {
- super(commandExecutor);
- }
-
- /**
- * @see SingleUseQueueingExtendedCommandExecutor#waitToExecute(Command)
- */
- public void waitToExecute(Command command) throws InterruptedException {
- this.commandExecutor.waitToExecute(command);
- }
-
- /**
- * @see SingleUseQueueingExtendedCommandExecutor#waitToExecute(Command, long)
- */
- public boolean waitToExecute(Command command, long timeout) throws InterruptedException {
- return this.commandExecutor.waitToExecute(command, timeout);
- }
-
- /**
- * @see SingleUseQueueingExtendedCommandExecutor#waitToExecute(Command)
- */
- public void waitToExecute(JobCommand command) throws InterruptedException {
- this.commandExecutor.waitToExecute(new JobCommandCommandAdapter(command));
- }
-
- /**
- * @see SingleUseQueueingExtendedCommandExecutor#waitToExecute(Command, long)
- */
- public boolean waitToExecute(JobCommand command, long timeout) throws InterruptedException {
- return this.commandExecutor.waitToExecute(new JobCommandCommandAdapter(command), timeout);
- }
-
- /**
- * @see SingleUseQueueingExtendedCommandExecutor#waitToExecute(Command)
- */
- public void waitToExecute(JobCommand command, String jobName) throws InterruptedException {
- // ignore 'jobName'
- this.commandExecutor.waitToExecute(new JobCommandCommandAdapter(command));
- }
-
- /**
- * @see SingleUseQueueingExtendedCommandExecutor#waitToExecute(Command, long)
- */
- public boolean waitToExecute(JobCommand command, String jobName, long timeout) throws InterruptedException {
- // ignore 'jobName'
- return this.commandExecutor.waitToExecute(new JobCommandCommandAdapter(command), timeout);
- }
-
- /**
- * @see SingleUseQueueingExtendedCommandExecutor#waitToExecute(Command)
- */
- public void waitToExecute(JobCommand command, String jobName, ISchedulingRule rule) throws InterruptedException {
- // ignore 'jobName' and 'rule'
- this.commandExecutor.waitToExecute(new JobCommandCommandAdapter(command));
- }
-
- /**
- * @see SingleUseQueueingExtendedCommandExecutor#waitToExecute(Command, long)
- */
- public boolean waitToExecute(JobCommand command, String jobName, ISchedulingRule rule, long timeout) throws InterruptedException {
- // ignore 'jobName' and 'rule'
- return this.commandExecutor.waitToExecute(new JobCommandCommandAdapter(command), timeout);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SingleUseQueueingJobCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SingleUseQueueingJobCommandExecutor.java
deleted file mode 100644
index 3b25de6625..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/command/SingleUseQueueingJobCommandExecutor.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.command;
-
-import org.eclipse.jpt.common.core.utility.command.JobCommand;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.command.SingleUseQueueingCommandExecutor;
-
-/**
- * This command executor wraps and extends a {@link SingleUseQueueingCommandExecutor},
- * adding support for executing {@link JobCommand}s.
- */
-public class SingleUseQueueingJobCommandExecutor
- extends AbstractSingleUseQueueingJobCommandExecutor<SingleUseQueueingCommandExecutor, StatefulCommandExecutor>
-{
- public SingleUseQueueingJobCommandExecutor() {
- this(new SingleUseQueueingCommandExecutor());
- }
-
- public SingleUseQueueingJobCommandExecutor(CommandExecutor commandExecutor) {
- this(new SingleUseQueueingCommandExecutor(commandExecutor));
- }
-
- public SingleUseQueueingJobCommandExecutor(StatefulCommandExecutor commandExecutor) {
- this(new SingleUseQueueingCommandExecutor(commandExecutor));
- }
-
- public SingleUseQueueingJobCommandExecutor(SingleUseQueueingCommandExecutor commandExecutor) {
- super(commandExecutor);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ASTTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ASTTools.java
deleted file mode 100644
index cafdf479a8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ASTTools.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.HashSet;
-import java.util.List;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ASTParser;
-import org.eclipse.jdt.core.dom.ArrayInitializer;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.TypeLiteral;
-import org.eclipse.jpt.common.core.internal.utility.SimpleTextRange;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.JavaType;
-import org.eclipse.jpt.common.utility.MethodSignature;
-import org.eclipse.jpt.common.utility.internal.SimpleJavaType;
-import org.eclipse.jpt.common.utility.internal.SimpleMethodSignature;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-
-/**
- * Convenience methods for dealing with JDT ASTs.
- */
-public class ASTTools {
-
- /**
- * Build an AST without method bodies for the specified compilation unit
- * with its bindings resolved (and the resultant performance hit).
- */
- public static CompilationUnit buildASTRoot(ICompilationUnit compilationUnit) {
- ASTParser parser = ASTParser.newParser(AST.JLS3);
- parser.setSource(compilationUnit);
- parser.setIgnoreMethodBodies(true); // we don't need method bodies
- parser.setResolveBindings(true);
- parser.setBindingsRecovery(true); // see bugs 196200, 222735
- return (CompilationUnit) parser.createAST(null);
- }
-
-
- // ********** JDT DOM **********
-
- public static String resolveEnum(Expression expression) {
- if (expression == null) {
- return null;
- }
- switch (expression.getNodeType()) {
- case ASTNode.QUALIFIED_NAME:
- case ASTNode.SIMPLE_NAME:
- return resolveEnum((Name) expression);
- default:
- return null;
- }
- }
-
- public static String resolveEnum(Name enumExpression) {
- IBinding binding = enumExpression.resolveBinding();
- if (binding == null) {
- return null; // TODO figure out why this is null sometimes
- }
- if (binding.getKind() != IBinding.VARIABLE) {
- return null;
- }
- IVariableBinding variableBinding = (IVariableBinding) binding;
- return variableBinding.getType().getQualifiedName() + '.' + variableBinding.getName();
- }
-
- /**
- * If the specified expression is a type literal, return the type's fully-
- * qualified name. Return null otherwise.
- */
- public static String resolveFullyQualifiedName(Expression expression) {
- ITypeBinding resolvedTypeBinding = resolveTypeBinding(expression);
- return (resolvedTypeBinding == null) ? null : resolvedTypeBinding.getQualifiedName();
- }
-
- /**
- * If the specified expression is an array initializer, return an an iterable
- * on the types' fully qualfified names.
- * The results may include nulls.
- */
- public static Iterable<String> resolveFullyQualifiedNames(Expression expression) {
- return new TransformationIterable<ITypeBinding, String>(resolveTypeBindings(expression)) {
- @Override
- protected String transform(ITypeBinding o) {
- return (o == null) ? null : o.getQualifiedName();
- }
- };
- }
-
- /**
- * If the specified expression is a type literal, return the corresponding
- * type binding.
- */
- public static ITypeBinding resolveTypeBinding(Expression expression) {
- if (expression != null && expression.getNodeType() == ASTNode.TYPE_LITERAL) {
- return ((TypeLiteral) expression).getType().resolveBinding();
- }
- return null;
- }
-
- /**
- * If the specified expression is an array initializer, return an iterable of
- * the corresponding type bindings for each sub-expression.
- * The result may include <code>null</code> elements.
- */
- public static Iterable<ITypeBinding> resolveTypeBindings(Expression expression) {
- return (expression != null && expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) ?
- resolveTypeBindings((ArrayInitializer) expression) :
- EmptyIterable.<ITypeBinding>instance();
- }
-
- private static Iterable<ITypeBinding> resolveTypeBindings(ArrayInitializer arrayExpression) {
- @SuppressWarnings("unchecked")
- Iterable<Expression> expressions = arrayExpression.expressions();
- return new TransformationIterable<Expression, ITypeBinding>(expressions) {
- @Override
- protected ITypeBinding transform(Expression expression) {
- return resolveTypeBinding(expression);
- }
- };
- }
-
- public static MethodSignature buildMethodSignature(MethodDeclaration methodDeclaration) {
- return new SimpleMethodSignature(
- methodDeclaration.getName().getFullyQualifiedName(),
- buildParameterTypes(methodDeclaration)
- );
- }
-
- public static JavaType[] buildParameterTypes(MethodDeclaration methodDeclaration) {
- List<SingleVariableDeclaration> parameters = parameters(methodDeclaration);
- int len = parameters.size();
- JavaType[] parameterTypes = new JavaType[len];
- for (int i = 0; i < len; i++) {
- ITypeBinding type = parameters.get(i).getType().resolveBinding();
- parameterTypes[i] = SimpleJavaType.buildSimpleJavaType(type.getQualifiedName(), type.getDimensions());
- }
- return parameterTypes;
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private static List<SingleVariableDeclaration> parameters(MethodDeclaration methodDeclaration) {
- return methodDeclaration.parameters();
- }
-
- /**
- * Return whether the specified expression is a type literal and the type binding
- * corresponding to the specified type name exists in the type
- * literal's inheritance hierarchy (superclasses and interfaces).
- * Return null otherwise.
- */
- public static boolean typeIsSubTypeOf(Expression expression, String searchTypeName) {
- return findTypeInHierarchy(expression, searchTypeName) != null;
- }
-
- /**
- * If the specified expression is a type literal, return the type binding
- * corresponding to the specified type name if it exists in the type
- * literal's inheritance hierarchy (superclasses and interfaces).
- * Return null otherwise.
- */
- public static ITypeBinding findTypeInHierarchy(Expression expression, String searchTypeName) {
- ITypeBinding typeBinding = resolveTypeBinding(expression);
- return (typeBinding == null) ? null : findTypeInHierarchy(typeBinding, searchTypeName);
- }
-
- /**
- * Return whether a type binding with the specified type name exists in
- * the specified type binding's inheritance hierarchy (superclasses
- * and interfaces).
- */
- public static boolean typeIsSubTypeOf(ITypeBinding typeBinding, String searchTypeName) {
- return findTypeInHierarchy(typeBinding, searchTypeName) != null;
- }
-
- /**
- * Return the type binding corresponding to the specified type name if it
- * exists in the specified type binding's inheritance hierarchy (superclasses
- * and interfaces). Return null otherwise.
- */
- public static ITypeBinding findTypeInHierarchy(ITypeBinding typeBinding, String searchTypeName) {
- return findTypeInHierarchy(typeBinding, searchTypeName, new HashSet<String>());
- }
-
- private static ITypeBinding findTypeInHierarchy(ITypeBinding typeBinding, String searchTypeName, HashSet<String> visited) {
- String typeName = typeBinding.getTypeDeclaration().getQualifiedName();
- if (visited.contains(typeName)) {
- return null;
- }
- if (typeName.equals(searchTypeName)) {
- return typeBinding;
- }
- visited.add(typeName);
-
- ITypeBinding interfaceBinding = findTypeInInterfaces(typeBinding, searchTypeName, visited);
- if (interfaceBinding != null) {
- return interfaceBinding;
- }
-
- return findTypeInSuperclasses(typeBinding, searchTypeName, visited);
- }
-
- private static ITypeBinding findTypeInInterfaces(ITypeBinding typeBinding, String searchTypeName, HashSet<String> visited) {
- ITypeBinding[] interfaceBindings = typeBinding.getInterfaces();
- for (ITypeBinding interfaceBinding : interfaceBindings) { // recurse up interfaces
- ITypeBinding result = findTypeInHierarchy(interfaceBinding, searchTypeName, visited);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
- private static ITypeBinding findTypeInSuperclasses(ITypeBinding typeBinding, String searchTypeName, HashSet<String> visited) {
- ITypeBinding superBinding = typeBinding.getSuperclass();
- if (superBinding != null) { // recurse up superclasses
- ITypeBinding result = findTypeInHierarchy(superBinding, searchTypeName, visited);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
- /**
- * Return whether the specified expression is a type literal and the type binding
- * corresponding to the specified interface name exists in the type
- * literal's inheritance hierarchy (superclasses and interfaces).
- * Return null otherwise.
- */
- public static boolean typeImplementsInterface(Expression expression, String searchInterfaceName) {
- ITypeBinding typeBinding = resolveTypeBinding(expression);
- if (typeBinding == null) {
- return false;
- }
- return findInterfaceInHierarchy(typeBinding, searchInterfaceName) != null;
- }
-
- /**
- * Return whether a type binding with the specified interface name exists in
- * the specified type binding's inheritance hierarchy (superclasses
- * and interfaces).
- */
- public static boolean typeImplementsInterface(ITypeBinding typeBinding, String searchInterfaceName) {
- return findInterfaceInHierarchy(typeBinding, searchInterfaceName) != null;
- }
-
- private static ITypeBinding findInterfaceInHierarchy(ITypeBinding typeBinding, String searchInterfaceName) {
- HashSet<String> visited = new HashSet<String>();
- ITypeBinding interfaceBinding = findTypeInInterfaces(typeBinding, searchInterfaceName, visited);
- if (interfaceBinding != null) {
- return interfaceBinding;
- }
-
- return findTypeInSuperclasses(typeBinding, searchInterfaceName, visited);
-
- }
-
- /**
- * Build and return a text range for the specified AST node.
- */
- public static TextRange buildTextRange(ASTNode astNode) {
- return buildTextRange(astNode, null);
- }
-
- /**
- * Build and return a text range for the specified AST node if it differs
- * from the specified text range or the specified text range is
- * <code>null</code>. If the AST node already matches the
- * specified text range, simply return the text range unchanged.
- */
- public static TextRange buildTextRange(ASTNode astNode, TextRange textRange) {
- int offset = astNode.getStartPosition();
- int length = astNode.getLength();
- int lineNumber = ((CompilationUnit) astNode.getRoot()).getLineNumber(offset);
- return (textRange == null) ?
- new SimpleTextRange(offset, length, lineNumber) :
- textRange.buildTextRange(offset, length, lineNumber);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractAnnotationAdapter.java
deleted file mode 100644
index 7333322d48..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractAnnotationAdapter.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Adapt an annotated element and a declaration annotation adapter.
- */
-public abstract class AbstractAnnotationAdapter implements AnnotationAdapter {
- private final AnnotatedElement annotatedElement;
- private final DeclarationAnnotationAdapter daa;
-
-
- // ********** constructor **********
-
- public AbstractAnnotationAdapter(AnnotatedElement annotatedElement, DeclarationAnnotationAdapter daa) {
- super();
- this.annotatedElement = annotatedElement;
- this.daa = daa;
- }
-
-
- // ********** AnnotationAdapter implementation **********
-
- public Annotation getAnnotation(CompilationUnit astRoot) {
- return this.daa.getAnnotation(this.annotatedElement.getModifiedDeclaration(astRoot));
- }
-
- public void newMarkerAnnotation() {
- this.edit(this.buildNewMarkerAnnotationEditor());
- }
-
- public void newSingleMemberAnnotation() {
- this.edit(this.buildNewSingleMemberAnnotationEditor());
- }
-
- public void newNormalAnnotation() {
- this.edit(this.buildNewNormalAnnotationEditor());
- }
-
- public void removeAnnotation() {
- this.edit(this.buildRemoveAnnotationEditor());
- }
-
- public ASTNode getAstNode(CompilationUnit astRoot) {
- return this.daa.getAstNode(this.annotatedElement.getModifiedDeclaration(astRoot));
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.daa);
- }
-
-
- // ********** internal methods **********
-
- protected void edit(AnnotatedElement.Editor editor) {
- this.annotatedElement.edit(editor);
- }
-
-
- // ********** factory methods **********
-
- protected AnnotatedElement.Editor buildNewMarkerAnnotationEditor() {
- return new NewMarkerAnnotationEditor(this.daa);
- }
-
- protected AnnotatedElement.Editor buildNewSingleMemberAnnotationEditor() {
- return new NewSingleMemberAnnotationEditor(this.daa);
- }
-
- protected AnnotatedElement.Editor buildNewNormalAnnotationEditor() {
- return new NewNormalAnnotationEditor(this.daa);
- }
-
- protected AnnotatedElement.Editor buildRemoveAnnotationEditor() {
- return new RemoveAnnotationEditor(this.daa);
- }
-
-
- // ********** member classes **********
-
- protected static class NewMarkerAnnotationEditor implements AnnotatedElement.Editor {
- private final DeclarationAnnotationAdapter daa;
-
- NewMarkerAnnotationEditor(DeclarationAnnotationAdapter daa) {
- super();
- this.daa = daa;
- }
- public void edit(ModifiedDeclaration declaration) {
- this.daa.newMarkerAnnotation(declaration);
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
-
-
- protected static class NewSingleMemberAnnotationEditor implements AnnotatedElement.Editor {
- private final DeclarationAnnotationAdapter daa;
-
- NewSingleMemberAnnotationEditor(DeclarationAnnotationAdapter daa) {
- super();
- this.daa = daa;
- }
- public void edit(ModifiedDeclaration declaration) {
- this.daa.newSingleMemberAnnotation(declaration);
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
-
-
- protected static class NewNormalAnnotationEditor implements AnnotatedElement.Editor {
- private final DeclarationAnnotationAdapter daa;
-
- NewNormalAnnotationEditor(DeclarationAnnotationAdapter daa) {
- super();
- this.daa = daa;
- }
- public void edit(ModifiedDeclaration declaration) {
- this.daa.newNormalAnnotation(declaration);
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
-
-
- protected static class RemoveAnnotationEditor implements AnnotatedElement.Editor {
- private final DeclarationAnnotationAdapter daa;
-
- RemoveAnnotationEditor(DeclarationAnnotationAdapter daa) {
- super();
- this.daa = daa;
- }
- public void edit(ModifiedDeclaration declaration) {
- this.daa.removeAnnotation(declaration);
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractDeclarationAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractDeclarationAnnotationAdapter.java
deleted file mode 100644
index 821c4ed618..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractDeclarationAnnotationAdapter.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.List;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- *
- */
-public abstract class AbstractDeclarationAnnotationAdapter implements DeclarationAnnotationAdapter {
- private final String annotationName;
-
-
- // ********** constructors **********
-
- protected AbstractDeclarationAnnotationAdapter(String annotationName) {
- super();
- this.annotationName = annotationName;
- }
-
-
- // ********** DeclarationAnnotationAdapter implementation **********
-
- public MarkerAnnotation newMarkerAnnotation(ModifiedDeclaration declaration) {
- MarkerAnnotation annotation = this.newMarkerAnnotation(declaration.getAst());
- this.addAnnotationAndImport(declaration, annotation);
- return annotation;
- }
-
- public SingleMemberAnnotation newSingleMemberAnnotation(ModifiedDeclaration declaration) {
- SingleMemberAnnotation annotation = this.newSingleMemberAnnotation(declaration.getAst());
- this.addAnnotationAndImport(declaration, annotation);
- return annotation;
- }
-
- public NormalAnnotation newNormalAnnotation(ModifiedDeclaration declaration) {
- NormalAnnotation annotation = this.newNormalAnnotation(declaration.getAst());
- this.addAnnotationAndImport(declaration, annotation);
- return annotation;
- }
-
- /**
- * Add the appropriate import statement, then shorten the annotation's
- * name before adding it to the declaration.
- */
- protected void addAnnotationAndImport(ModifiedDeclaration declaration, Annotation annotation) {
- annotation.setTypeName(declaration.getAst().newName(this.getSourceCodeAnnotationName(declaration)));
- this.addAnnotation(declaration, annotation);
- }
-
- /**
- * Return the annotation's name as it can be used in source code;
- * i.e. if we can add it to the compilation unit's imports, return the short
- * name; if we can't (because of a collision), return the fully-qualified name.
- * NB: an import may be added as a side-effect :-(
- */
- protected String getSourceCodeAnnotationName(ModifiedDeclaration declaration) {
- return declaration.addImport(this.annotationName) ? this.getShortAnnotationName() : this.annotationName;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.annotationName);
- }
-
- /**
- * Add the specified annotation to the specified declaration,
- * replacing the original annotation if present.
- */
- protected abstract void addAnnotation(ModifiedDeclaration declaration, Annotation annotation);
-
-
- // ********** public methods **********
-
- /**
- * This is 'public' because we use it in CombinationIndexedDeclarationAnnotationAdapter
- * to get the annotation name from a NestedIndexedDeclarationAnnotationAdapter.
- */
- public String getAnnotationName() {
- return this.annotationName;
- }
-
-
- // ********** helper methods **********
-
- protected boolean nameMatches(ModifiedDeclaration declaration, Annotation annotation) {
- return this.nameMatches(declaration, annotation, this.annotationName);
- }
-
- protected boolean nameMatches(ModifiedDeclaration declaration, Annotation annotation, String name) {
- return declaration.annotationIsNamed(annotation, name);
- }
-
- protected MarkerAnnotation newMarkerAnnotation(AST ast) {
- return this.newMarkerAnnotation(ast, this.annotationName);
- }
-
- protected MarkerAnnotation newMarkerAnnotation(AST ast, String name) {
- MarkerAnnotation annotation = ast.newMarkerAnnotation();
- annotation.setTypeName(ast.newName(name));
- return annotation;
- }
-
- protected SingleMemberAnnotation newSingleMemberAnnotation(AST ast) {
- return this.newSingleMemberAnnotation(ast, this.annotationName);
- }
-
- protected SingleMemberAnnotation newSingleMemberAnnotation(AST ast, String name) {
- SingleMemberAnnotation annotation = ast.newSingleMemberAnnotation();
- annotation.setTypeName(ast.newName(name));
- return annotation;
- }
-
- protected NormalAnnotation newNormalAnnotation(AST ast) {
- return this.newNormalAnnotation(ast, this.annotationName);
- }
-
- protected NormalAnnotation newNormalAnnotation(AST ast, String name) {
- NormalAnnotation annotation = ast.newNormalAnnotation();
- annotation.setTypeName(ast.newName(name));
- return annotation;
- }
-
- protected String getShortAnnotationName() {
- return convertToShortName(this.annotationName);
- }
-
- protected static String convertToShortName(String name) {
- return name.substring(name.lastIndexOf('.') + 1);
- }
-
- @SuppressWarnings("unchecked")
- protected List<MemberValuePair> values(NormalAnnotation na) {
- return na.values();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractExpressionConverter.java
deleted file mode 100644
index 6fd4d1d99a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractExpressionConverter.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Gather together the common implementation behavior.
- *
- * We're still figuring out Java Generics here.... The methods in this abstract
- * class work fine with any subclass of Expression E; but a ClassCastException
- * will occur as soon as we call any method implemented by a subclass
- * (e.g. StringExpressionConverter) that expects a particular subclass of
- * Expression (e.g. StringLiteral).
- *
- * @param <T> the type of the object to be converted to and from an expression
- */
-public abstract class AbstractExpressionConverter<T>
- implements ExpressionConverter<T>
-{
- protected AbstractExpressionConverter() {
- super();
- }
-
-
- // ********** object -> expression **********
-
- public Expression convert(T object, AST ast) {
- return (object == null) ? this.convertNull(ast) : this.convertObject(object, ast);
- }
-
- /**
- * Return the expression for a <code>null</code> object.
- * By default, a <code>null</code> object will
- * be converted into a <code>null</code> expression.
- */
- protected Expression convertNull(@SuppressWarnings("unused") AST ast) {
- return null;
- }
-
- /**
- * The specified object is not <code>null</code>.
- * @see #convert(Object, AST)
- */
- protected abstract Expression convertObject(T object, AST ast);
-
-
- // ********** expression -> object **********
-
- public T convert(Expression expression) {
- return (expression == null) ? this.convertNull() : this.convertExpression(expression);
- }
-
- /**
- * Return the object for a <code>null</code> expression.
- * By default, a <code>null</code> expression will
- * be converted into a <code>null</code> object.
- */
- protected T convertNull() {
- return null;
- }
-
- /**
- * The specified expression is not <code>null</code>.
- * @see #convert(Expression)
- */
- protected abstract T convertExpression(Expression expression);
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractJDTType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractJDTType.java
deleted file mode 100644
index 9a264f76d2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractJDTType.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.core.utility.jdt.AbstractType;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.core.utility.jdt.Type;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-
-/**
- * Adapt and extend a JDT abstract type.
- */
-public abstract class AbstractJDTType
- extends JDTMember
- implements AbstractType
-{
-
- /**
- * constructor for the compilation unit's primary type
- */
- protected AbstractJDTType(
- AbstractTypeDeclaration typeDeclaration,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- this(typeDeclaration, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- /**
- * constructor for the compilation unit's primary type
- */
- protected AbstractJDTType(
- AbstractTypeDeclaration typeDeclaration,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- this(null, typeDeclaration, 1, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- }
-
- /**
- * constructor for nested types
- */
- protected AbstractJDTType(
- Type declaringType,
- AbstractTypeDeclaration typeDeclaration,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- this(declaringType, typeDeclaration, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- /**
- * constructor for nested types
- */
- protected AbstractJDTType(
- Type declaringType,
- AbstractTypeDeclaration typeDeclaration,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- super(declaringType, typeDeclaration.getName().getFullyQualifiedName(), occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- }
-
- /**
- * constructor for testing
- */
- protected AbstractJDTType(Type declaringType, String name, int occurrence, ICompilationUnit compilationUnit) {
- super(declaringType, name, occurrence, compilationUnit, CommandExecutor.Default.instance(), DefaultAnnotationEditFormatter.instance());
- }
-
- @Override
- protected Type getDeclaringType() {
- return (Type) super.getDeclaringType();
- }
-
- // ********** Member/Type implementation **********
-
- public ITypeBinding getBinding(CompilationUnit astRoot) {
- AbstractTypeDeclaration td = this.getBodyDeclaration(astRoot);
- return (td == null) ? null : td.resolveBinding();
- }
-
- /**
- * find the type's body declaration in the specified AST
- */
- @Override
- public AbstractTypeDeclaration getBodyDeclaration(CompilationUnit astRoot) {
- Type declaringType = this.getDeclaringType();
- if (declaringType == null) {
- return this.getTopLevelTypeDeclaration(astRoot);
- }
- TypeDeclaration typeDeclaration = declaringType.getBodyDeclaration(astRoot);
- // the type declaration can be null when the source is completely hosed
- return (typeDeclaration == null) ? null : this.getNestedTypeDeclaration(typeDeclaration);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- AbstractTypeDeclaration bodyDeclaration = this.getBodyDeclaration(astRoot);
- // the declaration can be null if the resource is out of sync with the file system
- return (bodyDeclaration) == null ? null : ASTTools.buildTextRange(bodyDeclaration.getName());
- }
-
-
- // ********** internal **********
-
- /**
- * return the first top-level type in the specified AST with a matching name
- */
- protected AbstractTypeDeclaration getTopLevelTypeDeclaration(CompilationUnit astRoot) {
- return this.getTypeDeclaration(types(astRoot));
- }
-
- protected AbstractTypeDeclaration getTypeDeclaration(List<AbstractTypeDeclaration> typeDeclarations) {
- return this.getTypeDeclaration(typeDeclarations.toArray(new AbstractTypeDeclaration[typeDeclarations.size()]));
- }
-
- /**
- * Return the nested type declaration with matching name and occurrence within the declaring type
- */
- protected abstract AbstractTypeDeclaration getNestedTypeDeclaration(TypeDeclaration declaringTypeDeclaration);
-
- /**
- * return the type declaration corresponding to the type from the specified
- * set of type declarations (match name and occurrence).
- * Only return type or enum declarations
- */
- protected AbstractTypeDeclaration getTypeDeclaration(AbstractTypeDeclaration[] typeDeclarations) {
- String name = this.getName();
- int occurrence = this.getOccurrence();
- int count = 0;
- for (AbstractTypeDeclaration typeDeclaration : typeDeclarations) {
- if (typeDeclaration.getName().getFullyQualifiedName().equals(name)) {
- count++;
- if (count == occurrence) {
- return (typeDeclaration.getNodeType() == this.getASTNodeType()) ? typeDeclaration : null;
- }
- }
- }
- // return null if the type is no longer in the source code;
- // this can happen when the context model has not yet
- // been synchronized with the resource model but is still
- // asking for an ASTNode (e.g. during a selection event)
- return null;
- }
-
- protected abstract int getASTNodeType();
-
- /**
- * we only instantiate a single top-level, non-annotation
- * type per compilation unit (i.e. a class, enum, or interface)
- */
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected static List<AbstractTypeDeclaration> types(CompilationUnit astRoot) {
- return astRoot.types();
- }
-
- protected static EnumDeclaration[] getEnums(TypeDeclaration declaringTypeDeclaration) {
- List<BodyDeclaration> bd = bodyDeclarations(declaringTypeDeclaration);
- int typeCount = 0;
- for (Iterator<BodyDeclaration> it = bd.listIterator(); it.hasNext(); ) {
- if (it.next().getNodeType() == ASTNode.ENUM_DECLARATION) {
- typeCount++;
- }
- }
- EnumDeclaration[] memberEnums = new EnumDeclaration[typeCount];
- int next = 0;
- for (Iterator<BodyDeclaration> it = bd.listIterator(); it.hasNext(); ) {
- BodyDeclaration decl = it.next();
- if (decl.getNodeType() == ASTNode.ENUM_DECLARATION) {
- memberEnums[next++] = (EnumDeclaration) decl;
- }
- }
- return memberEnums;
- }
-
- @SuppressWarnings("unchecked")
- protected static List<BodyDeclaration> bodyDeclarations(TypeDeclaration typeDeclaration) {
- return typeDeclaration.bodyDeclarations();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractNestedDeclarationAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractNestedDeclarationAnnotationAdapter.java
deleted file mode 100644
index 1e12f713b0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AbstractNestedDeclarationAnnotationAdapter.java
+++ /dev/null
@@ -1,403 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-
-/**
- * Pull together some of the behavior common to
- * {@link NestedDeclarationAnnotationAdapter}
- * and {@link NestedIndexedDeclarationAnnotationAdapter}
- */
-public abstract class AbstractNestedDeclarationAnnotationAdapter
- extends AbstractDeclarationAnnotationAdapter
-{
- private final DeclarationAnnotationAdapter outerAnnotationAdapter;
- private final String elementName;
-
- // reduce NLS checks
- protected static final String VALUE = "value"; //$NON-NLS-1$
-
-
- // ********** constructors **********
-
- /**
- * The default element name is <code>value</code>.
- */
- protected AbstractNestedDeclarationAnnotationAdapter(DeclarationAnnotationAdapter outerAnnotationAdapter, String annotationName) {
- this(outerAnnotationAdapter, VALUE, annotationName);
- }
-
- protected AbstractNestedDeclarationAnnotationAdapter(DeclarationAnnotationAdapter outerAnnotationAdapter, String elementName, String annotationName) {
- super(annotationName);
- this.outerAnnotationAdapter = outerAnnotationAdapter;
- this.elementName = elementName;
- }
-
-
- // ********** DeclarationAnnotationAdapter implementation **********
-
- public Annotation getAnnotation(ModifiedDeclaration declaration) {
- Annotation outer = this.outerAnnotationAdapter.getAnnotation(declaration);
- if (outer == null) {
- return null;
- }
- Expression value = this.elementValue(outer);
- if (value == null) {
- return null;
- }
- Annotation inner = this.getAnnotation(value);
- if (inner == null) {
- return null;
- }
- // return the annotation only if it has a matching name(?)
- return this.nameMatches(declaration, inner) ? inner : null;
- }
-
- public void removeAnnotation(ModifiedDeclaration declaration) {
- Annotation outer = this.outerAnnotationAdapter.getAnnotation(declaration);
- if (outer == null) {
- return;
- }
- Expression value = this.elementValue(outer);
- if (value == null) {
- return;
- }
- // hack to allow short-circuit when the value is an array initializer
- if (this.removeAnnotation(declaration, outer, value)) {
- return;
- }
- Annotation inner = this.annotationValue(value);
- if (inner == null) {
- return;
- }
- // remove the annotation only if it has a matching name(?)
- if (this.nameMatches(declaration, inner)) {
- this.removeElementAndNormalize(declaration, outer);
- }
- }
-
- public ASTNode getAstNode(ModifiedDeclaration declaration) {
- // if the annotation is missing, return the outer annotation's node
- Annotation annotation = this.getAnnotation(declaration);
- return (annotation != null) ? annotation : this.outerAnnotationAdapter.getAstNode(declaration);
- }
-
- @Override
- protected void addAnnotation(ModifiedDeclaration declaration, Annotation inner) {
- Annotation outer = this.outerAnnotationAdapter.getAnnotation(declaration);
- if (outer == null) {
- this.buildNewOuterAnnotation(declaration, inner);
- } else if (outer.isMarkerAnnotation()) {
- this.modifyAnnotation(declaration, (MarkerAnnotation) outer, inner);
- } else if (outer.isSingleMemberAnnotation()) {
- this.modifyAnnotation(declaration, (SingleMemberAnnotation) outer, inner);
- } else if (outer.isNormalAnnotation()) {
- this.modifyAnnotation(declaration, (NormalAnnotation) outer, inner);
- } else {
- throw new IllegalStateException("unknown annotation type: " + outer); //$NON-NLS-1$
- }
- }
-
-
- // ********** abstract methods **********
-
- /**
- * Return an annotation extracted from the specified expression,
- * which is the value of the adapter's element.
- */
- protected abstract Annotation getAnnotation(Expression value);
-
- /**
- * Remove the annotation from the specified expression,
- * which is the value of the adapter's element.
- * Return whether the removal was successful.
- */
- protected abstract boolean removeAnnotation(ModifiedDeclaration declaration, Annotation outer, Expression value);
-
- /**
- * Set the value of the specified outer annotation to the
- * specified inner annotation.
- */
- protected abstract void modifyAnnotationValue(SingleMemberAnnotation outer, Annotation inner);
-
- /**
- * Set the value of the specified member value pair to the
- * specified inner annotation.
- */
- protected abstract void modifyMemberValuePair(MemberValuePair pair, Annotation inner);
-
-
- // ********** public methods **********
-
- public DeclarationAnnotationAdapter getOuterAnnotationAdapter() {
- return this.outerAnnotationAdapter;
- }
-
- public String getElementName() {
- return this.elementName;
- }
-
-
- // ********** internal methods **********
-
- /**
- * If the specified expression is an annotation, cast it to an annotation;
- * otherwise return null.
- */
- protected Annotation annotationValue(Expression expression) {
- switch (expression.getNodeType()) {
- case ASTNode.NORMAL_ANNOTATION:
- case ASTNode.SINGLE_MEMBER_ANNOTATION:
- case ASTNode.MARKER_ANNOTATION:
- return (Annotation) expression;
- default:
- return null;
- }
- }
-
- /**
- * Remove the <em>first</em> annotation element with the specified name
- * from the specified annotation, converting the annotation as appropriate.
- */
- protected void removeElementAndNormalize(ModifiedDeclaration declaration, Annotation outer) {
- if (outer.isNormalAnnotation()) {
- this.removeElementAndNormalize(declaration, (NormalAnnotation) outer);
- } else if (outer.isSingleMemberAnnotation()) {
- this.removeElementAndNormalize(declaration, (SingleMemberAnnotation) outer);
- } else if (outer.isMarkerAnnotation()) {
- this.removeElementAndNormalize(declaration, (MarkerAnnotation) outer);
- } else {
- throw new IllegalArgumentException("unknown annotation type: " + outer); //$NON-NLS-1$
- }
- }
-
- /**
- * Remove the <em>first</em> annotation element with the adapter's element
- * name from the specified annotation. Convert the annotation to
- * a marker annotation or single member annotation if appropriate.
- * <pre>
- * &#64;Outer(name="Fred", foo=&#64;Inner) => &#64;Outer(name="Fred")
- * &#64;Outer(foo=&#64;Inner) => &#64;Outer
- * </pre>
- */
- protected void removeElementAndNormalize(ModifiedDeclaration declaration, NormalAnnotation outer) {
- this.removeElement(outer);
- this.normalizeAnnotation(declaration, outer);
- }
-
- /**
- * Remove from the specified annotation the element with
- * the adapter's element name.
- */
- protected void removeElement(NormalAnnotation annotation) {
- for (Iterator<MemberValuePair> stream = this.values(annotation).iterator(); stream.hasNext(); ) {
- MemberValuePair pair = stream.next();
- if (pair.getName().getFullyQualifiedName().equals(this.elementName)) {
- stream.remove();
- break;
- }
- }
- }
-
- /**
- * Convert the specified normal annotation to a marker annotation or
- * single member annotation if appropriate.
- */
- protected void normalizeAnnotation(ModifiedDeclaration declaration, NormalAnnotation outer) {
- List<MemberValuePair> values = this.values(outer);
- switch (values.size()) {
- case 0:
- // if the elements are all gone, convert the annotation to a marker annotation
- this.outerAnnotationAdapter.newMarkerAnnotation(declaration);
- break;
- case 1:
- MemberValuePair pair = values.get(0);
- if (pair.getName().getFullyQualifiedName().equals(VALUE)) {
- // if the last remaining element is 'value', convert the annotation to a single member annotation
- Expression vv = pair.getValue();
- vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv);
- this.outerAnnotationAdapter.newSingleMemberAnnotation(declaration).setValue(vv);
- }
- break;
- default:
- // do nothing
- break;
- }
- }
-
- /**
- * Convert the specified single member annotation to a marker annotation
- * if the adapter's element name is <code>value</code>.
- */
- protected void removeElementAndNormalize(ModifiedDeclaration declaration, @SuppressWarnings("unused") SingleMemberAnnotation outer) {
- if (this.elementName.equals(VALUE)) {
- this.outerAnnotationAdapter.newMarkerAnnotation(declaration);
- }
- }
-
- protected void removeElementAndNormalize(@SuppressWarnings("unused") ModifiedDeclaration declaration, @SuppressWarnings("unused") MarkerAnnotation outer) {
- // NOP
- }
-
- /**
- * Return the value of the *first* annotation element
- * with the adapter's element name.
- * Return null if the annotation has no such element.
- * (An element name of "value" will return the value of a single
- * member annotation.)
- */
- protected Expression elementValue(Annotation annotation) {
- if (annotation.isNormalAnnotation()) {
- return this.elementValue((NormalAnnotation) annotation);
- }
- if (annotation.isSingleMemberAnnotation()) {
- return this.elementValue((SingleMemberAnnotation) annotation);
- }
- return null;
- }
-
- protected Expression elementValue(NormalAnnotation annotation) {
- MemberValuePair pair = this.memberValuePair(annotation);
- return (pair == null) ? null : pair.getValue();
- }
-
- /**
- * If the adapter's element name is "value", return the value of the
- * annotation, otherwise return null.
- */
- protected Expression elementValue(SingleMemberAnnotation annotation) {
- return this.elementName.equals(VALUE) ? annotation.getValue() : null;
- }
-
- /**
- * Return the *first* member value pair for the adapter's element name.
- * Return null if the specified annotation has no such element.
- */
- protected MemberValuePair memberValuePair(NormalAnnotation annotation) {
- for (MemberValuePair pair : this.values(annotation)) {
- if (pair.getName().getFullyQualifiedName().equals(this.elementName)) {
- return pair;
- }
- }
- return null;
- }
-
- /**
- * Build a new outer annotation and add the specified
- * inner annotation to it:
- * <pre>
- * &#64;Outer(&#64;Inner)
- * </pre>
- * or
- * <pre>
- * &#64;Outer(foo=&#64;Inner)
- * </pre>
- */
- protected void buildNewOuterAnnotation(ModifiedDeclaration declaration, Annotation inner) {
- if (this.elementName.equals(VALUE)) {
- this.outerAnnotationAdapter.newSingleMemberAnnotation(declaration).setValue(this.buildNewInnerExpression(inner));
- } else {
- List<MemberValuePair> values = this.values(this.outerAnnotationAdapter.newNormalAnnotation(declaration));
- values.add(this.newMemberValuePair(this.buildNewInnerExpression(inner)));
- }
- }
-
- /**
- * Build an expression to be added to a new outer annotation
- * for the specified inner annotation.
- */
- protected abstract Expression buildNewInnerExpression(Annotation inner);
-
- /**
- * Build a new member value pair with the specified name and value.
- */
- protected MemberValuePair newMemberValuePair(String name, Expression value) {
- AST ast = value.getAST();
- MemberValuePair pair = ast.newMemberValuePair();
- pair.setName(ast.newSimpleName(name));
- pair.setValue(value);
- return pair;
- }
-
- /**
- * Build a new member value pair with the adapter's element name
- * and the specified inner annotation.
- */
- protected MemberValuePair newMemberValuePair(Expression value) {
- return this.newMemberValuePair(this.elementName, value);
- }
-
- /**
- * Add the specified inner annotation to the marker annotation.
- */
- protected void modifyAnnotation(ModifiedDeclaration declaration, @SuppressWarnings("unused") MarkerAnnotation outer, Annotation inner) {
- this.buildNewOuterAnnotation(declaration, inner);
- }
-
- /**
- * Add the specified inner annotation to the single member annotation.
- */
- protected void modifyAnnotation(ModifiedDeclaration declaration, SingleMemberAnnotation outer, Annotation inner) {
- if (this.elementName.equals(VALUE)) {
- this.modifyAnnotationValue(outer, inner);
- } else {
- this.modifyAnnotationNonValue(declaration, outer, inner);
- }
- }
-
- /**
- * Add the specified inner annotation to the single member annotation,
- * converting it to a normal annotation:
- * <pre>
- * &#64;Outer("lorem ipsum") => &#64;Outer(value="lorem ipsum", foo=&#64;Inner)
- * </pre>
- */
- protected void modifyAnnotationNonValue(ModifiedDeclaration declaration, SingleMemberAnnotation outer, Annotation inner) {
- Expression vv = outer.getValue();
- vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv);
- NormalAnnotation newOuter = this.outerAnnotationAdapter.newNormalAnnotation(declaration);
- List<MemberValuePair> values = this.values(newOuter);
- values.add(this.newMemberValuePair(VALUE, vv));
- values.add(this.newMemberValuePair(this.buildNewInnerExpression(inner)));
- }
-
- /**
- * Add the specified inner annotation to the normal annotation:
- * <pre>
- * &#64;Outer(bar="lorem ipsum") => &#64;Outer(bar="lorem ipsum", foo=&#64;Inner)
- * </pre>
- * or
- * <pre>
- * &#64;Outer(foo=&#64;Inner("lorem ipsum")) => &#64;Outer(foo=&#64;Inner)
- * </pre>
- */
- protected void modifyAnnotation(@SuppressWarnings("unused") ModifiedDeclaration declaration, NormalAnnotation outer, Annotation inner) {
- MemberValuePair pair = this.memberValuePair(outer);
- if (pair == null) {
- List<MemberValuePair> values = this.values(outer);
- values.add(this.newMemberValuePair(inner));
- } else {
- this.modifyMemberValuePair(pair, inner);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AnnotatedElementAnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AnnotatedElementAnnotationElementAdapter.java
deleted file mode 100644
index 4419a56f0c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AnnotatedElementAnnotationElementAdapter.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
- /**
- * Adapt an annotated element and a declaration annotation element adapter.
- */
-public class AnnotatedElementAnnotationElementAdapter<T>
- implements AnnotationElementAdapter<T>
-{
- private final AnnotatedElement annotatedElement;
- private final DeclarationAnnotationElementAdapter<T> daea;
-
-
- // ********** constructor **********
-
- public AnnotatedElementAnnotationElementAdapter(AnnotatedElement annotatedElement, DeclarationAnnotationElementAdapter<T> daea) {
- super();
- this.annotatedElement = annotatedElement;
- this.daea = daea;
- }
-
-
- // ********** AnnotationElementAdapter implementation **********
-
- public T getValue() {
- return this.daea.getValue(this.annotatedElement.getModifiedDeclaration());
- }
-
- public T getValue(CompilationUnit astRoot) {
- return this.daea.getValue(this.annotatedElement.getModifiedDeclaration(astRoot));
- }
-
- public void setValue(T value) {
- this.edit(this.buildSetValueEditor(value));
- }
-
- public Expression getExpression(CompilationUnit astRoot) {
- return this.daea.getExpression(this.annotatedElement.getModifiedDeclaration(astRoot));
- }
-
- public ASTNode getAstNode(CompilationUnit astRoot) {
- return this.daea.getAstNode(this.annotatedElement.getModifiedDeclaration(astRoot));
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.daea);
- }
-
-
- // ********** internal methods **********
-
- protected void edit(AnnotatedElement.Editor editor) {
- this.annotatedElement.edit(editor);
- }
-
- protected AnnotatedElement.Editor buildSetValueEditor(T value) {
- return new SetValueEditor<T>(value, this.daea);
- }
-
-
- // ********** member classes **********
-
- protected static class SetValueEditor<T> implements AnnotatedElement.Editor {
- private final DeclarationAnnotationElementAdapter<T> daea;
- private final T value;
-
- SetValueEditor(T value, DeclarationAnnotationElementAdapter<T> daea) {
- super();
- this.value = value;
- this.daea = daea;
- }
- public void edit(ModifiedDeclaration declaration) {
- this.daea.setValue(this.value, declaration);
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AnnotationStringArrayExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AnnotationStringArrayExpressionConverter.java
deleted file mode 100644
index 337a054865..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/AnnotationStringArrayExpressionConverter.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ArrayInitializer;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedExpressionConverter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Convert an array initializer or single expression to/from an array of
- * strings (e.g. {"text0", "text1"}).
- * E is the type of the expressions to be found either stand-alone or
- * as elements in the array initializer.
- */
-public class AnnotationStringArrayExpressionConverter
- extends AbstractExpressionConverter<String[]>
- implements IndexedExpressionConverter<String>
-{
- private final ExpressionConverter<String> elementConverter;
- private final StringArrayExpressionConverter arrayConverter;
-
-
- /**
- * The default behavior is to remove the array initializer if it is empty.
- */
- public AnnotationStringArrayExpressionConverter(ExpressionConverter<String> elementConverter) {
- this(elementConverter, true);
- }
-
- public AnnotationStringArrayExpressionConverter(ExpressionConverter<String> elementConverter, boolean removeArrayInitializerWhenEmpty) {
- super();
- this.elementConverter = elementConverter;
- this.arrayConverter = new StringArrayExpressionConverter(elementConverter, removeArrayInitializerWhenEmpty);
- }
-
- /**
- * if we only have a single string in the array return the single expression,
- * without braces, instead of an array initializer
- */
- @Override
- protected Expression convertObject(String[] strings, AST ast) {
- return (strings.length == 1) ?
- this.elementConverter.convert(strings[0], ast) :
- this.arrayConverter.convertObject(strings, ast);
- }
-
- @Override
- protected String[] convertNull() {
- return this.arrayConverter.convertNull();
- }
-
- /**
- * check for a single expression with no surrounding braces, implying a
- * single-entry array
- */
- @Override
- protected String[] convertExpression(Expression expression) {
- return (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) ?
- this.convertArrayInitializer((ArrayInitializer) expression) :
- this.convertNonArrayInitializer(expression);
- }
-
- protected String[] convertArrayInitializer(ArrayInitializer arrayInitializer) {
- return this.arrayConverter.convertArrayInitializer(arrayInitializer);
- }
-
- /**
- * The specified expression is <em>not</em> an array initializer.
- * If we have trouble converting the standalone expression, simply return an
- * empty array (as opposed to an array with a <code>null</code> element).
- */
- protected String[] convertNonArrayInitializer(Expression expression) {
- String element = this.elementConverter.convert(expression);
- return (element == null) ? StringTools.EMPTY_STRING_ARRAY : new String[] { element };
- }
-
- public Expression selectExpression(Expression expression, int index) {
- if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
- return this.arrayConverter.selectExpression(expression, index);
- }
- if (index == 0) {
- return expression;
- }
- throw new ArrayIndexOutOfBoundsException();
- }
-
-
- // ********** factory methods **********
-
- /**
- * Build an expression converter for an annotation element of type String[].
- * @Foo(bar={"text0", "text1"})
- * or
- * @Foo(bar="text0")
- */
- public static AnnotationStringArrayExpressionConverter forStrings() {
- return new AnnotationStringArrayExpressionConverter(StringExpressionConverter.instance());
- }
-
- /**
- * Build an expression converter for an annotation element of type <enum>[].
- * @Foo(bar={BAZ, BAT})
- * or
- * @Foo(bar=BAZ)
- */
- public static AnnotationStringArrayExpressionConverter forNames() {
- return new AnnotationStringArrayExpressionConverter(NameStringExpressionConverter.instance());
- }
-
-
- /**
- * Build an expression converter for an annotation element of type Class[].
- * @Foo(bar={Baz.class, Bat.class})
- * or
- * @Foo(bar=Baz.class)
- */
- public static AnnotationStringArrayExpressionConverter forTypes() {
- return new AnnotationStringArrayExpressionConverter(TypeStringExpressionConverter.instance());
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/BooleanExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/BooleanExpressionConverter.java
deleted file mode 100644
index f33a719986..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/BooleanExpressionConverter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.BooleanLiteral;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-
-/**
- * Convert a boolean literal to/from a Boolean
- * (e.g. Boolean.TRUE).
- */
-public final class BooleanExpressionConverter
- extends AbstractExpressionConverter<Boolean>
-{
- private static final ExpressionConverter<Boolean> INSTANCE = new BooleanExpressionConverter();
-
- /**
- * Return the singleton.
- */
- public static ExpressionConverter<Boolean> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private BooleanExpressionConverter() {
- super();
- }
-
- @Override
- protected BooleanLiteral convertObject(Boolean booleanObject, AST ast) {
- return ast.newBooleanLiteral(booleanObject.booleanValue());
- }
-
- @Override
- protected Boolean convertExpression(Expression expression) {
- Object value = expression.resolveConstantExpressionValue();
- return (value instanceof Boolean) ? ((Boolean) value) : null;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/CharacterStringExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/CharacterStringExpressionConverter.java
deleted file mode 100644
index cfb470581b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/CharacterStringExpressionConverter.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.CharacterLiteral;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-
-/**
- * Convert a character literal to/from a string representation of a character
- * (e.g. "A").
- */
-public final class CharacterStringExpressionConverter
- extends AbstractExpressionConverter<String>
-{
- private static final ExpressionConverter<String> INSTANCE = new CharacterStringExpressionConverter();
-
- /**
- * Return the singleton.
- */
- public static ExpressionConverter<String> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private CharacterStringExpressionConverter() {
- super();
- }
-
- @Override
- protected CharacterLiteral convertObject(String string, AST ast) {
- CharacterLiteral characterLiteral = ast.newCharacterLiteral();
- characterLiteral.setCharValue(string.charAt(0));
- return characterLiteral;
- }
-
- @Override
- protected String convertExpression(Expression expression) {
- Object value = expression.resolveConstantExpressionValue();
- return (value instanceof Character) ? ((Character) value).toString() : null;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapter.java
deleted file mode 100644
index dde05b2a59..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapter.java
+++ /dev/null
@@ -1,500 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.List;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Manipulate an annotation that either occurs stand-alone, e.g.
- * <pre>
- * &#64;Inner("zero")
- * private int id;
- * </pre>
- *
- * or is embedded in an element array within another annotation, e.g.
- * <pre>
- * &#64;Outer(foo={&#64;Inner("zero"), &#64;Inner("one"), &#64;Inner("two")})
- * private int id;
- *
- * annotationName = "Inner"
- * containerAnnotationName = "Outer"
- * elementName = "foo"
- * index = 0-2
- * </pre>
- *
- * This is a useful pattern because a declaration cannot have more
- * than one annotation of the same type, and allowing the stand-alone
- * configuration reduces clutter.
- * <br>
- * NB: This configuration only makes sense for "top-level" annotations, as
- * opposed to "nested" annotations. This is because annotation elements
- * can only be declared with a type of a single annotation and annotations
- * cannot be part of an inheritance hierarchy.
- * For example, the following configurations cannot *both* be supported:
- * <pre>
- * &#64;Foo(bar=&#64;Outer(...))
- * private int id;
- *
- * &#64;Foo(bar=&#64;Inner(...)) // not allowed
- * private int id;
- * </pre>
- *
- * NB: Behavior is undefined when both the stand-alone and the nested
- * configurations annotate the same declaration, e.g.
- * <pre>
- * // undefined behavior
- * &#64;Inner("zero")
- * &#64;Outer(foo={&#64;Inner("zero"), &#64;Inner("one"), &#64;Inner("two")})
- * private int id;
- * </pre>
- */
-public class CombinationIndexedDeclarationAnnotationAdapter
- implements IndexedDeclarationAnnotationAdapter
-{
-
- /**
- * this adapter is used when the annotation is "stand-alone":
- * <pre>
- * &#64;Inner("zero")
- * </pre>
- * and is only used when the index is 0 or 1
- */
- private final DeclarationAnnotationAdapter standAloneAnnotationAdapter;
-
- /**
- * this adapter is used when the annotation is "nested":
- * <pre>
- * &#64;Outer(foo={&#64;Inner("zero"), &#64;Inner("one")})
- * </pre>
- */
- private final NestedIndexedDeclarationAnnotationAdapter nestedAnnotationAdapter;
-
- /**
- * this adapter is for the "nested" annotation at the zero index;
- * and is only used when the index is 1
- */
- private final NestedIndexedDeclarationAnnotationAdapter zeroNestedAnnotationAdapter;
-
- // reduce NLS checks
- protected static final String VALUE = "value"; //$NON-NLS-1$
-
-
- // ********** constructors **********
-
- /**
- * default element name is "value"
- * <pre>
- * &#64;Inner("zero")
- * &#64;Outer({&#64;Inner("zero"), &#64;Inner("one")})
- * </pre>
- */
- public CombinationIndexedDeclarationAnnotationAdapter(String annotationName, String containerAnnotationName, int index) {
- this(annotationName, containerAnnotationName, VALUE, index);
- }
-
- public CombinationIndexedDeclarationAnnotationAdapter(String annotationName, String containerAnnotationName, String elementName, int index) {
- this(new SimpleDeclarationAnnotationAdapter(annotationName), new SimpleDeclarationAnnotationAdapter(containerAnnotationName), elementName, index, annotationName);
- }
-
- /**
- * default element name is "value"
- */
- public CombinationIndexedDeclarationAnnotationAdapter(
- DeclarationAnnotationAdapter standAloneAnnotationAdapter,
- DeclarationAnnotationAdapter containerAnnotationAdapter,
- int index,
- String nestedAnnotationName
- ) {
- this(standAloneAnnotationAdapter, containerAnnotationAdapter, VALUE, index, nestedAnnotationName);
- }
-
- public CombinationIndexedDeclarationAnnotationAdapter(
- DeclarationAnnotationAdapter standAloneAnnotationAdapter,
- DeclarationAnnotationAdapter containerAnnotationAdapter,
- String elementName,
- int index,
- String nestedAnnotationName
- ) {
- super();
- this.standAloneAnnotationAdapter = standAloneAnnotationAdapter;
- this.nestedAnnotationAdapter = new NestedIndexedDeclarationAnnotationAdapter(containerAnnotationAdapter, elementName, index, nestedAnnotationName);
- this.zeroNestedAnnotationAdapter = new NestedIndexedDeclarationAnnotationAdapter(containerAnnotationAdapter, elementName, 0, nestedAnnotationName);
- }
-
-
- // ********** DeclarationAnnotationAdapter implementation **********
-
- public Annotation getAnnotation(ModifiedDeclaration declaration) {
- if (this.getIndex() == 0) {
- // check for the stand-alone annotation
- Annotation standAloneAnnotation = this.getStandAloneAnnotation(declaration);
- if (standAloneAnnotation != null) {
- return standAloneAnnotation;
- }
- }
- return this.getNestedAnnotation(declaration);
- }
-
- /**
- * <pre>
- * [none] => &#64;Inner
- * or
- * &#64;Inner("lorem ipsum") => &#64;Inner
- * or
- * &#64;Inner(text="lorem ipsum") => &#64;Inner
- * or
- * &#64;Outer(foo={&#64;Inner, &#64;Inner}) => &#64;Outer(foo={&#64;Inner, &#64;Inner, &#64;Inner})
- * or
- * &#64;Outer(foo=&#64;Inner) => &#64;Outer(foo={&#64;Inner, &#64;Inner})
- * or
- * &#64;Inner => &#64;Outer(foo={&#64;Inner, &#64;Inner})
- * etc.
- * </pre>
- */
- public MarkerAnnotation newMarkerAnnotation(ModifiedDeclaration declaration) {
- return (MarkerAnnotation) this.newAnnotation(MARKER_ANNOTATION_FACTORY, declaration);
- }
-
- public SingleMemberAnnotation newSingleMemberAnnotation(ModifiedDeclaration declaration) {
- return (SingleMemberAnnotation) this.newAnnotation(SINGLE_MEMBER_ANNOTATION_FACTORY, declaration);
- }
-
- public NormalAnnotation newNormalAnnotation(ModifiedDeclaration declaration) {
- return (NormalAnnotation) this.newAnnotation(NORMAL_ANNOTATION_FACTORY, declaration);
- }
-
- public void removeAnnotation(ModifiedDeclaration declaration) {
- if (this.getIndex() == 0) {
- // check for the stand-alone annotation
- if (this.standAloneAnnotationIsPresent(declaration)) {
- this.removeStandAloneAnnotation(declaration);
- return;
- }
- }
- this.removeNestedAnnotation(declaration);
- if (this.nestedElementCanBeConvertedToStandAlone(declaration)) {
- this.convertLastElementAnnotationToStandAloneAnnotation(declaration);
- }
- }
-
- public ASTNode getAstNode(ModifiedDeclaration declaration) {
- // if the annotation is missing, delegate to the nested annotation adapter
- Annotation annotation = this.getAnnotation(declaration);
- return (annotation != null) ? annotation : this.nestedAnnotationAdapter.getAstNode(declaration);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.getAnnotationName());
- }
-
-
- // ********** IndexedDeclarationAnnotationAdapter implementation **********
-
- public int getIndex() {
- return this.nestedAnnotationAdapter.getIndex();
- }
-
- public void moveAnnotation(int newIndex, ModifiedDeclaration declaration) {
- int oldIndex = this.getIndex();
- if (newIndex == oldIndex) {
- return;
- }
-
- Annotation standAloneAnnotation = this.getStandAloneAnnotation(declaration);
- if (standAloneAnnotation == null) {
- this.moveNestedAnnotation(newIndex, declaration);
- if (this.nestedElementCanBeConvertedToStandAlone(declaration)) {
- this.convertLastElementAnnotationToStandAloneAnnotation(declaration);
- }
- } else {
- if ((oldIndex == 0) && (newIndex == 1)) {
- // this is one of two situations where we transition from stand-alone to container
- this.moveStandAloneAnnotationToContainerAnnotation(standAloneAnnotation, declaration);
- this.moveNestedAnnotation(newIndex, declaration);
- } else if (newIndex == 0) {
- // we are moving a 'null' entry on top of the stand-alone, so remove it
- this.removeStandAloneAnnotation(declaration);
- } else {
- throw new IllegalStateException("old index = " + oldIndex + "; new index = " + newIndex); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
-
- // ********** internal methods **********
-
- /**
- * build the appropriate new annotation,
- * which may require moving the 0th annotation from "stand-alone" to "nested"
- */
- private Annotation newAnnotation(AnnotationFactory annotationFactory, ModifiedDeclaration declaration) {
- if (this.getIndex() == 0) {
- return this.newZeroAnnotation(annotationFactory, declaration);
- }
- if (this.zeroNestedAnnotationIsPresent(declaration)) {
- // manipulate the container annotation - ignore the stand-alone annotation(?)
- // @Outer(foo=@Inner("zero")) => @Outer(foo={@Inner("zero"), @Inner})
- // or
- // @Outer(foo={@Inner("zero"), @Inner("one")}) => @Outer(foo={@Inner("zero"), @Inner})
- return annotationFactory.newAnnotation(this.nestedAnnotationAdapter, declaration);
- }
-
- // this is one of two situations where we transition from stand-alone to container
- this.moveStandAloneAnnotationToContainerAnnotation(declaration);
- // once the stand-alone annotation is moved to index=0, build the new annotation at index=1
- return annotationFactory.newAnnotation(this.nestedAnnotationAdapter, declaration);
- }
-
- /**
- * the index is 0 - build the appropriate new annotation,
- * which may be either "stand-alone" or "nested"
- */
- private Annotation newZeroAnnotation(AnnotationFactory annotationFactory, ModifiedDeclaration declaration) {
- if (this.standAloneAnnotationIsPresent(declaration)) {
- // replace the stand-alone annotation - ignore the container annotation(?)
- // @Inner(text="lorem ipsum") => @Inner
- return annotationFactory.newAnnotation(this.standAloneAnnotationAdapter, declaration);
- }
- if (this.containerAnnotationIsPresent(declaration)) {
- // manipulate the container annotation
- // @Outer(foo=@Inner(text="lorem ipsum")) => @Outer(foo=@Inner)
- return annotationFactory.newAnnotation(this.nestedAnnotationAdapter, declaration);
- }
- // neither annotation is present - add a new stand-alone annotation
- return annotationFactory.newAnnotation(this.standAloneAnnotationAdapter, declaration);
- }
-
- /**
- * move the stand-alone annotation to the container annotation at index=0
- */
- private void moveStandAloneAnnotationToContainerAnnotation(ModifiedDeclaration declaration) {
- Annotation standAloneAnnotation = this.getStandAloneAnnotation(declaration);
- if (standAloneAnnotation == null) {
- throw new IllegalStateException("the stand-alone annotation is missing"); //$NON-NLS-1$
- }
- this.moveStandAloneAnnotationToContainerAnnotation(standAloneAnnotation, declaration);
- }
-
- /**
- * move the specified, non-null, stand-alone annotation to
- * the container annotation at index=0
- */
- private void moveStandAloneAnnotationToContainerAnnotation(Annotation standAloneAnnotation, ModifiedDeclaration declaration) {
- if (standAloneAnnotation.isMarkerAnnotation()) {
- this.zeroNestedAnnotationAdapter.newMarkerAnnotation(declaration);
- } else if (standAloneAnnotation.isSingleMemberAnnotation()) {
- Expression vv = ((SingleMemberAnnotation) standAloneAnnotation).getValue();
- vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv);
- this.zeroNestedAnnotationAdapter.newSingleMemberAnnotation(declaration).setValue(vv);
- } else if (standAloneAnnotation.isNormalAnnotation()) {
- NormalAnnotation newNA = this.zeroNestedAnnotationAdapter.newNormalAnnotation(declaration);
- List<MemberValuePair> values = this.values(newNA);
- for (MemberValuePair pair : this.values((NormalAnnotation) standAloneAnnotation)) {
- values.add((MemberValuePair) ASTNode.copySubtree(pair.getAST(), pair));
- }
- } else {
- throw new IllegalStateException("unknown annotation type: " + standAloneAnnotation); //$NON-NLS-1$
- }
- this.removeStandAloneAnnotation(declaration);
- }
-
- /**
- * return whether the "nested" annotation container has been reduced to
- * a single element (and the array initializer is converted to just
- * the single remaining element) and can be further converted to the
- * "stand-alone" annotation:
- * <pre>
- * &#64;Outer(foo={&#64;Inner("zero"), &#64;Inner("one")}) =>
- * &#64;Outer(foo=&#64;Inner("zero")) =>
- * &#64;Inner("zero")
- * </pre>
- */
- private boolean nestedElementCanBeConvertedToStandAlone(ModifiedDeclaration declaration) {
- Annotation containerAnnotation = this.getContainerAnnotation(declaration);
- if (containerAnnotation == null) {
- return false;
- }
- if (containerAnnotation.isMarkerAnnotation()) {
- return false;
- }
- if (containerAnnotation.isSingleMemberAnnotation()) {
- if (this.getElementName().equals(VALUE)) {
- return (((SingleMemberAnnotation) containerAnnotation).getValue().getNodeType() != ASTNode.ARRAY_INITIALIZER)
- && (this.zeroNestedAnnotationAdapter.getAnnotation(declaration) != null);
- }
- return false;
- }
- if (containerAnnotation.isNormalAnnotation()) {
- NormalAnnotation na = (NormalAnnotation) containerAnnotation;
- if (na.values().size() == 0) {
- return false; // there are no elements present
- }
- if (na.values().size() != 1) {
- return false; // there are other elements present - leave them all alone
- }
- MemberValuePair pair = (MemberValuePair) na.values().get(0);
- if (this.getElementName().equals(pair.getName().getFullyQualifiedName())) {
- return (pair.getValue().getNodeType() != ASTNode.ARRAY_INITIALIZER)
- && (this.zeroNestedAnnotationAdapter.getAnnotation(declaration) != null);
- }
- return false;
- }
- throw new IllegalStateException("unknown annotation type: " + containerAnnotation); //$NON-NLS-1$
- }
-
- /**
- * move the annotation in the container annotation at index=0
- * to the stand-alone annotation
- */
- private void convertLastElementAnnotationToStandAloneAnnotation(ModifiedDeclaration declaration) {
- Annotation last = this.zeroNestedAnnotationAdapter.getAnnotation(declaration);
- if (last == null) {
- throw new IllegalStateException("the last nested annotation is missing"); //$NON-NLS-1$
- } else if (last.isMarkerAnnotation()) {
- this.newStandAloneMarkerAnnotation(declaration);
- } else if (last.isSingleMemberAnnotation()) {
- Expression vv = ((SingleMemberAnnotation) last).getValue();
- vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv);
- this.newStandAloneSingleMemberAnnotation(declaration).setValue(vv);
- } else if (last.isNormalAnnotation()) {
- NormalAnnotation newNA = this.newStandAloneNormalAnnotation(declaration);
- List<MemberValuePair> values = this.values(newNA);
- for (MemberValuePair pair : this.values((NormalAnnotation) last)) {
- values.add((MemberValuePair) ASTNode.copySubtree(pair.getAST(), pair));
- }
- } else {
- throw new IllegalStateException("unknown annotation type: " + last); //$NON-NLS-1$
- }
- this.removeContainerAnnotation(declaration);
- }
-
- private boolean standAloneAnnotationIsPresent(ModifiedDeclaration declaration) {
- return this.getStandAloneAnnotation(declaration) != null;
- }
-
- private Annotation getStandAloneAnnotation(ModifiedDeclaration declaration) {
- return this.standAloneAnnotationAdapter.getAnnotation(declaration);
- }
-
- private MarkerAnnotation newStandAloneMarkerAnnotation(ModifiedDeclaration declaration) {
- return this.standAloneAnnotationAdapter.newMarkerAnnotation(declaration);
- }
-
- private SingleMemberAnnotation newStandAloneSingleMemberAnnotation(ModifiedDeclaration declaration) {
- return this.standAloneAnnotationAdapter.newSingleMemberAnnotation(declaration);
- }
-
- private NormalAnnotation newStandAloneNormalAnnotation(ModifiedDeclaration declaration) {
- return this.standAloneAnnotationAdapter.newNormalAnnotation(declaration);
- }
-
- private void removeStandAloneAnnotation(ModifiedDeclaration declaration) {
- this.standAloneAnnotationAdapter.removeAnnotation(declaration);
- }
-
- private Annotation getNestedAnnotation(ModifiedDeclaration declaration) {
- return this.nestedAnnotationAdapter.getAnnotation(declaration);
- }
-
- private void moveNestedAnnotation(int newIndex, ModifiedDeclaration declaration) {
- this.nestedAnnotationAdapter.moveAnnotation(newIndex, declaration);
- }
-
- private void removeNestedAnnotation(ModifiedDeclaration declaration) {
- this.nestedAnnotationAdapter.removeAnnotation(declaration);
- }
-
- private boolean containerAnnotationIsPresent(ModifiedDeclaration declaration) {
- return this.getContainerAnnotation(declaration) != null;
- }
-
- private Annotation getContainerAnnotation(ModifiedDeclaration declaration) {
- return this.nestedAnnotationAdapter.getOuterAnnotationAdapter().getAnnotation(declaration);
- }
-
- private void removeContainerAnnotation(ModifiedDeclaration declaration) {
- this.nestedAnnotationAdapter.getOuterAnnotationAdapter().removeAnnotation(declaration);
- }
-
- private boolean zeroNestedAnnotationIsPresent(ModifiedDeclaration declaration) {
- return this.getZeroNestedAnnotation(declaration) != null;
- }
-
- private Annotation getZeroNestedAnnotation(ModifiedDeclaration declaration) {
- return this.zeroNestedAnnotationAdapter.getAnnotation(declaration);
- }
-
- private String getAnnotationName() {
- return this.nestedAnnotationAdapter.getAnnotationName();
- }
-
- private String getElementName() {
- return this.nestedAnnotationAdapter.getElementName();
- }
-
- @SuppressWarnings("unchecked")
- protected List<MemberValuePair> values(NormalAnnotation na) {
- return na.values();
- }
-
-
- // ********** annotation factories **********
-
- /**
- * define interface that allows us to "re-use" the nasty code in
- * #newAnnotation(AnnotationFactory, ModifiedDeclaration)
- */
- private interface AnnotationFactory {
- Annotation newAnnotation(DeclarationAnnotationAdapter adapter, ModifiedDeclaration declaration);
- }
-
- private static final AnnotationFactory MARKER_ANNOTATION_FACTORY = new AnnotationFactory() {
- public Annotation newAnnotation(DeclarationAnnotationAdapter adapter, ModifiedDeclaration declaration) {
- return adapter.newMarkerAnnotation(declaration);
- }
- @Override
- public String toString() {
- return "MarkerAnnotationFactory"; //$NON-NLS-1$
- }
- };
-
- private static final AnnotationFactory SINGLE_MEMBER_ANNOTATION_FACTORY = new AnnotationFactory() {
- public Annotation newAnnotation(DeclarationAnnotationAdapter adapter, ModifiedDeclaration declaration) {
- return adapter.newSingleMemberAnnotation(declaration);
- }
- @Override
- public String toString() {
- return "SingleMemberAnnotationFactory"; //$NON-NLS-1$
- }
- };
-
- private static final AnnotationFactory NORMAL_ANNOTATION_FACTORY = new AnnotationFactory() {
- public Annotation newAnnotation(DeclarationAnnotationAdapter adapter, ModifiedDeclaration declaration) {
- return adapter.newNormalAnnotation(declaration);
- }
- @Override
- public String toString() {
- return "NormalAnnotationFactory"; //$NON-NLS-1$
- }
- };
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ConversionDeclarationAnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ConversionDeclarationAnnotationElementAdapter.java
deleted file mode 100644
index fb934f33be..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ConversionDeclarationAnnotationElementAdapter.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Wrap a declaration annotation element adapter that deals with AST
- * expressions, converting them to/from various other objects.
- *
- * @param <T> the type of the object be passed to and returned by the adapter
- */
-public class ConversionDeclarationAnnotationElementAdapter<T>
- implements DeclarationAnnotationElementAdapter<T>
-{
- /**
- * The wrapped adapter that returns and takes AST expressions.
- */
- protected final DeclarationAnnotationElementAdapter<Expression> adapter;
-
- /**
- * The converter that converts AST expressions to other objects
- * (e.g. Strings).
- */
- protected final ExpressionConverter<T> converter;
-
-
- // ********** constructors **********
-
- /**
- * The default element name is <code>value</code>.
- */
- public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, ExpressionConverter<T> converter) {
- this(new ExpressionDeclarationAnnotationElementAdapter<Expression>(annotationAdapter), converter);
- }
-
- public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<T> converter) {
- this(new ExpressionDeclarationAnnotationElementAdapter<Expression>(annotationAdapter, elementName), converter);
- }
-
- public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationElementAdapter<Expression> adapter, ExpressionConverter<T> converter) {
- super();
- this.adapter = adapter;
- this.converter = converter;
- }
-
-
- // ********** DeclarationAnnotationElementAdapter implementation **********
-
- public T getValue(ModifiedDeclaration declaration) {
- Expression expression = this.adapter.getValue(declaration);
- return this.converter.convert(expression);
- }
-
- public void setValue(T value, ModifiedDeclaration declaration) {
- Expression expression;
- try {
- expression = this.converter.convert(value, declaration.getAst());
- } catch (IllegalArgumentException ex) {
- // if there is a problem converting the 'value' to an Expression we get this exception
- return; // don't set the value if it is "illegal"
- }
- this.adapter.setValue(expression, declaration);
- }
-
- public Expression getExpression(ModifiedDeclaration declaration) {
- return this.adapter.getExpression(declaration);
- }
-
- public ASTNode getAstNode(ModifiedDeclaration declaration) {
- return this.adapter.getAstNode(declaration);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.adapter);
- }
-
-
- // ********** factory static methods **********
-
- /**
- * The default element name is <code>value</code>;
- * the default expression converter expects string constant expressions.
- */
- public static ConversionDeclarationAnnotationElementAdapter<String> forStrings(DeclarationAnnotationAdapter annotationAdapter) {
- return new ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, StringExpressionConverter.instance());
- }
-
- /**
- * The default expression converter expects string constant expressions.
- */
- public static ConversionDeclarationAnnotationElementAdapter<String> forStrings(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
- return new ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, elementName, StringExpressionConverter.instance());
- }
-
- /**
- * The default element name is <code>value</code>;
- * the default expression converter expects number constant expressions.
- */
- public static ConversionDeclarationAnnotationElementAdapter<Integer> forNumbers(DeclarationAnnotationAdapter annotationAdapter) {
- return new ConversionDeclarationAnnotationElementAdapter<Integer>(annotationAdapter, NumberIntegerExpressionConverter.instance());
- }
-
- /**
- * The default expression converter expects number constant expressions.
- */
- public static ConversionDeclarationAnnotationElementAdapter<Integer> forNumbers(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
- return new ConversionDeclarationAnnotationElementAdapter<Integer>(annotationAdapter, elementName, NumberIntegerExpressionConverter.instance());
- }
-
- /**
- * The default element name is <code>value</code>;
- * the default expression converter expects boolean constant expressions.
- */
- public static ConversionDeclarationAnnotationElementAdapter<Boolean> forBooleans(DeclarationAnnotationAdapter annotationAdapter) {
- return new ConversionDeclarationAnnotationElementAdapter<Boolean>(annotationAdapter, BooleanExpressionConverter.instance());
- }
-
- /**
- * The default expression converter expects boolean constant expressions.
- */
- public static ConversionDeclarationAnnotationElementAdapter<Boolean> forBooleans(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
- return new ConversionDeclarationAnnotationElementAdapter<Boolean>(annotationAdapter, elementName, BooleanExpressionConverter.instance());
- }
-
- /**
- * The default element name is <code>value</code>;
- * the default expression converter expects character constant expressions.
- */
- public static ConversionDeclarationAnnotationElementAdapter<String> forCharacters(DeclarationAnnotationAdapter annotationAdapter) {
- return new ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, CharacterStringExpressionConverter.instance());
- }
-
- /**
- * The default expression converter expects character constant expressions.
- */
- public static ConversionDeclarationAnnotationElementAdapter<String> forCharacters(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
- return new ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, elementName, CharacterStringExpressionConverter.instance());
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/DefaultAnnotationEditFormatter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/DefaultAnnotationEditFormatter.java
deleted file mode 100644
index 97264a9d93..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/DefaultAnnotationEditFormatter.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.text.edits.InsertEdit;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.text.edits.TextEdit;
-
-/**
- * This implementation will clean up some of the nasty Eclipse annotation
- * formatting (or lack thereof); e.g. arrays of annotations.
- */
-public final class DefaultAnnotationEditFormatter
- implements AnnotationEditFormatter
-{
- private static final DefaultAnnotationEditFormatter INSTANCE = new DefaultAnnotationEditFormatter();
-
- /**
- * Return the singleton.
- */
- public static DefaultAnnotationEditFormatter instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private DefaultAnnotationEditFormatter() {
- super();
- }
-
- /**
- * TODO
- */
- public void format(IDocument doc, TextEdit editTree) throws MalformedTreeException, BadLocationException {
- TextEdit[] edits = editTree.getChildren();
- int len = edits.length;
- if (len == 0) {
- return;
- }
-
- MultiTextEdit extraEdits = new MultiTextEdit();
- for (int i = 0; i < len; i++) {
- TextEdit edit1 = edits[i];
- if ( ! (edit1 instanceof InsertEdit)) {
- continue; // if the edit is not an insert, skip to the next edit
- }
- InsertEdit insert1 = (InsertEdit) edit1;
- int j = i + 1;
- if (j < len) {
- TextEdit edit2 = edits[j];
- if (edit2 instanceof InsertEdit) {
- InsertEdit insert2 = (InsertEdit) edit2;
- String text1 = insert1.getText();
- String text2 = insert2.getText();
- int offset1 = insert1.getOffset();
- int offset2 = insert2.getOffset();
- if (this.stringIsAnnotation(text1) && text2.equals(" ")) { //$NON-NLS-1$
- // an annotation was inserted before something on the same line;
- // replace the trailing space with a newline and appropriate indent
- extraEdits.addChild(new ReplaceEdit(offset2, 1, this.buildCR(doc, offset2)));
- i++; // jump the index past 'edit2'
- continue; // go to the next edit
- }
- int comma1Length = this.commaLength(text1);
- if ((comma1Length != 0) && this.stringIsAnnotation(text2)) {
- // an annotation was inserted in an array initializer on the
- // same line as the previous array element;
- // replace the preceding space with a newline and appropriate indent
- extraEdits.addChild(new ReplaceEdit(offset1 + comma1Length, text1.length() - comma1Length, this.buildCR(doc, offset1)));
- i++; // jump the index past 'edit2'
- continue; // go to the next edit
- }
- }
- }
- this.formatArrayInitializer(doc, insert1, extraEdits);
- }
- extraEdits.apply(doc, TextEdit.NONE);
- }
-
- /**
- * If the insert edit is inserting an annotation containing an array of annotations as
- * its value then format them nicely.
- */
- private void formatArrayInitializer(IDocument doc, InsertEdit insertEdit, MultiTextEdit extraEdits) throws BadLocationException {
- String s = insertEdit.getText();
- if ( ! this.stringIsAnnotation(s)) {
- return;
- }
- int len = s.length();
- int pos = 1; // skip '@'
- while (pos < len) {
- char c = s.charAt(pos);
- pos++; // bump to just past first '('
- if (c == '(') {
- break;
- }
- }
- if (pos == len) {
- return; // reached end of string
- }
- while (pos < len) {
- char c = s.charAt(pos);
- pos++; // bump to just past first '{'
- if (c == '{') {
- break;
- }
- if (c != ' ') {
- return;
- }
- }
- if (pos == len) {
- return; // reached end of string
- }
- // now look for '@' not inside parentheses and put in
- // line delimeter and indent string before each
- int offset = insertEdit.getOffset();
- String indent = null;
- int parenDepth = 0;
- while (pos < len) {
- switch (s.charAt(pos)) {
- case '(' :
- parenDepth++;
- break;
- case ')' :
- parenDepth--;
- break;
- case '@' :
- if (parenDepth == 0) {
- if (indent == null) {
- indent = this.buildCR(doc, offset, "\t"); // TODO use tab preference? //$NON-NLS-1$
- }
- extraEdits.addChild(new InsertEdit(offset + pos, indent));
- }
- break;
- case '}' :
- if (parenDepth == 0) {
- extraEdits.addChild(new InsertEdit(offset + pos, this.buildCR(doc, offset)));
- }
- break;
- }
- pos++;
- }
- }
-
- /**
- * Build a string containing a line delimeter and indenting characters
- * matching the indent level of the line containing the character offset
- * (i.e. the new line's indent matches the current line).
- */
- private String buildCR(IDocument doc, int offset) throws BadLocationException {
- return this.buildCR(doc, offset, ""); //$NON-NLS-1$
- }
-
- private String buildCR(IDocument doc, int offset, String suffix) throws BadLocationException {
- int line = doc.getLineOfOffset(offset);
- StringBuilder sb = new StringBuilder();
- sb.append(doc.getLineDelimiter(line)); // use same CR as current line
-
- int o = doc.getLineOffset(line); // match the whitespace of the current line
- char c = doc.getChar(o++);
- while ((c == ' ') || (c == '\t')) {
- sb.append(c);
- c = doc.getChar(o++);
- }
- sb.append(suffix);
- return sb.toString();
- }
-
- /**
- * Return whether the specified string is an annotation.
- */
- private boolean stringIsAnnotation(String string) {
- return (string.length() > 1) && string.charAt(0) == '@';
- }
-
- /**
- * If the specified string is a single comma, possibly surrounded by
- * spaces, return the length of the substring containing the
- * initial spaces and the comma.
- */
- private int commaLength(String string) {
- boolean comma = false;
- int len = string.length();
- int result = 0;
- for (int i = 0; i < len; i++) {
- switch (string.charAt(i)) {
- case ' ' :
- if ( ! comma) {
- result++; // space preceding comma
- }
- break;
- case ',' :
- if (comma) {
- return 0; // second comma!
- }
- comma = true;
- result++;
- break;
- default:
- return 0; // non-comma, non-space char
- }
- }
- return result;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ElementAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ElementAnnotationAdapter.java
deleted file mode 100644
index 17f14a4b22..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ElementAnnotationAdapter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-
-/**
- * Adapt an annotated element and a declaration annotation adapter.
- */
-public class ElementAnnotationAdapter extends AbstractAnnotationAdapter {
-
-
- // ********** constructor **********
-
- public ElementAnnotationAdapter(AnnotatedElement annotatedElement, DeclarationAnnotationAdapter daa) {
- super(annotatedElement, daa);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ElementIndexedAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ElementIndexedAnnotationAdapter.java
deleted file mode 100644
index f3e3467b8b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ElementIndexedAnnotationAdapter.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Adapt an annotated element and an indexed declaration annotation adapter.
- */
-public class ElementIndexedAnnotationAdapter
- extends AbstractAnnotationAdapter
- implements IndexedAnnotationAdapter
-{
- private final IndexedDeclarationAnnotationAdapter idaa;
-
-
- // ********** constructor **********
-
- public ElementIndexedAnnotationAdapter(AnnotatedElement annotatedElement, IndexedDeclarationAnnotationAdapter idaa) {
- super(annotatedElement, idaa);
- this.idaa = idaa;
- }
-
-
- // ********** IndexedAnnotationAdapter implementation **********
-
- public int getIndex() {
- return this.idaa.getIndex();
- }
-
- public void moveAnnotation(int newIndex) {
- this.edit(this.buildMoveAnnotationEditor(newIndex));
- }
-
-
- // ********** factory methods **********
-
- protected AnnotatedElement.Editor buildMoveAnnotationEditor(int newIndex) {
- return new MoveAnnotationEditor(this.idaa, newIndex);
- }
-
-
- // ********** member classes **********
-
- protected static class MoveAnnotationEditor implements AnnotatedElement.Editor {
- private final IndexedDeclarationAnnotationAdapter idaa;
- private int index;
-
- MoveAnnotationEditor(IndexedDeclarationAnnotationAdapter idaa, int index) {
- super();
- this.idaa = idaa;
- this.index = index;
- }
- public void edit(ModifiedDeclaration declaration) {
- this.idaa.moveAnnotation(this.index, declaration);
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/EnumArrayDeclarationAnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/EnumArrayDeclarationAnnotationElementAdapter.java
deleted file mode 100644
index 3b3a74be0d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/EnumArrayDeclarationAnnotationElementAdapter.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.List;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ArrayInitializer;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Wrap a declaration annotation element adapter and simply
- * add an import for the enums when necessary.
- */
-public class EnumArrayDeclarationAnnotationElementAdapter
- implements DeclarationAnnotationElementAdapter<String[]>
-{
- /**
- * The wrapped adapter that returns and takes name strings (enums).
- */
- private final ConversionDeclarationAnnotationElementAdapter<String[]> adapter;
-
-
- // ********** constructors **********
-
- /**
- * The default element name is <code>value</code>.
- * The default behavior is to remove the array initializer if it is empty.
- */
- public EnumArrayDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter) {
- this(annotationAdapter, VALUE);
- }
-
- /**
- * The default behavior is to remove the array initializer if it is empty.
- */
- public EnumArrayDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
- this(annotationAdapter, elementName, true);
- }
-
- public EnumArrayDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeArrayInitializerWhenEmpty) {
- this(new ConversionDeclarationAnnotationElementAdapter<String[]>(annotationAdapter, elementName, buildExpressionConverter(removeArrayInitializerWhenEmpty)));
- }
-
- private static ExpressionConverter<String[]> buildExpressionConverter(boolean removeArrayInitializerWhenEmpty) {
- return new AnnotationStringArrayExpressionConverter(NameStringExpressionConverter.instance(), removeArrayInitializerWhenEmpty);
- }
-
- protected EnumArrayDeclarationAnnotationElementAdapter(ConversionDeclarationAnnotationElementAdapter<String[]> adapter) {
- super();
- this.adapter = adapter;
- }
-
-
- // ********** DeclarationAnnotationElementAdapter implementation **********
-
- public String[] getValue(ModifiedDeclaration declaration) {
- // ignore the adapter's getValue() - we want the expression
- return this.resolve(this.adapter.getExpression(declaration), declaration);
- }
-
- public void setValue(String[] value, ModifiedDeclaration declaration) {
- this.adapter.setValue(this.convertToSourceCodeNames(value, declaration), declaration);
- }
-
- public Expression getExpression(ModifiedDeclaration declaration) {
- return this.adapter.getExpression(declaration);
- }
-
- public ASTNode getAstNode(ModifiedDeclaration declaration) {
- return this.adapter.getAstNode(declaration);
- }
-
-
- // ********** internal methods **********
-
- /**
- * resolve the enums, which can be
- * null
- * or
- * {FOO, BAR, BAZ}
- * or
- * FOO
- */
- protected String[] resolve(Expression expression, ModifiedDeclaration declaration) {
- if (expression == null) {
- return StringTools.EMPTY_STRING_ARRAY;
- } else if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
- return this.resolveArray((ArrayInitializer) expression, declaration);
- } else {
- return this.resolveSingleElement(expression, declaration);
- }
- }
-
- protected String[] resolveArray(ArrayInitializer ai, @SuppressWarnings("unused") ModifiedDeclaration declaration) {
- List<Expression> expressions = this.expressions(ai);
- int len = expressions.size();
- String[] enums = new String[len];
- for (int i = len; i-- > 0; ) {
- enums[i] = this.resolveEnum(expressions.get(i));
- }
- return enums;
- }
-
- protected String[] resolveSingleElement(Expression enumExpression, @SuppressWarnings("unused") ModifiedDeclaration declaration) {
- return new String[] {this.resolveEnum(enumExpression)};
- }
-
- protected String resolveEnum(Expression expression) {
- return ASTTools.resolveEnum(expression);
- }
-
- // minimize scope of suppressd warnings
- @SuppressWarnings("unchecked")
- private List<Expression> expressions(ArrayInitializer arrayInitializer) {
- return arrayInitializer.expressions();
- }
-
- /**
- * convert the fully-qualified enums to names that can be inserted in source code
- * NB: imports may be added as a side-effect :-(
- */
- protected String[] convertToSourceCodeNames(String[] enums, ModifiedDeclaration declaration) {
- if (enums == null) {
- return null;
- }
- int len = enums.length;
- String[] sourceCodeNames = new String[len];
- for (int i = 0; i < len; i++) {
- sourceCodeNames[i] = this.convertToSourceCodeName(enums[i], declaration);
- }
- return sourceCodeNames;
- }
-
- protected String convertToSourceCodeName(String enum_, ModifiedDeclaration declaration) {
- return EnumDeclarationAnnotationElementAdapter.convertToSourceCodeName(enum_, declaration);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/EnumDeclarationAnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/EnumDeclarationAnnotationElementAdapter.java
deleted file mode 100644
index 21cbe29aaa..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/EnumDeclarationAnnotationElementAdapter.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-
-/**
- * Wrap a declaration annotation element adapter and simply
- * add an import for the enum when necessary.
- */
-public class EnumDeclarationAnnotationElementAdapter
- implements DeclarationAnnotationElementAdapter<String>
-{
- /**
- * The wrapped adapter that returns and takes name strings (enums).
- */
- private final ConversionDeclarationAnnotationElementAdapter<String> adapter;
-
-
- // ********** constructors **********
-
- /**
- * The default element name is <code>value</code>.
- */
- public EnumDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter) {
- this(annotationAdapter, VALUE);
- }
-
- public EnumDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
- this(new ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, elementName, NameStringExpressionConverter.instance()));
- }
-
- protected EnumDeclarationAnnotationElementAdapter(ConversionDeclarationAnnotationElementAdapter<String> adapter) {
- super();
- this.adapter = adapter;
- }
-
-
- // ********** DeclarationAnnotationElementAdapter implementation **********
-
- public String getValue(ModifiedDeclaration declaration) {
- return this.resolve(this.adapter.getExpression(declaration));
- }
-
- public void setValue(String value, ModifiedDeclaration declaration) {
- this.adapter.setValue(convertToSourceCodeName(value, declaration), declaration);
- }
-
- public Expression getExpression(ModifiedDeclaration declaration) {
- return this.adapter.getExpression(declaration);
- }
-
- public ASTNode getAstNode(ModifiedDeclaration declaration) {
- return this.adapter.getAstNode(declaration);
- }
-
-
- // ********** internal methods **********
-
- /**
- * resolve the enum
- */
- protected String resolve(Expression expression) {
- return ASTTools.resolveEnum(expression);
- }
-
- /**
- * convert the fully-qualified enum constant to a static import and the constant's short name, e.g.
- * static import javax.persistence.FetchType.EAGER;
- * return "EAGER"
- * if that doesn't work, convert to a normal import and the constant's partially-qualified name, e.g.
- * import javax.persistence.FetchType;
- * return "FetchType.EAGER"
- * if that doesn't work, simply return the constant's fully-qualified name, e.g.
- * return "javax.persistence.FetchType.EAGER"
- * NB: an import may be added as a side-effect :-(
- */
- protected static String convertToSourceCodeName(String enumConstantName, ModifiedDeclaration declaration) {
- return (enumConstantName == null) ? null : convertToSourceCodeName_(enumConstantName, declaration);
- }
-
- /**
- * pre-condition: enum constant name is non-null;
- * convert it to its short version if we can add a static import etc.
- */
- protected static String convertToSourceCodeName_(String enumConstantName, ModifiedDeclaration declaration) {
- if (declaration.addStaticImport(enumConstantName)) {
- return convertToShortName(enumConstantName);
- }
- if (declaration.addImport(convertToTypeName(enumConstantName))) {
- return convertToPartiallyQualifiedName(enumConstantName);
- }
- return enumConstantName;
- }
-
- protected static String convertToShortName(String name) {
- return name.substring(name.lastIndexOf('.') + 1);
- }
-
- protected static String convertToTypeName(String name) {
- return name.substring(0, name.lastIndexOf('.'));
- }
-
- protected static String convertToPartiallyQualifiedName(String name) {
- return name.substring(name.lastIndexOf('.', name.lastIndexOf('.') - 1) + 1);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ExpressionDeclarationAnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ExpressionDeclarationAnnotationElementAdapter.java
deleted file mode 100644
index d3b0370942..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ExpressionDeclarationAnnotationElementAdapter.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Most obvious implementation of the interface.
- * Assume the element's value is an Expression.
- */
-public class ExpressionDeclarationAnnotationElementAdapter<E extends Expression>
- implements DeclarationAnnotationElementAdapter<E>
-{
- /**
- * Adapter used to manipulate the element's annotation.
- */
- private final DeclarationAnnotationAdapter annotationAdapter;
-
- /**
- * The name of the relevant annotation element.
- */
- private final String elementName;
-
-
- // ********** constructors **********
-
- /**
- * The default element name is <code>value</code>.
- */
- public ExpressionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter) {
- this(annotationAdapter, VALUE);
- }
-
- public ExpressionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) {
- this.annotationAdapter = annotationAdapter;
- this.elementName = elementName;
- }
-
-
- // ********** DeclarationAnnotationElementAdapter implementation **********
-
- public E getValue(ModifiedDeclaration declaration) {
- // return the expression unmodified
- return this.getExpression(declaration);
- }
-
- public void setValue(E value, ModifiedDeclaration declaration) {
- this.setValue(value, this.annotationAdapter.getAnnotation(declaration), declaration);
- }
-
- public E getExpression(ModifiedDeclaration declaration) {
- return this.expression(this.annotationAdapter.getAnnotation(declaration));
- }
-
- public ASTNode getAstNode(ModifiedDeclaration declaration) {
- Expression exp = this.getExpression(declaration);
- return (exp != null) ? exp : this.annotationAdapter.getAstNode(declaration);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.elementName);
- }
-
-
- // ********** expression **********
-
- /**
- * Return the expression value of the *first* annotation element
- * with the adapter's element name.
- * Return null if the annotation has no such element.
- * (An element name of "value" will return the value of a single
- * member annotation.)
- */
- protected E expression(Annotation annotation) {
- if (annotation == null) {
- return this.expressionNoAnnotation();
- }
- if (annotation.isMarkerAnnotation()) {
- return this.expressionMarkerAnnotation((MarkerAnnotation) annotation);
- }
- if (annotation.isSingleMemberAnnotation()) {
- return this.expressionSingleMemberAnnotation((SingleMemberAnnotation) annotation);
- }
- if (annotation.isNormalAnnotation()) {
- return this.expressionNormalAnnotation((NormalAnnotation) annotation);
- }
- throw new IllegalArgumentException("unknown annotation type: " + annotation); //$NON-NLS-1$
- }
-
- protected E expressionNoAnnotation() {
- return null;
- }
-
- /**
- * Return the expression value of the *first* annotation element
- * with the adapter's element name.
- * Return null if the annotation has no such element.
- */
- protected E expressionMarkerAnnotation(@SuppressWarnings("unused") MarkerAnnotation annotation) {
- return null;
- }
-
- /**
- * Return the expression value of the *first* annotation element
- * with the adapter's element name.
- * Return null if the annotation has no such element.
- */
- protected E expressionSingleMemberAnnotation(SingleMemberAnnotation annotation) {
- return this.downcast(this.elementName.equals(VALUE) ? annotation.getValue() : null);
- }
-
- @SuppressWarnings("unchecked")
- private E downcast(Expression e) {
- return (E) e;
- }
-
- /**
- * Return the expression value of the *first* annotation element
- * with the adapter's element name.
- * Return null if the annotation has no such element.
- */
- protected E expressionNormalAnnotation(NormalAnnotation annotation) {
- MemberValuePair pair = this.memberValuePair(annotation);
- return this.downcast((pair == null) ? null : pair.getValue());
- }
-
-
- // ********** set value **********
-
- /**
- * set non-null, non-empty value
- */
- protected void setValue(Expression value, Annotation annotation, ModifiedDeclaration declaration) {
- if (value == null) {
- this.removeElement(annotation, declaration);
- }
- else if (annotation == null) {
- this.setValueNoAnnotation(value, declaration);
- }
- else if (annotation.isMarkerAnnotation()) {
- this.setValueMarkerAnnotation(value, (MarkerAnnotation) annotation, declaration);
- }
- else if (annotation.isSingleMemberAnnotation()) {
- this.setValueSingleMemberAnnotation(value, (SingleMemberAnnotation) annotation, declaration);
- }
- else if (annotation.isNormalAnnotation()) {
- this.setValueNormalAnnotation(value, (NormalAnnotation) annotation, declaration);
- }
- else {
- throw new IllegalArgumentException("unknown annotation type: " + annotation); //$NON-NLS-1$
- }
- }
-
- /**
- * add non-null, non-empty value
- */
- protected void setValueNoAnnotation(Expression value, ModifiedDeclaration declaration) {
- if (this.elementName.equals(VALUE)) {
- // @Foo("xxx")
- this.annotationAdapter.newSingleMemberAnnotation(declaration).setValue(value);
- } else {
- // @Foo(bar="xxx")
- this.addValue(value, this.annotationAdapter.newNormalAnnotation(declaration));
- }
- }
-
- protected void addValue(Expression value, NormalAnnotation annotation) {
- this.addValue(value, annotation, this.elementName);
- }
-
- protected void addValue(Expression value, NormalAnnotation annotation, String annotationElementName) {
- AST ast = annotation.getAST();
- MemberValuePair pair = ast.newMemberValuePair();
- pair.setName(ast.newSimpleName(annotationElementName));
- pair.setValue(value);
- List<MemberValuePair> values = this.values(annotation);
- values.add(pair);
- }
-
- protected void setValueMarkerAnnotation(Expression value, @SuppressWarnings("unused") MarkerAnnotation annotation, ModifiedDeclaration declaration) {
- // @Foo => @Foo("xxx")
- // or
- // @Foo => @Foo(bar="xxx")
- this.setValueNoAnnotation(value, declaration);
- }
-
- protected void setValueSingleMemberAnnotation(Expression value, SingleMemberAnnotation annotation, ModifiedDeclaration declaration) {
- if (this.elementName.equals(VALUE)) {
- // @Foo("yyy") => @Foo("xxx")
- annotation.setValue(value);
- } else {
- // @Foo("yyy") => @Foo(value="yyy", bar="xxx")
- Expression vv = annotation.getValue();
- vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv);
- NormalAnnotation normalAnnotation = this.annotationAdapter.newNormalAnnotation(declaration);
- this.addValue(vv, normalAnnotation, VALUE);
- this.addValue(value, normalAnnotation);
- }
- }
-
- protected void setValueNormalAnnotation(Expression value, NormalAnnotation annotation, @SuppressWarnings("unused") ModifiedDeclaration declaration) {
- MemberValuePair pair = this.memberValuePair(annotation);
- if (pair == null) {
- this.addValue(value, annotation);
- } else {
- pair.setValue(value);
- }
- }
-
-
- // ********** remove element **********
-
- protected void removeElement(Annotation annotation, ModifiedDeclaration declaration) {
- if (annotation == null) {
- this.removeElementNoAnnotation(declaration);
- }
- else if (annotation.isMarkerAnnotation()) {
- this.removeElementMarkerAnnotation((MarkerAnnotation) annotation, declaration);
- }
- else if (annotation.isSingleMemberAnnotation()) {
- this.removeElementSingleMemberAnnotation((SingleMemberAnnotation) annotation, declaration);
- }
- else if (annotation.isNormalAnnotation()) {
- this.removeElementNormalAnnotation((NormalAnnotation) annotation, declaration);
- }
- else {
- throw new IllegalArgumentException("unknown annotation type: " + annotation); //$NON-NLS-1$
- }
- }
-
- protected void removeElementNoAnnotation(@SuppressWarnings("unused") ModifiedDeclaration declaration) {
- // the element is already gone (?)
- }
-
- protected void removeElementMarkerAnnotation(@SuppressWarnings("unused") MarkerAnnotation annotation, @SuppressWarnings("unused") ModifiedDeclaration declaration) {
- // the element is already gone (?)
- }
-
- protected void removeElementSingleMemberAnnotation(@SuppressWarnings("unused") SingleMemberAnnotation annotation, ModifiedDeclaration declaration) {
- if (this.elementName.equals(VALUE)) {
- // @Foo("xxx") => @Foo
- this.annotationAdapter.newMarkerAnnotation(declaration);
- } else {
- // the [non-'value'] element is already gone (?)
- }
- }
-
- protected void removeElementNormalAnnotation(NormalAnnotation annotation, ModifiedDeclaration declaration) {
- List<MemberValuePair> values = this.values(annotation);
- if ((values.size() == 1) && values.get(0).getName().getFullyQualifiedName().equals(this.elementName)) {
- // @Foo(bar="xxx") => @Foo
- this.annotationAdapter.newMarkerAnnotation(declaration);
- } else {
- this.removeElement(annotation);
- if (values.size() == 1) {
- MemberValuePair pair = values.get(0);
- if (pair.getName().getFullyQualifiedName().equals(VALUE)) {
- // @Foo(bar="xxx", value="yyy") => @Foo("yyy")
- Expression vv = pair.getValue();
- vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv);
- this.annotationAdapter.newSingleMemberAnnotation(declaration).setValue(vv);
- } else {
- // @Foo(bar="xxx", baz="yyy") => @Foo(baz="yyy")
- }
- } else {
- // @Foo(bar="xxx", baz="yyy", joo="xxx") => @Foo(baz="yyy", joo="xxx")
- }
- }
- }
-
- /**
- * Remove the *first* member value pair from the specified annotation element
- * with the adapter's element name.
- */
- protected void removeElement(NormalAnnotation annotation) {
- for (Iterator<MemberValuePair> stream = this.values(annotation).iterator(); stream.hasNext(); ) {
- MemberValuePair pair = stream.next();
- if (pair.getName().getFullyQualifiedName().equals(this.elementName)) {
- stream.remove();
- }
- }
- }
-
-
- // ********** convenience methods **********
-
- /**
- * Return the *first* member value pair for the specified annotation element
- * with the adapter's element name.
- * Return null if the annotation has no such element.
- */
- protected MemberValuePair memberValuePair(NormalAnnotation annotation) {
- for (MemberValuePair pair : this.values(annotation)) {
- if (pair.getName().getFullyQualifiedName().equals(this.elementName)) {
- return pair;
- }
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- protected List<MemberValuePair> values(NormalAnnotation na) {
- return na.values();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/GenericVisitor.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/GenericVisitor.java
deleted file mode 100644
index 92160afdf5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/GenericVisitor.java
+++ /dev/null
@@ -1,791 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ASTVisitor;
-import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
-import org.eclipse.jdt.core.dom.AnnotationTypeMemberDeclaration;
-import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
-import org.eclipse.jdt.core.dom.ArrayAccess;
-import org.eclipse.jdt.core.dom.ArrayCreation;
-import org.eclipse.jdt.core.dom.ArrayInitializer;
-import org.eclipse.jdt.core.dom.ArrayType;
-import org.eclipse.jdt.core.dom.AssertStatement;
-import org.eclipse.jdt.core.dom.Assignment;
-import org.eclipse.jdt.core.dom.Block;
-import org.eclipse.jdt.core.dom.BlockComment;
-import org.eclipse.jdt.core.dom.BooleanLiteral;
-import org.eclipse.jdt.core.dom.BreakStatement;
-import org.eclipse.jdt.core.dom.CastExpression;
-import org.eclipse.jdt.core.dom.CatchClause;
-import org.eclipse.jdt.core.dom.CharacterLiteral;
-import org.eclipse.jdt.core.dom.ClassInstanceCreation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.ConditionalExpression;
-import org.eclipse.jdt.core.dom.ConstructorInvocation;
-import org.eclipse.jdt.core.dom.ContinueStatement;
-import org.eclipse.jdt.core.dom.DoStatement;
-import org.eclipse.jdt.core.dom.EmptyStatement;
-import org.eclipse.jdt.core.dom.EnhancedForStatement;
-import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.ExpressionStatement;
-import org.eclipse.jdt.core.dom.FieldAccess;
-import org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.eclipse.jdt.core.dom.ForStatement;
-import org.eclipse.jdt.core.dom.IfStatement;
-import org.eclipse.jdt.core.dom.ImportDeclaration;
-import org.eclipse.jdt.core.dom.InfixExpression;
-import org.eclipse.jdt.core.dom.Initializer;
-import org.eclipse.jdt.core.dom.InstanceofExpression;
-import org.eclipse.jdt.core.dom.Javadoc;
-import org.eclipse.jdt.core.dom.LabeledStatement;
-import org.eclipse.jdt.core.dom.LineComment;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.MemberRef;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.MethodInvocation;
-import org.eclipse.jdt.core.dom.MethodRef;
-import org.eclipse.jdt.core.dom.MethodRefParameter;
-import org.eclipse.jdt.core.dom.Modifier;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.NullLiteral;
-import org.eclipse.jdt.core.dom.NumberLiteral;
-import org.eclipse.jdt.core.dom.PackageDeclaration;
-import org.eclipse.jdt.core.dom.ParameterizedType;
-import org.eclipse.jdt.core.dom.ParenthesizedExpression;
-import org.eclipse.jdt.core.dom.PostfixExpression;
-import org.eclipse.jdt.core.dom.PrefixExpression;
-import org.eclipse.jdt.core.dom.PrimitiveType;
-import org.eclipse.jdt.core.dom.QualifiedName;
-import org.eclipse.jdt.core.dom.QualifiedType;
-import org.eclipse.jdt.core.dom.ReturnStatement;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.SimpleType;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jdt.core.dom.SuperConstructorInvocation;
-import org.eclipse.jdt.core.dom.SuperFieldAccess;
-import org.eclipse.jdt.core.dom.SuperMethodInvocation;
-import org.eclipse.jdt.core.dom.SwitchCase;
-import org.eclipse.jdt.core.dom.SwitchStatement;
-import org.eclipse.jdt.core.dom.SynchronizedStatement;
-import org.eclipse.jdt.core.dom.TagElement;
-import org.eclipse.jdt.core.dom.TextElement;
-import org.eclipse.jdt.core.dom.ThisExpression;
-import org.eclipse.jdt.core.dom.ThrowStatement;
-import org.eclipse.jdt.core.dom.TryStatement;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jdt.core.dom.TypeDeclarationStatement;
-import org.eclipse.jdt.core.dom.TypeLiteral;
-import org.eclipse.jdt.core.dom.TypeParameter;
-import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
-import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
-import org.eclipse.jdt.core.dom.WhileStatement;
-import org.eclipse.jdt.core.dom.WildcardType;
-
-/**
- * copied from org.eclipse.jdt.internal.corext.dom.GenericVisitor
- */
-public class GenericVisitor extends ASTVisitor {
-
- public GenericVisitor() {
- super();
- }
-
- public GenericVisitor(boolean visitJavadocTags) {
- super(visitJavadocTags);
- }
-
- // ********** hooks for subclasses **********
-
- protected boolean visit_(@SuppressWarnings("unused") ASTNode node) {
- return true;
- }
-
- protected void endVisit_(@SuppressWarnings("unused") ASTNode node) {
- // do nothing
- }
-
- // ********** overrides **********
-
- @Override
- public boolean visit(AnonymousClassDeclaration node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ArrayAccess node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ArrayCreation node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ArrayInitializer node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ArrayType node) {
- return visit_(node);
- }
- @Override
- public boolean visit(AssertStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(Assignment node) {
- return visit_(node);
- }
- @Override
- public boolean visit(Block node) {
- return visit_(node);
- }
- @Override
- public boolean visit(BooleanLiteral node) {
- return visit_(node);
- }
- @Override
- public boolean visit(BreakStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(CastExpression node) {
- return visit_(node);
- }
- @Override
- public boolean visit(CatchClause node) {
- return visit_(node);
- }
- @Override
- public boolean visit(CharacterLiteral node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ClassInstanceCreation node) {
- return visit_(node);
- }
- @Override
- public boolean visit(CompilationUnit node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ConditionalExpression node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ConstructorInvocation node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ContinueStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(DoStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(EmptyStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ExpressionStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(FieldAccess node) {
- return visit_(node);
- }
- @Override
- public boolean visit(FieldDeclaration node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ForStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(IfStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ImportDeclaration node) {
- return visit_(node);
- }
- @Override
- public boolean visit(InfixExpression node) {
- return visit_(node);
- }
- @Override
- public boolean visit(InstanceofExpression node) {
- return visit_(node);
- }
- @Override
- public boolean visit(Initializer node) {
- return visit_(node);
- }
- @Override
- public boolean visit(Javadoc node) {
- return (super.visit(node)) ? visit_(node) : false;
- }
- @Override
- public boolean visit(LabeledStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(MethodDeclaration node) {
- return visit_(node);
- }
- @Override
- public boolean visit(MethodInvocation node) {
- return visit_(node);
- }
- @Override
- public boolean visit(NullLiteral node) {
- return visit_(node);
- }
- @Override
- public boolean visit(NumberLiteral node) {
- return visit_(node);
- }
- @Override
- public boolean visit(PackageDeclaration node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ParenthesizedExpression node) {
- return visit_(node);
- }
- @Override
- public boolean visit(PostfixExpression node) {
- return visit_(node);
- }
- @Override
- public boolean visit(PrefixExpression node) {
- return visit_(node);
- }
- @Override
- public boolean visit(PrimitiveType node) {
- return visit_(node);
- }
- @Override
- public boolean visit(QualifiedName node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ReturnStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(SimpleName node) {
- return visit_(node);
- }
- @Override
- public boolean visit(SimpleType node) {
- return visit_(node);
- }
- @Override
- public boolean visit(StringLiteral node) {
- return visit_(node);
- }
- @Override
- public boolean visit(SuperConstructorInvocation node) {
- return visit_(node);
- }
- @Override
- public boolean visit(SuperFieldAccess node) {
- return visit_(node);
- }
- @Override
- public boolean visit(SuperMethodInvocation node) {
- return visit_(node);
- }
- @Override
- public boolean visit(SwitchCase node) {
- return visit_(node);
- }
- @Override
- public boolean visit(SwitchStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(SynchronizedStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ThisExpression node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ThrowStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(TryStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(TypeDeclaration node) {
- return visit_(node);
- }
- @Override
- public boolean visit(TypeDeclarationStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(TypeLiteral node) {
- return visit_(node);
- }
- @Override
- public boolean visit(SingleVariableDeclaration node) {
- return visit_(node);
- }
- @Override
- public boolean visit(VariableDeclarationExpression node) {
- return visit_(node);
- }
- @Override
- public boolean visit(VariableDeclarationStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(VariableDeclarationFragment node) {
- return visit_(node);
- }
- @Override
- public boolean visit(WhileStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(AnnotationTypeDeclaration node) {
- return visit_(node);
- }
- @Override
- public boolean visit(AnnotationTypeMemberDeclaration node) {
- return visit_(node);
- }
- @Override
- public boolean visit(BlockComment node) {
- return visit_(node);
- }
- @Override
- public boolean visit(EnhancedForStatement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(EnumConstantDeclaration node) {
- return visit_(node);
- }
- @Override
- public boolean visit(EnumDeclaration node) {
- return visit_(node);
- }
- @Override
- public boolean visit(LineComment node) {
- return visit_(node);
- }
- @Override
- public boolean visit(MarkerAnnotation node) {
- return visit_(node);
- }
- @Override
- public boolean visit(MemberRef node) {
- return visit_(node);
- }
- @Override
- public boolean visit(MemberValuePair node) {
- return visit_(node);
- }
- @Override
- public boolean visit(MethodRef node) {
- return visit_(node);
- }
- @Override
- public boolean visit(MethodRefParameter node) {
- return visit_(node);
- }
- @Override
- public boolean visit(Modifier node) {
- return visit_(node);
- }
- @Override
- public boolean visit(NormalAnnotation node) {
- return visit_(node);
- }
- @Override
- public boolean visit(ParameterizedType node) {
- return visit_(node);
- }
- @Override
- public boolean visit(QualifiedType node) {
- return visit_(node);
- }
- @Override
- public boolean visit(SingleMemberAnnotation node) {
- return visit_(node);
- }
- @Override
- public boolean visit(TagElement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(TextElement node) {
- return visit_(node);
- }
- @Override
- public boolean visit(TypeParameter node) {
- return visit_(node);
- }
- @Override
- public boolean visit(WildcardType node) {
- return visit_(node);
- }
-
- @Override
- public void endVisit(AnonymousClassDeclaration node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ArrayAccess node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ArrayCreation node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ArrayInitializer node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ArrayType node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(AssertStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(Assignment node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(Block node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(BooleanLiteral node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(BreakStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(CastExpression node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(CatchClause node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(CharacterLiteral node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ClassInstanceCreation node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(CompilationUnit node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ConditionalExpression node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ConstructorInvocation node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ContinueStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(DoStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(EmptyStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ExpressionStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(FieldAccess node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(FieldDeclaration node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ForStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(IfStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ImportDeclaration node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(InfixExpression node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(InstanceofExpression node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(Initializer node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(Javadoc node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(LabeledStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(MethodDeclaration node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(MethodInvocation node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(NullLiteral node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(NumberLiteral node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(PackageDeclaration node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ParenthesizedExpression node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(PostfixExpression node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(PrefixExpression node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(PrimitiveType node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(QualifiedName node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ReturnStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(SimpleName node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(SimpleType node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(StringLiteral node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(SuperConstructorInvocation node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(SuperFieldAccess node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(SuperMethodInvocation node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(SwitchCase node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(SwitchStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(SynchronizedStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ThisExpression node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ThrowStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(TryStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(TypeDeclaration node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(TypeDeclarationStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(TypeLiteral node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(SingleVariableDeclaration node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(VariableDeclarationExpression node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(VariableDeclarationStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(VariableDeclarationFragment node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(WhileStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(AnnotationTypeDeclaration node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(AnnotationTypeMemberDeclaration node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(BlockComment node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(EnhancedForStatement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(EnumConstantDeclaration node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(EnumDeclaration node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(LineComment node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(MarkerAnnotation node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(MemberRef node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(MemberValuePair node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(MethodRef node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(MethodRefParameter node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(Modifier node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(NormalAnnotation node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(ParameterizedType node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(QualifiedType node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(SingleMemberAnnotation node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(TagElement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(TextElement node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(TypeParameter node) {
- endVisit_(node);
- }
- @Override
- public void endVisit(WildcardType node) {
- endVisit_(node);
- }
-
-}
-
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/IndexedConversionDeclarationAnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/IndexedConversionDeclarationAnnotationElementAdapter.java
deleted file mode 100644
index fe84b5a40c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/IndexedConversionDeclarationAnnotationElementAdapter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedExpressionConverter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-
-/**
- * Wrap a declaration annotation element adapter that deals with AST
- * array expressions, converting them to/from various other objects.
- *
- * @param <T> the type of the object in the array to be passed to and
- * returned by the adapter
- */
-public class IndexedConversionDeclarationAnnotationElementAdapter<T>
- extends ConversionDeclarationAnnotationElementAdapter<T[]>
- implements IndexedDeclarationAnnotationElementAdapter<T>
-{
- public IndexedConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, IndexedExpressionConverter<T> converter) {
- super(annotationAdapter, converter);
- }
-
- public IndexedConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, IndexedExpressionConverter<T> converter) {
- super(annotationAdapter, elementName, converter);
- }
-
- protected IndexedExpressionConverter<T> getConverter() {
- return (IndexedExpressionConverter<T>) this.converter;
- }
-
- public Expression selectExpression(ModifiedDeclaration declaration, int index) {
- return this.getConverter().selectExpression(this.getExpression(declaration), index);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTAnnotatedElement.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTAnnotatedElement.java
deleted file mode 100644
index 85171fede1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTAnnotatedElement.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.TextEdit;
-
-/**
- * Adapt and extend a JDT member with simplified annotation handling.
- */
-public abstract class JDTAnnotatedElement
- implements AnnotatedElement
-{
-
- /** the annotated element's name (duh) */
- private final String name;
-
- /**
- * the compilation unit (file) containing the annotated element;
- * used for building an AST when we modify the annotated element
- */
- private final ICompilationUnit compilationUnit;
-
- /**
- * this allows clients to provide a way to modify the compilation unit
- * (file) when it is open in an editor and should be modified on the UI
- * thread
- */
- private final CommandExecutor modifySharedDocumentCommandExecutor;
-
- /** this will format the annotated element's annotations a bit */
- private final AnnotationEditFormatter annotationEditFormatter;
-
-
- // ********** constructors **********
-
- protected JDTAnnotatedElement(
- String name,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- this(name, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- protected JDTAnnotatedElement(
- String name,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- super();
- this.name = name;
- this.compilationUnit = compilationUnit;
- this.modifySharedDocumentCommandExecutor = modifySharedDocumentCommandExecutor;
- this.annotationEditFormatter = annotationEditFormatter;
- }
-
-
- // ********** AnnotatedElement implementation **********
-
- public String getName() {
- return this.name;
- }
-
- public abstract ModifiedDeclaration getModifiedDeclaration(CompilationUnit astRoot);
-
- public ModifiedDeclaration getModifiedDeclaration() {
- return this.getModifiedDeclaration(this.buildASTRoot());
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.name);
- }
-
-
- // ********** editing **********
-
- /**
- * Edit the member with the specified editor.
- * The editor will be invoked once the member's compilation unit
- * is in an editable state.
- */
- public void edit(Editor editor) {
- try {
- this.edit_(editor);
- } catch (JavaModelException ex) {
- throw new RuntimeException(ex);
- } catch (BadLocationException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * NB: Be careful changing this method.
- * Things to look out for:
- * - when editing via the JavaEditor there is no need to create a working copy
- * - when editing without an editor or via a simple text editor, a "working copy" must be created.
- * (at least as far as I can tell ~kfm)
- * - sharedDocument is only ever false in tests (headless mode). In the UI, even if the file
- * is not open in an editor, sharedDocument is still true (buffer is not null)
- * - if a working copy is created, then we must discard it
- */
- protected void edit_(Editor editor) throws JavaModelException, BadLocationException {
- boolean createWorkingCopy = ! this.compilationUnit.isWorkingCopy();
- if (createWorkingCopy) {
- this.compilationUnit.becomeWorkingCopy(null);
- }
-
- ITextFileBuffer buffer = FileBuffers.getTextFileBufferManager().getTextFileBuffer(this.compilationUnit.getResource().getFullPath(), LocationKind.NORMALIZE);
- boolean sharedDocument = (buffer != null); // documents are typically shared when they are already open in an editor
- IDocument doc = sharedDocument ?
- buffer.getDocument() :
- new Document(this.compilationUnit.getBuffer().getContents());
-
- try {
- CompilationUnit astRoot = this.buildASTRoot();
- astRoot.recordModifications();
-
- editor.edit(this.getModifiedDeclaration(astRoot));
-
- TextEdit edits = astRoot.rewrite(doc, this.compilationUnit.getJavaProject().getOptions(true));
- if (sharedDocument) {
- this.modifySharedDocumentCommandExecutor.execute(new ModifySharedDocumentCommand(edits, doc));
- } else {
- this.applyEdits(edits, doc);
- }
- }
- finally {
- if (createWorkingCopy) {
- //discardWorkingCopy must be called every time becomeWorkingCopy is called.
- this.compilationUnit.getBuffer().setContents(doc.get());
- this.compilationUnit.commitWorkingCopy(true, null); // true="force"
- this.compilationUnit.discardWorkingCopy();
- }
- }
- }
-
- /**
- * apply the specified edits to the specified document,
- * reformatting the document if necessary
- */
- protected void applyEdits(TextEdit edits, IDocument doc) throws MalformedTreeException, BadLocationException {
- edits.apply(doc, TextEdit.UPDATE_REGIONS);
- this.annotationEditFormatter.format(doc, edits);
- }
-
- protected CompilationUnit buildASTRoot() {
- return ASTTools.buildASTRoot(this.compilationUnit);
- }
-
-
- // ********** modify shared document command class **********
-
- /**
- * simple command that calls back to the member to apply the edits
- * in the same way as if the document were not shared
- */
- protected class ModifySharedDocumentCommand
- implements Command
- {
- private final TextEdit edits;
- private final IDocument doc;
-
- protected ModifySharedDocumentCommand(TextEdit edits, IDocument doc) {
- super();
- this.edits = edits;
- this.doc = doc;
- }
-
- public void execute() {
- try {
- JDTAnnotatedElement.this.applyEdits(this.edits, this.doc);
- } catch (MalformedTreeException ex) {
- throw new RuntimeException(ex);
- } catch (BadLocationException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTEnum.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTEnum.java
deleted file mode 100644
index 47ed58b777..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTEnum.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.List;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.core.utility.jdt.Enum;
-import org.eclipse.jpt.common.core.utility.jdt.Type;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-
-/**
- * Adapt and extend a JDT enum.
- */
-public class JDTEnum
- extends AbstractJDTType
- implements Enum
-{
-
- /**
- * constructor for the compilation unit's primary type, an enum
- */
- public JDTEnum(
- EnumDeclaration enumDeclaration,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- this(enumDeclaration, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- /**
- * constructor for the compilation unit's primary type, an enum
- */
- public JDTEnum(
- EnumDeclaration enumDeclaration,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- super(null, enumDeclaration, 1, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- }
-
- /**
- * constructor for nested enums
- */
- public JDTEnum(
- Type declaringType,
- EnumDeclaration enumDeclaration,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- this(declaringType, enumDeclaration, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- /**
- * constructor for nested enums
- */
- public JDTEnum(
- Type declaringType,
- EnumDeclaration enumDeclaration,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- super(declaringType, enumDeclaration, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- }
-
- /**
- * constructor for testing
- */
- public JDTEnum(Type declaringType, String name, int occurrence, ICompilationUnit compilationUnit) {
- super(declaringType, name, occurrence, compilationUnit);
- }
-
- @Override
- public EnumDeclaration getBodyDeclaration(CompilationUnit astRoot) {
- return (EnumDeclaration) super.getBodyDeclaration(astRoot);
- }
-
- public boolean isPersistable(CompilationUnit astRoot) {
- return true;
- }
-
- public EnumConstantDeclaration[] getEnumConstants(CompilationUnit astRoot) {
- List<EnumConstantDeclaration> enumConstants = enumConstants(getBodyDeclaration(astRoot));
- return enumConstants.toArray(new EnumConstantDeclaration[enumConstants.size()]);
- }
-
- @SuppressWarnings("unchecked")
- private static List<EnumConstantDeclaration> enumConstants(EnumDeclaration ed) {
- return ed.enumConstants();
- }
-
-
- // ********** internal **********
-
- @Override
- protected EnumDeclaration getTopLevelTypeDeclaration(CompilationUnit astRoot) {
- return (EnumDeclaration) super.getTopLevelTypeDeclaration(astRoot);
- }
-
- @Override
- protected EnumDeclaration getTypeDeclaration(List<AbstractTypeDeclaration> typeDeclarations) {
- return (EnumDeclaration) super.getTypeDeclaration(typeDeclarations);
- }
-
- @Override
- protected EnumDeclaration getNestedTypeDeclaration(TypeDeclaration declaringTypeDeclaration) {
- return this.getTypeDeclaration(getEnums(declaringTypeDeclaration));
- }
-
- @Override
- protected EnumDeclaration getTypeDeclaration(AbstractTypeDeclaration[] typeDeclarations) {
- return (EnumDeclaration) super.getTypeDeclaration(typeDeclarations);
- }
-
- @Override
- protected int getASTNodeType() {
- return ASTNode.ENUM_DECLARATION;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTEnumConstant.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTEnumConstant.java
deleted file mode 100644
index ea3529597d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTEnumConstant.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.List;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.core.utility.jdt.Enum;
-import org.eclipse.jpt.common.core.utility.jdt.EnumConstant;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-
-/**
- * Adapt and extend a JDT enum constant.
- */
-public class JDTEnumConstant
- extends JDTMember
- implements EnumConstant
-{
-
- // ********** constructors **********
-
- public JDTEnumConstant(
- Enum declaringEnum,
- String name,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- this(declaringEnum, name, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- public JDTEnumConstant(
- Enum declaringEnum,
- String name,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- super(declaringEnum, name, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- }
-
- /**
- * constructor for testing
- */
- public JDTEnumConstant(Enum declaringEnum, String name, int occurrence, ICompilationUnit compilationUnit) {
- this(declaringEnum, name, occurrence, compilationUnit, CommandExecutor.Default.instance(), DefaultAnnotationEditFormatter.instance());
- }
-
- @Override
- protected Enum getDeclaringType() {
- return (Enum) super.getDeclaringType();
- }
-
- // ********** AnnotatedElement/EnumConstant implementation **********
-
- public IVariableBinding getBinding(CompilationUnit astRoot) {
- return this.getBodyDeclaration(astRoot).resolveVariable();
- }
-
- @Override
- public EnumConstantDeclaration getBodyDeclaration(CompilationUnit astRoot) {
- return this.getSelectedDeclaration(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- EnumConstantDeclaration declaration = this.getBodyDeclaration(astRoot);
- // the declaration can be null if the resource is out of sync with the file system
- return (declaration == null) ? null : ASTTools.buildTextRange(declaration.getName());
- }
-
- //As far as I can tell, enum constants are always "persistable",
- //there are no modifiers you can add to an enum constant
- public boolean isPersistable(CompilationUnit astRoot) {
- return true;
- }
-
-
- // ********** internal **********
-
- protected EnumConstantDeclaration getSelectedDeclaration(CompilationUnit astRoot) {
- String name = this.getName();
- int occurrence = this.getOccurrence();
- int count = 0;
- for (EnumConstantDeclaration enumConstantDeclaration : this.getDeclaringTypeEnumConstantDeclarations(astRoot)) {
- if (enumConstantDeclaration.getName().getFullyQualifiedName().equals(name)) {
- count++;
- if (count == occurrence) {
- return enumConstantDeclaration;
- }
- }
- }
- // return null if the field is no longer in the source code;
- // this can happen when the context model has not yet
- // been synchronized with the resource model but is still
- // asking for an ASTNode (e.g. during a selection event)
- return null;
- }
-
- protected EnumConstantDeclaration[] getDeclaringTypeEnumConstantDeclarations(CompilationUnit astRoot) {
- List<EnumConstantDeclaration> enumConstants = enumConstants(this.getDeclaringTypeDeclaration(astRoot));
- return enumConstants.toArray(new EnumConstantDeclaration[enumConstants.size()]);
- }
-
- @SuppressWarnings("unchecked")
- private static List<EnumConstantDeclaration> enumConstants(EnumDeclaration ed) {
- return ed.enumConstants();
- }
-
- protected EnumDeclaration getDeclaringTypeDeclaration(CompilationUnit astRoot) {
- return this.getDeclaringType().getBodyDeclaration(astRoot);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTFieldAttribute.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTFieldAttribute.java
deleted file mode 100644
index 45668bf042..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTFieldAttribute.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.List;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.core.utility.jdt.FieldAttribute;
-import org.eclipse.jpt.common.core.utility.jdt.Type;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-
-/**
- * Adapt and extend a JDT field.
- * Attribute based on a Java field, e.g.
- * private int foo;
- */
-public class JDTFieldAttribute
- extends JDTMember
- implements FieldAttribute
-{
-
- // ********** constructors **********
-
- public JDTFieldAttribute(
- Type declaringType,
- String name,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- this(declaringType, name, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- public JDTFieldAttribute(
- Type declaringType,
- String name,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- super(declaringType, name, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- }
-
- /**
- * constructor for testing
- */
- public JDTFieldAttribute(Type declaringType, String name, int occurrence, ICompilationUnit compilationUnit) {
- this(declaringType, name, occurrence, compilationUnit, CommandExecutor.Default.instance(), DefaultAnnotationEditFormatter.instance());
- }
-
-
- // ********** Member/Attribute/FieldAttribute implementation **********
-
- @Override
- protected Type getDeclaringType() {
- return (Type) super.getDeclaringType();
- }
-
- public IVariableBinding getBinding(CompilationUnit astRoot) {
- return this.getFragment(astRoot).resolveBinding();
- }
-
- @Override
- public FieldDeclaration getBodyDeclaration(CompilationUnit astRoot) {
- return this.getSelectedDeclaration(astRoot, FIELD_DECLARATION_SELECTOR);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- VariableDeclarationFragment fragment = this.getFragment(astRoot);
- // the fragment can be null if the resource is out of sync with the file system
- return (fragment == null) ? null : ASTTools.buildTextRange(fragment.getName());
- }
-
- public String getAttributeName() {
- return this.getName();
- }
-
- public ITypeBinding getTypeBinding(CompilationUnit astRoot) {
- return this.getBodyDeclaration(astRoot).getType().resolveBinding();
- }
-
- public boolean isField() {
- return true;
- }
-
- public boolean isPersistable(CompilationUnit astRoot) {
- IVariableBinding binding = this.getBinding(astRoot);
- return (binding == null) ? false : JPTTools.fieldIsPersistable(new JPTToolsAdapter(binding));
- }
-
-
- // ********** internal **********
-
- protected TypeDeclaration getDeclaringTypeDeclaration(CompilationUnit astRoot) {
- // assume the declaring type is not an enum or annotation
- // since they do not have field or method declarations
- return this.getDeclaringType().getBodyDeclaration(astRoot);
- }
-
- protected VariableDeclarationFragment getFragment(CompilationUnit astRoot) {
- return this.getSelectedDeclaration(astRoot, VARIABLE_DECLARATION_FRAGMENT_SELECTOR);
- }
-
- /**
- * return either a FieldDeclaration or a VariableDeclarationFragment,
- * depending on the specified selector;
- *
- * handle multiple fields declared in a single statement:
- * private int foo, bar;
- */
- protected <T extends ASTNode> T getSelectedDeclaration(CompilationUnit astRoot, Selector<T> selector) {
- String name = this.getName();
- int occurrence = this.getOccurrence();
- int count = 0;
- for (FieldDeclaration fieldDeclaration : this.getDeclaringTypeFieldDeclarations(astRoot)) {
- for (VariableDeclarationFragment fragment : fragments(fieldDeclaration)) {
- if (fragment.getName().getFullyQualifiedName().equals(name)) {
- count++;
- if (count == occurrence) {
- return selector.select(fieldDeclaration, fragment);
- }
- }
- }
- }
- // return null if the field is no longer in the source code;
- // this can happen when the context model has not yet
- // been synchronized with the resource model but is still
- // asking for an ASTNode (e.g. during a selection event)
- return null;
- }
-
- protected FieldDeclaration[] getDeclaringTypeFieldDeclarations(CompilationUnit astRoot) {
- TypeDeclaration typeDeclaration = this.getDeclaringTypeDeclaration(astRoot);
- // the declaration can be null if the resource is out of sync with the file system
- return (typeDeclaration == null) ? EMPTY_FIELD_DECLARATION_ARRAY : typeDeclaration.getFields();
- }
- protected static final FieldDeclaration[] EMPTY_FIELD_DECLARATION_ARRAY = new FieldDeclaration[0];
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected static List<VariableDeclarationFragment> fragments(FieldDeclaration fd) {
- return fd.fragments();
- }
-
-
- // ********** Selector **********
-
- // I'm not quite sure this interface is worth the resulting obfuscation,
- // but, then, I kept changing both methods, so... ~bjv
- protected interface Selector<T extends ASTNode> {
- T select(FieldDeclaration fieldDeclaration, VariableDeclarationFragment variableDeclarationFragment);
- String getDescription();
- }
-
- protected static final Selector<FieldDeclaration> FIELD_DECLARATION_SELECTOR =
- new Selector<FieldDeclaration>() {
- public FieldDeclaration select(FieldDeclaration fieldDeclaration, VariableDeclarationFragment variableDeclarationFragment) {
- return fieldDeclaration;
- }
- public String getDescription() {
- return "field declaration"; //$NON-NLS-1$
- }
- @Override
- public String toString() {
- return "FIELD_DECLARATION_SELECTOR"; //$NON-NLS-1$
- }
- };
-
- protected static final Selector<VariableDeclarationFragment> VARIABLE_DECLARATION_FRAGMENT_SELECTOR =
- new Selector<VariableDeclarationFragment>() {
- public VariableDeclarationFragment select(FieldDeclaration fieldDeclaration, VariableDeclarationFragment variableDeclarationFragment) {
- return variableDeclarationFragment;
- }
- public String getDescription() {
- return "variable declaration fragment"; //$NON-NLS-1$
- }
- @Override
- public String toString() {
- return "VARIABLE_DECLARATION_FRAGMENT_SELECTOR"; //$NON-NLS-1$
- }
- };
-
-
- // ********** JPTTools adapter **********
-
- /**
- * JPTTools needs an adapter so it can work with either an IField
- * or an IVariableBinding etc.
- */
- protected static class JPTToolsAdapter implements JPTTools.FieldAdapter {
- private final IVariableBinding fieldBinding;
-
- protected JPTToolsAdapter(IVariableBinding fieldBinding) {
- super();
- if (fieldBinding == null) {
- throw new NullPointerException();
- }
- this.fieldBinding = fieldBinding;
- }
-
- public int getModifiers() {
- return this.fieldBinding.getModifiers();
- }
-
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTMember.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTMember.java
deleted file mode 100644
index 609e79756f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTMember.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.jdt.AbstractType;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-
-/**
- * Adapt and extend a JDT member with simplified annotation handling.
- */
-public abstract class JDTMember extends JDTAnnotatedElement
- implements Member
-{
-
- /** this will be null for the primary type */
- private final AbstractType declaringType;
-
- /**
- * members can occur more than once in non-compiling source;
- * count starts at 1; the primary type will have occurrence 1
- */
- private final int occurrence;
-
-
- // ********** constructors **********
-
- protected JDTMember(
- AbstractType declaringType,
- String name,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- this(declaringType, name, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- protected JDTMember(
- AbstractType declaringType,
- String name,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- super(name, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- this.declaringType = declaringType;
- this.occurrence = occurrence;
- }
-
- //covariant override
- public abstract BodyDeclaration getBodyDeclaration(CompilationUnit astRoot);
-
-
- // ********** Member implementation **********
-
- @Override
- public ModifiedDeclaration getModifiedDeclaration(CompilationUnit astRoot) {
- return new JDTModifiedDeclaration(this.getBodyDeclaration(astRoot));
- }
-
- public boolean matches(String memberName, int occur) {
- return memberName.equals(this.getName()) && (occur == this.occurrence);
- }
-
-
- // ********** internal **********
-
- protected int getOccurrence() {
- return this.occurrence;
- }
-
- /**
- * this will return null for a top-level type
- */
- protected AbstractType getDeclaringType() {
- return this.declaringType;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTMethodAttribute.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTMethodAttribute.java
deleted file mode 100644
index 17d31b430d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTMethodAttribute.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.Arrays;
-import java.util.List;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.core.utility.jdt.MethodAttribute;
-import org.eclipse.jpt.common.core.utility.jdt.Type;
-import org.eclipse.jpt.common.utility.JavaType;
-import org.eclipse.jpt.common.utility.MethodSignature;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.internal.NameTools;
-import org.eclipse.jpt.common.utility.internal.SimpleMethodSignature;
-
-/**
- * Adapt and extend a JDT method.
- * Attribute based on a Java property, e.g.
- * private int getFoo() {
- * return foo;
- * }
- * private void setFoo(int foo) {
- * this.foo = foo;
- * }
- */
-public class JDTMethodAttribute
- extends JDTMember
- implements MethodAttribute
-{
- /** we need the parameter types to build the method signature */
- private final JavaType[] parameterTypes;
-
-
- // ********** constructors **********
-
- public static JDTMethodAttribute newInstance(
- Type declaringType,
- MethodSignature signature,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- return newInstance(declaringType, signature, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- public static JDTMethodAttribute newInstance(
- Type declaringType,
- MethodSignature signature,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- return new JDTMethodAttribute(declaringType, signature, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- }
-
- private JDTMethodAttribute(
- Type declaringType,
- MethodSignature methodSignature,
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- super(declaringType, methodSignature.getName(), occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- this.parameterTypes = methodSignature.getParameterTypes();
- }
-
- /**
- * constructor for testing
- */
- public JDTMethodAttribute(Type declaringType, String name, String[] parameterTypeNames, int occurrence, ICompilationUnit compilationUnit) {
- this(declaringType, new SimpleMethodSignature(name, parameterTypeNames), occurrence, compilationUnit, CommandExecutor.Default.instance(), DefaultAnnotationEditFormatter.instance());
- }
-
-
- // ********** Member/Attribute/MethodAttribute implementation **********
-
- @Override
- protected Type getDeclaringType() {
- return (Type) super.getDeclaringType();
- }
-
- public boolean isField() {
- return false;
- }
-
- public IMethodBinding getBinding(CompilationUnit astRoot) {
- return this.getBodyDeclaration(astRoot).resolveBinding();
- }
-
- @Override
- public MethodDeclaration getBodyDeclaration(CompilationUnit astRoot) {
- int count = 0;
- for (MethodDeclaration methodDeclaration : this.getDeclaringTypeMethodDeclarations(astRoot)) {
- if (this.matches(methodDeclaration)) {
- count++;
- if (count == this.getOccurrence()) {
- return methodDeclaration;
- }
- }
- }
- // return null if the method is no longer in the source code;
- // this can happen when the context model has not yet
- // been synchronized with the resource model but is still
- // asking for an ASTNode (e.g. during a selection event)
- return null;
- }
-
- public boolean matches(MethodSignature signature, int occurrence) {
- return this.matches(signature) && (occurrence == this.getOccurrence());
- }
-
- protected boolean matches(MethodSignature signature) {
- return signature.getName().equals(this.getName())
- && Arrays.equals(this.parameterTypes, signature.getParameterTypes());
- }
-
- protected boolean matches(MethodDeclaration methodDeclaration) {
- return this.matches(ASTTools.buildMethodSignature(methodDeclaration));
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected static List<SingleVariableDeclaration> parameters(MethodDeclaration methodDeclaration) {
- return methodDeclaration.parameters();
- }
-
- @Override
- public boolean matches(String memberName, int occurrence) {
- throw new UnsupportedOperationException("Use #matches(MethodSignature, int)."); //$NON-NLS-1$
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- MethodDeclaration methodDeclaration = this.getBodyDeclaration(astRoot);
- // the declaration can be null if the resource is out of sync with the file system
- return (methodDeclaration == null) ? null : ASTTools.buildTextRange(methodDeclaration.getName());
- }
-
- /**
- * return "foo" for a method named "getFoo", "isFoo", "setFoo"
- */
- public String getAttributeName() {
- return NameTools.convertGetterSetterMethodNameToPropertyName(this.getName());
- }
-
- public ITypeBinding getTypeBinding(CompilationUnit astRoot) {
- IMethodBinding methodBinding = getBodyDeclaration(astRoot).resolveBinding();
- return (methodBinding == null) ? null : methodBinding.getReturnType();
- }
-
- public boolean isPersistable(CompilationUnit astRoot) {
- IMethodBinding binding = this.getBinding(astRoot);
- return (binding == null) ? false : JPTTools.methodIsPersistablePropertyGetter(new JPTToolsAdapter(binding));
- }
-
-
- // ********** internal **********
-
- protected TypeDeclaration getDeclaringTypeDeclaration(CompilationUnit astRoot) {
- // assume the declaring type is not an enum or annotation
- // since they do not have field or method declarations
- return this.getDeclaringType().getBodyDeclaration(astRoot);
- }
-
- protected MethodDeclaration[] getDeclaringTypeMethodDeclarations(CompilationUnit astRoot) {
- TypeDeclaration typeDeclaration = this.getDeclaringTypeDeclaration(astRoot);
- // the declaration can be null if the resource is out of sync with the file system
- return (typeDeclaration == null) ? EMPTY_METHOD_DECLARATION_ARRAY : typeDeclaration.getMethods();
- }
- protected static final MethodDeclaration[] EMPTY_METHOD_DECLARATION_ARRAY = new MethodDeclaration[0];
-
-
- // ********** JPTTools adapter **********
-
- /**
- * JPTTools needs an adapter so it can work with either an IMethod
- * or an IMethodBinding etc.
- */
- protected static class SimpleJPTToolsAdapter
- implements JPTTools.SimpleMethodAdapter
- {
- protected final IMethodBinding methodBinding;
-
- protected SimpleJPTToolsAdapter(IMethodBinding methodBinding) {
- super();
- if (methodBinding == null) {
- throw new NullPointerException();
- }
- this.methodBinding = methodBinding;
- }
-
- public int getModifiers() {
- return this.methodBinding.getModifiers();
- }
-
- public String getReturnTypeErasureName() {
- ITypeBinding returnType = this.methodBinding.getReturnType();
- return (returnType == null) ? null : returnType.getTypeDeclaration().getErasure().getQualifiedName();
- }
-
- public boolean isConstructor() {
- return this.methodBinding.isConstructor();
- }
- }
-
- protected static class JPTToolsAdapter
- extends SimpleJPTToolsAdapter
- implements JPTTools.MethodAdapter
- {
- protected JPTToolsAdapter(IMethodBinding methodBinding) {
- super(methodBinding);
- }
-
- public String getName() {
- return this.methodBinding.getName();
- }
-
- public int getParametersLength() {
- return this.methodBinding.getParameterTypes().length;
- }
-
- public JPTTools.SimpleMethodAdapter getSibling(String name) {
- ITypeBinding typeBinding = this.methodBinding.getDeclaringClass();
- if (typeBinding == null) {
- return null;
- }
- for (IMethodBinding sibling : typeBinding.getDeclaredMethods()) {
- if ((sibling.getParameterTypes().length == 0)
- && sibling.getName().equals(name)) {
- return new SimpleJPTToolsAdapter(sibling);
- }
- }
- return null;
- }
-
- public JPTTools.SimpleMethodAdapter getSibling(String name, String parameterTypeErasureName) {
- ITypeBinding typeBinding = this.methodBinding.getDeclaringClass();
- if (typeBinding == null) {
- return null;
- }
- for (IMethodBinding sibling : typeBinding.getDeclaredMethods()) {
- ITypeBinding[] siblingParmTypes = sibling.getParameterTypes();
- if ((siblingParmTypes.length == 1)
- && sibling.getName().equals(name)
- && siblingParmTypes[0].getTypeDeclaration().getErasure().getQualifiedName().equals(parameterTypeErasureName)) {
- return new SimpleJPTToolsAdapter(sibling);
- }
- }
- return null;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTModifiedDeclaration.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTModifiedDeclaration.java
deleted file mode 100644
index 6e67e46fbc..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTModifiedDeclaration.java
+++ /dev/null
@@ -1,584 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IExtendedModifier;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.ImportDeclaration;
-import org.eclipse.jdt.core.dom.PackageDeclaration;
-import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
-import org.eclipse.jdt.core.dom.VariableDeclarationExpression;
-import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.SubIteratorWrapper;
-
-/**
- * Wrap any of the AST nodes that have modifiers (specifically, annotations);
- * i.e. BodyDeclaration, SingleVariableDeclaration, VariableDeclarationExpression,
- * and VariableDeclarationStatement.
- */
-public class JDTModifiedDeclaration
- implements ModifiedDeclaration
-{
- private final Adapter adapter;
-
-
- // ********** constructors **********
-
- public JDTModifiedDeclaration(Adapter adapter) {
- super();
- this.adapter = adapter;
- }
-
- public JDTModifiedDeclaration(BodyDeclaration declaration) {
- this(new BodyDeclarationAdapter(declaration));
- }
-
- public JDTModifiedDeclaration(PackageDeclaration declaration) {
- this(new PackageDeclarationAdapter(declaration));
- }
-
- public JDTModifiedDeclaration(SingleVariableDeclaration declaration) {
- this(new SingleVariableDeclarationAdapter(declaration));
- }
-
- public JDTModifiedDeclaration(VariableDeclarationExpression declaration) {
- this(new VariableDeclarationExpressionAdapter(declaration));
- }
-
- public JDTModifiedDeclaration(VariableDeclarationStatement declaration) {
- this(new VariableDeclarationStatementAdapter(declaration));
- }
-
-
- // ********** annotations **********
-
- public Annotation getAnnotationNamed(String annotationName) {
- for (Iterator<Annotation> stream = this.annotations(); stream.hasNext(); ) {
- Annotation annotation = stream.next();
- if (this.annotationIsNamed(annotation, annotationName)) {
- return annotation;
- }
- }
- return null;
- }
-
- public void removeAnnotationNamed(String annotationName) {
- for (Iterator<IExtendedModifier> stream = this.getModifiers().iterator(); stream.hasNext(); ) {
- IExtendedModifier modifier = stream.next();
- if (modifier.isAnnotation()) {
- if (this.annotationIsNamed((Annotation) modifier, annotationName)) {
- stream.remove();
- break;
- }
- }
- }
- }
-
- public void replaceAnnotationNamed(String oldAnnotationName, Annotation newAnnotation) {
- List<IExtendedModifier> modifiers = this.getModifiers();
- for (ListIterator<IExtendedModifier> stream = modifiers.listIterator(); stream.hasNext(); ) {
- IExtendedModifier modifier = stream.next();
- if (modifier.isAnnotation()) {
- if (this.annotationIsNamed((Annotation) modifier, oldAnnotationName)) {
- stream.set(newAnnotation);
- return;
- }
- }
- }
- this.addAnnotation(newAnnotation);
- }
-
- /**
- * Add the specified annotation to the declaration.
- * By convention annotations precede the "standard" (JLS2) modifiers;
- * though, technically, they can be interspersed.
- */
- protected void addAnnotation(Annotation annotation) {
- List<IExtendedModifier> modifiers = this.getModifiers();
- for (ListIterator<IExtendedModifier> stream = modifiers.listIterator(); stream.hasNext(); ) {
- if (stream.next().isModifier()) {
- stream.previous(); // put the annotation *before* the first "standard" (JLS2) modifier
- stream.add(annotation);
- return;
- }
- }
- modifiers.add(annotation); // just tack it on to the end
- }
-
- /**
- * Return the declaration's annotations.
- */
- protected Iterator<Annotation> annotations() {
- return new SubIteratorWrapper<IExtendedModifier, Annotation>(this.annotations_());
- }
-
- protected Iterator<IExtendedModifier> annotations_() {
- return new FilteringIterator<IExtendedModifier>(this.getModifiers().iterator()) {
- @Override
- protected boolean accept(IExtendedModifier next) {
- return next.isAnnotation();
- }
- };
- }
-
-
- // ********** add import **********
-
- public boolean addImport(String className) {
- if (className.indexOf('.') == -1) {
- return true; // the class is in the default package - no need for import
- }
- return this.addImport(className, false);
- }
-
- public boolean addStaticImport(String enumConstantName) {
- int index1 = enumConstantName.indexOf('.');
- if (index1 == -1) {
- throw new IllegalArgumentException(enumConstantName); // shouldn't happen?
- }
- int index2 = enumConstantName.indexOf('.', index1 + 1);
- if (index2 == -1) {
- return true; // the enum is in the default package - no need for import
- }
- return this.addImport(enumConstantName, true);
- }
-
- public boolean addImport(String importName, boolean staticImport) {
- Boolean include = this.importsInclude(importName, staticImport);
- if (include != null) {
- return include.booleanValue();
- }
-
- ImportDeclaration importDeclaration = this.getAst().newImportDeclaration();
- importDeclaration.setName(this.getAst().newName(importName));
- importDeclaration.setStatic(staticImport);
- this.getImports().add(importDeclaration);
- return true;
- }
-
- /**
- * Just a bit hacky:
- * Return Boolean.TRUE if the import is already present.
- * Return Boolean.FALSE if a colliding import is already present.
- * Return null if a new import may be added.
- * This hackery allows us to loop through the imports only once
- * (and compose our methods).
- * Pre-condition: 'importName' is not in the "default" package (i.e. it *is* qualified)
- */
- protected Boolean importsInclude(String importName, boolean staticImport) {
- int period = importName.lastIndexOf('.'); // should not be -1
- String importNameQualifier = importName.substring(0, period);
- String shortImportName = importName.substring(period + 1);
- return this.importsInclude(importName, importNameQualifier, shortImportName, staticImport);
- }
-
- /**
- * pre-calculate the qualifier and short name
- */
- protected Boolean importsInclude(String importName, String importNameQualifier, String shortImportName, boolean staticImport) {
- for (ImportDeclaration importDeclaration : this.getImports()) {
- if (importDeclaration.isStatic() == staticImport) {
- Boolean match = this.importMatches(importDeclaration, importName, importNameQualifier, shortImportName);
- if (match != null) {
- return match;
- }
- }
- }
- return null;
- }
-
- /**
- * we should be able to rely on the JDT model here, since we are looking
- * at objects that should not be changing underneath us...
- */
- protected Boolean importMatches(ImportDeclaration importDeclaration, String importName, String importNameQualifier, String shortImportName) {
- // examples:
- // 'importName' is "java.util.Date"
- // or
- // 'importName' is "java.lang.annotation.ElementType.TYPE"
- String idn = importDeclaration.getName().getFullyQualifiedName();
- if (importName.equals(idn)) {
- // import java.util.Date; => "Date" will resolve to "java.util.Date"
- // import static java.lang.annotation.ElementType.TYPE; => "TYPE" will resolve to "java.lang.annotation.ElementType.TYPE"
- return Boolean.TRUE;
- }
-
- String shortIDN = idn.substring(idn.lastIndexOf('.') + 1);
- if (shortImportName.equals(shortIDN)) {
- // import java.sql.Date; => ambiguous resolution of "Date"
- // import static org.foo.Bar.TYPE; => ambiguous resolution of "TYPE"
- return Boolean.FALSE;
- }
-
- if (importDeclaration.isOnDemand()) {
- if (importNameQualifier.equals(idn)) {
- // import java.util.*; => "Date" will resolve to "java.util.Date"
- // import static java.lang.annotation.ElementType.*; => "TYPE" will resolve to "java.lang.annotation.ElementType.TYPE"
- return Boolean.TRUE;
- }
- if (importDeclaration.isStatic()) {
- if (this.enumResolves(idn, shortImportName)) {
- // import static org.foo.Bar.*; => ambiguous resolution of "TYPE"
- return Boolean.FALSE;
- }
- } else {
- if (this.typeResolves(idn + '.' + shortImportName)) {
- // import java.sql.*; => ambiguous resolution of "Date"
- return Boolean.FALSE;
- }
- }
- }
- // no matches - OK to add explicit import
- return null;
- }
-
- protected boolean enumResolves(String enumTypeName, String enumConstantName) {
- try {
- return this.enumResolves_(enumTypeName, enumConstantName);
- } catch (JavaModelException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- protected boolean enumResolves_(String enumTypeName, String enumConstantName) throws JavaModelException {
- IType jdtType = this.findType_(enumTypeName);
- if (jdtType == null) {
- return false;
- }
- if ( ! jdtType.isEnum()) {
- return false;
- }
- for (IField jdtField : jdtType.getFields()) {
- if (jdtField.isEnumConstant() && jdtField.getElementName().equals(enumConstantName)) {
- return true;
- }
- }
- return false;
- }
-
- protected boolean typeResolves(String name) {
- return this.findType(name) != null;
- }
-
- protected IType findType(String name) {
- try {
- return this.findType_(name);
- } catch (JavaModelException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- protected IType findType_(String name) throws JavaModelException {
- return this.getCompilationUnit().getJavaElement().getJavaProject().findType(name);
- }
-
- protected List<ImportDeclaration> getImports() {
- return this.imports(this.getCompilationUnit());
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected List<ImportDeclaration> imports(CompilationUnit astRoot) {
- return astRoot.imports();
- }
-
-
- // ********** annotation name resolution **********
-
- public boolean annotationIsNamed(Annotation annotation, String name) {
- return this.getQualifiedName(annotation).equals(name);
- }
-
- /**
- * Simply return the annotation's unqualified name if we can't "resolve" it.
- */
- protected String getQualifiedName(Annotation annotation) {
- ITypeBinding typeBinding = annotation.resolveTypeBinding();
- if (typeBinding != null) {
- String resolvedName = typeBinding.getQualifiedName();
- if (resolvedName != null) {
- return resolvedName;
- }
- }
- // hack(?): check for a matching import because when moving a stand-alone
- // annotation to its container in CombinationIndexedDeclarationAnnotationAdapter
- // the container's import is added but then it won't "resolve" upon
- // subsequent lookups (because the parser hasn't had time to run?)... :-(
- return this.convertToFullClassName(annotation.getTypeName().getFullyQualifiedName());
- }
-
- /**
- * If necessary, use the declaration's imports to calculate a guess as to
- * the specified name's fully-qualified form.
- * Simply return the unqualified name if we can't "resolve" it.
- */
- protected String convertToFullClassName(String name) {
- // check for fully-qualified name
- return (name.lastIndexOf('.') != -1) ? name : this.resolveAgainstImports(name, false);
- }
-
- /**
- * If necessary, use the declaration's imports to calculate a guess as to
- * the specified name's fully-qualified form.
- * Simply return the unqualified name if we can't "resolve" it.
- */
- protected String convertToFullEnumConstantName(String name) {
- int index1 = name.indexOf('.');
- if (index1 == -1) {
- // short name, e.g. "TYPE"
- // true = look for static import of enum constant
- return this.resolveAgainstImports(name, true);
- }
-
- int index2 = name.indexOf('.', index1 + 1);
- if (index2 == -1) {
- // partially-qualified name, e.g. "ElementType.TYPE"
- // false = look regular import of enum class, not static import of enum constant
- return this.resolveAgainstImports(name, false);
- }
-
- // fully-qualified name, e.g. "java.lang.annotation.ElementType.TYPE"
- return name;
- }
-
- /**
- * Attempt to resolve the specified "short" name against the declaration's
- * imports. Return the name unchanged if we can't resolve it (perhaps it is
- * in the "default" package).
- */
- protected String resolveAgainstImports(String shortName, boolean static_) {
- for (ImportDeclaration importDeclaration : this.getImports()) {
- if (importDeclaration.isStatic() == static_) {
- String resolvedName = this.resolveAgainstImport(importDeclaration, shortName);
- if (resolvedName != null) {
- return resolvedName;
- }
- }
- }
- return shortName; // "default" package or unknown
- }
-
- /**
- * Attempt to resolve the specified "short" name against the specified
- * import. Return the resolved name if the import resolves it; otherwise
- * return null.
- */
- protected String resolveAgainstImport(ImportDeclaration importDeclaration, String shortName) {
- String idn = importDeclaration.getName().getFullyQualifiedName();
- if (importDeclaration.isOnDemand()) {
- String candidate = idn + '.' + shortName;
- if (importDeclaration.isStatic()) {
- if (this.enumResolves(idn, shortName)) {
- return candidate;
- }
- } else {
- if (this.typeResolves(candidate)) {
- return candidate;
- }
- }
- // no match
- return null;
- }
-
- // explicit import - see whether its end matches 'shortName'
- int period = idn.length() - shortName.length() - 1;
- if (period < 1) {
- // something must precede period
- return null;
- }
- if ((idn.charAt(period) == '.') && idn.endsWith(shortName)) {
- return idn; // probable exact match
- }
- return null;
- }
-
-
- // ********** miscellaneous methods **********
-
- public ASTNode getDeclaration() {
- return this.adapter.getDeclaration();
- }
-
- /**
- * Return the declaration's list of modifiers.
- * Element type: org.eclipse.jdt.core.dom.IExtendedModifier
- */
- protected List<IExtendedModifier> getModifiers() {
- return this.adapter.getModifiers();
- }
-
- public AST getAst() {
- return this.getDeclaration().getAST();
- }
-
- protected CompilationUnit getCompilationUnit() {
- return (CompilationUnit) this.getDeclaration().getRoot();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.adapter.toString());
- }
-
-
- // ********** declaration adapter interface and implementations **********
-
- /**
- * Define common protocol among the various "declarations".
- */
- public interface Adapter {
-
- /**
- * Return the adapted "declaration".
- */
- ASTNode getDeclaration();
-
- /**
- * Return the "declaration"'s list of modifiers.
- * Element type: org.eclipse.jdt.core.dom.IExtendedModifier
- */
- List<IExtendedModifier> getModifiers();
-
- }
-
- public static class BodyDeclarationAdapter implements Adapter {
- private final BodyDeclaration declaration;
- public BodyDeclarationAdapter(BodyDeclaration declaration) {
- super();
- this.declaration = declaration;
- }
- public ASTNode getDeclaration() {
- return this.declaration;
- }
- @SuppressWarnings("unchecked")
- public List<IExtendedModifier> getModifiers() {
- return this.declaration.modifiers();
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.declaration.toString());
- }
- }
-
- public static class PackageDeclarationAdapter implements Adapter {
- private final PackageDeclaration declaration;
- public PackageDeclarationAdapter(PackageDeclaration declaration) {
- super();
- this.declaration = declaration;
- }
- public ASTNode getDeclaration() {
- return this.declaration;
- }
- @SuppressWarnings("unchecked")
- public List<IExtendedModifier> getModifiers() {
- return this.declaration.annotations();
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.declaration.toString());
- }
- }
-
- /*public static class ASTNodeAdapter implements Adapter {
- private final ASTNode declaration;
- public ASTNodeAdapter(ASTNode declaration) {
- super();
- this.declaration = declaration;
- }
- public ASTNode getDeclaration() {
- return this.declaration;
- }
- @SuppressWarnings("unchecked")
- public List<IExtendedModifier> getModifiers() {
- if (declaration instanceof BodyDeclaration) {
- return ((BodyDeclaration) declaration).modifiers();
- } else if (declaration instanceof PackageDeclaration) {
- return ((PackageDeclaration) declaration).annotations();
- }
- return Collections.emptyList();
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.declaration.toString());
- }
- }*/
-
- public static class SingleVariableDeclarationAdapter implements Adapter {
- private final SingleVariableDeclaration declaration;
- public SingleVariableDeclarationAdapter(SingleVariableDeclaration declaration) {
- super();
- this.declaration = declaration;
- }
- public ASTNode getDeclaration() {
- return this.declaration;
- }
- @SuppressWarnings("unchecked")
- public List<IExtendedModifier> getModifiers() {
- return this.declaration.modifiers();
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.declaration.toString());
- }
- }
-
- public static class VariableDeclarationExpressionAdapter implements Adapter {
- private final VariableDeclarationExpression declaration;
- public VariableDeclarationExpressionAdapter(VariableDeclarationExpression declaration) {
- super();
- this.declaration = declaration;
- }
- public ASTNode getDeclaration() {
- return this.declaration;
- }
- @SuppressWarnings("unchecked")
- public List<IExtendedModifier> getModifiers() {
- return this.declaration.modifiers();
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.declaration.toString());
- }
- }
-
- public static class VariableDeclarationStatementAdapter implements Adapter {
- private final VariableDeclarationStatement declaration;
- public VariableDeclarationStatementAdapter(VariableDeclarationStatement declaration) {
- super();
- this.declaration = declaration;
- }
- public ASTNode getDeclaration() {
- return this.declaration;
- }
- @SuppressWarnings("unchecked")
- public List<IExtendedModifier> getModifiers() {
- return this.declaration.modifiers();
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.declaration.toString());
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTPackage.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTPackage.java
deleted file mode 100644
index 3057928eaf..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTPackage.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Red Hat, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- * Oracle
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IPackageBinding;
-import org.eclipse.jdt.core.dom.PackageDeclaration;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedPackage;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-
-public class JDTPackage
- extends JDTAnnotatedElement
- implements AnnotatedPackage
-{
- protected JDTPackage(PackageDeclaration declaringPackage,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- super(declaringPackage.getName().getFullyQualifiedName(),
- compilationUnit,
- modifySharedDocumentCommandExecutor);
- }
-
- public JDTPackage(
- PackageDeclaration declaringPackage,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- super(declaringPackage.getName().getFullyQualifiedName(),
- compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- }
-
- @Override
- public ModifiedDeclaration getModifiedDeclaration(CompilationUnit astRoot) {
- return new JDTModifiedDeclaration(this.getBodyDeclaration(astRoot));
- }
-
- public IPackageBinding getBinding(CompilationUnit astRoot) {
- PackageDeclaration pd = this.getBodyDeclaration(astRoot);
- return (pd == null) ? null : pd.resolveBinding();
- }
-
- public PackageDeclaration getBodyDeclaration(CompilationUnit astRoot) {
- return astRoot.getPackage();
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return ASTTools.buildTextRange(this.getBodyDeclaration(astRoot).getName());
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTType.java
deleted file mode 100644
index 48d3da117e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JDTType.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.List;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.core.utility.jdt.Type;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-
-/**
- * Adapt and extend a JDT type.
- */
-public class JDTType
- extends AbstractJDTType
- implements Type
-{
-
- /**
- * constructor for the compilation unit's primary type
- */
- public JDTType(
- TypeDeclaration typeDeclaration, // exclude annotations and enums
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- this(typeDeclaration, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- /**
- * constructor for the compilation unit's primary type
- */
- public JDTType(
- TypeDeclaration typeDeclaration, // exclude annotations and enums
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- this(null, typeDeclaration, 1, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- }
-
- /**
- * constructor for nested types
- */
- public JDTType(
- Type declaringType,
- TypeDeclaration typeDeclaration, // exclude annotations and enums
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor) {
- this(declaringType, typeDeclaration, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, DefaultAnnotationEditFormatter.instance());
- }
-
- /**
- * constructor for nested types
- */
- public JDTType(
- Type declaringType,
- TypeDeclaration typeDeclaration, // exclude annotations and enums
- int occurrence,
- ICompilationUnit compilationUnit,
- CommandExecutor modifySharedDocumentCommandExecutor,
- AnnotationEditFormatter annotationEditFormatter) {
- super(declaringType, typeDeclaration, occurrence, compilationUnit, modifySharedDocumentCommandExecutor, annotationEditFormatter);
- }
-
- /**
- * constructor for testing
- */
- public JDTType(Type declaringType, String name, int occurrence, ICompilationUnit compilationUnit) {
- super(declaringType, name, occurrence, compilationUnit);
- }
-
-
- // ********** Member/Type implementation **********
-
- /**
- * find the type's body declaration in the specified AST
- */
- @Override
- public TypeDeclaration getBodyDeclaration(CompilationUnit astRoot) {
- return (TypeDeclaration) super.getBodyDeclaration(astRoot);
- }
-
- public boolean isPersistable(CompilationUnit astRoot) {
- ITypeBinding binding = this.getBinding(astRoot);
- return (binding == null) ? false : JPTTools.typeIsPersistable(new JPTToolsAdapter(binding));
- }
-
- public TypeDeclaration[] getTypes(CompilationUnit astRoot) {
- return this.getBodyDeclaration(astRoot).getTypes();
- }
-
- public EnumDeclaration[] getEnums(CompilationUnit astRoot) {
- return getEnums(this.getBodyDeclaration(astRoot));
- }
-
- public FieldDeclaration[] getFields(CompilationUnit astRoot) {
- return this.getBodyDeclaration(astRoot).getFields();
- }
-
- public MethodDeclaration[] getMethods(CompilationUnit astRoot) {
- return this.getBodyDeclaration(astRoot).getMethods();
- }
-
-
- // ********** internal **********
-
- /**
- * return the first top-level type in the specified AST with a matching name
- */
- @Override
- protected TypeDeclaration getTopLevelTypeDeclaration(CompilationUnit astRoot) {
- return (TypeDeclaration) super.getTopLevelTypeDeclaration(astRoot);
- }
-
- @Override
- protected TypeDeclaration getTypeDeclaration(List<AbstractTypeDeclaration> typeDeclarations) {
- return (TypeDeclaration) super.getTypeDeclaration(typeDeclarations);
- }
-
- /**
- * return the nested type with a matching name and occurrence
- */
- @Override
- protected TypeDeclaration getNestedTypeDeclaration(TypeDeclaration declaringTypeDeclaration) {
- return this.getTypeDeclaration(declaringTypeDeclaration.getTypes());
- }
-
- /**
- * return the type declaration corresponding to the type from the specified
- * set of type declarations (match name and occurrence)
- */
- @Override
- protected TypeDeclaration getTypeDeclaration(AbstractTypeDeclaration[] typeDeclarations) {
- return (TypeDeclaration) super.getTypeDeclaration(typeDeclarations);
- }
-
- @Override
- protected int getASTNodeType() {
- return ASTNode.TYPE_DECLARATION;
- }
-
-
- // ********** JPT tools adapter **********
-
- protected static class JPTToolsAdapter
- implements JPTTools.TypeAdapter
- {
- private final ITypeBinding typeBinding;
- protected JPTToolsAdapter(ITypeBinding typeBinding) {
- super();
- if (typeBinding == null) {
- throw new NullPointerException();
- }
- this.typeBinding = typeBinding;
- }
-
- public int getModifiers() {
- return this.typeBinding.getModifiers();
- }
-
- public boolean isAnnotation() {
- return this.typeBinding.isAnnotation();
- }
-
- public boolean isAnonymous() {
- return this.typeBinding.isAnonymous();
- }
-
- public boolean isArray() {
- return this.typeBinding.isArray();
- }
-
- public boolean isEnum() {
- return this.typeBinding.isEnum();
- }
-
- public boolean isInterface() {
- return this.typeBinding.isInterface();
- }
-
- public boolean isLocal() {
- return this.typeBinding.isLocal();
- }
-
- public boolean isMember() {
- return this.typeBinding.isMember();
- }
-
- public boolean isPrimitive() {
- return this.typeBinding.isPrimitive();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JPTTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JPTTools.java
deleted file mode 100644
index f1930c829c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/JPTTools.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.lang.reflect.Modifier;
-
-/**
- * Convenience methods for JPA-related queries concerning JDT objects.
- */
-//TODO this needs to move because it is only used for JPA
-public class JPTTools {
-
- // ********** type **********
-
- /**
- * Return whether the specified type can be "persisted", i.e. marked as
- * Entity, MappedSuperclass, Embeddable
- */
- public static boolean typeIsPersistable(TypeAdapter typeAdapter) {
- if (typeAdapter.isInterface()) {
- return false;
- }
- if (typeAdapter.isAnnotation()) {
- return false;
- }
- if (typeAdapter.isEnum()) {
- return false;
- }
- if (typeAdapter.isLocal()) {
- return false;
- }
- if (typeAdapter.isAnonymous()) {
- return false;
- }
- if (typeAdapter.isPrimitive()) {
- return false; // should never get here(?)
- }
- if (typeAdapter.isArray()) {
- return false; // should never get here(?)
- }
- return true;
- }
-
- /**
- * Queries needed to calculate whether a type is "persistable".
- * Adapted to ITypeBinding and IType.
- */
- public interface TypeAdapter {
- int getModifiers();
- boolean isAnnotation();
- boolean isAnonymous();
- boolean isArray();
- boolean isEnum();
- boolean isInterface();
- boolean isLocal();
- boolean isMember();
- boolean isPrimitive();
- }
-
-
- // ********** field **********
-
- /**
- * Return whether the specified field may be "persisted".
- * According to the spec, "All non-transient instance variables that are not
- * annotated with the Transient annotation are persistent."
- */
- public static boolean fieldIsPersistable(FieldAdapter fieldAdapter) {
- int modifiers = fieldAdapter.getModifiers();
- if (Modifier.isStatic(modifiers)) {
- return false;
- }
- if (Modifier.isTransient(modifiers)) {
- return false;
- }
- return true;
- }
-
- /**
- * Queries needed to calculate whether a field is "persistable".
- * Adapted to IVariableBinding and IField.
- */
- public interface FieldAdapter {
- /**
- * Return the field's modifiers. We use these to check whether the
- * field is static or transient.
- */
- int getModifiers();
- }
-
-
- // ********** method **********
-
- /**
- * Return whether the specified method is a "getter" method that
- * represents a property that may be "persisted".
- */
- public static boolean methodIsPersistablePropertyGetter(MethodAdapter methodAdapter) {
- if (methodHasInvalidModifiers(methodAdapter)) {
- return false;
- }
- if (methodAdapter.isConstructor()) {
- return false;
- }
-
- String returnTypeName = methodAdapter.getReturnTypeErasureName();
- if (returnTypeName == null) {
- return false; // DOM method bindings can have a null name
- }
- if (returnTypeName.equals("void")) { //$NON-NLS-1$
- return false;
- }
- if (methodHasParameters(methodAdapter)) {
- return false;
- }
-
- String name = methodAdapter.getName();
- int beginIndex = 0;
- boolean booleanGetter = false;
- if (name.startsWith("is")) { //$NON-NLS-1$
- if (returnTypeName.equals("boolean")) { //$NON-NLS-1$
- beginIndex = 2;
- } else {
- return false;
- }
- } else if (name.startsWith("get")) { //$NON-NLS-1$
- beginIndex = 3;
- if (returnTypeName.equals("boolean")) { //$NON-NLS-1$
- booleanGetter = true;
- }
- } else {
- return false;
- }
-
- String capitalizedAttributeName = name.substring(beginIndex);
- // if the type has both methods:
- // boolean isProperty()
- // boolean getProperty()
- // then #isProperty() takes precedence and we ignore #getProperty();
- // but only having #getProperty() is OK too
- // (see the JavaBeans spec 1.01)
- if (booleanGetter && methodHasValidSiblingIsMethod(methodAdapter, capitalizedAttributeName)) {
- return false; // since the type also defines #isProperty(), ignore #getProperty()
- }
- return methodHasValidSiblingSetMethod(methodAdapter, capitalizedAttributeName, returnTypeName);
- }
-
- /**
- * Return whether the method's modifiers prevent it
- * from being a getter or setter for a "persistent" property.
- */
- private static boolean methodHasInvalidModifiers(SimpleMethodAdapter methodAdapter) {
- int modifiers = methodAdapter.getModifiers();
- if (Modifier.isStatic(modifiers)) {
- return true;
- }
- return false;
- }
-
- private static boolean methodHasParameters(MethodAdapter methodAdapter) {
- return methodAdapter.getParametersLength() != 0;
- }
-
- /**
- * Return whether the method has a sibling "is" method for the specified
- * property and that method is valid for a "persistable" property.
- * Pre-condition: the method is a "boolean getter" (e.g. 'public boolean getProperty()');
- * this prevents us from returning true when the method itself is an
- * "is" method.
- */
- private static boolean methodHasValidSiblingIsMethod(MethodAdapter methodAdapter, String capitalizedAttributeName) {
- SimpleMethodAdapter isMethodAdapter = methodAdapter.getSibling("is" + capitalizedAttributeName); //$NON-NLS-1$
- return methodIsValidSibling(isMethodAdapter, "boolean"); //$NON-NLS-1$
- }
-
- /**
- * Return whether the method has a sibling "set" method
- * and that method is valid for a "persistable" property.
- */
- private static boolean methodHasValidSiblingSetMethod(MethodAdapter methodAdapter, String capitalizedAttributeName, String parameterTypeErasureName) {
- SimpleMethodAdapter setMethodAdapter = methodAdapter.getSibling("set" + capitalizedAttributeName, parameterTypeErasureName); //$NON-NLS-1$
- return methodIsValidSibling(setMethodAdapter, "void"); //$NON-NLS-1$
- }
-
- /**
- * Return whether the specified method is a valid sibling with the
- * specified return type.
- */
- private static boolean methodIsValidSibling(SimpleMethodAdapter methodAdapter, String returnTypeName) {
- if (methodAdapter == null) {
- return false;
- }
- if (methodHasInvalidModifiers(methodAdapter)) {
- return false;
- }
- if (methodAdapter.isConstructor()) {
- return false;
- }
- String rtName = methodAdapter.getReturnTypeErasureName();
- if (rtName == null) {
- return false; // DOM method bindings can have a null name
- }
- return rtName.equals(returnTypeName);
- }
-
- /**
- * Queries needed to calculate whether a method is "persistable".
- * Adapted to IMethodBinding and IMethod.
- */
- public interface SimpleMethodAdapter {
- /**
- * Return the method's modifiers.
- * We use these to check whether the method is static, final, etc.
- */
- int getModifiers();
-
- /**
- * Return the name of the method's return type erasure.
- * We use this to check for
- * - boolean getters
- * - void return types
- * - matching getters and setters
- */
- String getReturnTypeErasureName();
-
- /**
- * Return whether the method is a constructor.
- */
- boolean isConstructor();
- }
-
- /**
- * Queries needed to calculate whether a method is "persistable".
- * Adapted to IMethodBinding and IMethod.
- */
- public interface MethodAdapter extends SimpleMethodAdapter {
- /**
- * Return the method's name.
- * We use this to determine
- * - whether the method is a "getter"
- * - the property name implied by the getter's name
- */
- String getName();
-
- /**
- * Return the number of paramters declared by the method.
- * We use this to determine whether the method is a "getter".
- */
- int getParametersLength();
-
- /**
- * Return the method's "sibling" with the specified name and no parameters.
- * We use this to find an "is" boolean getter that would take precedence
- * over a "get" boolean getter.
- */
- SimpleMethodAdapter getSibling(String name);
-
- /**
- * Return the method's "sibling" with the specified name and single parameter.
- * We use this to find a matching "setter" for a possible "getter".
- */
- SimpleMethodAdapter getSibling(String name, String parameterTypeErasureName);
- }
-
-
- // ********** suppressed constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private JPTTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NameStringExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NameStringExpressionConverter.java
deleted file mode 100644
index 5c9bc46dde..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NameStringExpressionConverter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-
-/**
- * Convert a name to/from a string representation of a name/identifier
- * (e.g. "com.xxx.Foo.VALUE1" or "value").
- */
-public final class NameStringExpressionConverter
- extends AbstractExpressionConverter<String>
-{
- private static final ExpressionConverter<String> INSTANCE = new NameStringExpressionConverter();
-
- /**
- * Return the singleton.
- */
- public static ExpressionConverter<String> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private NameStringExpressionConverter() {
- super();
- }
-
- @Override
- protected Name convertObject(String string, AST ast) {
- return ast.newName(string);
- }
-
- @Override
- protected String convertExpression(Expression expression) {
- switch (expression.getNodeType()) {
- case ASTNode.QUALIFIED_NAME:
- case ASTNode.SIMPLE_NAME:
- return ((Name) expression).getFullyQualifiedName();
- default:
- return null;
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NestedDeclarationAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NestedDeclarationAnnotationAdapter.java
deleted file mode 100644
index 17eb956055..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NestedDeclarationAnnotationAdapter.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-
-/**
- * Manipulate an annotation that is embedded as an element within
- * another annotation, e.g.
- * <pre>
- * &#64;Outer(foo=&#64;Inner)
- * private int id;
- * outerAnnotationAdapter = AnnotationAdapter<&#64;Outer>
- * elementName = "foo"
- * annotationName = "Inner"
- * </pre>
- */
-public class NestedDeclarationAnnotationAdapter
- extends AbstractNestedDeclarationAnnotationAdapter
-{
- // ********** constructors **********
-
- /**
- * The default element name is <code>value</code>.
- */
- public NestedDeclarationAnnotationAdapter(DeclarationAnnotationAdapter outerAnnotationAdapter, String annotationName) {
- super(outerAnnotationAdapter, annotationName);
- }
-
- /**
- * default behavior is to remove the outer annotation when it is empty
- */
- public NestedDeclarationAnnotationAdapter(DeclarationAnnotationAdapter outerAnnotationAdapter, String elementName, String annotationName) {
- super(outerAnnotationAdapter, elementName, annotationName);
- }
-
-
- // ********** AbstractNestedDeclarationAnnotationAdapter implementation **********
-
- @Override
- protected Annotation getAnnotation(Expression value) {
- return this.annotationValue(value);
- }
-
- @Override
- protected Expression buildNewInnerExpression(Annotation inner) {
- return inner;
- }
-
- /**
- * the annotation is the expression itself, so the annotation cannot be
- * "removed" from itself - return 'false'
- */
- @Override
- protected boolean removeAnnotation(ModifiedDeclaration declaration, Annotation outer, Expression value) {
- return false;
- }
-
- /**
- * <pre>
- * &#64;Outer("lorem ipsum") => &#64;Outer(&#64;Inner)
- * </pre>
- */
- @Override
- protected void modifyAnnotationValue(SingleMemberAnnotation outer, Annotation inner) {
- // replace(?) the current element value
- outer.setValue(inner);
- }
-
- /**
- * Simply set the pair's value.
- */
- @Override
- protected void modifyMemberValuePair(MemberValuePair pair, Annotation inner) {
- pair.setValue(inner);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapter.java
deleted file mode 100644
index acfd74372f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapter.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.List;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.ArrayInitializer;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-
-/**
- * Manipulate an annotation that is embedded in an element array within
- * another annotation, e.g.
- * <pre>
- * &#64;Outer(foo={&#64;Inner("zero"), &#64;Inner("one"), &#64;Inner("two")})
- * private int id;
- * outerAnnotationAdapter = AnnotationAdapter<&#64;Outer>
- * elementName = "foo"
- * index = 0-2
- * annotationName = "Inner"
- * </pre>
- */
-public class NestedIndexedDeclarationAnnotationAdapter
- extends AbstractNestedDeclarationAnnotationAdapter
- implements IndexedDeclarationAnnotationAdapter
-{
- private int index;
-
-
- // ********** constructors **********
-
- /**
- * The default element name is <code>value</code>.
- */
- public NestedIndexedDeclarationAnnotationAdapter(DeclarationAnnotationAdapter annotationAdapter, int index, String annotationName) {
- super(annotationAdapter, annotationName);
- this.index = index;
- }
-
- public NestedIndexedDeclarationAnnotationAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, int index, String annotationName) {
- super(annotationAdapter, elementName, annotationName);
- this.index = index;
- }
-
-
- // ********** AbstractNestedDeclarationAnnotationAdapter implementation **********
-
- @Override
- protected Annotation getAnnotation(Expression value) {
- if (value.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
- return this.annotation((ArrayInitializer) value);
- }
- return (this.index == 0) ? this.annotationValue(value) : null;
- }
-
- @Override
- protected Expression buildNewInnerExpression(Annotation inner) {
- return (this.index == 0) ? inner : (Expression) this.buildNewInnerArrayInitializer(inner);
- }
-
- @Override
- protected boolean removeAnnotation(ModifiedDeclaration declaration, Annotation outer, Expression value) {
- if (value.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
- this.removeAnnotation(declaration, outer, (ArrayInitializer) value);
- return true;
- }
- // if our index is greater than zero, but we don't have an array,
- // then the annotation must already be gone
- return (this.index != 0);
- }
-
- /**
- * <pre>
- * &#64;Outer({&#64;Inner(0), &#64;Inner(1)}) => &#64;Outer({&#64;Inner(0), &#64;Inner(1), &#64;Inner(2)})
- * or
- * &#64;Outer("lorem ipsum") => &#64;Outer(&#64;Inner(0))
- * or
- * &#64;Outer(&#64;Inner(0)) => &#64;Outer({&#64;Inner(0), &#64;Inner(1)})
- * </pre>
- */
- @Override
- protected void modifyAnnotationValue(SingleMemberAnnotation outer, Annotation inner) {
- this.modifyExpression(outer, SINGLE_MEMBER_ANNOTATION_EXPRESSION_PROVIDER, inner);
- }
-
- /**
- * <pre>
- * &#64;Outer(text="lorem ipsum") => &#64;Outer(text="lorem ipsum", foo=&#64;Inner(0))
- * or
- * &#64;Outer(foo={&#64;Inner(0), &#64;Inner(1)}) => &#64;Outer(foo={&#64;Inner(0), &#64;Inner(1), &#64;Inner(2)})
- * or
- * &#64;Outer(foo="lorem ipsum") => &#64;Outer(foo=&#64;Inner(0))
- * or
- * &#64;Outer(foo=&#64;NotInner) => &#64;Outer(foo=&#64;Inner(0))
- * or
- * &#64;Outer(foo=&#64;Inner(0)) => &#64;Outer(foo={&#64;Inner(0), &#64;Inner(1)})
- * </pre>
- */
- @Override
- protected void modifyMemberValuePair(MemberValuePair pair, Annotation inner) {
- this.modifyExpression(pair, MEMBER_VALUE_PAIR_EXPRESSION_PROVIDER, inner);
- }
-
-
- // ********** IndexedDeclarationAnnotationAdapter implementation **********
-
- public int getIndex() {
- return this.index;
- }
-
- /**
- * Move the annotation to the specified index, leaving its original
- * position cleared out.
- */
- public void moveAnnotation(int newIndex, ModifiedDeclaration declaration) {
- int oldIndex = this.index;
- if (newIndex == oldIndex) {
- return;
- }
-
- Annotation original = this.getAnnotation(declaration);
- if (original == null) {
- this.index = newIndex;
- this.removeAnnotation(declaration); // clear out the new location (?)
- } else {
- Annotation copy = (Annotation) ASTNode.copySubtree(original.getAST(), original);
- this.index = newIndex;
- this.addAnnotation(declaration, copy); // install the copy in the new location
- this.index = oldIndex;
- this.removeAnnotation(declaration); // go back and clear out the original location (AFTER the move)
- this.index = newIndex;
- }
- }
-
-
- // ********** internal methods **********
-
- /**
- * Return the adapter's annotation from the specified array initializer.
- */
- private Annotation annotation(ArrayInitializer value) {
- List<Expression> expressions = this.expressions(value);
- return (this.index >= expressions.size()) ? null : this.annotationValue(expressions.get(this.index));
- }
-
- /**
- * Build a new array initializer to hold the specified annotation,
- * padding it with 'null' literals as necessary
- */
- private ArrayInitializer buildNewInnerArrayInitializer(Annotation inner) {
- ArrayInitializer ai = inner.getAST().newArrayInitializer();
- this.addInnerToExpressions(inner, this.expressions(ai));
- return ai;
- }
-
- /**
- * Add the specified annotation to the specified array initializer,
- * padding it with 'null' literals as necessary
- */
- private void addInnerToExpressions(Annotation inner, List<Expression> expressions) {
- if (expressions.size() > this.index) {
- throw new IllegalStateException("expressions size is greater than index (size: " + expressions.size() + " index: " + this.index + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- while (expressions.size() < this.index) {
- expressions.add(inner.getAST().newNullLiteral());
- }
- expressions.add(inner);
- }
-
- /**
- * Remove the adapter's annotation from the specified array initializer.
- */
- private void removeAnnotation(ModifiedDeclaration declaration, Annotation outer, ArrayInitializer value) {
- List<Expression> expressions = this.expressions(value);
- if (this.index >= expressions.size()) {
- return; // avoid IndexOutOfBoundsException(?)
- }
- Annotation inner = this.annotationValue(expressions.get(this.index));
- if (inner == null) {
- return;
- }
- if ( ! this.nameMatches(declaration, inner)) {
- return;
- }
- if (this.index == (expressions.size() - 1)) {
- expressions.remove(this.index);
- } else {
- expressions.set(this.index, value.getAST().newNullLiteral());
- }
- this.trimExpressions(declaration, outer, expressions);
- }
-
- /**
- * Strip all the null literals off the end of the specified list of expressions
- * and normalize the specified outer annotation.
- */
- private void trimExpressions(ModifiedDeclaration declaration, Annotation outer, List<Expression> expressions) {
- // start at the end of the list
- for (int i = expressions.size(); i-- > 0; ) {
- if (expressions.get(i).getNodeType() == ASTNode.NULL_LITERAL) {
- expressions.remove(i);
- } else {
- break; // stop with the first non-null literal encountered
- }
- }
- switch (expressions.size()) {
- case 0:
- this.removeElementAndNormalize(declaration, outer);
- break;
- case 1:
- this.convertArrayToLastRemainingExpression(outer, expressions.get(0));
- break;
- default:
- break;
- }
- }
-
- /**
- * When there is only a single element in an array initializer, convert the
- * expression to be just the single element; e.g.
- * <pre>
- * &#64;Foo(xxx={"abc"}) => &#64;Foo(xxx="abc")
- * or
- * &#64;Foo({"abc"}) => &#64;Foo("abc")
- * </pre>
- */
- private void convertArrayToLastRemainingExpression(Annotation outer, Expression lastValue) {
- lastValue = (Expression) ASTNode.copySubtree(lastValue.getAST(), lastValue);
- if (outer.isNormalAnnotation()) {
- this.memberValuePair((NormalAnnotation) outer).setValue(lastValue);
- } else if (outer.isSingleMemberAnnotation()) {
- ((SingleMemberAnnotation) outer).setValue(lastValue);
- } else {
- throw new IllegalArgumentException("unexpected annotation type: " + outer); //$NON-NLS-1$
- }
- }
-
- /**
- * Manipulate the specified expression appropriately.
- * If it is an array initializer, add the specified annotation to it.
- * If it is not, replace the expression or convert it into an array
- * initializer.
- */
- private void modifyExpression(ASTNode node, ExpressionProvider expProvider, Annotation inner) {
- Expression value = expProvider.getExpression(node);
- if (value.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
- // ignore the other entries in the array initializer(?) - they may not be matching Annotations...
- List<Expression> expressions = this.expressions((ArrayInitializer) value);
- if (this.index >= expressions.size()) {
- this.addInnerToExpressions(inner, expressions);
- } else {
- expressions.set(this.index, inner);
- }
- } else {
- if (this.index == 0) {
- // replace whatever was there before
- expProvider.setExpression(node, inner);
- } else {
- // convert to an array
- ArrayInitializer ai = inner.getAST().newArrayInitializer();
- List<Expression> expressions = this.expressions(ai);
- expressions.add((Expression) ASTNode.copySubtree(value.getAST(), value));
- this.addInnerToExpressions(inner, expressions);
- expProvider.setExpression(node, ai);
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- protected List<Expression> expressions(ArrayInitializer ai) {
- return ai.expressions();
- }
-
-
- // ********** expression providers **********
-
- /**
- * define interface that allows us to "re-use" the code in
- * #modifyExpression(ASTNode, ExpressionProvider, Annotation)
- */
- private interface ExpressionProvider {
- Expression getExpression(ASTNode node);
- void setExpression(ASTNode node, Expression expression);
- }
-
- private static final ExpressionProvider MEMBER_VALUE_PAIR_EXPRESSION_PROVIDER = new ExpressionProvider() {
- public Expression getExpression(ASTNode node) {
- return ((MemberValuePair) node).getValue();
- }
- public void setExpression(ASTNode node, Expression expression) {
- ((MemberValuePair) node).setValue(expression);
- }
- @Override
- public String toString() {
- return "MemberValuePairExpressionProvider"; //$NON-NLS-1$
- }
- };
-
- private static final ExpressionProvider SINGLE_MEMBER_ANNOTATION_EXPRESSION_PROVIDER = new ExpressionProvider() {
- public Expression getExpression(ASTNode node) {
- return ((SingleMemberAnnotation) node).getValue();
- }
- public void setExpression(ASTNode node, Expression expression) {
- ((SingleMemberAnnotation) node).setValue(expression);
- }
- @Override
- public String toString() {
- return "SingleMemberAnnotationExpressionProvider"; //$NON-NLS-1$
- }
- };
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullAnnotationEditFormatter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullAnnotationEditFormatter.java
deleted file mode 100644
index 284e9379b4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullAnnotationEditFormatter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.TextEdit;
-
-public final class NullAnnotationEditFormatter
- implements AnnotationEditFormatter
-{
-
- private static final NullAnnotationEditFormatter INSTANCE = new NullAnnotationEditFormatter();
-
- /**
- * Return the singleton.
- */
- public static AnnotationEditFormatter instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private NullAnnotationEditFormatter() {
- super();
- }
-
- public void format(IDocument doc, TextEdit editTree) throws MalformedTreeException, BadLocationException {
- // no formatting
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullDeclarationAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullDeclarationAnnotationAdapter.java
deleted file mode 100644
index c9fe2d94e4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullDeclarationAnnotationAdapter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-
-/**
- * Behaviorless implementation.
- */
-public final class NullDeclarationAnnotationAdapter
- implements IndexedDeclarationAnnotationAdapter
-{
-
- // singleton
- private static final NullDeclarationAnnotationAdapter INSTANCE = new NullDeclarationAnnotationAdapter();
-
- /**
- * Return the singleton.
- */
- public static IndexedDeclarationAnnotationAdapter instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private NullDeclarationAnnotationAdapter() {
- super();
- }
-
-
- // ********** DeclarationAnnotationAdapter implementation **********
-
- public Annotation getAnnotation(ModifiedDeclaration declaration) {
- return null;
- }
-
- public MarkerAnnotation newMarkerAnnotation(ModifiedDeclaration declaration) {
- return null;
- }
-
- public SingleMemberAnnotation newSingleMemberAnnotation(ModifiedDeclaration declaration) {
- return null;
- }
-
- public NormalAnnotation newNormalAnnotation(ModifiedDeclaration declaration) {
- return null;
- }
-
- public void removeAnnotation(ModifiedDeclaration declaration) {
- // do nothing
- }
-
- public ASTNode getAstNode(ModifiedDeclaration declaration) {
- return declaration.getDeclaration();
- }
-
-
- // ********** IndexedDeclarationAnnotationAdapter implementation **********
-
- public int getIndex() {
- return -1;
- }
-
- public void moveAnnotation(int newIndex, ModifiedDeclaration declaration) {
- // do nothing
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullDeclarationAnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullDeclarationAnnotationElementAdapter.java
deleted file mode 100644
index dd3e616a2d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullDeclarationAnnotationElementAdapter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-
-/**
- * Behaviorless implementation.
- */
-public class NullDeclarationAnnotationElementAdapter<T>
- implements DeclarationAnnotationElementAdapter<T>
-{
-
- // singleton
- @SuppressWarnings("rawtypes")
- private static final DeclarationAnnotationElementAdapter INSTANCE
- = new NullDeclarationAnnotationElementAdapter();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <S> DeclarationAnnotationElementAdapter<S> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private NullDeclarationAnnotationElementAdapter() {
- super();
- }
-
- public T getValue(ModifiedDeclaration declaration) {
- return null;
- }
-
- public void setValue(T value, ModifiedDeclaration declaration) {
- // do nothing
- }
-
- public ASTNode getAstNode(ModifiedDeclaration declaration) {
- return declaration.getDeclaration();
- }
-
- public Expression getExpression(ModifiedDeclaration declaration) {
- return null;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullExpressionConverter.java
deleted file mode 100644
index 8245a74a34..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NullExpressionConverter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * No conversion.
- */
-public final class NullExpressionConverter
- implements ExpressionConverter<Expression>
-{
-
- // singleton
- private static final ExpressionConverter<Expression> INSTANCE = new NullExpressionConverter();
-
- /**
- * Return the singleton.
- */
- public static ExpressionConverter<Expression> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private NullExpressionConverter() {
- super();
- }
-
- public Expression convert(Expression expression, AST ast) {
- return expression;
- }
-
- public Expression convert(Expression expression) {
- return expression;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NumberIntegerExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NumberIntegerExpressionConverter.java
deleted file mode 100644
index 775d2d705a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/NumberIntegerExpressionConverter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.NumberLiteral;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-
-/**
- * Convert a number literal to/from an Integer
- * (e.g. 5).
- */
-public final class NumberIntegerExpressionConverter
- extends AbstractExpressionConverter<Integer>
-{
- private static final ExpressionConverter<Integer> INSTANCE = new NumberIntegerExpressionConverter();
-
- /**
- * Return the singleton.
- */
- public static ExpressionConverter<Integer> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private NumberIntegerExpressionConverter() {
- super();
- }
-
- @Override
- protected NumberLiteral convertObject(Integer integer, AST ast) {
- return ast.newNumberLiteral(integer.toString());
- }
-
- @Override
- protected Integer convertExpression(Expression expression) {
- Object value = expression.resolveConstantExpressionValue();
- return (value instanceof Integer) ? ((Integer) value) : null;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/PrimitiveTypeStringExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/PrimitiveTypeStringExpressionConverter.java
deleted file mode 100644
index 7b17501e51..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/PrimitiveTypeStringExpressionConverter.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.PrimitiveType;
-import org.eclipse.jdt.core.dom.TypeLiteral;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-
-/**
- * Convert a type literal to/from a string representation of a primitive type
- * (e.g. "int").
- */
-public final class PrimitiveTypeStringExpressionConverter
- extends AbstractExpressionConverter<String>
-{
- private static final ExpressionConverter<String> INSTANCE = new PrimitiveTypeStringExpressionConverter();
-
- /**
- * Return the singleton.
- */
- public static ExpressionConverter<String> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private PrimitiveTypeStringExpressionConverter() {
- super();
- }
-
- @Override
- protected TypeLiteral convertObject(String string, AST ast) {
- org.eclipse.jdt.core.dom.Type type = ast.newPrimitiveType(PrimitiveType.toCode(string));
- TypeLiteral typeLiteral = ast.newTypeLiteral();
- typeLiteral.setType(type);
- return typeLiteral;
- }
-
- @Override
- protected String convertExpression(Expression expression) {
- if (expression.getNodeType() == ASTNode.TYPE_LITERAL) {
- org.eclipse.jdt.core.dom.Type type = ((TypeLiteral) expression).getType();
- if (type.getNodeType() == ASTNode.PRIMITIVE_TYPE) {
- return ((PrimitiveType) type).getPrimitiveTypeCode().toString();
- }
- }
- return null;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ShortCircuitAnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ShortCircuitAnnotationElementAdapter.java
deleted file mode 100644
index c9ee5748c8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ShortCircuitAnnotationElementAdapter.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Wrap another annotation element adapter and short-circuit the
- * #setValue method if the value has not changed.
- */
-public class ShortCircuitAnnotationElementAdapter<T>
- implements AnnotationElementAdapter<T>
-{
- /** the wrapped adapter */
- private final AnnotationElementAdapter<T> adapter;
-
-
- // ********** constructor **********
-
- public ShortCircuitAnnotationElementAdapter(AnnotatedElement annotatedElement, DeclarationAnnotationElementAdapter<T> daea) {
- this(new AnnotatedElementAnnotationElementAdapter<T>(annotatedElement, daea));
- }
-
- public ShortCircuitAnnotationElementAdapter(AnnotationElementAdapter<T> adapter) {
- super();
- this.adapter = adapter;
- }
-
-
- // ********** AnnotationElementAdapter implementation **********
-
- public T getValue() {
- return this.adapter.getValue();
- }
-
- public T getValue(CompilationUnit astRoot) {
- return this.adapter.getValue(astRoot);
- }
-
- public void setValue(T value) {
- this.setValue(this.adapter.getValue(), value);
- }
-
- public Expression getExpression(CompilationUnit astRoot) {
- return this.adapter.getExpression(astRoot);
- }
-
- public ASTNode getAstNode(CompilationUnit astRoot) {
- return this.adapter.getAstNode(astRoot);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.adapter);
- }
-
-
- // ********** internal methods **********
-
- /**
- * set the adapter's value to the specified new value if it
- * is different from the specified old value
- */
- protected void setValue(T oldValue, T newValue) {
- if (oldValue == null) {
- if (newValue == null) { // null => null
- // do nothing
- } else { // null => object
- this.adapter.setValue(newValue);
- }
- } else {
- if (newValue == null) { // object => null
- this.adapter.setValue(null);
- } else { // object => object
- if (this.valuesAreEqual(oldValue, newValue)) {
- // do nothing
- } else {
- this.adapter.setValue(newValue);
- }
- }
- }
- }
-
- /**
- * both values are non-null when this method is called
- */
- protected boolean valuesAreEqual(T oldValue, T newValue) {
- return newValue.equals(oldValue);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ShortCircuitArrayAnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ShortCircuitArrayAnnotationElementAdapter.java
deleted file mode 100644
index 0676bc2840..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ShortCircuitArrayAnnotationElementAdapter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.Arrays;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-
-/**
- * Wrap another annotation element adapter and short-circuit the
- * #setValue method if the value has not changed. Overrides #valuesAreEqual()
- * to check equality on arrays
- */
-public class ShortCircuitArrayAnnotationElementAdapter<T>
- extends ShortCircuitAnnotationElementAdapter<T[]>
-{
- // ********** constructor **********
-
- public ShortCircuitArrayAnnotationElementAdapter(AnnotatedElement annotatedElement, DeclarationAnnotationElementAdapter<T[]> daea) {
- super(annotatedElement, daea);
- }
-
- public ShortCircuitArrayAnnotationElementAdapter(AnnotationElementAdapter<T[]> adapter) {
- super(adapter);
- }
-
-
- // ********** AnnotationElementAdapter implementation **********
-
- @Override
- protected boolean valuesAreEqual(T[] oldValue, T[] newValue) {
- return Arrays.equals(newValue, oldValue);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/SimpleDeclarationAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/SimpleDeclarationAnnotationAdapter.java
deleted file mode 100644
index 195dc197ec..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/SimpleDeclarationAnnotationAdapter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-
-/**
- * Manipulate an annotation with a specific name, e.g.
- * <pre>
- * &#64;Foo
- * private int id;
- * </pre>
- *
- * NB:
- * If the declaration contains more than one annotation with the same
- * name, the adapter will correspond to the first annotation with the specified
- * name. (Also note that the compiler will not allow a declaration to be
- * modified by multiple annotations with the same name, i.e. of the same type;
- * so if there *are* multiple annotations of the same type, there are bigger
- * problems to worry about than which annotation the adapter manipulates.)
- */
-public class SimpleDeclarationAnnotationAdapter extends AbstractDeclarationAnnotationAdapter {
-
-
- // ********** constructors **********
-
- public SimpleDeclarationAnnotationAdapter(String annotationName) {
- super(annotationName);
- }
-
-
- // ********** DeclarationAnnotationAdapter implementation **********
-
- public Annotation getAnnotation(ModifiedDeclaration declaration) {
- return declaration.getAnnotationNamed(this.getAnnotationName());
- }
-
- public void removeAnnotation(ModifiedDeclaration declaration) {
- declaration.removeAnnotationNamed(this.getAnnotationName());
- }
-
- @Override
- protected void addAnnotation(ModifiedDeclaration declaration, Annotation annotation) {
- declaration.replaceAnnotationNamed(this.getAnnotationName(), annotation);
- }
-
- public ASTNode getAstNode(ModifiedDeclaration declaration) {
- // if the annotation is missing, return the declaration
- Annotation annotation = this.getAnnotation(declaration);
- return (annotation != null) ? annotation : declaration.getDeclaration();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/SimpleTypeStringExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/SimpleTypeStringExpressionConverter.java
deleted file mode 100644
index 156dc5fa73..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/SimpleTypeStringExpressionConverter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jdt.core.dom.SimpleType;
-import org.eclipse.jdt.core.dom.TypeLiteral;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-
-/**
- * Convert a type literal to/from a string representation of a simple type
- * (e.g. "java.lang.Object").
- */
-public final class SimpleTypeStringExpressionConverter
- extends AbstractExpressionConverter<String>
-{
- private static final ExpressionConverter<String> INSTANCE = new SimpleTypeStringExpressionConverter();
-
- /**
- * Return the singleton.
- */
- public static ExpressionConverter<String> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private SimpleTypeStringExpressionConverter() {
- super();
- }
-
- @Override
- protected TypeLiteral convertObject(String string, AST ast) {
- Name name = ast.newName(string);
- org.eclipse.jdt.core.dom.Type type = ast.newSimpleType(name);
- TypeLiteral typeLiteral = ast.newTypeLiteral();
- typeLiteral.setType(type);
- return typeLiteral;
- }
-
- @Override
- protected String convertExpression(Expression expression) {
- if (expression.getNodeType() == ASTNode.TYPE_LITERAL) {
- org.eclipse.jdt.core.dom.Type type = ((TypeLiteral) expression).getType();
- if (type.getNodeType() == ASTNode.SIMPLE_TYPE) {
- return ((SimpleType) type).getName().getFullyQualifiedName();
- }
- }
- return null;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/StringArrayExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/StringArrayExpressionConverter.java
deleted file mode 100644
index 060e2cb52d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/StringArrayExpressionConverter.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import java.util.List;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.ArrayInitializer;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedExpressionConverter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Convert an array initializer to/from an array of strings
- * (e.g. <code>{"text0", "text1"}</code>).
- * <p>
- * Do <em>not</em> use this class for converting array initializers in
- * annotation elements:
- * Java5 has a bit of syntactic sugar that allows a single-element array
- * initializer to not have curly braces. This converter will return
- * an empty array if it encounters anything other than an array initializer.
- * Use {@link AnnotationStringArrayExpressionConverter} for converting
- * annotation elements.
- * <p>
- * Invalid entries in the array initializer will result in <code>null</code>
- * elements in the resulting string array. This allows clients to manipulate
- * elements at the appropriate index.
- */
-public class StringArrayExpressionConverter
- extends AbstractExpressionConverter<String[]>
- implements IndexedExpressionConverter<String>
-{
- private final ExpressionConverter<String> elementConverter;
- private final boolean removeArrayInitializerWhenEmpty;
-
-
- /**
- * The default behavior is to remove the array initializer if it is empty.
- */
- public StringArrayExpressionConverter(ExpressionConverter<String> elementConverter) {
- this(elementConverter, true);
- }
-
- public StringArrayExpressionConverter(ExpressionConverter<String> elementConverter, boolean removeArrayInitializerWhenEmpty) {
- super();
- this.elementConverter = elementConverter;
- this.removeArrayInitializerWhenEmpty = removeArrayInitializerWhenEmpty;
- }
-
- /**
- * This method is non-<code>private</code> so it can be called by
- * {@link AnnotationStringArrayExpressionConverter}
- */
- @Override
- protected ArrayInitializer convertObject(String[] strings, AST ast) {
- if ((strings.length == 0) && this.removeArrayInitializerWhenEmpty) {
- return null;
- }
- ArrayInitializer arrayInitializer = ast.newArrayInitializer();
- List<Expression> expressions = this.expressions(arrayInitializer);
- for (String string : strings) {
- expressions.add(this.elementConverter.convert(string, ast));
- }
- return arrayInitializer;
- }
-
- @SuppressWarnings("unchecked")
- private List<Expression> expressions(ArrayInitializer arrayInitializer) {
- return arrayInitializer.expressions();
- }
-
- /**
- * This method is non-<code>private</code> so it can be called by
- * {@link AnnotationStringArrayExpressionConverter}
- */
- @Override
- protected String[] convertNull() {
- return StringTools.EMPTY_STRING_ARRAY;
- }
-
- @Override
- protected String[] convertExpression(Expression expression) {
- return (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) ?
- this.convertArrayInitializer((ArrayInitializer) expression) :
- StringTools.EMPTY_STRING_ARRAY;
- }
-
- /**
- * This method is non-<code>private</code> so it can be called by
- * {@link AnnotationStringArrayExpressionConverter}
- */
- String[] convertArrayInitializer(ArrayInitializer arrayInitializer) {
- List<Expression> expressions = this.expressions(arrayInitializer);
- int len = expressions.size();
- String[] strings = new String[len];
- for (int i = len; i-- > 0; ) {
- strings[i] = this.elementConverter.convert(expressions.get(i));
- }
- return strings;
- }
-
- public Expression selectExpression(Expression expression, int index) {
- if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
- return this.expressions((ArrayInitializer) expression).get(index);
- }
- throw new ArrayIndexOutOfBoundsException();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/StringExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/StringExpressionConverter.java
deleted file mode 100644
index f0e88b5331..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/StringExpressionConverter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-
-/**
- * Convert a string literal to/from a string (e.g. "text").
- */
-public final class StringExpressionConverter
- extends AbstractExpressionConverter<String>
-{
- private static final ExpressionConverter<String> INSTANCE = new StringExpressionConverter();
-
- /**
- * Return the singleton.
- */
- public static ExpressionConverter<String> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private StringExpressionConverter() {
- super();
- }
-
- @Override
- protected StringLiteral convertObject(String string, AST ast) {
- StringLiteral stringLiteral = ast.newStringLiteral();
- stringLiteral.setLiteralValue(string);
- return stringLiteral;
- }
-
- @Override
- protected String convertExpression(Expression expression) {
- Object value = expression.resolveConstantExpressionValue();
- return (value instanceof String) ? (String) value : null;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/TypeStringExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/TypeStringExpressionConverter.java
deleted file mode 100644
index 3ed1b74189..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/TypeStringExpressionConverter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.PrimitiveType;
-import org.eclipse.jdt.core.dom.TypeLiteral;
-import org.eclipse.jpt.common.core.utility.jdt.ExpressionConverter;
-
-/**
- * Convert a type literal to/from a string representation of a
- * simple type (e.g. "java.lang.Object") or primitive type (e.g. "int").
- */
-public final class TypeStringExpressionConverter
- extends AbstractExpressionConverter<String>
-{
- private static final ExpressionConverter<String> INSTANCE = new TypeStringExpressionConverter();
-
- /**
- * Return the singleton.
- */
- public static ExpressionConverter<String> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private TypeStringExpressionConverter() {
- super();
- }
-
- @Override
- protected TypeLiteral convertObject(String string, AST ast) {
- if (PrimitiveType.toCode(string) != null) {
- return (TypeLiteral) PrimitiveTypeStringExpressionConverter.instance().convert(string, ast);
- }
- return (TypeLiteral) SimpleTypeStringExpressionConverter.instance().convert(string, ast);
- }
-
- @Override
- protected String convertExpression(Expression expression) {
- String name = SimpleTypeStringExpressionConverter.instance().convert(expression);
- return name != null ? name : PrimitiveTypeStringExpressionConverter.instance().convert(expression);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/BooleanTranslator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/BooleanTranslator.java
deleted file mode 100644
index 7f2825c1a3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/BooleanTranslator.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.translators;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.wst.common.internal.emf.resource.Translator;
-
-public class BooleanTranslator
- extends Translator
-{
- public BooleanTranslator(String domPathAndNames, EStructuralFeature structuralFeature) {
- super(domPathAndNames, structuralFeature, BOOLEAN_FEATURE | BOOLEAN_LOWERCASE);
- }
-
- public BooleanTranslator(String domPathAndNames, EStructuralFeature structuralFeature, int style) {
- super(domPathAndNames, structuralFeature, BOOLEAN_FEATURE | BOOLEAN_LOWERCASE | style);
- }
-
- @Override
- public Object convertStringToValue(String string, EObject owner) {
- return Boolean.valueOf(string);
- }
-
- @Override
- public String convertValueToString(Object value, EObject owner) {
- return ((Boolean) value).toString();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/EmptyTagBooleanTranslator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/EmptyTagBooleanTranslator.java
deleted file mode 100644
index 1d94705cca..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/EmptyTagBooleanTranslator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.translators;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.wst.common.internal.emf.resource.Translator;
-
-/**
- * This translator is to be used for empty xml tags that correspond
- * to a boolean attribute in the emf model.
- * cascade-persist is an example from the orm.xsd:
- *
- * <persistence-unit-defaults>
- * <cascade-persist/>
- * </persistence-unit-defaults> ==> cascadePersist == true
- *
- * vs.
- *
- * <persistence-unit-defaults>
- * </persistence-unit-defaults> ==> cascadePersist == false
- *
- */
-public class EmptyTagBooleanTranslator
- extends Translator
-{
- public EmptyTagBooleanTranslator(String domPathAndNames, EStructuralFeature structuralFeature) {
- this(domPathAndNames, structuralFeature, NO_STYLE);
- }
-
- public EmptyTagBooleanTranslator(String domPathAndNames, EStructuralFeature structuralFeature, int style) {
- super(domPathAndNames, structuralFeature, style | EMPTY_TAG | BOOLEAN_FEATURE);
- }
-
- @Override
- public Object getMOFValue(EObject mofObject) {
- // I am overriding this method. This is so the tag will be removed when
- // the value is false.
- // I'm not sure if this is a bug in the ecore or maybe in the translators,
- // but I really don't think that we should have to depend on the boolean
- // being "unset" to remove the tag.
- Boolean value = (Boolean) super.getMOFValue(mofObject);
- return (value == null) ? null : value.booleanValue() ? value : null;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/EnumeratedValueTranslator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/EnumeratedValueTranslator.java
deleted file mode 100644
index fc74b4a730..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/EnumeratedValueTranslator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.translators;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.wst.common.internal.emf.resource.Translator;
-
-public abstract class EnumeratedValueTranslator
- extends Translator
-{
- public EnumeratedValueTranslator(String domPathAndNames, EStructuralFeature structuralFeature) {
- super(domPathAndNames, structuralFeature);
- }
-
- public EnumeratedValueTranslator(String domPathAndNames, EStructuralFeature structuralFeature, int style) {
- super(domPathAndNames, structuralFeature, style);
- }
-
-
- protected abstract Iterable<?> getEnumeratedObjectValues();
-
- @Override
- public Object convertStringToValue(String string, EObject owner) {
- for (Object each : getEnumeratedObjectValues()) {
- if (each.toString().equals(string)) {
- return each;
- }
- }
- return null;
- }
-
- @Override
- public String convertValueToString(Object value, EObject owner) {
- return value.toString();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/SimpleRootTranslator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/SimpleRootTranslator.java
deleted file mode 100644
index 08c20d3b1d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/SimpleRootTranslator.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.translators;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.wst.common.internal.emf.resource.RootTranslator;
-import org.eclipse.wst.common.internal.emf.resource.Translator;
-
-/**
- * Root translator that contains a list of child translators and no special
- * behavior.
- */
-public class SimpleRootTranslator
- extends RootTranslator
-{
- protected Translator[] children;
-
- public SimpleRootTranslator(String domPathAndNames, EClass eClass) {
- super(domPathAndNames, eClass);
- }
-
- public SimpleRootTranslator(String domPathAndNames, EClass eClass, Translator[] children) {
- super(domPathAndNames, eClass);
- this.children = children;
- }
-
- /**
- * Widen method access to 'public'.
- */
- @Override
- public Translator[] getChildren() {
- return this.children;
- }
-
- protected Translator[] getChildren_() {
- return (this.children == null) ? EMPTY_TRANSLATOR_ARRAY : this.children;
- }
- protected static final Translator[] EMPTY_TRANSLATOR_ARRAY = new Translator[0];
-
- /**
- * Set the translator's children.
- * Return the translator.
- */
- public void setChildren(Translator[] children) {
- this.children = children;
- }
-
- /**
- * Add the specified translator to the translator's list of children.
- * Return the translator for method chaining.
- */
- public SimpleRootTranslator addChild(Translator translator) {
- this.children = ArrayTools.add(this.getChildren_(), translator);
- return this;
- }
-
- /**
- * Add the specified translators to the translator's list of children.
- * Return the translator for method chaining.
- */
- public SimpleRootTranslator addChildren(Translator[] translators) {
- this.children = ArrayTools.addAll(this.getChildren_(), translators);
- return this;
- }
-
- /**
- * Remove the specified translator from the translator's list of children.
- * Return the translator for method chaining.
- */
- public SimpleRootTranslator removeChild(Translator translator) {
- this.children = ArrayTools.remove(this.children, translator);
- return this;
- }
-
- /**
- * Remove the specified translators from the translator's list of children.
- * Return the translator for method chaining.
- */
- public SimpleRootTranslator removeChildren(Translator[] translators) {
- this.children = ArrayTools.removeAll(this.children, (Object[]) translators);
- return this;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/SimpleTranslator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/SimpleTranslator.java
deleted file mode 100644
index 20db025e8a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/translators/SimpleTranslator.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.internal.utility.translators;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.wst.common.internal.emf.resource.Translator;
-import org.eclipse.wst.common.internal.emf.resource.TranslatorPath;
-
-/**
- * Translator that contains a list of child translators and no special
- * behavior.
- */
-public class SimpleTranslator
- extends Translator
-{
- protected Translator[] children;
-
-
- // ********** constructors **********
-
- public SimpleTranslator(String domPathAndNames, EClass eClass) {
- super(domPathAndNames, eClass);
- }
-
- public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature) {
- super(domPathAndNames, eStructuralFeature);
- }
-
- public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, Translator[] children) {
- super(domPathAndNames, eStructuralFeature);
- this.children = children;
- }
-
- public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, EClass eClass) {
- super(domPathAndNames, eStructuralFeature, eClass);
- }
-
- public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, EClass eClass, Translator[] children) {
- super(domPathAndNames, eStructuralFeature, eClass);
- this.children = children;
- }
-
- public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, TranslatorPath translatorPath) {
- super(domPathAndNames, eStructuralFeature, translatorPath);
- }
-
- public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, TranslatorPath[] translatorPaths) {
- super(domPathAndNames, eStructuralFeature, translatorPaths);
- }
-
- public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, int style) {
- super(domPathAndNames, eStructuralFeature, style);
- }
-
- public SimpleTranslator(String domPathAndNames, EStructuralFeature aFeature, int style, EClass eClass, Translator[] children) {
- this(domPathAndNames, aFeature, style);
- setEMFClass(eClass);
- this.children = children;
- }
-
- public SimpleTranslator(String domPathAndNames, EStructuralFeature eStructuralFeature, int style, Translator[] children) {
- super(domPathAndNames, eStructuralFeature, style);
- this.children = children;
- }
-
-
- // ********** children **********
-
- /**
- * Widen method access to 'public'.
- */
- @Override
- public Translator[] getChildren() {
- return this.children;
- }
-
- protected Translator[] getChildren_() {
- return (this.children == null) ? EMPTY_TRANSLATOR_ARRAY : this.children;
- }
- protected static final Translator[] EMPTY_TRANSLATOR_ARRAY = new Translator[0];
-
- /**
- * Set the translator's children.
- * Return the translator.
- */
- public void setChildren(Translator[] children) {
- this.children = children;
- }
-
- /**
- * Add the specified translator to the translator's list of children.
- * Return the translator for method chaining.
- */
- public SimpleTranslator addChild(Translator translator) {
- this.children = ArrayTools.add(this.getChildren_(), translator);
- return this;
- }
-
- /**
- * Add the specified translators to the translator's list of children.
- * Return the translator for method chaining.
- */
- public SimpleTranslator addChildren(Translator[] translators) {
- this.children = ArrayTools.addAll(this.getChildren_(), translators);
- return this;
- }
-
- /**
- * Remove the specified translator from the translator's list of children.
- * Return the translator for method chaining.
- */
- public SimpleTranslator removeChild(Translator translator) {
- this.children = ArrayTools.remove(this.children, translator);
- return this;
- }
-
- /**
- * Remove the specified translators from the translator's list of children.
- * Return the translator for method chaining.
- */
- public SimpleTranslator removeChildren(Translator[] translators) {
- this.children = ArrayTools.removeAll(this.children, (Object[]) translators);
- return this;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/libprov/JptLibraryProviderInstallOperationConfig.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/libprov/JptLibraryProviderInstallOperationConfig.java
deleted file mode 100644
index 3e524487f7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/libprov/JptLibraryProviderInstallOperationConfig.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.libprov;
-
-import org.eclipse.jst.common.project.facet.core.libprov.ILibraryProvider;
-import org.eclipse.wst.common.project.facet.core.IFacetedProjectBase;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-
-/**
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JptLibraryProviderInstallOperationConfig {
-
- IFacetedProjectBase getFacetedProject();
-
- ILibraryProvider getLibraryProvider();
-
- IProjectFacetVersion getProjectFacetVersion();
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/libval/LibraryValidator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/libval/LibraryValidator.java
deleted file mode 100644
index af15c438ce..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/libval/LibraryValidator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.libval;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jpt.common.core.libprov.JptLibraryProviderInstallOperationConfig;
-
-/**
- * Interface for extender-supplied library validators.
- * Each library validator must have a zero-arg constructor.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface LibraryValidator {
-
- IStatus validate(JptLibraryProviderInstallOperationConfig config);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/ProjectResourceLocator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/ProjectResourceLocator.java
deleted file mode 100644
index e8c05d6045..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/ProjectResourceLocator.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.resource;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Implementations of this interface can be retrieved via the Adapter framework:
- * <pre>
- * IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("Foo Project");
- * ProjectResourceLocator locator = (ProjectResourceLocator) project.getAdapter(ProjectResourceLocator.class);
- * </pre>
- * <p>
- * See <code>org.eclipse.jpt.common.core/plugin.xml</code>.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.2
- * @since 3.2
- * @see org.eclipse.jpt.common.core.internal.resource.ProjectAdapterFactory
- */
-public interface ProjectResourceLocator {
- /**
- * Return whether the specified container is an acceptable (non-Java)
- * resource location for the locator's project.
- */
- boolean resourceLocationIsValid(IContainer container);
-
- /**
- * Return the default location in which to create new (non-Java) resources.
- */
- IContainer getDefaultResourceLocation();
-
- /**
- * Return the workspace relative absolute resource path best represented by
- * the specified runtime path for the locator's project.
- */
- IPath getResourcePath(IPath runtimePath);
-
- /**
- * Return the runtime path best represented by the specified workspace
- * relative absolute resource path for the locator's project.
- */
- IPath getRuntimePath(IPath resourcePath);
-
- /**
- * Return an {@link IFile} that best represents the specified runtime
- * location.
- */
- IFile getPlatformFile(IPath runtimePath);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/ResourceLocator.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/ResourceLocator.java
deleted file mode 100644
index fcb82ba6c7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/ResourceLocator.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.resource;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * Client-defined resource locator.
- * <p>
- * See <code>org.eclipse.jpt.common.core/plugin.xml</code>.
- * <p>
- * See <code>org.eclipse.jpt.common.core/schema/resourceLocators.exsd</code>.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface ResourceLocator {
- /**
- * Return whether the specified container is an acceptable (non-Java)
- * resource location for the specified project.
- */
- boolean resourceLocationIsValid(IProject project, IContainer container);
-
- /**
- * Return the default location in which to create new (non-Java) resources.
- */
- IContainer getDefaultResourceLocation(IProject project);
-
- /**
- * Return the workspace relative absolute resource path best represented by
- * the specified runtime path for the specified project.
- */
- IPath getResourcePath(IProject project, IPath runtimePath);
-
- /**
- * Return the runtime path best represented by the specified workspace
- * relative absolute resource path for the specified project.
- */
- IPath getRuntimePath(IProject project, IPath resourcePath);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/Annotation.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/Annotation.java
deleted file mode 100644
index a4cd5e0352..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/Annotation.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-
-/**
- * Common Java resource annotation behavior
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface Annotation
- extends JavaResourceNode
-{
- /**
- * Return the annotation's fully qualified name, as opposed to the value of
- * the annotation's 'name' element. For example:
- * @com.foo.Bar(name="Thomas")
- * #getAnnotationName() will return "com.foo.Bar".
- * In typical subclasses, #getName() would return "Thomas".
- */
- String getAnnotationName();
-
- /**
- * Return the corresponding JDT DOM annotation from the specified
- * AST compilation unit.
- */
- org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot);
-
- /**
- * Create and add the corresponding Java annotation to the JDT DOM.
- */
- void newAnnotation();
-
- /**
- * Remove the corresponding Java annotation from the JDT DOM.
- */
- void removeAnnotation();
-
- /**
- * Return whether all the annotation's member values are <code>null</code>;
- * implying the annotation can be removed if it has no semantic value as a
- * marker annotation.
- */
- boolean isUnset();
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/AnnotationDefinition.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/AnnotationDefinition.java
deleted file mode 100644
index 9df453ed8a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/AnnotationDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-
-/**
- * Used to build Annotations discovered in the Java source code.
- * To provide new AnnotationDefinitions, create a new JaxbPlatform
- * by implementing JaxbPlatformDefinition.
- *
- * @see Annotation
- * @see org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface AnnotationDefinition
-{
- /**
- * Return the name of the annotation the definition will build in the
- * various #build...(...) methods.
- */
- String getAnnotationName();
-
- /**
- * Build and return an annotation for the specified annotated element.
- */
- Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement);
-
- /**
- * Build and return an annotation for the specified JDT annotation
- * on the specified annotated element.
- */
- Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation);
-
- /**
- * Build and return a "null" annotation for the specified annotated element.
- * Only certain annotations are required to have "null" implementations;
- * typically the annotations with reasonably complex default behavior.
- * The "null" annotation is used by the corresponding default context model.
- * The "null" annotation simplifies the context model code, allowing the
- * context model to simply set various bits of state (e.g. 'name') and the
- * "null" annotation will create a new "real" annotation and forward the
- * new state to it. This reduces the number of null checks in the context
- * model (hopefully).
- */
- Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAbstractType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAbstractType.java
deleted file mode 100644
index c228a6e8c6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAbstractType.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-
-/**
- * Java source code or binary type. This corresponds to a {@link AbstractTypeDeclaration}
- * (which is why the name is somewhat wonky.)
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JavaResourceAbstractType
- extends JavaResourceMember {
-
- /**
- * Property change String for the unqualified (short) type name.
- * @see JavaResourceMember#getName()
- */
- String NAME_PROPERTY = "name"; //$NON-NLS-1$
-
- /**
- * Return the fully qualified type name.
- */
- String getQualifiedName();
- String QUALIFIED_NAME_PROPERTY = "qualifiedName"; //$NON-NLS-1$
-
- /**
- * Return the package name.
- */
- String getPackageName();
- String PACKAGE_NAME_PROPERTY = "packageName"; //$NON-NLS-1$
-
- /**
- * Return the name of the type's "declaring type".
- * Return <code>null</code> if the type is a top-level type.
- */
- String getDeclaringTypeName();
- String DECLARING_TYPE_NAME_PROPERTY = "declaringTypeName"; //$NON-NLS-1$
-
- /**
- * Return whether the type is a member type.
- */
- boolean isMemberType();
- String MEMBER_TYPE_PROPERTY = "memberType"; //$NON-NLS-1$
-
- boolean isIn(IPackageFragment packageFragment);
-
- boolean isIn(IPackageFragmentRoot sourceFolder);
-
-
- /**
- * Return the immediately nested types (classes or interfaces, not enums or annotations) (children).
- */
- Iterable<JavaResourceType> getTypes();
- String TYPES_COLLECTION = "types"; //$NON-NLS-1$
-
- /**
- * Return all the types; the type itself, its children, its grandchildren,
- * etc.
- */
- Iterable<JavaResourceType> getAllTypes();
-
- /**
- * Return the immediately nested enums (children).
- */
- Iterable<JavaResourceEnum> getEnums();
- String ENUMS_COLLECTION = "enums"; //$NON-NLS-1$
-
- /**
- * Return all the enums; the enum itself, its children, its grandchildren,
- * etc.
- */
- Iterable<JavaResourceEnum> getAllEnums();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAnnotatedElement.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAnnotatedElement.java
deleted file mode 100644
index 5176d120ef..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAnnotatedElement.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-/**
- * Java source code or binary annotated element.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JavaResourceAnnotatedElement
- extends JavaResourceNode
-{
- // ********** annotations **********
-
- /**
- * String associated with changes to the "annotations" collection
- */
- String ANNOTATIONS_COLLECTION = "annotations"; //$NON-NLS-1$
-
- /**
- * String associated with changes to the "nestableAnnotations" collection
- */
- String NESTABLE_ANNOTATIONS_COLLECTION = "nestableAnnotations"; //$NON-NLS-1$
-
- /**
- * Return the member's annotations in the order that they appear.
- * Do not return duplicate annotations as this error is handled by the Java
- * compiler.
- */
- Iterable<Annotation> getAnnotations();
-
- /**
- * Return the number of annotations.
- */
- int getAnnotationsSize();
-
- /**
- * Return the annotation with the specified name.
- * Return the first if there are duplicates in the source code.
- */
- Annotation getAnnotation(String annotationName);
-
- /**
- * Return the specified annotation.
- * Return the first if there are duplicates in the source code.
- * Do not return null, but a Null Object instead if no annotation
- * with the specified name exists in the source code.
- */
- Annotation getNonNullAnnotation(String annotationName);
-
- /**
- * Return the nestable annotations with the specified name in the order that
- * they appear.
- * If nestable and container annotations are both specified on the
- * member directly, the behavior is undefined
- */
- // TODO tie the singular and plural annotations together so we can generate
- // a validation error when both are specified
- ListIterable<NestableAnnotation> getAnnotations(String nestableAnnotationName);
-
- /**
- * Return the number of nestable annotations with the specified name.
- * If nestable and container annotations are both specified on the
- * member directly, the behavior is undefined
- */
- int getAnnotationsSize(String nestableAnnotationName);
-
- /**
- * Return the nestable annotation at the specified index with the specified name.
- * If nestable and container annotations are both specified on the
- * member directly, the behavior is undefined
- */
- NestableAnnotation getAnnotation(int index, String nestableAnnotationName);
-
- /**
- * Add an annotation with the specified name.
- * Return the newly-created annotation.
- */
- Annotation addAnnotation(String annotationName);
-
- /**
- * Add a new nestable annotation with the specified name.
- * Create a new container annotation if necessary and add the nestable
- * annotation to it.
- * If both the nestable annotation and the container annotation already
- * exist, then add to the container annotation, leaving the existing
- * nestable annotation alone.
- * If only the nestable annotation exists, then create the new container
- * annotation and move the existing nestable annotation to it along with
- * the new one. If neither annotation exists, then create a new nestable
- * annotation.
- */
- NestableAnnotation addAnnotation(int index, String nestableAnnotationName);
-
- /**
- * Move the nestable annotation at the specified source index to the specified target index.
- */
- void moveAnnotation(int targetIndex, int sourceIndex, String nestableAnnotationName);
-
- /**
- * Remove the specified annotation.
- */
- void removeAnnotation(String annotationName);
-
- /**
- * Remove the specified nestable annotation from the container annotation at the specified
- * index.
- * If there is no container, assume the index is zero and just remove the nestable annotation
- */
- void removeAnnotation(int index, String nestableAnnotationName);
-
-
- // ********** queries **********
-
- /**
- * Return the element's "top level" annotations.
- * For "combination" annotations (i.e. a virtual array of annotations that
- * can be either a single <em>standalone</em> annotation [representing an
- * array of length one] or an array of annotations witin a
- * <em>container</em> annotation), only the <em>container</em> annotation is
- * included (if it is present) or the single <em>standalone</em> annotation.
- */
- Iterable<Annotation> getTopLevelAnnotations();
-
- /**
- * Return whether the underlying JDT member is currently annotated with any recognized
- * annotations.
- */
- boolean isAnnotated();
-
- /**
- * Return whether the underlying JDT member is annotated with any of the given annotations.
- */
- boolean isAnnotatedWithAnyOf(Iterable<String> annotationNames);
-
- /**
- * Return the element kind
- */
- Kind getKind();
-
- /**
- * Return the text range for the member's name.
- */
- TextRange getNameTextRange(CompilationUnit astRoot);
-
- /**
- * Return the text range for the nestable annotation if it is currently
- * unnested. If it is nested, return the text range for the corresponding
- * container annotation.
- *
- * @see AnnotationProvider#getContainerAnnotationName(String)
- */
- TextRange getTextRange(String nestableAnnotationName, CompilationUnit astRoot);
-
- /**
- * The kind of java element.
- */
- public enum Kind {
-
- /**
- * Represents an annotatable package.
- * An {@link JavaResourceAnnotatedElement} of {@link Kind} PACKAGE may safely be cast as a
- * {@link JavaResourcePackage}
- */
- PACKAGE(ASTNode.PACKAGE_DECLARATION),
-
- /**
- * Represents a class or interface.
- * An {@link JavaResourceAnnotatedElement} of {@link Kind} TYPE may safely be cast as a
- * {@link JavaResourceType}
- */
- TYPE(ASTNode.TYPE_DECLARATION),
-
- /**
- * Represents an enum.
- * An {@link JavaResourceAnnotatedElement} of {@link Kind} ENUM may safely be cast as a
- * {@link JavaResourceEnum}
- */
- ENUM(ASTNode.ENUM_DECLARATION),
-
- /**
- * Represents a method.
- * An {@link JavaResourceAnnotatedElement} of {@link Kind} METHOD may safely be cast as a
- * {@link JavaResourceMethod}
- */
- METHOD(ASTNode.METHOD_DECLARATION),
-
- /**
- * Represents a type field.
- * An {@link JavaResourceAnnotatedElement} of {@link Kind} FIELD may safely be cast as a
- * {@link JavaResourceField}
- */
- FIELD(ASTNode.FIELD_DECLARATION),
-
- /**
- * Represents an enum constant.
- * An {@link JavaResourceAnnotatedElement} of {@link Kind} ENUM_CONSTANT may safely be cast as a
- * {@link JavaResourceEnumConstant}
- */
- ENUM_CONSTANT(ASTNode.ENUM_CONSTANT_DECLARATION);
-
-
- private int astNodeType;
-
- Kind(int astNodeType) {
- this.astNodeType = astNodeType;
- }
-
- public int getAstNodeType() {
- return this.astNodeType;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAttribute.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAttribute.java
deleted file mode 100644
index 565c27ea46..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceAttribute.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-/**
- * Java source code or binary attribute (field/method)
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JavaResourceAttribute
- extends JavaResourceMember
-{
- JavaResourceType getParent();
-
- JavaResourceType getResourceType();
-
- /**
- * Return whether the attribute's type implements or extends the specified
- * type.
- */
- boolean typeIsSubTypeOf(String typeName);
-
- /**
- * Return whether the attribute's type is a "variable" primitive type
- * (i.e. any primitive type except 'void').
- */
- boolean typeIsVariablePrimitive();
-
- /**
- * @see java.lang.reflect.Modifier
- */
- int getModifiers();
- String MODIFIERS_PROPERTY = "modifiers"; //$NON-NLS-1$
-
- /**
- * Return the resolved, qualified name of the attribute's type
- * (e.g. "java.util.Collection" or "byte[]").
- * If the type is an array, this name will include the appropriate number
- * of bracket pairs.
- * This name will not include the type's generic type arguments
- * (e.g. "java.util.Collection<java.lang.String>" will only return
- * "java.util.Collection").
- * @see #getTypeTypeArgumentNames()
- */
- String getTypeName();
- String TYPE_NAME_PROPERTY = "typeName"; //$NON-NLS-1$
-
- /**
- * Return whether the attribute type is an interface.
- */
- boolean typeIsInterface();
- String TYPE_IS_INTERFACE_PROPERTY = "typeIsInterface"; //$NON-NLS-1$
-
- /**
- * Return whether the attribute type is an enum.
- */
- boolean typeIsEnum();
- String TYPE_IS_ENUM_PROPERTY = "typeIsEnum"; //$NON-NLS-1$
-
- /**
- * Return whether the attribute type is an array.
- */
- boolean typeIsArray();
- String TYPE_IS_ARRAY_PROPERTY = "typeIsArray"; //$NON-NLS-1$
-
- /**
- * Return the dimensionality of the array, 0 otherwise.
- * (String[][] -> 2, Collection<String> -> 0)
- */
- int getTypeArrayDimensionality();
- String TYPE_ARRAY_DIMENSIONALITY_PROPERTY = "typeArrayDimensionality"; //$NON-NLS-1$
-
- /**
- * Return the component type name of the array, null otherwise.
- * (String[][] -> "java.lang.String", Collection<String> -> null)
- */
- String getTypeArrayComponentTypeName();
- String TYPE_ARRAY_COMPONENT_TYPE_NAME_PROPERTY = "typeArrayComponentTypeName"; //$NON-NLS-1$
-
- /**
- * Return the names of the attribute type's superclasses.
- */
- ListIterable<String> getTypeSuperclassNames();
- String TYPE_SUPERCLASS_NAMES_LIST = "typeSuperclassNames"; //$NON-NLS-1$
-
- /**
- * Return the names of the attribute type's interfaces.
- */
- Iterable<String> getTypeInterfaceNames();
- String TYPE_INTERFACE_NAMES_COLLECTION = "typeInterfaceNames"; //$NON-NLS-1$
-
- /**
- * Return the names of the attribute type's type arguments.
- * The name for any argument that is an array will contain the appropriate
- * number of bracket pairs.
- * The names will not include any further generic type arguments.
- */
- ListIterable<String> getTypeTypeArgumentNames();
- String TYPE_TYPE_ARGUMENT_NAMES_LIST = "typeTypeArgumentNames"; //$NON-NLS-1$
-
- int getTypeTypeArgumentNamesSize();
-
- String getTypeTypeArgumentName(int index);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceClassFile.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceClassFile.java
deleted file mode 100644
index ebda076809..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceClassFile.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-
-
-/**
- * Java class file
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JavaResourceClassFile
- extends JavaResourceNode
-{
- /**
- * Return the class file's type.
- */
- JavaResourceAbstractType getType();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceCompilationUnit.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceCompilationUnit.java
deleted file mode 100644
index 0a752f4137..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceCompilationUnit.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-
-/**
- * Dali resource for JDT compilation unit.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JavaResourceCompilationUnit
- extends JavaResourceNode.Root
-{
- /**
- * Return the corresponding JDT compilation unit.
- */
- ICompilationUnit getCompilationUnit();
-
- /**
- * Return the JPA project's annotation formatter. This is used to make any
- * manipulated annotations reasonably readable after being written to the
- * Java source file.
- */
- AnnotationEditFormatter getAnnotationEditFormatter();
-
- /**
- * This allows the resource model to modify the Java source code on the
- * UI thread when it is executing on another thread.
- */
- CommandExecutor getModifySharedDocumentCommandExecutor();
-
- /**
- * Resolve type information that could be dependent on other files being
- * added/removed.
- */
- void resolveTypes();
-
- /**
- * The primary type of the AST compilation unit, can be null.
- * This is named the same as the compilation unit.
- */
- JavaResourceAbstractType getPrimaryType();
-
- /**
- * Something in Java has changed (typically either the compilation unit's
- * source code or the Java classpath); synchronize the compilation unit's
- * state with the Java source code etc.
- */
- void synchronizeWithJavaSource();
-
- /**
- * Build an AST for the compilation unit with its bindings resolved.
- */
- CompilationUnit buildASTRoot();
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceEnum.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceEnum.java
deleted file mode 100644
index 774d95aa5c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceEnum.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-
-
-/**
- * Java source code or binary enum.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JavaResourceEnum
- extends JavaResourceAbstractType
-{
-
-
- // ********** enum constants **********
-
- /**
- * Return the enum's enum constants.
- */
- Iterable<JavaResourceEnumConstant> getEnumConstants();
- String ENUM_CONSTANTS_COLLECTION = "enumConstants"; //$NON-NLS-1$
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceEnumConstant.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceEnumConstant.java
deleted file mode 100644
index c72c4c43bd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceEnumConstant.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-/**
- * Java source code or binary enum constant
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JavaResourceEnumConstant
- extends JavaResourceMember
-{
- /**
- * The Java resource enum constant's name does not change.
- */
- String getName();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceField.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceField.java
deleted file mode 100644
index 1119f901c9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceField.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-/**
- * Java source code or binary field
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JavaResourceField
- extends JavaResourceAttribute
-{
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceMember.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceMember.java
deleted file mode 100644
index 6acbee48d2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceMember.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-
-/**
- * Java source code or binary persistent member.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 2.0
- */
-public interface JavaResourceMember
- extends JavaResourceAnnotatedElement
-{
- String getName();
-
- // ********** annotations **********
-
- /**
- * Sets the specified primary annotation as the first annotation, and removes all known
- * annotations (i.e. does not remove non-persistence annotations) which are not included
- * in the supporting annotations.
- */
- Annotation setPrimaryAnnotation(String primaryAnnotationName, Iterable<String> supportingAnnotationNames);
-
-
-
- // ********** modifiers **********
-
- /**
- * Return whether the member is final.
- */
- boolean isFinal();
- String FINAL_PROPERTY = "final"; //$NON-NLS-1$
-
- boolean isTransient();
- String TRANSIENT_PROPERTY = "transient"; //$NON-NLS-1$
-
- boolean isPublic();
- String PUBLIC_PROPERTY = "public"; //$NON-NLS-1$
-
- boolean isStatic();
- String STATIC_PROPERTY = "static"; //$NON-NLS-1$
-
- boolean isProtected();
- String PROTECTED_PROPERTY = "protected"; //$NON-NLS-1$
-
-
- // ********** queries **********
-
- /**
- * Return whether the Java resource member is for the specified
- * member.
- */
- boolean isFor(String memberName, int occurrence);
-
-
- // ********** behavior **********
-
- /**
- * Resolve type information that could be dependent on changes elsewhere
- * in the workspace.
- */
- void resolveTypes(CompilationUnit astRoot);
-
- /**
- * Return whether the Java resource member is public or protected
- */
- boolean isPublicOrProtected();
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceMethod.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceMethod.java
deleted file mode 100644
index 491a5c3ca6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceMethod.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jpt.common.utility.MethodSignature;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-/**
- * Java source code or binary method
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.2
- * @since 3.0
- */
-public interface JavaResourceMethod
- extends JavaResourceAttribute {
-
- // ***** method name *****
-
- /**
- * The Java resource method's name does not change.
- */
- String getMethodName();
-
-
- // ***** parameter type names *****
-
- String PARAMETER_TYPE_NAMES_LIST = "parameterTypeNames"; //$NON-NLS-1$
-
- ListIterable<String> getParameterTypeNames();
-
- String getParameterTypeName(int index);
-
- int getParametersSize();
-
-
- // ***** constructor *****
-
- String CONSTRUCTOR_PROPERTY = "constructor"; //$NON-NLS-1$
-
- boolean isConstructor();
-
-
- // ***** misc *****
-
- /**
- * Return whether the Java resource persistent attribute is for the specified
- * method.
- */
- boolean isFor(MethodSignature methodSignature, int occurrence);
-
- /**
- * Call this instead of initialize(CompilationUnit)
- * TODO remove initialize(CompilationUnit) from the hierarchy
- */
- void initialize(MethodDeclaration methodDeclaration);
-
- /**
- * Call this instead of synchronizeWith(CompilationUnit)
- * TODO remove synchronizeWith(CompilationUnit) from the hierarchy
- */
- void synchronizeWith(MethodDeclaration methodDeclaration);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceNode.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceNode.java
deleted file mode 100644
index 21e446ebfd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceNode.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.JptResourceModel;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * Common interface for Java resource nodes (source code or binary).
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JavaResourceNode
- extends Model
-{
- /**
- * Return the node's parent node.
- */
- JavaResourceNode getParent();
-
- /**
- * Return the Eclipse file that contains the Java resource node
- * (typically either a Java source code file or a JAR).
- */
- IFile getFile();
-
- /**
- * Return the root of the Java resource containment hierarchy
- * (typically either a compilation unit or a package fragment root).
- */
- Root getRoot();
-
- /**
- * Return the [source] node's root (the compilation unit).
- */
- // TODO get rid of this method...?
- JavaResourceCompilationUnit getJavaResourceCompilationUnit();
-
- /**
- * Return the [source] node's text range in the compilation unit's file.
- */
- TextRange getTextRange(CompilationUnit astRoot);
-
- /**
- * Initialize the [source] node from the specified AST.
- */
- void initialize(CompilationUnit astRoot);
-
- /**
- * Synchronize the [source] node with the specified AST.
- */
- void synchronizeWith(CompilationUnit astRoot);
-
-
- /**
- * Root of Java resource model containment hierarchy.
- */
- interface Root
- extends JavaResourceNode, JptResourceModel {
-
- /**
- * Return the root's Java resource "abstract" types.
- */
- Iterable<JavaResourceAbstractType> getTypes();
- String TYPES_COLLECTION = "types"; //$NON-NLS-1$
-
- /**
- * Called (via a hook in change notification) whenever anything in the
- * Java resource model changes. Forwarded to listeners.
- */
- void resourceModelChanged();
-
- /**
- * Return the annotation provider that supplies the annotations found
- * in the Java resource model.
- */
- AnnotationProvider getAnnotationProvider();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackage.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackage.java
deleted file mode 100644
index 471b951473..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackage.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-/**
- * @author Dmitry Geraskov
- *
- * Java source code of package-info
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface JavaResourcePackage
- extends JavaResourceAnnotatedElement {
-
- /**
- * The Java resource persistent package's name.
- */
- String getName();
- String NAME_PROPERTY = "name"; //$NON-NLS-1$
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageFragment.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageFragment.java
deleted file mode 100644
index 87ceb27c66..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageFragment.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.jpt.common.core.AnnotationProvider;
-
-
-
-/**
- * Java package fragment
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 2.2
- * @since 2.2
- */
-public interface JavaResourcePackageFragment
- extends JavaResourceNode
-{
- /**
- * Return the package fragment's class files that contain "annotated" types.
- * Annotated with the annotations we care about,
- * @see AnnotationProvider
- */
- Iterable<JavaResourceClassFile> getClassFiles();
- String CLASS_FILES_COLLECTION = "classFiles"; //$NON-NLS-1$
-
- /**
- * Return the size of the package fragment's class files.
- */
- int getClassFilesSize();
-
- /**
- * Return the package fragment's Java types.
- * This is a convenience method that returns the JavaResourceTypes of the classFiles.
- */
- Iterable<JavaResourceAbstractType> getTypes();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageFragmentRoot.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageFragmentRoot.java
deleted file mode 100644
index 12082c6532..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageFragmentRoot.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-
-/**
- * Java package fragement root
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 2.2
- * @since 2.2
- */
-public interface JavaResourcePackageFragmentRoot
- extends JavaResourceNode.Root
-{
- /**
- * Return the package fragment root's package fragments.
- */
- Iterable<JavaResourcePackageFragment> getPackageFragments();
- String PACKAGE_FRAGMENTS_COLLECTION = "packageFragments"; //$NON-NLS-1$
-
- /**
- * Return the size of the package fragment root's package fragments.
- */
- int getPackageFragmentsSize();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageInfoCompilationUnit.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageInfoCompilationUnit.java
deleted file mode 100644
index 9371615344..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourcePackageInfoCompilationUnit.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-/**
- * Dali resource for JDT compilation unit named package-info.java.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface JavaResourcePackageInfoCompilationUnit
- extends JavaResourceCompilationUnit
-{
- JavaResourcePackage getPackage();
- String PACKAGE = "package"; //$NON-NLS-1$
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceType.java
deleted file mode 100644
index b4f237120c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceType.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-
-/**
- * Java source code or binary class or interface.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 2.0
- */
-public interface JavaResourceType
- extends JavaResourceAbstractType
-{
-
- /**
- * Return the fully qualified name of the type's superclass.
- */
- String getSuperclassQualifiedName();
- String SUPERCLASS_QUALIFIED_NAME_PROPERTY = "superclassQualifiedName"; //$NON-NLS-1$
-
- /**
- * Return whether the type is abstract.
- */
- boolean isAbstract();
- String ABSTRACT_PROPERTY = "abstract"; //$NON-NLS-1$
-
- /**
- * Return whether the type has a no-arg constructor (private, protected, or public)
- */
- boolean hasNoArgConstructor();
- String NO_ARG_CONSTRUCTOR_PROPERTY = "noArgConstructor"; //$NON-NLS-1$
-
- /**
- * Return whether the type has a private no-arg constructor
- */
- boolean hasPrivateNoArgConstructor();
- String PRIVATE_NO_ARG_CONSTRUCTOR_PROPERTY = "privateNoArgConstructor"; //$NON-NLS-1$
-
- /**
- * Return whether the type has a public or protected no-arg constructor
- * <em>or</em> only the default constructor.
- */
- boolean hasPublicOrProtectedNoArgConstructor();
-
- /**
- * Return whether the type has a public no-arg constructor
- * <em>or</em> only the default constructor.
- */
- boolean hasPublicNoArgConstructor();
-
- /**
- * Return whether the type has any field that have relevant annotations
- * on them (which can be used to infer the type's access type).
- */
- boolean hasAnyAnnotatedFields();
-
- /**
- * Return whether the type has any field that have relevant annotations
- * on them (which can be used to infer the type's access type).
- */
- boolean hasAnyAnnotatedMethods();
-
- /**
- * Return whether the type overrides the
- * {@link Object#equals(Object)} method.
- */
- boolean hasEqualsMethod();
-
- /**
- * Return whether the type overrides the
- * {@link Object#hashCode()} method.
- */
- boolean hasHashCodeMethod();
-
- // ********** fields **********
-
- /**
- * Return the type's fields.
- */
- Iterable<JavaResourceField> getFields();
- String FIELDS_COLLECTION = "fields"; //$NON-NLS-1$
-
-
- // ********** methods **********
-
- /**
- * Return the type's methods. This returns *all* methods from the JDT Type
- */
- Iterable<JavaResourceMethod> getMethods();
- String METHODS_COLLECTION = "methods"; //$NON-NLS-1$
-
- JavaResourceMethod getMethod(String name);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceTypeCache.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceTypeCache.java
deleted file mode 100644
index 59d5e7e883..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/JavaResourceTypeCache.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jdt.core.IType;
-
-/**
- * Java persistent type cache - used to hold "external" types
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 2.3
- * @since 2.2
- */
-public interface JavaResourceTypeCache
- extends JavaResourceNode.Root
-{
-
- /**
- * Return the size of the cache's types.
- */
- int getTypesSize();
-
- /**
- * Add a Java resource type for the specified JDT type to the
- * cache. Return the new type.
- */
- JavaResourceAbstractType addType(IType jdtType);
-
- /**
- * Remove all the types associated with the specified JAR file.
- * Return whether any types were removed.
- */
- boolean removeTypes(IFile jarFile);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/NestableAnnotation.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/NestableAnnotation.java
deleted file mode 100644
index 68d364bcdd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/NestableAnnotation.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-/**
- * Interface for dealing with annotations that can be "nested" within other
- * annotations, typically within arrays.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 2.0
- */
-public interface NestableAnnotation
- extends Annotation {
-
- /**
- * Move the annotation to the specified index within its container annotation.
- * This should only be called when the annotation is actually nested.
- */
- void moveAnnotation(int index);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/NestableAnnotationDefinition.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/NestableAnnotationDefinition.java
deleted file mode 100644
index eb9784f1d0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/resource/java/NestableAnnotationDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.resource.java;
-
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotatedElement;
-
-/**
- * Used to build NestableAnnotations discovered in the Java source code.
- * To provide new NestableAnnotationDefinitions, create a new JaxbPlatform
- * by implementing JaxbPlatformDefinition.
- *
- * @see NestableAnnotation
- * @see org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDefinition
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 3.0
- * @since 3.0
- */
-public interface NestableAnnotationDefinition
-{
- /**
- * Return the name of the annotation the definition will build in the
- * various #build...(...) methods.
- */
- String getNestableAnnotationName();
-
- String getContainerAnnotationName();
-
- String getElementName();
-
- /**
- * Build and return an annotation for the specified annotated element.
- */
- NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement, int index);
-
- /**
- * Build and return an annotation for the specified JDT annotation
- * on the specified annotated element.
- */
- NestableAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation, int index);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/AbstractTextRange.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/AbstractTextRange.java
deleted file mode 100644
index 266e65366a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/AbstractTextRange.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility;
-
-import org.eclipse.jpt.common.core.internal.utility.SimpleTextRange;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Partial implementation of text range.
- *
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @version 2.0
- * @since 2.0
- */
-public abstract class AbstractTextRange
- implements TextRange
-{
- protected AbstractTextRange() {
- super();
- }
-
- public boolean includes(int index) {
- return (this.getOffset() <= index) && (index < this.getEnd());
- }
-
- public boolean touches(int index) {
- return (this.getOffset() <= index) && (index <= this.getEnd());
- }
-
- /**
- * The end offset is <em>exclusive</em>, i.e. the element at the end offset
- * is not included in the range.
- */
- protected int getEnd() {
- return this.getOffset() + this.getLength();
- }
-
- public TextRange buildTextRange(int offset, int length, int lineNumber) {
- return ((offset == this.getOffset()) &&
- (length == this.getLength()) &&
- (lineNumber == this.getLineNumber())) ?
- this :
- new SimpleTextRange(offset, length, lineNumber);
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if ( ! (o instanceof TextRange)) {
- return false;
- }
- TextRange other = (TextRange) o;
- return (other.getOffset() == this.getOffset())
- && (other.getLength() == this.getLength())
- && (other.getLineNumber() == this.getLineNumber());
- }
-
- @Override
- public int hashCode() {
- return this.getOffset() ^ this.getLength() ^ this.getLineNumber();
- }
-
- @Override
- public String toString() {
- String start = String.valueOf(this.getOffset());
- String end = String.valueOf(this.getEnd());
- String line = String.valueOf(this.getLineNumber());
- return StringTools.buildToStringFor(this, start + ", " + end + " [" + line + ']'); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/BodySourceWriter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/BodySourceWriter.java
deleted file mode 100644
index 9aabeebdd5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/BodySourceWriter.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility;
-
-import java.io.Serializable;
-import java.io.StringWriter;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeSet;
-
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.IndentingPrintWriter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-
-import com.ibm.icu.text.Collator;
-
-/**
- * Extend {@link IndentingPrintWriter} with some methods that facilitate
- * building class source code.
- */
-@SuppressWarnings("nls")
-public class BodySourceWriter
- extends IndentingPrintWriter
-{
- protected final String packageName;
- protected final String className;
- // key = short class name; value = import package
- protected final HashMap<String, ImportPackage> imports = new HashMap<String, ImportPackage>();
-
- public BodySourceWriter(String packageName, String className) {
- super(new StringWriter(2000));
- this.packageName = packageName;
- this.className = className;
- }
-
- public String getSource() {
- return this.out.toString();
- }
-
- public int getLength() {
- return ((StringWriter) this.out).getBuffer().length();
- }
-
- protected void printVisibility(String visibilityModifier) {
- if (visibilityModifier.length() != 0) {
- this.print(visibilityModifier);
- this.print(' ');
- }
- }
-
- public void printAnnotation(String annotationName) {
- this.print('@');
- this.printTypeDeclaration(annotationName);
- }
-
- public void printTypeDeclaration(String typeDeclaration) {
- this.print(this.buildImportedTypeDeclaration(typeDeclaration));
- }
-
- protected void printField(String fieldName, String typeDeclaration, String visibility) {
- this.printVisibility(visibility);
- this.printTypeDeclaration(typeDeclaration);
- this.print(' ');
- this.print(fieldName);
- this.print(';');
- this.println();
- this.println();
- }
-
- protected void printParameterizedField(String fieldName, String typeDeclaration, String parameterTypeDeclaration, String visibility) {
- this.printVisibility(visibility);
- this.printTypeDeclaration(typeDeclaration);
- this.print('<');
- this.printTypeDeclaration(parameterTypeDeclaration);
- this.print('>');
- this.print(' ');
- this.print(fieldName);
- this.print(';');
- this.println();
- this.println();
- }
-
- /**
- * Convert the specified string to a <em>String Literal</em> and print it,
- * adding the surrounding double-quotes and escaping characters
- * as necessary.
- */
- public void printStringLiteral(String string) {
- StringTools.convertToJavaStringLiteralOn(string, this);
- }
-
-
- // ********** imports **********
-
- // ***** writing
- /**
- * Return the specified class's "imported" name.
- * The class declaration must be of the form:
- * "int"
- * "int[]" (not "[I")
- * "java.lang.Object"
- * "java.lang.Object[]" (not "[Ljava.lang.Object;")
- * "java.util.Map.Entry" (not "java.util.Map$Entry")
- * "java.util.Map.Entry[][]" (not "[[Ljava.util.Map$Entry;")
- *
- * To really do this right, we would need to gather all the types from
- * the "unamed" (default) package that were referenced in the
- * compilation unit beforehand. *Any* collisions with one of these
- * types would have to be fully qualified (whether it was from
- * 'java.lang' or the same package as the current compilation unit).
- * In other words, if we have any types from the "unnamed" package,
- * results are unpredictable....
- */
- protected String buildImportedTypeDeclaration(String typeDeclaration) {
- if (this.typeDeclarationIsMemberClass(typeDeclaration)) {
- // no need for an import, just return the partially-qualified name
- return this.buildMemberClassTypeDeclaration(typeDeclaration);
- }
- int last = typeDeclaration.lastIndexOf('.');
- String currentPackageName = (last == -1) ? "" : typeDeclaration.substring(0, last);
- String shortTypeDeclaration = typeDeclaration.substring(last + 1);
- String shortElementTypeName = shortTypeDeclaration;
- while (shortElementTypeName.endsWith("[]")) {
- shortElementTypeName = shortElementTypeName.substring(0, shortElementTypeName.length() - 2);
- }
- ImportPackage prev = this.imports.get(shortElementTypeName);
- if (prev == null) {
- // this is the first class with this short element type name
- this.imports.put(shortElementTypeName, new ImportPackage(currentPackageName));
- return shortTypeDeclaration;
- }
- if (prev.packageName.equals(currentPackageName)) {
- // this element type has already been imported
- return shortTypeDeclaration;
- }
- if (currentPackageName.equals(this.packageName) &&
- prev.packageName.equals("java.lang")) {
- // we force the 'java.lang' class to be explicitly imported
- prev.collision = true;
- }
- // another class with the same short element type name has been
- // previously imported, so this one must be used fully-qualified
- return typeDeclaration;
- }
-
- /**
- * e.g. "foo.bar.Employee.PK" will return true
- */
- protected boolean typeDeclarationIsMemberClass(String typeDeclaration) {
- return (typeDeclaration.length() > this.className.length())
- && typeDeclaration.startsWith(this.className)
- && (typeDeclaration.charAt(this.className.length()) == '.');
- }
-
- /**
- * e.g. "foo.bar.Employee.PK" will return "Employee.PK"
- * this prevents collisions with other imported classes (e.g. "joo.jar.PK")
- */
- protected String buildMemberClassTypeDeclaration(String typeDeclaration) {
- int index = this.packageName.length();
- if (index != 0) {
- index++; // bump past the '.'
- }
- return typeDeclaration.substring(index);
- }
-
- // ***** reading
- public Iterable<String> getImports() {
- return this.getSortedRequiredImports();
- }
-
- /**
- * transform our map entries to class names
- */
- protected Iterable<String> getSortedRequiredImports() {
- return new TransformationIterable<Map.Entry<String, ImportPackage>, String>(this.getSortedRequiredImportEntries(), this.buildImportEntriesTransformer());
- }
-
- protected Transformer<Map.Entry<String, ImportPackage>, String> buildImportEntriesTransformer() {
- return IMPORT_ENTRIES_TRANSFORMER;
- }
-
- protected static final Transformer<Map.Entry<String, ImportPackage>, String> IMPORT_ENTRIES_TRANSFORMER = new ImportEntriesTransformer();
-
- protected static class ImportEntriesTransformer
- implements Transformer<Map.Entry<String, ImportPackage>, String>
- {
- public String transform(Entry<String, ImportPackage> importEntry) {
- String pkg = importEntry.getValue().packageName;
- String type = importEntry.getKey();
- StringBuilder sb = new StringBuilder(pkg.length() + 1 + type.length());
- sb.append(pkg);
- sb.append('.');
- sb.append(type);
- return sb.toString();
- }
- }
-
- /**
- * sort by package first, then class (*not* by fully-qualified class name)
- */
- protected Iterable<Map.Entry<String, ImportPackage>> getSortedRequiredImportEntries() {
- TreeSet<Map.Entry<String, ImportPackage>> sortedEntries = new TreeSet<Map.Entry<String, ImportPackage>>(this.buildImportEntriesComparator());
- CollectionTools.addAll(sortedEntries, this.getRequiredImportEntries());
- return sortedEntries;
- }
-
- protected Comparator<Map.Entry<String, ImportPackage>> buildImportEntriesComparator() {
- return IMPORT_ENTRIES_COMPARATOR;
- }
-
- protected static final Comparator<Map.Entry<String, ImportPackage>> IMPORT_ENTRIES_COMPARATOR = new ImportEntriesComparator();
-
- protected static class ImportEntriesComparator
- implements Comparator<Map.Entry<String, ImportPackage>>, Serializable
- {
- public int compare(Map.Entry<String, ImportPackage> e1, Map.Entry<String, ImportPackage> e2) {
- Collator collator = Collator.getInstance();
- int pkg = collator.compare(e1.getValue().packageName, e2.getValue().packageName);
- return (pkg == 0) ? collator.compare(e1.getKey(), e2.getKey()) : pkg;
- }
- }
-
- /**
- * strip off any non-required imports (e.g. "java.lang.Object')
- */
- protected Iterable<Map.Entry<String, ImportPackage>> getRequiredImportEntries() {
- return new FilteringIterable<Map.Entry<String, ImportPackage>>(this.imports.entrySet(), this.buildRequiredImportEntriesFilter());
- }
-
- protected Filter<Map.Entry<String, ImportPackage>> buildRequiredImportEntriesFilter() {
- return new RequiredImportEntriesFilter();
- }
-
- protected class RequiredImportEntriesFilter
- implements Filter<Map.Entry<String, ImportPackage>>
- {
- public boolean accept(Map.Entry<String, ImportPackage> importEntry) {
- return this.packageMustBeImported(importEntry.getValue());
- }
-
- protected boolean packageMustBeImported(ImportPackage importPackage) {
- String pkg = importPackage.packageName;
- if (pkg.equals("")) {
- // cannot import a type from the "unnamed" package
- return false;
- }
- if (pkg.equals("java.lang")) {
- // we must import from 'java.lang' if we also have a class in the same package
- return importPackage.collision;
- }
- if (pkg.equals(BodySourceWriter.this.packageName)) {
- // we never need to import a class from the same package
- return false;
- }
- return true;
- }
- }
-
- /**
- * We need a 'collision' flag for when we encounter a class from
- * 'java.lang' followed by a class from the current compilation unit's
- * package. We will need to include the explicit import of the
- * 'java.lang' class and all the references to the other class will
- * have to be fully-qualified.
- *
- * If the classes are encountered in the opposite order (i.e. the class
- * from the current compilation unit's package followed by the class
- * from 'java.lang'), we do *not* need to import the first class while
- * all the references to the 'java.lang' class will be fully-qualified.
- *
- * Unfortunately, we still have a problem: if we reference a class from
- * 'java.lang' and there is a conflicting class from the current
- * compilation unit's package (but that class is *not* revealed to us
- * here), the simple name will be resolved to the non-'java.lang' class.
- * Unless we simply force an import of *all* 'java.lang' classes.... :-(
- *
- * This shouldn't happen very often. :-)
- */
- protected static class ImportPackage {
- protected final String packageName;
- protected boolean collision = false;
-
- protected ImportPackage(String packageName) {
- super();
- this.packageName = packageName;
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/TextRange.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/TextRange.java
deleted file mode 100644
index f31dd77adf..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/TextRange.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-
-/**
- * A text range defines the offset into, length of, and line of a piece
- * of text.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- * <p>
- * This interface is not intended to be implemented by clients.
- *
- * @version 2.0
- * @since 2.0
- */
-public interface TextRange {
-
- /**
- * Return the offset of the text.
- */
- int getOffset();
-
- /**
- * Return the length of the text.
- */
- int getLength();
-
- /**
- * Return whether the range includes the character at the specified index.
- */
- boolean includes(int index);
-
- /**
- * Return whether the range touches an insertion cursor at the
- * specified index.
- */
- boolean touches(int index);
-
- /**
- * Return the line number of the text.
- */
- int getLineNumber();
-
- /**
- * Build and return a new text range for the specified values if they differ
- * from the text range. If the specified values match the
- * text range, simply return the text range unchanged.
- */
- TextRange buildTextRange(int offset, int length, int lineNumber);
-
- /**
- * Return whether the offsets, lengths, and line numbers are the same.
- */
- boolean equals(Object obj);
-
- /**
- * Return a hash code that corresponds to the {@link Object#equals(Object)}
- * contract.
- */
- int hashCode();
-
-
- /**
- * Empty implementation of text range.
- */
- final class Empty extends AbstractTextRange {
- public static final TextRange INSTANCE = new Empty();
- public static TextRange instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Empty() {
- super();
- }
- public int getLineNumber() {
- return IMessage.LINENO_UNSET;
- }
- public int getOffset() {
- return IMessage.OFFSET_UNSET;
- }
- public int getLength() {
- return IMessage.OFFSET_UNSET;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/CombinedCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/CombinedCommandExecutor.java
deleted file mode 100644
index 982911ad1f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/CombinedCommandExecutor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Combine the job command executor and command executor interfaces.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface CombinedCommandExecutor
- extends JobCommandExecutor, CommandExecutor
-{
- /**
- * Singleton implementation of the command executor interface
- * that simply executes the command without any sort of enhancement.
- */
- final class Default
- implements CombinedCommandExecutor, Serializable
- {
- public static final CombinedCommandExecutor INSTANCE = new Default();
- public static CombinedCommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- public void execute(Command command) {
- command.execute();
- }
- public void execute(JobCommand command) {
- command.execute(new NullProgressMonitor());
- }
- public void execute(JobCommand command, String jobName) {
- this.execute(command);
- }
- public void execute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- this.execute(command);
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
-
- /**
- * Singleton implementation of the command executor interface
- * that ignores any commands.
- */
- final class Inactive
- implements CombinedCommandExecutor, Serializable
- {
- public static final CombinedCommandExecutor INSTANCE = new Inactive();
- public static CombinedCommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Inactive() {
- super();
- }
- public void execute(Command command) {
- // do nothing
- }
- public void execute(JobCommand command) {
- // do nothing
- }
- public void execute(JobCommand command, String jobName) {
- // do nothing
- }
- public void execute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/CombinedExtendedCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/CombinedExtendedCommandExecutor.java
deleted file mode 100644
index f1a57014b9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/CombinedExtendedCommandExecutor.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Combine the synchronouse job command executor and command executor
- * interfaces.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface CombinedExtendedCommandExecutor
- extends CombinedCommandExecutor, ExtendedJobCommandExecutor, ExtendedCommandExecutor
-{
- /**
- * Singleton implementation of the command executor interface
- * that simply executes the command without any sort of enhancement.
- */
- final class Default
- implements CombinedExtendedCommandExecutor, Serializable
- {
- public static final CombinedExtendedCommandExecutor INSTANCE = new Default();
- public static CombinedExtendedCommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- public void execute(Command command) {
- command.execute();
- }
- public void waitToExecute(Command command) {
- command.execute();
- }
- public boolean waitToExecute(Command command, long timeout) {
- command.execute();
- return true;
- }
- public void execute(JobCommand command) {
- command.execute(new NullProgressMonitor());
- }
- public void execute(JobCommand command, String jobName) {
- this.execute(command);
- }
- public void execute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- this.execute(command);
- }
- public void waitToExecute(JobCommand command) {
- this.execute(command);
- }
- public boolean waitToExecute(JobCommand command, long timeout) {
- this.execute(command);
- return true;
- }
- public void waitToExecute(JobCommand command, String jobName) {
- this.execute(command);
- }
- public boolean waitToExecute(JobCommand command, String jobName, long timeout) {
- this.execute(command);
- return true;
- }
- public void waitToExecute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- this.execute(command);
- }
- public boolean waitToExecute(JobCommand command, String jobName, ISchedulingRule schedulingRule, long timeout) {
- this.execute(command);
- return true;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
-
- /**
- * Singleton implementation of the command executor interface
- * that ignores any commands.
- */
- final class Inactive
- implements CombinedExtendedCommandExecutor, Serializable
- {
- public static final CombinedExtendedCommandExecutor INSTANCE = new Inactive();
- public static CombinedExtendedCommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Inactive() {
- super();
- }
- public void execute(Command command) {
- // do nothing
- }
- public void waitToExecute(Command command) {
- // do nothing
- }
- public boolean waitToExecute(Command command, long timeout) {
- // do nothing
- return true;
- }
- public void execute(JobCommand command) {
- // do nothing
- }
- public void execute(JobCommand command, String jobName) {
- // do nothing
- }
- public void execute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- // do nothing
- }
- public void waitToExecute(JobCommand command) {
- // do nothing
- }
- public boolean waitToExecute(JobCommand command, long timeout) throws InterruptedException {
- // do nothing
- return true;
- }
- public void waitToExecute(JobCommand command, String jobName) {
- // do nothing
- }
- public boolean waitToExecute(JobCommand command, String jobName, long timeout) throws InterruptedException {
- // do nothing
- return true;
- }
- public void waitToExecute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- // do nothing
- }
- public boolean waitToExecute(JobCommand command, String jobName, ISchedulingRule schedulingRule, long timeout) throws InterruptedException {
- // do nothing
- return true;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/ExtendedJobCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/ExtendedJobCommandExecutor.java
deleted file mode 100644
index 15c4b5d0a9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/ExtendedJobCommandExecutor.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This interface extends the normal command executor to allow the client
- * to control when a command is required to be executed synchronously.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ExtendedJobCommandExecutor
- extends JobCommandExecutor
-{
- /**
- * Suspend the current thread until the specified command is executed.
- * The command itself must be executed <em>after</em> any other commands
- * previously passed to the command executor. The command may or may
- * not be assigned to a {@link org.eclipse.core.runtime.jobs.Job}
- * for execution.
- * @see #execute(JobCommand)
- */
- void waitToExecute(JobCommand command) throws InterruptedException;
-
- /**
- * Suspend the current thread until the specified command is executed
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the command was executed in the allotted time;
- * return <code>false</code> if a time-out occurred and the command was
- * <em>not</em> executed.
- * If the time-out is zero, wait indefinitely.
- * <p>
- * The command itself must be executed <em>after</em> any other commands
- * previously passed to the command executor. The command may or may
- * not be assigned to a {@link org.eclipse.core.runtime.jobs.Job}
- * for execution.
- * @see #execute(JobCommand)
- */
- boolean waitToExecute(JobCommand command, long timeout) throws InterruptedException;
-
- /**
- * Suspend the current thread until the specified command is executed.
- * The command itself must be executed <em>after</em> any other commands
- * previously passed to the command executor. The command may or may
- * not be assigned to a {@link org.eclipse.core.runtime.jobs.Job}
- * for execution.
- * @see #execute(JobCommand, String)
- */
- void waitToExecute(JobCommand command, String jobName) throws InterruptedException;
-
- /**
- * Suspend the current thread until the specified command is executed
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the command was executed in the allotted time;
- * return <code>false</code> if a time-out occurred and the command was
- * <em>not</em> executed.
- * If the time-out is zero, wait indefinitely.
- * <p>
- * The command itself must be executed <em>after</em> any other commands
- * previously passed to the command executor. The command may or may
- * not be assigned to a {@link org.eclipse.core.runtime.jobs.Job}
- * for execution.
- * @see #execute(JobCommand, String)
- */
- boolean waitToExecute(JobCommand command, String jobName, long timeout) throws InterruptedException;
-
- /**
- * Suspend the current thread until the specified command is executed.
- * The command itself must be executed <em>after</em> any other commands
- * previously passed to the command executor. The command may or may
- * not be assigned to a {@link org.eclipse.core.runtime.jobs.Job}
- * for execution.
- * @see #execute(JobCommand, String, ISchedulingRule)
- */
- void waitToExecute(JobCommand command, String jobName, ISchedulingRule schedulingRule) throws InterruptedException;
-
-
- /**
- * Suspend the current thread until the specified command is executed
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the command was executed in the allotted time;
- * return <code>false</code> if a time-out occurred and the command was
- * <em>not</em> executed.
- * If the time-out is zero, wait indefinitely.
- * <p>
- * The command itself must be executed <em>after</em> any other commands
- * previously passed to the command executor. The command may or may
- * not be assigned to a {@link org.eclipse.core.runtime.jobs.Job}
- * for execution.
- * @see #execute(JobCommand, String, ISchedulingRule)
- */
- boolean waitToExecute(JobCommand command, String jobName, ISchedulingRule schedulingRule, long timeout) throws InterruptedException;
-
-
- /**
- * Singleton implementation of the command executor interface
- * that simply executes the command without any sort of enhancement.
- */
- final class Default
- implements ExtendedJobCommandExecutor, Serializable
- {
- public static final ExtendedJobCommandExecutor INSTANCE = new Default();
- public static ExtendedJobCommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- public void execute(JobCommand command) {
- command.execute(new NullProgressMonitor());
- }
- public void execute(JobCommand command, String jobName) {
- this.execute(command);
- }
- public void execute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- this.execute(command);
- }
- public void waitToExecute(JobCommand command) {
- this.execute(command);
- }
- public boolean waitToExecute(JobCommand command, long timeout) {
- this.execute(command);
- return true;
- }
- public void waitToExecute(JobCommand command, String jobName) {
- this.execute(command);
- }
- public boolean waitToExecute(JobCommand command, String jobName, long timeout) {
- this.execute(command);
- return true;
- }
- public void waitToExecute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- this.execute(command);
- }
- public boolean waitToExecute(JobCommand command, String jobName, ISchedulingRule schedulingRule, long timeout) {
- this.execute(command);
- return true;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
-
- /**
- * Singleton implementation of the command executor interface
- * that ignores any commands.
- */
- final class Inactive
- implements ExtendedJobCommandExecutor, Serializable
- {
- public static final ExtendedJobCommandExecutor INSTANCE = new Inactive();
- public static ExtendedJobCommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Inactive() {
- super();
- }
- public void execute(JobCommand command) {
- // do nothing
- }
- public void execute(JobCommand command, String jobName) {
- // do nothing
- }
- public void execute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- // do nothing
- }
- public void waitToExecute(JobCommand command) {
- // do nothing
- }
- public boolean waitToExecute(JobCommand command, long timeout) throws InterruptedException {
- // do nothing
- return true;
- }
- public void waitToExecute(JobCommand command, String jobName) {
- // do nothing
- }
- public boolean waitToExecute(JobCommand command, String jobName, long timeout) throws InterruptedException {
- // do nothing
- return true;
- }
- public void waitToExecute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- // do nothing
- }
- public boolean waitToExecute(JobCommand command, String jobName, ISchedulingRule schedulingRule, long timeout) throws InterruptedException {
- // do nothing
- return true;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/InterruptibleJobCommand.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/InterruptibleJobCommand.java
deleted file mode 100644
index 4eb68d4bbb..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/InterruptibleJobCommand.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Simple interface for implementing the GOF Command design pattern
- * in an Eclipse job
- * and allows for the command to throw an {@link InterruptedException}.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @see org.eclipse.jpt.common.core.utility.command.JobCommand
- */
-public interface InterruptibleJobCommand {
-
- /**
- * Execute the command. The semantics of the command
- * is determined by the contract between the client and server.
- * The command should check, as appropriate, whether the specified progress
- * monitor is {@link IProgressMonitor#isCanceled() "canceled"}; if it is,
- * the command should return a result
- * status of severity {@link IStatus#CANCEL}. The singleton
- * cancel status {@link org.eclipse.core.runtime.Status#CANCEL_STATUS} can be used for
- * this purpose.
- * <p>
- * Nested methods can also check the progress monitor
- * and, if it is "canceled", throw an
- * {@link org.eclipse.core.runtime.OperationCanceledException OperationCanceledException}.
- *
- * @see IProgressMonitor#isCanceled()
- * @see org.eclipse.core.runtime.jobs.Job#run(IProgressMonitor monitor)
- */
- IStatus execute(IProgressMonitor monitor) throws InterruptedException;
-
-
- /**
- * Singleton implementation of the interruptible job command interface that
- * will throw an interrupted exception when executed.
- */
- final class Interrupted
- implements InterruptibleJobCommand, Serializable
- {
- public static final InterruptibleJobCommand INSTANCE = new Interrupted();
- public static InterruptibleJobCommand instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Interrupted() {
- super();
- }
- // throw an exception
- public IStatus execute(IProgressMonitor monitor) throws InterruptedException {
- throw new InterruptedException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/JobCommand.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/JobCommand.java
deleted file mode 100644
index b70f49e3dc..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/JobCommand.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.command;
-
-import java.io.Serializable;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Simple interface for implementing the GOF Command design pattern in an
- * Eclipse job.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface JobCommand
- extends InterruptibleJobCommand
-{
- /**
- * Execute the command. The semantics of the command
- * is determined by the contract between the client and server.
- * The command should check, as appropriate, whether the specified progress
- * monitor is {@link IProgressMonitor#isCanceled() "canceled"}; if it is,
- * the command should return a result
- * status of severity {@link IStatus#CANCEL}. The singleton
- * cancel status {@link Status#CANCEL_STATUS} can be used for
- * this purpose.
- * <p>
- * Nested methods can also check the progress monitor
- * and, if it is "canceled", throw an
- * {@link org.eclipse.core.runtime.OperationCanceledException OperationCanceledException}.
- *
- * @see IProgressMonitor#isCanceled()
- * @see org.eclipse.core.runtime.jobs.Job#run(IProgressMonitor monitor)
- */
- IStatus execute(IProgressMonitor monitor);
-
-
- /**
- * Singleton implementation of the job command interface that will do
- * nothing when executed.
- */
- final class Null
- implements JobCommand, Serializable
- {
- public static final JobCommand INSTANCE = new Null();
- public static JobCommand instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public IStatus execute(IProgressMonitor monitor) {
- return Status.OK_STATUS;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
-
- /**
- * Singleton implementation of the job command interface that will throw an
- * exception when executed.
- */
- final class Disabled
- implements JobCommand, Serializable
- {
- public static final JobCommand INSTANCE = new Disabled();
- public static JobCommand instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public IStatus execute(IProgressMonitor monitor) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/JobCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/JobCommandExecutor.java
deleted file mode 100644
index e2e1bcef8c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/JobCommandExecutor.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This interface allows clients to control how a job command is executed.
- * This is useful when the server provides the command but the client provides
- * the context (e.g. the client would like to execute the command synchronously
- * rather than dispatching it to a job queue).
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface JobCommandExecutor {
-
- /**
- * Execute the specified command, synchronously or asynchronously.
- * Commands with the same scheduling rule must be executed in the order in
- * which they are passed to the command executor.
- * The command may or may not be assigned to a
- * {@link org.eclipse.core.runtime.jobs.Job} for execution.
- */
- void execute(JobCommand command);
-
- /**
- * Execute the specified command, synchronously or asynchronously.
- * Commands with the same scheduling rule must be executed in the order in
- * which they are passed to the command executor.
- * The command may or may not be assigned to a
- * {@link org.eclipse.core.runtime.jobs.Job} for execution.
- */
- void execute(JobCommand command, String jobName);
-
- /**
- * Execute the specified command, synchronously or asynchronously.
- * Commands with the same scheduling rule must be executed in the order in
- * which they are passed to the command executor.
- * The command may or may not be assigned to a
- * {@link org.eclipse.core.runtime.jobs.Job} for execution.
- */
- void execute(JobCommand command, String jobName, ISchedulingRule schedulingRule);
-
-
- /**
- * Singleton implementation of the command executor interface
- * that simply executes the command without any sort of enhancement.
- */
- final class Default
- implements JobCommandExecutor, Serializable
- {
- public static final JobCommandExecutor INSTANCE = new Default();
- public static JobCommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- public void execute(JobCommand command) {
- command.execute(new NullProgressMonitor());
- }
- public void execute(JobCommand command, String jobName) {
- this.execute(command);
- }
- public void execute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- this.execute(command);
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
-
- /**
- * Singleton implementation of the command executor interface
- * that ignores any commands.
- */
- final class Inactive
- implements JobCommandExecutor, Serializable
- {
- public static final JobCommandExecutor INSTANCE = new Inactive();
- public static JobCommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Inactive() {
- super();
- }
- public void execute(JobCommand command) {
- // do nothing
- }
- public void execute(JobCommand command, String jobName) {
- // do nothing
- }
- public void execute(JobCommand command, String jobName, ISchedulingRule schedulingRule) {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/NotifyingRepeatingJobCommand.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/NotifyingRepeatingJobCommand.java
deleted file mode 100644
index 2710618aa2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/NotifyingRepeatingJobCommand.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.command;
-
-import java.io.Serializable;
-import java.util.EventListener;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Extend the repeating job command to support listeners that are notified
- * when an execution "cycle" is complete; i.e. the job command has,
- * for the moment, handled every execution request and quiesced.
- * This notification is <em>not</em> guaranteed to occur with <em>every</em>
- * execution "cycle"; since other, unrelated, executions can be triggered
- * concurrently, causing the "cycle" to continue.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface NotifyingRepeatingJobCommand
- extends RepeatingJobCommand
-{
- /**
- * Add the specified listener.
- */
- void addListener(Listener listener);
-
- /**
- * Remove the specified listener.
- */
- void removeListener(Listener listener);
-
-
- // ********** listener **********
-
- /**
- * Interface implemented by listeners to be notified whenever the
- * job command has quiesced.
- */
- public interface Listener
- extends EventListener
- {
- /**
- * The specified job command has quiesced.
- */
- IStatus executionQuiesced(JobCommand command, IProgressMonitor monitor);
- }
-
-
- // ********** null singleton **********
-
- /**
- * Singleton implementation of the notifying repeating command interface that
- * will do nothing when executed.
- */
- final class Null
- implements NotifyingRepeatingJobCommand, Serializable
- {
- public static final NotifyingRepeatingJobCommand INSTANCE = new Null();
- public static NotifyingRepeatingJobCommand instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void start() {
- // do nothing
- }
- public IStatus execute(IProgressMonitor monitor) {
- return Status.OK_STATUS;
- }
- public void stop() {
- // do nothing
- }
- public void addListener(Listener listener) {
- // do nothing
- }
- public void removeListener(Listener listener) {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/RepeatingJobCommand.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/RepeatingJobCommand.java
deleted file mode 100644
index c9952b5b59..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/command/RepeatingJobCommand.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This job command will execute repeatedly the minimum
- * number of times. The assumption is the job command's effects are
- * cumulative(?); i.e. the cumulative result of multiple executions of the
- * job command is no different than the result of a single execution of the job
- * command. Once the job command is executing, any further requests to execute
- * simply trigger a re-execution of the job command once it has finished its
- * current execution.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface RepeatingJobCommand
- extends JobCommand
-{
- /**
- * Start the job command, allowing it to begin executing with the next call
- * to {@link #execute(IProgressMonitor)}.
- * @exception IllegalStateException when the command is not stopped
- */
- void start();
-
- /**
- * Stop the job command; ignore further calls to
- * {@link #execute(IProgressMonitor)}.
- * @exception IllegalStateException when the command executor is not started
- */
- void stop() throws InterruptedException;
-
-
- /**
- * Singleton implementation of the repeating job command interface that
- * will do nothing when executed.
- */
- final class Null
- implements RepeatingJobCommand, Serializable
- {
- public static final RepeatingJobCommand INSTANCE = new Null();
- public static RepeatingJobCommand instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void start() {
- // do nothing
- }
- public IStatus execute(IProgressMonitor monitor) {
- return Status.OK_STATUS;
- }
- public void stop() {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AbstractType.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AbstractType.java
deleted file mode 100644
index 8be7a07d97..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AbstractType.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AbstractTypeDeclaration;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-/**
- * AbstractType: just some covariant overrides.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface AbstractType extends Member {
-
- /**
- * Covariant override.
- */
- ITypeBinding getBinding(CompilationUnit astRoot);
-
- /**
- * Covariant override.
- */
- AbstractTypeDeclaration getBodyDeclaration(CompilationUnit astRoot);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotatedElement.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotatedElement.java
deleted file mode 100644
index 8ce99cf49c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotatedElement.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IBinding;
-import org.eclipse.jpt.common.core.utility.TextRange;
-
-/**
- * Dali manipulates annotations on elements (packages, types, fields, and methods).
- * This interface simplifies those manipulations.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface AnnotatedElement {
-
- String getName();
-
- /**
- * Return the annotated element's body declaration from the specified AST.
- * This can be null if the annotated element is no longer present in the AST
- * because the source has been changed in another thread.
- */
- ASTNode getBodyDeclaration(CompilationUnit astRoot);
-
- /**
- * Return the annotated element's binding from the specified AST.
- */
- IBinding getBinding(CompilationUnit astRoot);
-
- /**
- * Return the annotated element's "modified" declaration from the specified AST.
- */
- ModifiedDeclaration getModifiedDeclaration(CompilationUnit astRoot);
-
- /**
- * Return the annotated element's "modified" declaration from a newly-generated AST.
- */
- ModifiedDeclaration getModifiedDeclaration();
-
- /**
- * Return the annotated element's name text range from the specified AST.
- */
- TextRange getNameTextRange(CompilationUnit astRoot);
-
- /**
- * Edit the annotated element's declaration using the specified editor.
- */
- void edit(Editor editor);
-
-
- // ********** "editor" interface **********
-
- /**
- * This interface defines a callback that is invoked when the annotated element's
- * compilation unit/AST is in a state to be manipulated.
- */
- public interface Editor {
-
- /**
- * Edit the specified declaration. Any changes made to the declaration
- * will be captured and applied to the annotated element's compilation unit.
- */
- void edit(ModifiedDeclaration declaration);
-
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotatedPackage.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotatedPackage.java
deleted file mode 100644
index c0a3ccc098..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotatedPackage.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IPackageBinding;
-import org.eclipse.jdt.core.dom.PackageDeclaration;
-
-/**
- * @author Dmitry Geraskov
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface AnnotatedPackage extends AnnotatedElement {
-
- /**
- * Covariant override.
- */
- IPackageBinding getBinding(CompilationUnit astRoot);
-
- /**
- * Covariant override.
- */
- PackageDeclaration getBodyDeclaration(CompilationUnit astRoot);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationAdapter.java
deleted file mode 100644
index b0b04c4938..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationAdapter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-
-/**
- * Adapt a Java annotation with a simple-to-use interface.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface AnnotationAdapter {
-
- /**
- * Given the specified compilation unit, return the value of the
- * adapter's annotation.
- * @see #getAnnotation()
- */
- Annotation getAnnotation(CompilationUnit astRoot);
-
- /**
- * Build a new marker annotation, replacing the original annotation if present.
- */
- void newMarkerAnnotation();
-
- /**
- * Build a new single member annotation, replacing the original annotation if present.
- */
- void newSingleMemberAnnotation();
-
- /**
- * Build a new normal annotation, replacing the original annotation if present.
- */
- void newNormalAnnotation();
-
- /**
- * Remove the annotation.
- */
- void removeAnnotation();
-
- /**
- * Return the AST node corresponding to the annotation.
- * If the annotation is missing, return the annotation's parent node.
- * @see #getAstNode()
- */
- ASTNode getAstNode(CompilationUnit astRoot);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationEditFormatter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationEditFormatter.java
deleted file mode 100644
index 77b3ac0682..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationEditFormatter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.TextEdit;
-
-/**
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface AnnotationEditFormatter {
-
- /**
- * Review the specified edits and format the specified document as needed.
- */
- void format(IDocument doc, TextEdit editTree) throws MalformedTreeException, BadLocationException;
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationElementAdapter.java
deleted file mode 100644
index 3fc6e95434..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/AnnotationElementAdapter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.Expression;
-
-/**
- * Adapt a Java annotation element with a simple-to-use interface.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface AnnotationElementAdapter<T> {
-
- /**
- * Return the value of the adapter's annotation element.
- * Return null if the element is not present.
- * If the compilation unit is available, #value(CompilationUnit)
- * might be more performant.
- * @see #getValue(org.eclipse.jdt.core.dom.CompilationUnit)
- */
- T getValue();
-
- /**
- * Given the specified compilation unit, return the value of the
- * adapter's annotation element.
- * Return null if the element is not present.
- * @see #getValue()
- */
- T getValue(CompilationUnit astRoot);
-
- /**
- * Set the value of the adapter's annotation element.
- * Setting the value of the element to null will cause
- * the element to be removed from its annotation.
- */
- void setValue(T value);
-
- /**
- * Given the specified compilation unit, return the expression value of the
- * adapter's annotation element.
- * Return null if the element is not present.
- * @see #getExpression()
- */
- Expression getExpression(CompilationUnit astRoot);
-
- /**
- * Return the AST node corresponding to the element.
- * If the element is missing, return the annotation's node.
- * @see #getAstNode()
- */
- ASTNode getAstNode(CompilationUnit astRoot);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Attribute.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Attribute.java
deleted file mode 100644
index cce19d5abc..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Attribute.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.ITypeBinding;
-
-/**
- * Attributes are either represented by fields ('foo') or properties/method
- * pairs ('getFoo()'/'setFoo()').
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface Attribute extends Member {
-
- /**
- * Return the attribute's name, as opposed to the member's name
- * (e.g. "getFoo()" returns "foo").
- */
- String getAttributeName();
-
- /**
- * Return the type binding for the attribute's declared type,
- * as opposed to its declaring type.
- */
- ITypeBinding getTypeBinding(CompilationUnit astRoot);
-
- /**
- * Return whether the attribute is a field.
- */
- boolean isField();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/DeclarationAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/DeclarationAnnotationAdapter.java
deleted file mode 100644
index 9f93a16ffd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/DeclarationAnnotationAdapter.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-
-/**
- * Provide clients with a pluggable way to manipulate an
- * annotation modifying a "declaration".
- *
- * TODO specify how multiple annotations with the same name are to be handled
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface DeclarationAnnotationAdapter {
-
- /**
- * Given the specified declaration, return the annotation.
- */
- Annotation getAnnotation(ModifiedDeclaration declaration);
-
- /**
- * Given the specified declaration, modify it with
- * a new marker annotation, replacing the original annotation if present.
- * Return the new annotation.
- */
- MarkerAnnotation newMarkerAnnotation(ModifiedDeclaration declaration);
-
- /**
- * Given the specified declaration, modify it with
- * a new single member annotation, replacing the original annotation if present.
- * Return the new annotation.
- */
- SingleMemberAnnotation newSingleMemberAnnotation(ModifiedDeclaration declaration);
-
- /**
- * Given the specified declaration, modify it with
- * a new normal annotation, replacing the original annotation if present.
- * Return the new annotation.
- */
- NormalAnnotation newNormalAnnotation(ModifiedDeclaration declaration);
-
- /**
- * Remove the annotation from the specified declaration.
- */
- void removeAnnotation(ModifiedDeclaration declaration);
-
- /**
- * Given the specified declaration, return the AST node
- * corresponding to the annotation.
- * If the annotation is missing, return its parent node.
- */
- ASTNode getAstNode(ModifiedDeclaration declaration);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/DeclarationAnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/DeclarationAnnotationElementAdapter.java
deleted file mode 100644
index 51ae1a6e33..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/DeclarationAnnotationElementAdapter.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Expression;
-
-/**
- * Provide clients with a pluggable way to manipulate an
- * annotation element modifying a "declaration".
- * <p>
- * This interface is not intended to be implemented by clients.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <T> the type of the object to be passed to and returned by the adapter
- */
-public interface DeclarationAnnotationElementAdapter<T> {
-
- /**
- * Reduce the number of NLS warnings.
- */
- String VALUE = "value"; //$NON-NLS-1$
-
- /**
- * Given the specified declaration, return the value of the
- * annotation element. Return null or an empty array
- * if the element is not present.
- */
- T getValue(ModifiedDeclaration declaration);
-
- /**
- * Given the specified declaration, set the value of the
- * annotation element. Setting the value of the element
- * to null will cause the element to be removed from its
- * annotation.
- */
- void setValue(T value, ModifiedDeclaration declaration);
-
- /**
- * Given the specified declaration, return the element's value expression.
- * Return null if the element is not present.
- */
- Expression getExpression(ModifiedDeclaration declaration);
-
- /**
- * Given the specified declaration, return the AST node
- * corresponding to the element's value.
- * If the element is missing, return the annotation's node.
- */
- ASTNode getAstNode(ModifiedDeclaration declaration);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Enum.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Enum.java
deleted file mode 100644
index da690b148b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Enum.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-
-/**
- * Enum: some covariant overrides plus enumConstants
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface Enum extends AbstractType {
-
- /**
- * Covariant override.
- */
- EnumDeclaration getBodyDeclaration(CompilationUnit astRoot);
-
- /**
- * Return the enum's constants
- */
- EnumConstantDeclaration[] getEnumConstants(CompilationUnit astRoot);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/EnumConstant.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/EnumConstant.java
deleted file mode 100644
index 88693d415a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/EnumConstant.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-
-/**
- * Enum constants are part of Enums
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface EnumConstant extends Member {
-
- String getName();
-
- /**
- * Covariant override.
- */
- IVariableBinding getBinding(CompilationUnit astRoot);
-
- /**
- * Covariant override.
- */
- EnumConstantDeclaration getBodyDeclaration(CompilationUnit astRoot);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/ExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/ExpressionConverter.java
deleted file mode 100644
index 3475609361..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/ExpressionConverter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.Expression;
-
-/**
- * Define the protocol for converting an AST expression back and forth
- * from an arbitrary type (e.g. StringLiteral <=> String).
- * <p>
- * This interface is not intended to be implemented by clients.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <T> the type of the object to be converted to and from an expression
- */
-public interface ExpressionConverter<T> {
-
- /**
- * Convert the specified object to an
- * expression that is owned by the specified AST.
- * The type of the object is determined by the
- * contract specified by the client.
- */
- Expression convert(T object, AST ast);
-
- /**
- * Convert the specified expression to an object of some
- * pre-determined type.
- */
- T convert(Expression expression);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/FieldAttribute.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/FieldAttribute.java
deleted file mode 100644
index 4e014ac72b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/FieldAttribute.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.eclipse.jdt.core.dom.IVariableBinding;
-
-/**
- * Field attribute: just some covariant overrides.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface FieldAttribute extends Attribute {
-
- /**
- * Covariant override.
- */
- IVariableBinding getBinding(CompilationUnit astRoot);
-
- /**
- * Covariant override.
- */
- FieldDeclaration getBodyDeclaration(CompilationUnit astRoot);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedAnnotationAdapter.java
deleted file mode 100644
index a55e9cbc77..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedAnnotationAdapter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-
-/**
- * Adapt an indexed Java annotation with a simple-to-use interface.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface IndexedAnnotationAdapter extends AnnotationAdapter {
-
- /**
- * Return the the index at which the annotation is situated.
- */
- int getIndex();
-
- /**
- * Move the annotation to the specified index, leaving its original
- * position cleared out.
- */
- void moveAnnotation(int newIndex);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedDeclarationAnnotationAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedDeclarationAnnotationAdapter.java
deleted file mode 100644
index 438f21e1e6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedDeclarationAnnotationAdapter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-
-/**
- * Allow clients to manipulate an annotation within an array of annotations.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface IndexedDeclarationAnnotationAdapter extends DeclarationAnnotationAdapter {
-
- /**
- * Return the the index at which the annotation is situated.
- */
- int getIndex();
-
- /**
- * Move the annotation to the specified index, leaving its original
- * position cleared out.
- */
- void moveAnnotation(int newIndex, ModifiedDeclaration declaration);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedDeclarationAnnotationElementAdapter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedDeclarationAnnotationElementAdapter.java
deleted file mode 100644
index 202e094ba6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedDeclarationAnnotationElementAdapter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.Expression;
-
-/**
- * Provide clients with a pluggable way to manipulate an <em>indexed</em>
- * annotation element modifying a "declaration".
- * <p>
- * This interface is not intended to be implemented by clients.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <T> the type of the objects in the array to be passed to and returned
- * by the adapter
- */
-public interface IndexedDeclarationAnnotationElementAdapter<T>
- extends DeclarationAnnotationElementAdapter<T[]>
-{
- /**
- * Given the specified declaration, return the expression at the specified
- * index.
- * @throws IndexOutOfBoundsException if the index is out of range
- */
- Expression selectExpression(ModifiedDeclaration declaration, int index);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedExpressionConverter.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedExpressionConverter.java
deleted file mode 100644
index 3589bc60ea..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/IndexedExpressionConverter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.Expression;
-
-/**
- * A type of {@link ExpressionConverter} that can further retrieve sub-expressions
- * based on indices.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- * <p>
- * This interface is not intended to be implemented by clients.
- */
-public interface IndexedExpressionConverter<T>
- extends ExpressionConverter<T[]>
-{
- /**
- * Return the expression at the specified index of the specified expression.
- * @throws ArrayIndexOutOfBoundsException if the index is out of range
- */
- Expression selectExpression(Expression expression, int index);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Member.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Member.java
deleted file mode 100644
index 8b9f398ea0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Member.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-
-/**
- * Dali manipulates annotations on members (types, fields, and methods).
- * This interface simplifies those manipulations.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface Member extends AnnotatedElement {
-
- /**
- * Return whether the member is persistable.
- */
- boolean isPersistable(CompilationUnit astRoot);
-
- /**
- * Return whether the member matches the specified member
- * and occurrence.
- */
- boolean matches(String memberName, int occurrence);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/MethodAttribute.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/MethodAttribute.java
deleted file mode 100644
index 2eca93d773..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/MethodAttribute.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.IMethodBinding;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jpt.common.utility.MethodSignature;
-
-/**
- * Method attribute: just some covariant overrides.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface MethodAttribute extends Attribute {
-
- /**
- * Covariant override.
- */
- IMethodBinding getBinding(CompilationUnit astRoot);
-
- /**
- * Covariant override.
- */
- MethodDeclaration getBodyDeclaration(CompilationUnit astRoot);
-
- /**
- * This method must be used instead of Member#matches(String, int).
- */
- boolean matches(MethodSignature signature, int occurrence);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/ModifiedDeclaration.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/ModifiedDeclaration.java
deleted file mode 100644
index 331e5391a0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/ModifiedDeclaration.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-
-/**
- * Define a wrapper that provides a common protocol for all the various AST
- * declarations that have modifiers (i.e. there are a number of AST node
- * classes that implement the method #modifiers(), but they do not implement
- * a common interface):
- * BodyDeclaration
- * SingleVariableDeclaration
- * VariableDeclarationExpression
- * VariableDeclarationStatement
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface ModifiedDeclaration {
-
- /**
- * Return the "declaration" AST node.
- */
- ASTNode getDeclaration();
-
- /**
- * Return the "declaration" AST.
- */
- AST getAst();
-
- /**
- * Return the *first* annotation with the specified name.
- * Return null if the declaration has no such annotation.
- */
- Annotation getAnnotationNamed(String annotationName);
-
- /**
- * Remove the *first* annotation with the specified name from the declaration.
- */
- void removeAnnotationNamed(String annotationName);
-
- /**
- * Replace the specified old annotation with the specified new annotation.
- * If there is no annotation with the specified name, simply add the new
- * annotation to the declaration's modifiers.
- */
- void replaceAnnotationNamed(String oldAnnotationName, Annotation newAnnotation);
-
- /**
- * Add the specified import to the declaration's compilation unit.
- * Return whether the appropriate import was added to or already present in
- * the declaration's compilation unit (i.e. the specified class can be
- * subsequently referenced using a "short" name).
- * Also return true if an import was unnecessary (i.e. the specified class
- * is part of the "default" package).
- * This does not support adding a "wildcard" import (e.g. "java.util.*").
- */
- boolean addImport(String className);
-
- /**
- * Add the specified static import to the declaration's compilation unit.
- * Return whether the appropriate import was added to or already present in
- * the declaration's compilation unit (i.e. the specified constant can be
- * subsequently referenced using a "short" name).
- * Also return true if an import was unnecessary (i.e. the specified enum
- * is part of the "default" package).
- * This does not support adding a "wildcard" import (e.g. "java.lang.annotation.ElementType.*").
- */
- boolean addStaticImport(String enumConstantName);
-
- /**
- * Add the specified import to the declaration's compilation unit.
- * Return whether the appropriate import was added to or already present in
- * the declaration's compilation unit (i.e. the specified name can be
- * subsequently referenced using a "short" name).
- * Also return true if an import was unnecessary (i.e. the specified class
- * or enum is part of the "default" package).
- * This does not support adding a "wildcard" import (e.g. "java.util.*").
- */
- boolean addImport(String importName, boolean static_);
-
- /**
- * Return whether the specified annotation has the specified
- * (fully-qualified) name within the declaration's context; i.e. attempt
- * to resolve the annotation's name (using imports etc.) and return
- * whether it matches the specified name.
- */
- boolean annotationIsNamed(Annotation annotation, String name);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Type.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Type.java
deleted file mode 100644
index 5a3a6a5a98..0000000000
--- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/utility/jdt/Type.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.utility.jdt;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.FieldDeclaration;
-import org.eclipse.jdt.core.dom.MethodDeclaration;
-import org.eclipse.jdt.core.dom.TypeDeclaration;
-
-/**
- * Type: nestedTypes, nestedEnums, fields, and methods.
- *
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * This interface is not intended to be implemented by clients.
- */
-public interface Type extends AbstractType {
-
- /**
- * Covariant override.
- */
- TypeDeclaration getBodyDeclaration(CompilationUnit astRoot);
-
- /**
- * Return the type's nested types (does not include annotations or enums).
- */
- TypeDeclaration[] getTypes(CompilationUnit astRoot);
-
- /**
- * Return the type's nested enums.
- */
- EnumDeclaration[] getEnums(CompilationUnit astRoot);
-
- /**
- * Return the type's fields.
- */
- FieldDeclaration[] getFields(CompilationUnit astRoot);
-
- /**
- * Return the type's methods.
- */
- MethodDeclaration[] getMethods(CompilationUnit astRoot);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/.cvsignore b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/.cvsignore
deleted file mode 100644
index c14487ceac..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-build.xml
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/.project b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/.project
deleted file mode 100644
index 9427ca0805..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/.project
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.eclipselink.branding</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/META-INF/MANIFEST.MF
deleted file mode 100644
index 8ca53128d7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,7 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.jpt.common.eclipselink.branding;singleton:=true
-Bundle-Version: 1.2.0.qualifier
-Bundle-Localization: plugin
-Bundle-Vendor: %providerName
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.html b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.html
deleted file mode 100644
index ca606b1bb5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>June 06, 2007</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.ini b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.ini
deleted file mode 100644
index 6c107d466d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.ini
+++ /dev/null
@@ -1,44 +0,0 @@
-###############################################################################
-# Copyright (c) 2006, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-# about.ini
-# contains information about a feature
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# "%key" are externalized strings defined in about.properties
-# This file does not need to be translated.
-
-# Property "aboutText" contains blurb for "About" dialog (translated)
-aboutText=%blurb
-
-# Property "windowImage" contains path to window icon (16x16)
-# needed for primary features only
-
-# Property "featureImage" contains path to feature image (32x32)
-featureImage=icons/WTP_icon_x32_v2.png
-
-# Property "aboutImage" contains path to product image (500x330 or 115x164)
-# needed for primary features only
-
-# Property "appName" contains name of the application (translated)
-# needed for primary features only
-
-# Property "welcomePage" contains path to welcome page (special XML-based format)
-# optional
-
-# Property "welcomePerspective" contains the id of the perspective in which the
-# welcome page is to be opened.
-# optional
-
-# Property "tipsAndTricksHref" contains the Help topic href to a tips and tricks page
-# optional
-tipsAndTricksHref=/org.eclipse.jpt.doc.user/tips_and_tricks.htm
-
-
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.mappings b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.mappings
deleted file mode 100644
index bddaab4310..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.mappings
+++ /dev/null
@@ -1,6 +0,0 @@
-# about.mappings
-# contains fill-ins for about.properties
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# This file does not need to be translated.
-
-0=@build@ \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.properties b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.properties
deleted file mode 100644
index 129f69e36a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/about.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-# about.properties
-# contains externalized strings for about.ini
-# java.io.Properties file (ISO 8859-1 with "\" escapes)
-# fill-ins are supplied by about.mappings
-# This file should be translated.
-
-blurb=Dali Java Persistence Tools - EclipseLink Common\n\
-\n\
-Version: {featureVersion}\n\
-Build id: {0}\n\
-\n\
-(c) Copyright Oracle contributors and others 2011. All rights reserved.\n\
-Visit http://www.eclipse.org/webtools
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/build.properties b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/build.properties
deleted file mode 100644
index 6c20e3b027..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-###############################################################################
-# Copyright (c) 2010, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-bin.includes = META-INF/,\
- about.ini,\
- about.html,\
- about.mappings,\
- about.properties,\
- icons/,\
- plugin.properties
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/component.xml b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/component.xml
deleted file mode 100644
index a433d25681..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/component.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt.common.eclipselink.branding">
-<description url=""></description>
-<component-depends unrestricted="true"></component-depends>
-<plugin id="org.eclipse.jpt.common.eclipselink.branding" fragment="false"/>
-<plugin id="org.eclipse.jpt.common.eclipselink.core" fragment="false"/>
-</component> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/icons/WTP_icon_x32_v2.png b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/icons/WTP_icon_x32_v2.png
deleted file mode 100644
index 6f09c2a700..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/icons/WTP_icon_x32_v2.png
+++ /dev/null
Binary files differ
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/plugin.properties b/common/plugins/org.eclipse.jpt.common.eclipselink.branding/plugin.properties
deleted file mode 100644
index 11a79f2639..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.branding/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-###############################################################################
-# Copyright (c) 2010, 2011 Oracle.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Oracle. - initial API and implementation
-###############################################################################
-
-pluginName = Dali Java Persistence Tools - EclipseLink Common
-providerName = Eclipse Web Tools Platform
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/.classpath b/common/plugins/org.eclipse.jpt.common.eclipselink.core/.classpath
deleted file mode 100644
index 042690f1e1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/.classpath
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="property_files"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="nonaccessible" pattern="org/eclipse/jpt/common/utility/model/value/**"/>
- <accessrule kind="nonaccessible" pattern="org/eclipse/jpt/common/utility/internal/model/listener/awt/**"/>
- <accessrule kind="nonaccessible" pattern="org/eclipse/jpt/common/utility/internal/model/value/**"/>
- <accessrule kind="nonaccessible" pattern="org/eclipse/jpt/common/utility/internal/swing/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/common/utility/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/.cvsignore b/common/plugins/org.eclipse.jpt.common.eclipselink.core/.cvsignore
deleted file mode 100644
index ba077a4031..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/.project b/common/plugins/org.eclipse.jpt.common.eclipselink.core/.project
deleted file mode 100644
index 4179bd967e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.eclipselink.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/.settings/org.eclipse.jdt.core.prefs b/common/plugins/org.eclipse.jpt.common.eclipselink.core/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 1322043060..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Tue Mar 08 12:06:31 EST 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
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.eclipselink.core/META-INF/MANIFEST.MF
deleted file mode 100644
index 10d2d0b159..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,23 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.common.eclipselink.core;singleton:=true
-Bundle-Version: 1.2.0.qualifier
-Bundle-Activator: org.eclipse.jpt.common.eclipselink.core.JptCommonEclipseLinkCorePlugin
-Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: .
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.7.0,4.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.7.0,4.0.0)",
- org.eclipse.jpt.common.utility;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jst.common.project.facet.core;bundle-version="[1.4.200,2.0.0)",
- org.eclipse.wst.xml.core;bundle-version="[1.1.600,2.0.0)"
-Export-Package: org.eclipse.jpt.common.eclipselink.core,
- org.eclipse.jpt.common.eclipselink.core.internal;
- x-friends:="org.eclipse.jpt.jpa.eclipselink.core,
- org.eclipse.jpt.jaxb.eclipselink.core",
- org.eclipse.jpt.common.eclipselink.core.internal.libval;
- x-friends:="org.eclipse.jpt.jpa.eclipselink.core,
- org.eclipse.jpt.jaxb.eclipselink.core"
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/about.html b/common/plugins/org.eclipse.jpt.common.eclipselink.core/about.html
deleted file mode 100644
index be534ba44f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>May 02, 2008</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/build.properties b/common/plugins/org.eclipse.jpt.common.eclipselink.core/build.properties
deleted file mode 100644
index d5ecbb9699..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/build.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-################################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-source.. = src/,\
- property_files/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- about.html,\
- plugin.xml,\
- plugin.properties,\
- schemas/
-src.includes = schemas/
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/plugin.properties b/common/plugins/org.eclipse.jpt.common.eclipselink.core/plugin.properties
deleted file mode 100644
index c3865d8607..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/plugin.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = Dali Java Persistence Tools - Common EclipseLink Core
-providerName = Eclipse Web Tools Platform
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/plugin.xml b/common/plugins/org.eclipse.jpt.common.eclipselink.core/plugin.xml
deleted file mode 100644
index c03f9269c5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/plugin.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-<!--
- Copyright (c) 2011 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0, which accompanies this distribution
- and is available at http://www.eclipse.org/legal/epl-v10.html.
-
- Contributors:
- Oracle - initial API and implementation
- -->
-
-<plugin>
-
- <!--
- ******************************************
- * Library Provider Framework Integration *
- ******************************************
- -->
-
- <extension point="org.eclipse.jst.common.project.facet.core.downloadableLibraries">
-
- <import-definitions
- url="http://www.eclipse.org/webtools/dali/dev/eclipselink/eclipselink-downloadable-libs.xml">
- <enablement>
- <with variable="requestingProjectFacet">
- <or>
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jaxb"
- forcePluginActivation="true"/>
- <test
- property="org.eclipse.wst.common.project.facet.core.projectFacet"
- value="jpt.jpa"
- forcePluginActivation="true"/>
- </or>
- </with>
- </enablement>
- </import-definitions>
-
- </extension>
-
-
- <!--
- ******************************************
- * EclipseLink schemas *
- ******************************************
- -->
-
- <extension
- point="org.eclipse.wst.xml.core.catalogContributions">
-
- <catalogContribution id="default">
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_1_0.xsd"
- uri="schemas/eclipselink_orm_1_0.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_1_1.xsd"
- uri="schemas/eclipselink_orm_1_1.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_1_2.xsd"
- uri="schemas/eclipselink_orm_1_2.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_0.xsd"
- uri="schemas/eclipselink_orm_2_0.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_1.xsd"
- uri="schemas/eclipselink_orm_2_1.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_2.xsd"
- uri="schemas/eclipselink_orm_2_2.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_3.xsd"
- uri="schemas/eclipselink_orm_2_3.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_4.xsd"
- uri="platform:/plugin/org.eclipse.persistence.jpa/org/eclipse/persistence/jpa/eclipselink_orm_2_4.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_0.xsd"
- uri="schemas/eclipselink_oxm_2_0.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_1.xsd"
- uri="schemas/eclipselink_oxm_2_1.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_2.xsd"
- uri="schemas/eclipselink_oxm_2_2.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_3.xsd"
- uri="schemas/eclipselink_oxm_2_3.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_oxm_2_4.xsd"
- uri="platform:/plugin/org.eclipse.persistence.moxy/org/eclipse/persistence/jaxb/eclipselink_oxm_2_4.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_persistence_map_1.0.xsd"
- uri="platform:/plugin/org.eclipse.persistence.core/org/eclipse/persistence/eclipselink_persistence_map_1.0.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_persistence_map_1.1.xsd"
- uri="schemas/eclipselink_persistence_map_1.1.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_persistence_map_1.2.xsd"
- uri="schemas/eclipselink_persistence_map_1.2.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_persistence_map_2.0.xsd"
- uri="schemas/eclipselink_persistence_map_2.0.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_persistence_map_2.3.xsd"
- uri="platform:/plugin/org.eclipse.persistence.core/org/eclipse/persistence/eclipselink_persistence_map_2.3.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_sessions_1.0.xsd"
- uri="schemas/eclipselink_sessions_1.0.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_sessions_1.1.xsd"
- uri="schemas/eclipselink_sessions_1.1.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_sessions_1.2.xsd"
- uri="schemas/eclipselink_sessions_1.2.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_sessions_2.0.xsd"
- uri="schemas/eclipselink_sessions_2.0.xsd"/>
-
- <uri
- name="http://www.eclipse.org/eclipselink/xsds/eclipselink_sessions_2.1.xsd"
- uri="platform:/plugin/org.eclipse.persistence.core/org/eclipse/persistence/eclipselink_sessions_2.1.xsd"/>
-
- </catalogContribution>
-
- </extension>
-
-</plugin>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/property_files/jpt_common_eclipselink_core.properties b/common/plugins/org.eclipse.jpt.common.eclipselink.core/property_files/jpt_common_eclipselink_core.properties
deleted file mode 100644
index 7b7ba929f4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/property_files/jpt_common_eclipselink_core.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-################################################################################
-# Copyright (c) 2010 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-
-EclipseLinkLibraryValidator_noEclipseLinkVersion=Selected libraries do not include required EclipseLink annotation classes.
-EclipseLinkLibraryValidator_multipleEclipseLinkVersions=There are multiple versions of EclipseLink in selected libraries.
-EclipseLinkLibraryValidator_improperEclipseLinkVersion=EclipseLink version does not meet platform requirements.
-
-ELJaxbUserLibraryValidator_noXjcClasses=Class generation may not be available if com.sun.tools.xjc and com.sun.xml.bind jars are not on project classpath.
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_0.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_0.xsd
deleted file mode 100644
index af1d1dadad..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_0.xsd
+++ /dev/null
@@ -1,3128 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Java Persistence API object-relational mapping file schema -->
-<xsd:schema targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:orm="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="1.0">
-
- <xsd:annotation>
- <xsd:documentation>
- @(#)eclipselink_orm_1_0.xsd 1.0 February 1 2008
- </xsd:documentation>
- </xsd:annotation>
- <xsd:annotation>
- <xsd:documentation><![CDATA[
-
- This is the XML Schema for the new native EclipseLink XML metadata
- format used for JPA and native deployment xml files.
-
- ]]></xsd:documentation>
- </xsd:annotation>
-
- <xsd:complexType name="emptyType"/>
-
- <xsd:simpleType name="versionType">
- <xsd:restriction base="xsd:token">
- <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:element name="entity-mappings">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
-
- The entity-mappings element is the root element of an mapping
- file. It contains the following four types of elements:
-
- 1. The persistence-unit-metadata element contains metadata
- for the entire persistence unit. It is undefined if this element
- occurs in multiple mapping files within the same persistence unit.
-
- 2. The package, schema, catalog and access elements apply to all of
- the entity, mapped-superclass and embeddable elements defined in
- the same file in which they occur.
-
- 3. The sequence-generator, table-generator, named-query,
- named-native-query and sql-result-set-mapping elements are global
- to the persistence unit. It is undefined to have more than one
- sequence-generator or table-generator of the same name in the same
- or different mapping files in a persistence unit. It is also
- undefined to have more than one named-query or named-native-query
- of the same name in the same or different mapping files in a
- persistence unit.
-
- 4. The entity, mapped-superclass and embeddable elements each define
- the mapping information for a managed persistent class. The mapping
- information contained in these elements may be complete or it may
- be partial.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="persistence-unit-metadata"
- type="orm:persistence-unit-metadata"
- minOccurs="0"/>
- <xsd:element name="package" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type"
- minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="mapped-superclass" type="orm:mapped-superclass"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="entity" type="orm:entity"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embeddable" type="orm:embeddable"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="version" type="orm:versionType"
- fixed="1.0" use="required"/>
- </xsd:complexType>
- </xsd:element>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-metadata">
- <xsd:annotation>
- <xsd:documentation>
-
- Metadata that applies to the persistence unit and not just to
- the mapping file in which it is contained.
-
- If the xml-mapping-metadata-complete element is specified then
- the complete set of mapping metadata for the persistence unit
- is contained in the XML mapping files for the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="xml-mapping-metadata-complete" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-default-mappings" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="persistence-unit-defaults"
- type="orm:persistence-unit-defaults"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-defaults">
- <xsd:annotation>
- <xsd:documentation>
-
- These defaults are applied to the persistence unit as a whole
- unless they are overridden by local annotation or XML
- element settings.
-
- schema - Used as the schema for all tables or secondary tables
- that apply to the persistence unit
- catalog - Used as the catalog for all tables or secondary tables
- that apply to the persistence unit
- access - Used as the access type for all managed classes in
- the persistence unit
- cascade-persist - Adds cascade-persist to the set of cascade options
- in entity relationships of the persistence unit
- entity-listeners - List of default entity listeners to be invoked
- on each entity in the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="schema" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type"
- minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for an entity. Is allowed to be
- sparsely populated and used in conjunction with the annotations.
- Alternatively, the metadata-complete attribute can be used to
- indicate that no annotations on the entity class (and its fields
- or properties) are to be processed. If this is the case then
- the defaulting rules for the entity and its subelements will
- be recursively applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface Entity {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking"
- minOccurs="0"/>
- <xsd:element name="table" type="orm:table" minOccurs="0"/>
- <xsd:element name="secondary-table" type="orm:secondary-table"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="inheritance" type="orm:inheritance" minOccurs="0"/>
- <xsd:element name="discriminator-value" type="orm:discriminator-value"
- minOccurs="0"/>
- <xsd:element name="discriminator-column"
- type="orm:discriminator-column"
- minOccurs="0"/>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking"
- minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override" type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="attributes">
- <xsd:annotation>
- <xsd:documentation>
-
- This element contains the entity field or property mappings.
- It may be sparsely populated to include only a subset of the
- fields or properties. If metadata-complete for the entity is true
- then the remainder of the attributes will be defaulted according
- to the default rules.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="id" type="orm:id"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded-id" type="orm:embedded-id"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="basic" type="orm:basic"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-collection" type="orm:basic-collection"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-map" type="orm:basic-map"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="version" type="orm:version"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-one" type="orm:many-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-many" type="orm:one-to-many"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-one" type="orm:one-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="variable-one-to-one" type="orm:variable-one-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-many" type="orm:many-to-many"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded" type="orm:embedded"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transformation" type="orm:transformation"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transient" type="orm:transient"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="access-type">
- <xsd:annotation>
- <xsd:documentation>
-
- This element determines how the persistence provider accesses the
- state of an entity or embedded object.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="PROPERTY"/>
- <xsd:enumeration value="FIELD"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-listeners">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface EntityListeners {
- Class[] value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="entity-listener" type="orm:entity-listener"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-listener">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines an entity listener to be invoked at lifecycle events
- for the entities that list this listener.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PrePersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostPersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-load">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostLoad {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="property">
- <xsd:annotation>
- <xsd:documentation>
- A user defined mapping's property.
- @Target({METHOD, FIELD, TYPE})
- @Retention(RUNTIME)
- public @interface Property {
- /**
- * Property name.
- */
- String name();
-
- /**
- * String representation of Property value,
- * converted to an instance of valueType.
- */
- String value();
-
- /**
- * Property value type.
- * The value converted to valueType by ConversionManager.
- * If specified must be a simple type that could be handled by
- * ConversionManager:
- * numerical, boolean, temporal.
- */
- Class valueType() default String.class;
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- <xsd:attribute name="value-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="query-hint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface QueryHint {
- String name();
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedQuery {
- String name();
- String query();
- QueryHint[] hints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="hint" type="orm:query-hint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-native-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedNativeQuery {
- String name();
- String query();
- QueryHint[] hints() default {};
- Class resultClass() default void.class;
- String resultSetMapping() default ""; //named SqlResultSetMapping
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="hint" type="orm:query-hint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="sql-result-set-mapping">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SqlResultSetMapping {
- String name();
- EntityResult[] entities() default {};
- ColumnResult[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="entity-result" type="orm:entity-result"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="column-result" type="orm:column-result"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface EntityResult {
- Class entityClass();
- FieldResult[] fields() default {};
- String discriminatorColumn() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field-result" type="orm:field-result"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="entity-class" type="xsd:string" use="required"/>
- <xsd:attribute name="discriminator-column" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="field-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface FieldResult {
- String name();
- String column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="column" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface ColumnResult {
- String name();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Table {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="secondary-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SecondaryTable {
- String name();
- String catalog() default "";
- String schema() default "";
- PrimaryKeyJoinColumn[] pkJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="unique-constraint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface UniqueConstraint {
- String[] columnNames();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column-name" type="xsd:string"
- maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Column {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="generation-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="TABLE"/>
- <xsd:enumeration value="SEQUENCE"/>
- <xsd:enumeration value="IDENTITY"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="access-methods">
- <xsd:annotation>
- <xsd:documentation>
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="get-method" type="xsd:string" use="required"/>
- <xsd:attribute name="set-method" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="attribute-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AttributeOverride {
- String name();
- Column column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="association-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AssociationOverride {
- String name();
- JoinColumn[] joinColumns();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column"
- maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="id-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface IdClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Id {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value" minOccurs="0"/>
- <xsd:element name="temporal" type="orm:temporal" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded-id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface EmbeddedId {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="transient">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Transient {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="version">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Version {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="temporal" type="orm:temporal" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Basic {
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="lob" type="orm:lob" minOccurs="0"/>
- <xsd:element name="temporal" type="orm:temporal" minOccurs="0"/>
- <xsd:element name="enumerated" type="orm:enumerated" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="read-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * Unless the TransformationMapping is write-only, it should have a
- * ReadTransformer, it defines transformation of database column(s)
- * value(s)into attribute value.
- *
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReadTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.AttributeTransformer
- * interface. The class will be instantiated, its
- * buildAttributeValue will be used to create the value to be
- * assigned to the attribute.
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be assigned to the attribute (not assigns the value to
- * the attribute). Either transformerClass or method must be
- * specified, but not both.
- */
- String method() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="write-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- *
- * A single WriteTransformer may be specified directly on the method or
- * attribute. Multiple WriteTransformers should be wrapped into
- * WriteTransformers annotation. No WriteTransformers specified for
- * read-only mapping. Unless the TransformationMapping is write-only, it
- * should have a ReadTransformer, it defines transformation of database
- * column(s) value(s)into attribute value.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface WriteTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.FieldTransformer
- * interface. The class will be instantiated, its buildFieldValue
- * will be used to create the value to be written into the database
- * column. Note that for ddl generation and returning to be
- * supported the method buildFieldValue in the class should be
- * defined to return the relevant Java type, not just Object as
- * defined in the interface, for instance:
- * public Time buildFieldValue(Object instance, String fieldName, Session session).
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be written into the database column.
- * Note that for ddl generation and returning to be supported the
- * method should be defined to return a particular type, not just
- * Object, for instance:
- * public Time getStartTime().
- * The method may require a Transient annotation to avoid being
- * mapped as Basic by default.
- * Either transformerClass or method must be specified, but not both.
- */
- String method() default "";
-
- /**
- * Specify here the column into which the value should be written.
- * The only case when this could be skipped is if a single
- * WriteTransformer annotates an attribute - the attribute's name
- * will be used as a column name.
- */
- Column column() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="transformation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Transformation is an optional annotation for
- * org.eclipse.persistence.mappings.TransformationMapping.
- * TransformationMapping allows to map an attribute to one or more
- * database columns.
- *
- * Transformation annotation is an optional part of
- * TransformationMapping definition. Unless the TransformationMapping is
- * write-only, it should have a ReadTransformer, it defines
- * transformation of database column(s) value(s)into attribute value.
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Transformation {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) The optional element is a hint as to whether the value
- * of the field or property may be null. It is disregarded
- * for primitive types, which are considered non-optional.
- */
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="read-transformer" type="orm:read-transformer"/>
- <xsd:element name="write-transformer" type="orm:write-transformer" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access" type="orm:access-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum FetchType { LAZY, EAGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="LAZY"/>
- <xsd:enumeration value="EAGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="lob">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Lob {}
-
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Temporal {
- TemporalType value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:temporal-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum TemporalType {
- DATE, // java.sql.Date
- TIME, // java.sql.Time
- TIMESTAMP // java.sql.Timestamp
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="DATE"/>
- <xsd:enumeration value="TIME"/>
- <xsd:enumeration value="TIMESTAMP"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="enumerated">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Enumerated {
- EnumType value() default ORDINAL;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:enum-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="enum-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum EnumType {
- ORDINAL,
- STRING
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ORDINAL"/>
- <xsd:enumeration value="STRING"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="many-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cascade-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REFRESH};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade-all" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-merge" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-remove" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-refresh" type="orm:emptyType"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="one-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="one-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="order-by" type="orm:order-by" minOccurs="0"/>
- <xsd:element name="map-key" type="orm:map-key" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- public @interface JoinTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- JoinColumn[] inverseJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="inverse-join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="many-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="order-by" type="orm:order-by" minOccurs="0"/>
- <xsd:element name="map-key" type="orm:map-key" minOccurs="0"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="generated-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface GeneratedValue {
- GenerationType strategy() default AUTO;
- String generator() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:generation-type"/>
- <xsd:attribute name="generator" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKey {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-by">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderBy {
- String value() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="inheritance">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Inheritance {
- InheritanceType strategy() default SINGLE_TABLE;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:inheritance-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="inheritance-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum InheritanceType
- { SINGLE_TABLE, JOINED, TABLE_PER_CLASS};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SINGLE_TABLE"/>
- <xsd:enumeration value="JOINED"/>
- <xsd:enumeration value="TABLE_PER_CLASS"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorValue {
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum DiscriminatorType { STRING, CHAR, INTEGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="STRING"/>
- <xsd:enumeration value="CHAR"/>
- <xsd:enumeration value="INTEGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="primary-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface PrimaryKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorColumn {
- String name() default "DTYPE";
- DiscriminatorType discriminatorType() default STRING;
- String columnDefinition() default "";
- int length() default 31;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="discriminator-type" type="orm:discriminator-type"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embeddable">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for embeddable objects. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- in the class. If this is the case then the defaulting rules will
- be recursively applied.
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Embeddable {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking"
- minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0"
- maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0"
- maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes"
- minOccurs="0"/>
- <xsd:element name="copy-policy" type="orm:copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Embedded {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="mapped-superclass">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for a mapped superclass. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- If this is the case then the defaulting rules will be recursively
- applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface MappedSuperclass{}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking"
- minOccurs="0"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking"
- minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="sequence-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface SequenceGenerator {
- String name();
- String sequenceName() default "";
- int initialValue() default 1;
- int allocationSize() default 50;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="sequence-name" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface TableGenerator {
- String name();
- String table() default "";
- String catalog() default "";
- String schema() default "";
- String pkColumnName() default "";
- String valueColumnName() default "";
- String pkColumnValue() default "";
- int initialValue() default 0;
- int allocationSize() default 50;
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="pk-column-name" type="xsd:string"/>
- <xsd:attribute name="value-column-name" type="xsd:string"/>
- <xsd:attribute name="pk-column-value" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Converter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must implement
- * the org.eclipse.persistence.mappings.converters.Converter interface.
- */
- Class converterClass();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface TypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence field
- * or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent field
- * or property.
- */
- Class objectType() default void.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="object-type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ObjectTypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence
- * field or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent
- * field or property.
- */
- Class objectType() default void.class;
-
- /**
- * (Required) Specify the conversion values to be used
- * with the object converter.
- */
- ConversionValue[] conversionValues();
-
- /**
- * (Optional) Specify a default object value. Used for
- * legacy data if the data value is missing.
- */
- String defaultObjectValue() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="conversion-value" type="orm:conversion-value" minOccurs="1" maxOccurs="unbounded"/>
- <xsd:element name="default-object-value" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="conversion-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface ConversionValue {
- /**
- * (Required) Specify the database value.
- */
- String dataValue();
-
- /**
- * (Required) Specify the object value.
- */
- String objectValue();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="data-value" type="xsd:string" use="required"/>
- <xsd:attribute name="object-value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="struct-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface StructConverter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must
- * implement the EclipseLink interface
- * org.eclipse.persistence.mappings.converters.Converter
- */
- String converter();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="converter" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CopyPolicy is used to set a
- * org.eclipse.persistence.descriptors.copying.CopyPolicy on an Entity.
- * It is required that a class that implements
- * org.eclipse.persistence.descriptors.copying.CopyPolicy be specified
- * as the argument.
- *
- * A CopyPolicy should be specified on an Entity or MappedSuperclass.
- *
- * For instance:
- * @Entity
- * @CopyPolicy("example.MyCopyPolicy")
- */
- public @interface CopyPolicy {
-
- /*
- * (Required)
- * This defines the class of the copy policy. It must specify a class
- * that implements org.eclipse.persistence.descriptors.copying.CopyPolicy
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="instantiation-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * An InstantiationCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.InstantiationCopyPolicy
- * on an Entity. InstantiationCopyPolicy is the default CopyPolicy in
- * EclipseLink and therefore this configuration option is only used to
- * override other types of copy policies
- *
- * An InstantiationCopyPolicy should be specified on an Entity or
- * MappedSuperclass.
- *
- * Example:
- * @Entity
- * @InstantiationCopyPolicy
- */
- public @interface InstantiationCopyPolicy {
- }
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="clone-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CloneCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.CloneCopyPolicy on an
- * Entity. A CloneCopyPolicy must specify at one or both of the "method"
- * or "workingCopyMethod". "workingCopyMethod" is used to clone objects
- * that will be returned to the user as they are registered in
- * EclipseLink's transactional mechanism, the UnitOfWork. "method" will
- * be used for the clone that is used for comparison in conjunction with
- * EclipseLink's DeferredChangeDetectionPolicy
- *
- * A CloneCopyPolicy should be specified on an Entity or
- * MappedSuperclass.
- *
- * Example:
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod", workingCopyMethod="myWorkingCopyCloneMethod")
- *
- * or:
- *
- @Entity
- * @CloneCopyPolicy(workingCopyMethodName="myWorkingCopyClone")
- */
- public @interface CloneCopyPolicy {
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified this defines
- * a method that will be used to create a clone that will be used
- * for comparison by
- * EclipseLink's DeferredChangeDetectionPolicy
- */
- String method();
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified
- * this defines a method that will be used to create a clone that
- * will be used to create the object returned when registering an
- * Object in an EclipseLink UnitOfWork
- */
- String workingCopyMethod();
-
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method" type="xsd:string"/>
- <xsd:attribute name="working-copy-method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface CollectionTable {
- /**
- * (Optional) The name of the collection table. If it is not
- * specified, it is defaulted to the concatenation of the following:
- * the name of the source entity; "_" ; the name of the relationship
- * property or field of the source entity.
- */
- String name() default "";
-
- /**
- * (Optional) The catalog of the table. It defaults to the persistence
- * unit default catalog.
- */
- String catalog() default "";
-
- /**
- * (Optional) The schema of the table. It defaults to the persistence
- * unit default schema.
- */
- String schema() default "";
-
- /**
- * (Optional) Used to specify a primary key column that is used as a
- * foreign key to join to another table. If the source entity uses a
- * composite primary key, a primary key join column must be specified
- * for each field of the composite primary key. In a single primary
- * key case, a primary key join column may optionally be specified.
- * Defaulting will apply otherwise as follows:
- * name, the same name as the primary key column of the primary table
- * of the source entity. referencedColumnName, the same name of
- * primary key column of the primary table of the source entity.
- */
- PrimaryKeyJoinColumn[] primaryKeyJoinColumns() default {};
-
- /**
- * (Optional) Unique constraints that are to be placed on the table.
- * These are only used if table generation is in effect.
- */
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicCollection {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the value column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- <xsd:element name="collection-table" type="orm:collection-table" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-map">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicMap {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the data column that holds the direct map
- * key. If the name on te key column is "", the name will default to:
- * the name of the property or field; "_key".
- */
- Column keyColumn();
-
- /**
- * (Optional) Specify the key converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the direct map key.
- */
- Convert keyConverter() default @Convert;
-
- /**
- * (Optional) The name of the data column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
-
- /**
- * (Optional) Specify the value converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the value column mapping.
- */
- Convert valueConverter() default @Convert;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="key-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="key-converter" type="xsd:string"/>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="value-converter" type="xsd:string"/>
- <xsd:element name="collection-table" type="orm:collection-table" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum JoinFetchType {
- /**
- * An inner join is used to fetch the related object.
- * This does not allow for null/empty values.
- */
- INNER,
-
- /**
- * An inner join is used to fetch the related object.
- * This allows for null/empty values.
- */
- OUTER,
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="INNER"/>
- <xsd:enumeration value="OUTER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="optimistic-locking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An optimistic-locking element is used to specify the type of
- * optimistic locking EclipseLink should use when updating or deleting
- * entities. An optimistic-locking specification is supported on
- * an entity or mapped-superclass.
- *
- * It is used in conjunction with the optimistic-locking-type.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface OptimisticLocking {
- /**
- * (Optional) The type of optimistic locking policy to use.
- */
- OptimisticLockingType type() default VERSION_COLUMN;
-
- /**
- * (Optional) For an optimistic locking policy of type
- * SELECTED_COLUMNS, this annotation member becomes a (Required)
- * field.
- */
- Column[] selectedColumns() default {};
-
- /**
- * (Optional) Specify where the optimistic locking policy should
- * cascade lock. Currently only supported with VERSION_COLUMN locking.
- */
- boolean cascade() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="selected-column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="type" type="orm:optimistic-locking-type"/>
- <xsd:attribute name="cascade" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="optimistic-locking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A simple type that is used within an optimistic-locking
- * specification to specify the type of optimistic-locking that
- * EclipseLink should use when updating or deleting entities.
- */
- public enum OptimisticLockingType {
- /**
- * Using this type of locking policy compares every field in the table
- * in the WHERE clause when doing an update or a delete. If any field
- * has been changed, an optimistic locking exception will be thrown.
- */
- ALL_COLUMNS,
-
- /**
- * Using this type of locking policy compares only the changed fields
- * in the WHERE clause when doing an update. If any field has been
- * changed, an optimistic locking exception will be thrown. A delete
- * will only compare the primary key.
- */
- CHANGED_COLUMNS,
-
- /**
- * Using this type of locking compares selected fields in the WHERE
- * clause when doing an update or a delete. If any field has been
- * changed, an optimistic locking exception will be thrown. Note that
- * the fields specified must be mapped and not be primary keys.
- */
- SELECTED_COLUMNS,
-
- /**
- * Using this type of locking policy compares a single version number
- * in the where clause when doing an update. The version field must be
- * mapped and not be the primary key.
- */
- VERSION_COLUMN
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ALL_COLUMNS"/>
- <xsd:enumeration value="CHANGED_COLUMNS"/>
- <xsd:enumeration value="SELECTED_COLUMNS"/>
- <xsd:enumeration value="VERSION_COLUMN"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cache">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Cache annotation is used to set an
- * org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy
- * which sets objects in EclipseLink's identity maps to be invalid
- * following given rules. By default in EclipseLink, objects do not
- * expire in the cache. Several different policies are available to
- * allow objects to expire.
- *
- * @see org.eclipse.persistence.annotations.CacheType
- *
- * A Cache anotation may be defined on an Entity or MappedSuperclass.
- * In the case of inheritance, a Cache annotation should only be defined
- * on the root of the inheritance hierarchy.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Cache {
- /**
- * (Optional) The type of cache to use.
- */
- CacheType type() default SOFT_WEAK;
-
- /**
- * (Optional) The size of cache to use.
- */
- int size() default 100;
-
- /**
- * (Optional) Cached instances in the shared cache or a client
- * isolated cache.
- */
- boolean shared() default true;
-
- /**
- * (Optional) Expire cached instance after a fix period of time (ms).
- * Queries executed against the cache after this will be forced back
- * to the database for a refreshed copy
- */
- int expiry() default -1; // minus one is no expiry.
-
- /**
- * (Optional) Expire cached instance a specific time of day. Queries
- * executed against the cache after this will be forced back to the
- * database for a refreshed copy
- */
- TimeOfDay expiryTimeOfDay() default @TimeOfDay(specified=false);
-
- /**
- * (Optional) Force all queries that go to the database to always
- * refresh the cache.
- */
- boolean alwaysRefresh() default false;
-
- /**
- * (Optional) For all queries that go to the database, refresh the
- * cache only if the data received from the database by a query is
- * newer than the data in the cache (as determined by the optimistic
- * locking field)
- */
- boolean refreshOnlyIfNewer() default false;
-
- /**
- * (Optional) Setting to true will force all queries to bypass the
- * cache for hits but still resolve against the cache for identity.
- * This forces all queries to hit the database.
- */
- boolean disableHits() default false;
-
- /**
- * (Optional) The cache coordination mode.
- */
- CacheCoordinationType coordinationType() default SEND_OBJECT_CHANGES;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:choice>
- <xsd:element name="expiry" type="xsd:integer" minOccurs="0"/>
- <xsd:element name="expiry-time-of-day" type="orm:time-of-day" minOccurs="0"/>
- </xsd:choice>
- <xsd:attribute name="size" type="xsd:integer"/>
- <xsd:attribute name="shared" type="xsd:boolean"/>
- <xsd:attribute name="type" type="orm:cache-type"/>
- <xsd:attribute name="always-refresh" type="xsd:boolean"/>
- <xsd:attribute name="refresh-only-if-newer" type="xsd:boolean"/>
- <xsd:attribute name="disable-hits" type="xsd:boolean"/>
- <xsd:attribute name="coordination-type" type="orm:cache-coordination-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The CacheType enum is used with the Cache annotation for a
- * persistent class. It defines the type of IdentityMap/Cache used for
- * the class. By default the SOFT_WEAK cache type is used.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheType {
- /**
- * Provides full caching and guaranteed identity. Caches all objects
- * and does not remove them.
- * WARNING: This method may be memory intensive when many objects are
- * read.
- */
- FULL,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using weak references. This method allows full garbage
- * collection and provides full caching and guaranteed identity.
- */
- WEAK,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using soft references. This method allows full garbage
- * collection when memory is low and provides full caching and
- * guaranteed identity.
- */
- SOFT,
-
- /**
- * Similar to the WEAK identity map except that it maintains a
- * most-frequently-used sub-cache. The size of the sub-cache is
- * proportional to the size of the identity map as specified by
- * descriptor's setIdentityMapSize() method. The sub-cache
- * uses soft references to ensure that these objects are
- * garbage-collected only if the system is low on memory.
- */
- SOFT_WEAK,
-
- /**
- * Identical to the soft cache weak (SOFT_WEAK) identity map except
- * that it uses hard references in the sub-cache. Use this identity
- * map if soft references do not behave properly on your platform.
- */
- HARD_WEAK,
-
- /**
- * A cache identity map maintains a fixed number of objects
- * specified by the application. Objects are removed from the cache
- * on a least-recently-used basis. This method allows object
- * identity for the most commonly used objects.
- * WARNING: Furnishes caching and identity, but does not guarantee
- * identity.
- */
- CACHE,
-
- /**
- * WARNING: Does not preserve object identity and does not cache
- * objects.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="FULL"/>
- <xsd:enumeration value="WEAK"/>
- <xsd:enumeration value="SOFT"/>
- <xsd:enumeration value="SOFT_WEAK"/>
- <xsd:enumeration value="HARD_WEAK"/>
- <xsd:enumeration value="CACHE"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-coordination-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the Cache annotation.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheCoordinationType {
- /**
- * Sends a list of changed objects including data about the changes.
- * This data is merged into the receiving cache.
- */
- SEND_OBJECT_CHANGES,
-
- /**
- * Sends a list of the identities of the objects that have changed.
- * The receiving cache invalidates the objects (rather than changing
- * any of the data)
- */
- INVALIDATE_CHANGED_OBJECTS,
-
- /**
- * Same as SEND_OBJECT_CHANGES except it also includes any newly
- * created objects from the transaction.
- */
- SEND_NEW_OBJECTS_WITH_CHANGES,
-
- /**
- * Does no cache coordination.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SEND_OBJECT_CHANGES"/>
- <xsd:enumeration value="INVALIDATE_CHANGED_OBJECTS"/>
- <xsd:enumeration value="SEND_NEW_OBJECTS_WITH_CHANGES"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="time-of-day">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface TimeOfDay {
- /**
- * (Optional) Hour of the day.
- */
- int hour() default 0;
-
- /**
- * (Optional) Minute of the day.
- */
- int minute() default 0;
-
- /**
- * (Optional) Second of the day.
- */
- int second() default 0;
-
- /**
- * (Optional) Millisecond of the day.
- */
- int millisecond() default 0;
-
- /**
- * Internal use. Do not modify.
- */
- boolean specified() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="hour" type="xsd:integer"/>
- <xsd:attribute name="minute" type="xsd:integer"/>
- <xsd:attribute name="second" type="xsd:integer"/>
- <xsd:attribute name="millisecond" type="xsd:integer"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="change-tracking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The ChangeTracking annotation is used to specify the
- * org.eclipse.persistence.descriptors.changetracking.ObjectChangePolicy
- * which computes changes sets for EclipseLink's UnitOfWork commit
- * process. An ObjectChangePolicy is stored on an Entity's descriptor.
- *
- * A ChangeTracking annotation may be specified on an Entity or
- * MappedSuperclass.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface ChangeTracking {
- /**
- * (Optional) The type of change tracking to use.
- */
- ChangeTrackingType value() default AUTO;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="type" type="orm:change-tracking-type" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="change-tracking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the ChangeTracking annotation.
- */
- public enum ChangeTrackingType {
- /**
- * An ATTRIBUTE change tracking type allows change tracking at the
- * attribute level of an object. Objects with changed attributes will
- * be processed in the commit process to include any changes in the
- * results of the commit. Unchanged objects will be ignored.
- */
- ATTRIBUTE,
-
- /**
- * An OBJECT change tracking policy allows an object to calculate for
- * itself whether it has changed. Changed objects will be processed in
- * the commit process to include any changes in the results of the
- * commit. Unchanged objects will be ignored.
- */
- OBJECT,
-
- /**
- * A DEFERRED change tracking policy defers all change detection to
- * the UnitOfWork's change detection process. Essentially, the
- * calculateChanges() method will run for all objects in a UnitOfWork.
- * This is the default ObjectChangePolicy
- */
- DEFERRED,
-
- /**
- * Will not set any change tracking policy.
- */
- AUTO
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ATTRIBUTE"/>
- <xsd:enumeration value="OBJECT"/>
- <xsd:enumeration value="DEFERRED"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="customizer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Customizer annotation is used to specify a class that implements
- * the org.eclipse.persistence.internal.sessions.factories.DescriptorCustomizer
- * interface and is to run against an enetity's class descriptor after all
- * metadata processing has been completed.
- *
- * The Customizer annotation may be defined on an Entity, MappedSuperclass
- * or Embeddable class. In the case of inheritance, a Customizer is not
- * inherited from its parent classes.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Customizer {
- /**
- * (Required) Defines the name of the descriptor customizer class that
- * should be applied for the related entity or embeddable class.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-stored-procedure-query">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A NamedStoredProcedureQuery annotation allows the definition of
- * queries that call stored procedures as named queries.
-
- * A NamedStoredProcedureQuery annotation may be defined on an Entity or
- * MappedSuperclass.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface NamedStoredProcedureQuery {
- /**
- * (Required) Unique name that references this stored procedure query.
- */
- String name();
-
- /**
- * (Optional) Query hints.
- */
- QueryHint[] hints() default {};
-
- /**
- * (Optional) Refers to the class of the result.
- */
- Class resultClass() default void.class;
-
- /**
- * (Optional) The name of the SQLResultMapping.
- */
- String resultSetMapping() default "";
-
- /**
- * (Required) The name of the stored procedure.
- */
- String procedureName();
-
- /**
- * (Optional) Whether the query should return a result set.
- */
- boolean returnsResultSet() default true;
-
- /**
- * (Optional) Defines arguments to the stored procedure.
- */
- StoredProcedureParameter[] parameters() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0"
- maxOccurs="unbounded"/>
- <xsd:element name="parameter" type="orm:stored-procedure-parameter"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- <xsd:attribute name="procedure-name" type="xsd:string" use="required"/>
- <xsd:attribute name="returns-result-set" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="stored-procedure-parameter">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A StoredProcedureParameter annotation is used within a
- * NamedStoredProcedureQuery annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface StoredProcedureParameter {
- /**
- * (Optional) The direction of the stored procedure parameter.
- */
- Direction direction() default IN;
-
- /**
- * (Optional) Stored procedure parameter name.
- */
- String name() default "";
-
- /**
- * (Required) The query parameter name.
- */
- String queryParameter();
-
- /**
- * (Optional) The type of Java class desired back from the procedure,
- * this is dependent on the type returned from the procedure.
- */
- Class type() default void.class;
-
- /**
- * (Optional) The JDBC type code, this dependent on the type returned
- * from the procedure.
- */
- int jdbcType() default -1;
-
- /**
- * (Optional) The JDBC type name, this may be required for ARRAY or
- * STRUCT types.
- */
- String jdbcTypeName() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="direction" type="orm:direction-type"/>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="query-parameter" type="xsd:string" use="required"/>
- <xsd:attribute name="type" type="xsd:string"/>
- <xsd:attribute name="jdbc-type" type="xsd:integer"/>
- <xsd:attribute name="jdbc-type-name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="direction-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the StoredProcedureParameter annotation.
- * It is used to specify the direction of the stored procedure
- * parameters of a named stored procedure query.
- */
- public enum Direction {
- /**
- * Input parameter
- */
- IN,
-
- /**
- * Output parameter
- */
- OUT,
-
- /**
- * Input and output parameter
- */
- IN_OUT,
-
- /**
- * Output cursor
- */
- OUT_CURSOR
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="IN"/>
- <xsd:enumeration value="OUT"/>
- <xsd:enumeration value="IN_OUT"/>
- <xsd:enumeration value="OUT_CURSOR"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="variable-one-to-one">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * Variable one to one mappings are used to represent a pointer
- * references between a java object and an implementer of an interface.
- * This mapping is usually represented by a single pointer (stored in an
- * instance variable) between the source and target objects. In the
- * relational database tables, these mappings are normally implemented
- * using a foreign key and a type code.
- *
- * A VariableOneToOne can be specified within an Entity,
- * MappedSuperclass and Embeddable class.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface VariableOneToOne {
- /**
- * (Optional) The interface class that is the target of the
- * association. If not specified it will be inferred from the type
- * of the object being referenced.
- */
- Class targetInterface() default void.class;
-
- /**
- * (Optional) The operations that must be cascaded to the target of
- * the association.
- */
- CascadeType[] cascade() default {};
-
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) Whether the association is optional. If set to false
- * then a non-null relationship must always exist.
- */
- boolean optional() default true;
-
- /**
- * (Optional) The discriminator column will hold the type
- * indicators. If the DiscriminatorColumn is not specified, the name
- * of the discriminator column defaults to "DTYPE" and the
- * discriminator type to STRING.
- */
- DiscriminatorColumn discriminatorColumn() default @DiscriminatorColumn;
-
- /**
- * (Optional) The list of discriminator types that can be used with
- * this VariableOneToOne. If none are specified then those entities
- * within the persistence unit that implement the target interface
- * will be added to the list of types. The discriminator type will
- * default as follows:
- * - If DiscriminatorColumn type is STRING: Entity.name()
- * - If DiscriminatorColumn type is CHAR: First letter of the
- * Entity class
- * - If DiscriminatorColumn type is INTEGER: The next integer after
- * the highest integer explicitly added.
- */
- DiscriminatorClass[] discriminatorClasses() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column"
- minOccurs="0"/>
- <xsd:element name="discriminator-class" type="orm:discriminator-class"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0"
- maxOccurs="unbounded"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-interface" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-class">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A DiscriminatorClass is used within a VariableOneToOne annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface DiscriminatorClass {
- /**
- * (Required) The discriminator to be stored on the database.
- */
- String discriminator();
-
- /**
- * (Required) The class to the instantiated with the given
- * discriminator.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="discriminator" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="existence-type">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * The ExistenceChecking annotation is used to specify the type of
- * checking EclipseLink should use when updating entities.
- *
- * An existence-checking specification is supported on an Entity or
- * MappedSuperclass annotation.
- */
- public @interface ExistenceChecking {
- /**
- * (Optional) Set the existence check for determining
- * if an insert or update should occur for an object.
- */
- ExistenceType value() default CHECK_CACHE;
- }
-
- /**
- * Assume that if the objects primary key does not include null and
- * it is in the cache, then it must exist.
- */
- CHECK_CACHE,
-
- /**
- * Perform does exist check on the database.
- */
- CHECK_DATABASE,
-
- /**
- * Assume that if the objects primary key does not include null then
- * it must exist. This may be used if the application guarantees or
- * does not care about the existence check.
- */
- ASSUME_EXISTENCE,
-
- /**
- * Assume that the object does not exist. This may be used if the
- * application guarantees or does not care about the existence check.
- * This will always force an insert to be called.
- */
- ASSUME_NON_EXISTENCE
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="CHECK_CACHE" />
- <xsd:enumeration value="CHECK_DATABASE" />
- <xsd:enumeration value="ASSUME_EXISTENCE" />
- <xsd:enumeration value="ASSUME_NON_EXISTENCE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-</xsd:schema>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_1.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_1.xsd
deleted file mode 100644
index 0d3ff1747c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_1.xsd
+++ /dev/null
@@ -1,3248 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Java Persistence API object-relational mapping file schema -->
-<xsd:schema targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:orm="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="1.1">
-
- <xsd:annotation>
- <xsd:documentation>
- @(#)eclipselink_orm_1_1.xsd 1.1 February 4 2009
- </xsd:documentation>
- </xsd:annotation>
- <xsd:annotation>
- <xsd:documentation><![CDATA[
-
- This is the XML Schema for the new native EclipseLink XML metadata
- format used for JPA and native deployment xml files.
-
- ]]></xsd:documentation>
- </xsd:annotation>
-
- <xsd:complexType name="emptyType"/>
-
- <xsd:simpleType name="versionType">
- <xsd:restriction base="xsd:token">
- <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:element name="entity-mappings">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
-
- The entity-mappings element is the root element of an mapping
- file. It contains the following four types of elements:
-
- 1. The persistence-unit-metadata element contains metadata
- for the entire persistence unit. It is undefined if this element
- occurs in multiple mapping files within the same persistence unit.
-
- 2. The package, schema, catalog and access elements apply to all of
- the entity, mapped-superclass and embeddable elements defined in
- the same file in which they occur.
-
- 3. The sequence-generator, table-generator, named-query,
- named-native-query and sql-result-set-mapping elements are global
- to the persistence unit. It is undefined to have more than one
- sequence-generator or table-generator of the same name in the same
- or different mapping files in a persistence unit. It is also
- undefined to have more than one named-query or named-native-query
- of the same name in the same or different mapping files in a
- persistence unit.
-
- 4. The entity, mapped-superclass and embeddable elements each define
- the mapping information for a managed persistent class. The mapping
- information contained in these elements may be complete or it may
- be partial.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="persistence-unit-metadata"
- type="orm:persistence-unit-metadata"
- minOccurs="0"/>
- <xsd:element name="package" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type"
- minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="mapped-superclass" type="orm:mapped-superclass"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="entity" type="orm:entity"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embeddable" type="orm:embeddable"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="version" type="orm:versionType"
- fixed="1.1" use="required"/>
- </xsd:complexType>
- </xsd:element>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-metadata">
- <xsd:annotation>
- <xsd:documentation>
-
- Metadata that applies to the persistence unit and not just to
- the mapping file in which it is contained.
-
- If the xml-mapping-metadata-complete element is specified then
- the complete set of mapping metadata for the persistence unit
- is contained in the XML mapping files for the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="xml-mapping-metadata-complete" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-default-mappings" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="persistence-unit-defaults"
- type="orm:persistence-unit-defaults"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-defaults">
- <xsd:annotation>
- <xsd:documentation>
-
- These defaults are applied to the persistence unit as a whole
- unless they are overridden by local annotation or XML
- element settings.
-
- schema - Used as the schema for all tables or secondary tables
- that apply to the persistence unit
- catalog - Used as the catalog for all tables or secondary tables
- that apply to the persistence unit
- access - Used as the access type for all managed classes in
- the persistence unit
- cascade-persist - Adds cascade-persist to the set of cascade options
- in entity relationships of the persistence unit
- entity-listeners - List of default entity listeners to be invoked
- on each entity in the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="schema" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type"
- minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for an entity. Is allowed to be
- sparsely populated and used in conjunction with the annotations.
- Alternatively, the metadata-complete attribute can be used to
- indicate that no annotations on the entity class (and its fields
- or properties) are to be processed. If this is the case then
- the defaulting rules for the entity and its subelements will
- be recursively applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface Entity {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking"
- minOccurs="0"/>
- <xsd:element name="table" type="orm:table" minOccurs="0"/>
- <xsd:element name="secondary-table" type="orm:secondary-table"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="inheritance" type="orm:inheritance" minOccurs="0"/>
- <xsd:element name="discriminator-value" type="orm:discriminator-value"
- minOccurs="0"/>
- <xsd:element name="discriminator-column"
- type="orm:discriminator-column"
- minOccurs="0"/>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking"
- minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override" type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="attributes">
- <xsd:annotation>
- <xsd:documentation>
-
- This element contains the entity field or property mappings.
- It may be sparsely populated to include only a subset of the
- fields or properties. If metadata-complete for the entity is true
- then the remainder of the attributes will be defaulted according
- to the default rules.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="id" type="orm:id"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded-id" type="orm:embedded-id"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="basic" type="orm:basic"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-collection" type="orm:basic-collection"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-map" type="orm:basic-map"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="version" type="orm:version"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-one" type="orm:many-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-many" type="orm:one-to-many"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-one" type="orm:one-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="variable-one-to-one" type="orm:variable-one-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-many" type="orm:many-to-many"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded" type="orm:embedded"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transformation" type="orm:transformation"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transient" type="orm:transient"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="access-type">
- <xsd:annotation>
- <xsd:documentation>
-
- This element determines how the persistence provider accesses the
- state of an entity or embedded object.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="PROPERTY"/>
- <xsd:enumeration value="FIELD"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-listeners">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface EntityListeners {
- Class[] value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="entity-listener" type="orm:entity-listener"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-listener">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines an entity listener to be invoked at lifecycle events
- for the entities that list this listener.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PrePersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostPersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-load">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostLoad {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="property">
- <xsd:annotation>
- <xsd:documentation>
- A user defined mapping's property.
- @Target({METHOD, FIELD, TYPE})
- @Retention(RUNTIME)
- public @interface Property {
- /**
- * Property name.
- */
- String name();
-
- /**
- * String representation of Property value,
- * converted to an instance of valueType.
- */
- String value();
-
- /**
- * Property value type.
- * The value converted to valueType by ConversionManager.
- * If specified must be a simple type that could be handled by
- * ConversionManager:
- * numerical, boolean, temporal.
- */
- Class valueType() default String.class;
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- <xsd:attribute name="value-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="query-hint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface QueryHint {
- String name();
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedQuery {
- String name();
- String query();
- QueryHint[] hints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="hint" type="orm:query-hint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-native-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedNativeQuery {
- String name();
- String query();
- QueryHint[] hints() default {};
- Class resultClass() default void.class;
- String resultSetMapping() default ""; //named SqlResultSetMapping
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="hint" type="orm:query-hint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="sql-result-set-mapping">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SqlResultSetMapping {
- String name();
- EntityResult[] entities() default {};
- ColumnResult[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="entity-result" type="orm:entity-result"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="column-result" type="orm:column-result"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface EntityResult {
- Class entityClass();
- FieldResult[] fields() default {};
- String discriminatorColumn() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field-result" type="orm:field-result"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="entity-class" type="xsd:string" use="required"/>
- <xsd:attribute name="discriminator-column" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="field-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface FieldResult {
- String name();
- String column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="column" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface ColumnResult {
- String name();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Table {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="secondary-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SecondaryTable {
- String name();
- String catalog() default "";
- String schema() default "";
- PrimaryKeyJoinColumn[] pkJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="unique-constraint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface UniqueConstraint {
- String[] columnNames();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column-name" type="xsd:string"
- maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Column {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="generation-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="TABLE"/>
- <xsd:enumeration value="SEQUENCE"/>
- <xsd:enumeration value="IDENTITY"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="access-methods">
- <xsd:annotation>
- <xsd:documentation>
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="get-method" type="xsd:string" use="required"/>
- <xsd:attribute name="set-method" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="attribute-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AttributeOverride {
- String name();
- Column column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="association-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AssociationOverride {
- String name();
- JoinColumn[] joinColumns();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column"
- maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="id-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface IdClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Id {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded-id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface EmbeddedId {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="transient">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Transient {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="version">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Version {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal" />
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Basic {
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="lob" type="orm:lob"/>
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="enumerated" type="orm:enumerated"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="read-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * Unless the TransformationMapping is write-only, it should have a
- * ReadTransformer, it defines transformation of database column(s)
- * value(s)into attribute value.
- *
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReadTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.AttributeTransformer
- * interface. The class will be instantiated, its
- * buildAttributeValue will be used to create the value to be
- * assigned to the attribute.
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be assigned to the attribute (not assigns the value to
- * the attribute). Either transformerClass or method must be
- * specified, but not both.
- */
- String method() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="write-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- *
- * A single WriteTransformer may be specified directly on the method or
- * attribute. Multiple WriteTransformers should be wrapped into
- * WriteTransformers annotation. No WriteTransformers specified for
- * read-only mapping. Unless the TransformationMapping is write-only, it
- * should have a ReadTransformer, it defines transformation of database
- * column(s) value(s)into attribute value.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface WriteTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.FieldTransformer
- * interface. The class will be instantiated, its buildFieldValue
- * will be used to create the value to be written into the database
- * column. Note that for ddl generation and returning to be
- * supported the method buildFieldValue in the class should be
- * defined to return the relevant Java type, not just Object as
- * defined in the interface, for instance:
- * public Time buildFieldValue(Object instance, String fieldName, Session session).
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be written into the database column.
- * Note that for ddl generation and returning to be supported the
- * method should be defined to return a particular type, not just
- * Object, for instance:
- * public Time getStartTime().
- * The method may require a Transient annotation to avoid being
- * mapped as Basic by default.
- * Either transformerClass or method must be specified, but not both.
- */
- String method() default "";
-
- /**
- * Specify here the column into which the value should be written.
- * The only case when this could be skipped is if a single
- * WriteTransformer annotates an attribute - the attribute's name
- * will be used as a column name.
- */
- Column column() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="transformation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Transformation is an optional annotation for
- * org.eclipse.persistence.mappings.TransformationMapping.
- * TransformationMapping allows to map an attribute to one or more
- * database columns.
- *
- * Transformation annotation is an optional part of
- * TransformationMapping definition. Unless the TransformationMapping is
- * write-only, it should have a ReadTransformer, it defines
- * transformation of database column(s) value(s)into attribute value.
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Transformation {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) The optional element is a hint as to whether the value
- * of the field or property may be null. It is disregarded
- * for primitive types, which are considered non-optional.
- */
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="read-transformer" type="orm:read-transformer"/>
- <xsd:element name="write-transformer" type="orm:write-transformer" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access" type="orm:access-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum FetchType { LAZY, EAGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="LAZY"/>
- <xsd:enumeration value="EAGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="lob">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Lob {}
-
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Temporal {
- TemporalType value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:temporal-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum TemporalType {
- DATE, // java.sql.Date
- TIME, // java.sql.Time
- TIMESTAMP // java.sql.Timestamp
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="DATE"/>
- <xsd:enumeration value="TIME"/>
- <xsd:enumeration value="TIMESTAMP"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="enumerated">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Enumerated {
- EnumType value() default ORDINAL;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:enum-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="enum-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum EnumType {
- ORDINAL,
- STRING
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ORDINAL"/>
- <xsd:enumeration value="STRING"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="many-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cascade-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REFRESH};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade-all" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-merge" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-remove" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-refresh" type="orm:emptyType"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="one-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="one-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="order-by" type="orm:order-by" minOccurs="0"/>
- <xsd:element name="map-key" type="orm:map-key" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- public @interface JoinTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- JoinColumn[] inverseJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="inverse-join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="many-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="order-by" type="orm:order-by" minOccurs="0"/>
- <xsd:element name="map-key" type="orm:map-key" minOccurs="0"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="generated-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface GeneratedValue {
- GenerationType strategy() default AUTO;
- String generator() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:generation-type"/>
- <xsd:attribute name="generator" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKey {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-by">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderBy {
- String value() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="inheritance">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Inheritance {
- InheritanceType strategy() default SINGLE_TABLE;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:inheritance-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="inheritance-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum InheritanceType
- { SINGLE_TABLE, JOINED, TABLE_PER_CLASS};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SINGLE_TABLE"/>
- <xsd:enumeration value="JOINED"/>
- <xsd:enumeration value="TABLE_PER_CLASS"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorValue {
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum DiscriminatorType { STRING, CHAR, INTEGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="STRING"/>
- <xsd:enumeration value="CHAR"/>
- <xsd:enumeration value="INTEGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="primary-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface PrimaryKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorColumn {
- String name() default "DTYPE";
- DiscriminatorType discriminatorType() default STRING;
- String columnDefinition() default "";
- int length() default 31;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="discriminator-type" type="orm:discriminator-type"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embeddable">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for embeddable objects. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- in the class. If this is the case then the defaulting rules will
- be recursively applied.
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Embeddable {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking"
- minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0"
- maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0"
- maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes"
- minOccurs="0"/>
- <xsd:element name="copy-policy" type="orm:copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Embedded {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="mapped-superclass">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for a mapped superclass. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- If this is the case then the defaulting rules will be recursively
- applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface MappedSuperclass{}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking"
- minOccurs="0"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking"
- minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy"
- minOccurs="0" maxOccurs="1"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="sequence-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface SequenceGenerator {
- String name();
- String sequenceName() default "";
- int initialValue() default 1;
- int allocationSize() default 50;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="sequence-name" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface TableGenerator {
- String name();
- String table() default "";
- String catalog() default "";
- String schema() default "";
- String pkColumnName() default "";
- String valueColumnName() default "";
- String pkColumnValue() default "";
- int initialValue() default 0;
- int allocationSize() default 50;
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="pk-column-name" type="xsd:string"/>
- <xsd:attribute name="value-column-name" type="xsd:string"/>
- <xsd:attribute name="pk-column-value" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Converter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must implement
- * the org.eclipse.persistence.mappings.converters.Converter interface.
- */
- Class converterClass();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface TypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence field
- * or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent field
- * or property.
- */
- Class objectType() default void.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="object-type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ObjectTypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence
- * field or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent
- * field or property.
- */
- Class objectType() default void.class;
-
- /**
- * (Required) Specify the conversion values to be used
- * with the object converter.
- */
- ConversionValue[] conversionValues();
-
- /**
- * (Optional) Specify a default object value. Used for
- * legacy data if the data value is missing.
- */
- String defaultObjectValue() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="conversion-value" type="orm:conversion-value" minOccurs="1" maxOccurs="unbounded"/>
- <xsd:element name="default-object-value" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="conversion-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface ConversionValue {
- /**
- * (Required) Specify the database value.
- */
- String dataValue();
-
- /**
- * (Required) Specify the object value.
- */
- String objectValue();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="data-value" type="xsd:string" use="required"/>
- <xsd:attribute name="object-value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="struct-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface StructConverter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must
- * implement the EclipseLink interface
- * org.eclipse.persistence.mappings.converters.Converter
- */
- String converter();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="converter" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CopyPolicy is used to set a
- * org.eclipse.persistence.descriptors.copying.CopyPolicy on an Entity.
- * It is required that a class that implements
- * org.eclipse.persistence.descriptors.copying.CopyPolicy be specified
- * as the argument.
- *
- * A CopyPolicy should be specified on an Entity, MappedSuperclass or
- * Embeddable.
- *
- * For instance:
- * @Entity
- * @CopyPolicy("example.MyCopyPolicy")
- */
- public @interface CopyPolicy {
-
- /*
- * (Required)
- * This defines the class of the copy policy. It must specify a class
- * that implements org.eclipse.persistence.descriptors.copying.CopyPolicy
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="instantiation-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * An InstantiationCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.InstantiationCopyPolicy
- * on an Entity. InstantiationCopyPolicy is the default CopyPolicy in
- * EclipseLink and therefore this configuration option is only used to
- * override other types of copy policies
- *
- * An InstantiationCopyPolicy should be specified on an Entity,
- * MappedSuperclass or Embeddable.
- *
- * Example:
- * @Entity
- * @InstantiationCopyPolicy
- */
- public @interface InstantiationCopyPolicy {
- }
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="clone-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CloneCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.CloneCopyPolicy on an
- * Entity. A CloneCopyPolicy must specify at one or both of the "method"
- * or "workingCopyMethod". "workingCopyMethod" is used to clone objects
- * that will be returned to the user as they are registered in
- * EclipseLink's transactional mechanism, the UnitOfWork. "method" will
- * be used for the clone that is used for comparison in conjunction with
- * EclipseLink's DeferredChangeDetectionPolicy
- *
- * A CloneCopyPolicy should be specified on an Entity, MappedSuperclass
- * or Embeddable.
- *
- * Example:
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod", workingCopyMethod="myWorkingCopyCloneMethod")
- *
- * or:
- *
- @Entity
- * @CloneCopyPolicy(workingCopyMethodName="myWorkingCopyClone")
- */
- public @interface CloneCopyPolicy {
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified this defines
- * a method that will be used to create a clone that will be used
- * for comparison by
- * EclipseLink's DeferredChangeDetectionPolicy
- */
- String method();
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified
- * this defines a method that will be used to create a clone that
- * will be used to create the object returned when registering an
- * Object in an EclipseLink UnitOfWork
- */
- String workingCopyMethod();
-
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method" type="xsd:string"/>
- <xsd:attribute name="working-copy-method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface CollectionTable {
- /**
- * (Optional) The name of the collection table. If it is not
- * specified, it is defaulted to the concatenation of the following:
- * the name of the source entity; "_" ; the name of the relationship
- * property or field of the source entity.
- */
- String name() default "";
-
- /**
- * (Optional) The catalog of the table. It defaults to the persistence
- * unit default catalog.
- */
- String catalog() default "";
-
- /**
- * (Optional) The schema of the table. It defaults to the persistence
- * unit default schema.
- */
- String schema() default "";
-
- /**
- * (Optional) Used to specify a primary key column that is used as a
- * foreign key to join to another table. If the source entity uses a
- * composite primary key, a primary key join column must be specified
- * for each field of the composite primary key. In a single primary
- * key case, a primary key join column may optionally be specified.
- * Defaulting will apply otherwise as follows:
- * name, the same name as the primary key column of the primary table
- * of the source entity. referencedColumnName, the same name of
- * primary key column of the primary table of the source entity.
- */
- PrimaryKeyJoinColumn[] primaryKeyJoinColumns() default {};
-
- /**
- * (Optional) Unique constraints that are to be placed on the table.
- * These are only used if table generation is in effect.
- */
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicCollection {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the value column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:collection-table" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-map">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicMap {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the data column that holds the direct map
- * key. If the name on te key column is "", the name will default to:
- * the name of the property or field; "_KEY".
- */
- Column keyColumn() default @Column;
-
- /**
- * (Optional) Specify the key converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the direct map key.
- */
- Convert keyConverter() default @Convert;
-
- /**
- * (Optional) The name of the data column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
-
- /**
- * (Optional) Specify the value converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the value column mapping.
- */
- Convert valueConverter() default @Convert;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="key-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="key-converter" type="xsd:string" minOccurs="0"/>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="value-converter" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:collection-table" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum JoinFetchType {
- /**
- * An inner join is used to fetch the related object.
- * This does not allow for null/empty values.
- */
- INNER,
-
- /**
- * An inner join is used to fetch the related object.
- * This allows for null/empty values.
- */
- OUTER,
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="INNER"/>
- <xsd:enumeration value="OUTER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="optimistic-locking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An optimistic-locking element is used to specify the type of
- * optimistic locking EclipseLink should use when updating or deleting
- * entities. An optimistic-locking specification is supported on
- * an entity or mapped-superclass.
- *
- * It is used in conjunction with the optimistic-locking-type.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface OptimisticLocking {
- /**
- * (Optional) The type of optimistic locking policy to use.
- */
- OptimisticLockingType type() default VERSION_COLUMN;
-
- /**
- * (Optional) For an optimistic locking policy of type
- * SELECTED_COLUMNS, this annotation member becomes a (Required)
- * field.
- */
- Column[] selectedColumns() default {};
-
- /**
- * (Optional) Specify where the optimistic locking policy should
- * cascade lock. Currently only supported with VERSION_COLUMN locking.
- */
- boolean cascade() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="selected-column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="type" type="orm:optimistic-locking-type"/>
- <xsd:attribute name="cascade" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="optimistic-locking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A simple type that is used within an optimistic-locking
- * specification to specify the type of optimistic-locking that
- * EclipseLink should use when updating or deleting entities.
- */
- public enum OptimisticLockingType {
- /**
- * Using this type of locking policy compares every field in the table
- * in the WHERE clause when doing an update or a delete. If any field
- * has been changed, an optimistic locking exception will be thrown.
- */
- ALL_COLUMNS,
-
- /**
- * Using this type of locking policy compares only the changed fields
- * in the WHERE clause when doing an update. If any field has been
- * changed, an optimistic locking exception will be thrown. A delete
- * will only compare the primary key.
- */
- CHANGED_COLUMNS,
-
- /**
- * Using this type of locking compares selected fields in the WHERE
- * clause when doing an update or a delete. If any field has been
- * changed, an optimistic locking exception will be thrown. Note that
- * the fields specified must be mapped and not be primary keys.
- */
- SELECTED_COLUMNS,
-
- /**
- * Using this type of locking policy compares a single version number
- * in the where clause when doing an update. The version field must be
- * mapped and not be the primary key.
- */
- VERSION_COLUMN
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ALL_COLUMNS"/>
- <xsd:enumeration value="CHANGED_COLUMNS"/>
- <xsd:enumeration value="SELECTED_COLUMNS"/>
- <xsd:enumeration value="VERSION_COLUMN"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="primary-key">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The PrimaryKey annotation allows advanced configuration of the Id.
- * A validation policy can be given that allows specifying if zero is a valid id value.
- * The set of primary key columns can also be specified precisely.
- *
- * @author James Sutherland
- * @since EclipseLink 1.1
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface PrimaryKey {
- /**
- * (Optional) Configures what id validation is done.
- * By default 0 is not a valid id value, this can be used to allow 0 id values.
- */
- IdValidation validation() default IdValidation.ZERO;
-
- /**
- * (Optional) Used to specify the primary key columns directly.
- * This can be used instead of @Id if the primary key includes a non basic field,
- * such as a foreign key, or a inheritance discriminator, embedded, or transformation mapped field.
- */
- Column[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="validation" type="orm:id-validation"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="id-validation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The IdValidation enum determines the type value that are valid for an Id.
- * By default null is not allowed, and 0 is not allow for singleton ids of long or int type.
- * The default value is ZERO for singleton ids, and NULL for composite ids.
- * This can be set using the @PrimaryKey annotation, or ClassDescriptor API.
- *
- * @see PrimaryKey
- * @see org.eclipse.persistence.descriptors.ClassDescriptor#setIdValidation(IdValidation)
- * @author James Sutherland
- * @since EclipseLink 1.0
- */
- public enum IdValidation {
- /**
- * Only null is not allowed as an id value, 0 is allowed.
- */
- NULL,
-
- /**
- * null and 0 are not allowed, (only int and long).
- */
- ZERO,
-
- /**
- * No id validation is done.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="NULL"/>
- <xsd:enumeration value="ZERO"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cache">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Cache annotation is used to set an
- * org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy
- * which sets objects in EclipseLink's identity maps to be invalid
- * following given rules. By default in EclipseLink, objects do not
- * expire in the cache. Several different policies are available to
- * allow objects to expire.
- *
- * @see org.eclipse.persistence.annotations.CacheType
- *
- * A Cache anotation may be defined on an Entity or MappedSuperclass.
- * In the case of inheritance, a Cache annotation should only be defined
- * on the root of the inheritance hierarchy.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Cache {
- /**
- * (Optional) The type of cache to use.
- */
- CacheType type() default SOFT_WEAK;
-
- /**
- * (Optional) The size of cache to use.
- */
- int size() default 100;
-
- /**
- * (Optional) Cached instances in the shared cache or a client
- * isolated cache.
- */
- boolean shared() default true;
-
- /**
- * (Optional) Expire cached instance after a fix period of time (ms).
- * Queries executed against the cache after this will be forced back
- * to the database for a refreshed copy
- */
- int expiry() default -1; // minus one is no expiry.
-
- /**
- * (Optional) Expire cached instance a specific time of day. Queries
- * executed against the cache after this will be forced back to the
- * database for a refreshed copy
- */
- TimeOfDay expiryTimeOfDay() default @TimeOfDay(specified=false);
-
- /**
- * (Optional) Force all queries that go to the database to always
- * refresh the cache.
- */
- boolean alwaysRefresh() default false;
-
- /**
- * (Optional) For all queries that go to the database, refresh the
- * cache only if the data received from the database by a query is
- * newer than the data in the cache (as determined by the optimistic
- * locking field)
- */
- boolean refreshOnlyIfNewer() default false;
-
- /**
- * (Optional) Setting to true will force all queries to bypass the
- * cache for hits but still resolve against the cache for identity.
- * This forces all queries to hit the database.
- */
- boolean disableHits() default false;
-
- /**
- * (Optional) The cache coordination mode.
- */
- CacheCoordinationType coordinationType() default SEND_OBJECT_CHANGES;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:choice>
- <xsd:element name="expiry" type="xsd:integer" minOccurs="0"/>
- <xsd:element name="expiry-time-of-day" type="orm:time-of-day" minOccurs="0"/>
- </xsd:choice>
- <xsd:attribute name="size" type="xsd:integer"/>
- <xsd:attribute name="shared" type="xsd:boolean"/>
- <xsd:attribute name="type" type="orm:cache-type"/>
- <xsd:attribute name="always-refresh" type="xsd:boolean"/>
- <xsd:attribute name="refresh-only-if-newer" type="xsd:boolean"/>
- <xsd:attribute name="disable-hits" type="xsd:boolean"/>
- <xsd:attribute name="coordination-type" type="orm:cache-coordination-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The CacheType enum is used with the Cache annotation for a
- * persistent class. It defines the type of IdentityMap/Cache used for
- * the class. By default the SOFT_WEAK cache type is used.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheType {
- /**
- * Provides full caching and guaranteed identity. Caches all objects
- * and does not remove them.
- * WARNING: This method may be memory intensive when many objects are
- * read.
- */
- FULL,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using weak references. This method allows full garbage
- * collection and provides full caching and guaranteed identity.
- */
- WEAK,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using soft references. This method allows full garbage
- * collection when memory is low and provides full caching and
- * guaranteed identity.
- */
- SOFT,
-
- /**
- * Similar to the WEAK identity map except that it maintains a
- * most-frequently-used sub-cache. The size of the sub-cache is
- * proportional to the size of the identity map as specified by
- * descriptor's setIdentityMapSize() method. The sub-cache
- * uses soft references to ensure that these objects are
- * garbage-collected only if the system is low on memory.
- */
- SOFT_WEAK,
-
- /**
- * Identical to the soft cache weak (SOFT_WEAK) identity map except
- * that it uses hard references in the sub-cache. Use this identity
- * map if soft references do not behave properly on your platform.
- */
- HARD_WEAK,
-
- /**
- * A cache identity map maintains a fixed number of objects
- * specified by the application. Objects are removed from the cache
- * on a least-recently-used basis. This method allows object
- * identity for the most commonly used objects.
- * WARNING: Furnishes caching and identity, but does not guarantee
- * identity.
- */
- CACHE,
-
- /**
- * WARNING: Does not preserve object identity and does not cache
- * objects.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="FULL"/>
- <xsd:enumeration value="WEAK"/>
- <xsd:enumeration value="SOFT"/>
- <xsd:enumeration value="SOFT_WEAK"/>
- <xsd:enumeration value="HARD_WEAK"/>
- <xsd:enumeration value="CACHE"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-coordination-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the Cache annotation.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheCoordinationType {
- /**
- * Sends a list of changed objects including data about the changes.
- * This data is merged into the receiving cache.
- */
- SEND_OBJECT_CHANGES,
-
- /**
- * Sends a list of the identities of the objects that have changed.
- * The receiving cache invalidates the objects (rather than changing
- * any of the data)
- */
- INVALIDATE_CHANGED_OBJECTS,
-
- /**
- * Same as SEND_OBJECT_CHANGES except it also includes any newly
- * created objects from the transaction.
- */
- SEND_NEW_OBJECTS_WITH_CHANGES,
-
- /**
- * Does no cache coordination.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SEND_OBJECT_CHANGES"/>
- <xsd:enumeration value="INVALIDATE_CHANGED_OBJECTS"/>
- <xsd:enumeration value="SEND_NEW_OBJECTS_WITH_CHANGES"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="time-of-day">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface TimeOfDay {
- /**
- * (Optional) Hour of the day.
- */
- int hour() default 0;
-
- /**
- * (Optional) Minute of the day.
- */
- int minute() default 0;
-
- /**
- * (Optional) Second of the day.
- */
- int second() default 0;
-
- /**
- * (Optional) Millisecond of the day.
- */
- int millisecond() default 0;
-
- /**
- * Internal use. Do not modify.
- */
- boolean specified() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="hour" type="xsd:integer"/>
- <xsd:attribute name="minute" type="xsd:integer"/>
- <xsd:attribute name="second" type="xsd:integer"/>
- <xsd:attribute name="millisecond" type="xsd:integer"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="change-tracking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The ChangeTracking annotation is used to specify the
- * org.eclipse.persistence.descriptors.changetracking.ObjectChangePolicy
- * which computes changes sets for EclipseLink's UnitOfWork commit
- * process. An ObjectChangePolicy is stored on an Entity's descriptor.
- *
- * A ChangeTracking annotation may be specified on an Entity,
- * MappedSuperclass or Embeddable.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface ChangeTracking {
- /**
- * (Optional) The type of change tracking to use.
- */
- ChangeTrackingType value() default AUTO;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="type" type="orm:change-tracking-type" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="change-tracking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the ChangeTracking annotation.
- */
- public enum ChangeTrackingType {
- /**
- * An ATTRIBUTE change tracking type allows change tracking at the
- * attribute level of an object. Objects with changed attributes will
- * be processed in the commit process to include any changes in the
- * results of the commit. Unchanged objects will be ignored.
- */
- ATTRIBUTE,
-
- /**
- * An OBJECT change tracking policy allows an object to calculate for
- * itself whether it has changed. Changed objects will be processed in
- * the commit process to include any changes in the results of the
- * commit. Unchanged objects will be ignored.
- */
- OBJECT,
-
- /**
- * A DEFERRED change tracking policy defers all change detection to
- * the UnitOfWork's change detection process. Essentially, the
- * calculateChanges() method will run for all objects in a UnitOfWork.
- * This is the default ObjectChangePolicy
- */
- DEFERRED,
-
- /**
- * Will not set any change tracking policy.
- */
- AUTO
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ATTRIBUTE"/>
- <xsd:enumeration value="OBJECT"/>
- <xsd:enumeration value="DEFERRED"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="customizer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Customizer annotation is used to specify a class that implements
- * the org.eclipse.persistence.config.DescriptorCustomizer
- * interface and is to run against an enetity's class descriptor after all
- * metadata processing has been completed.
- *
- * The Customizer annotation may be defined on an Entity, MappedSuperclass
- * or Embeddable class. In the case of inheritance, a Customizer is not
- * inherited from its parent classes.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Customizer {
- /**
- * (Required) Defines the name of the descriptor customizer class that
- * should be applied for the related entity or embeddable class.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-stored-procedure-query">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A NamedStoredProcedureQuery annotation allows the definition of
- * queries that call stored procedures as named queries.
-
- * A NamedStoredProcedureQuery annotation may be defined on an Entity or
- * MappedSuperclass.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface NamedStoredProcedureQuery {
- /**
- * (Required) Unique name that references this stored procedure query.
- */
- String name();
-
- /**
- * (Optional) Query hints.
- */
- QueryHint[] hints() default {};
-
- /**
- * (Optional) Refers to the class of the result.
- */
- Class resultClass() default void.class;
-
- /**
- * (Optional) The name of the SQLResultMapping.
- */
- String resultSetMapping() default "";
-
- /**
- * (Required) The name of the stored procedure.
- */
- String procedureName();
-
- /**
- * (Optional) Whether the query should return a result set.
- */
- boolean returnsResultSet() default true;
-
- /**
- * (Optional) Defines arguments to the stored procedure.
- */
- StoredProcedureParameter[] parameters() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0"
- maxOccurs="unbounded"/>
- <xsd:element name="parameter" type="orm:stored-procedure-parameter"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- <xsd:attribute name="procedure-name" type="xsd:string" use="required"/>
- <xsd:attribute name="returns-result-set" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="stored-procedure-parameter">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A StoredProcedureParameter annotation is used within a
- * NamedStoredProcedureQuery annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface StoredProcedureParameter {
- /**
- * (Optional) The direction of the stored procedure parameter.
- */
- Direction direction() default IN;
-
- /**
- * (Optional) Stored procedure parameter name.
- */
- String name() default "";
-
- /**
- * (Required) The query parameter name.
- */
- String queryParameter();
-
- /**
- * (Optional) The type of Java class desired back from the procedure,
- * this is dependent on the type returned from the procedure.
- */
- Class type() default void.class;
-
- /**
- * (Optional) The JDBC type code, this dependent on the type returned
- * from the procedure.
- */
- int jdbcType() default -1;
-
- /**
- * (Optional) The JDBC type name, this may be required for ARRAY or
- * STRUCT types.
- */
- String jdbcTypeName() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="direction" type="orm:direction-type"/>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="query-parameter" type="xsd:string" use="required"/>
- <xsd:attribute name="type" type="xsd:string"/>
- <xsd:attribute name="jdbc-type" type="xsd:integer"/>
- <xsd:attribute name="jdbc-type-name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="direction-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the StoredProcedureParameter annotation.
- * It is used to specify the direction of the stored procedure
- * parameters of a named stored procedure query.
- */
- public enum Direction {
- /**
- * Input parameter
- */
- IN,
-
- /**
- * Output parameter
- */
- OUT,
-
- /**
- * Input and output parameter
- */
- IN_OUT,
-
- /**
- * Output cursor
- */
- OUT_CURSOR
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="IN"/>
- <xsd:enumeration value="OUT"/>
- <xsd:enumeration value="IN_OUT"/>
- <xsd:enumeration value="OUT_CURSOR"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="variable-one-to-one">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * Variable one to one mappings are used to represent a pointer
- * references between a java object and an implementer of an interface.
- * This mapping is usually represented by a single pointer (stored in an
- * instance variable) between the source and target objects. In the
- * relational database tables, these mappings are normally implemented
- * using a foreign key and a type code.
- *
- * A VariableOneToOne can be specified within an Entity,
- * MappedSuperclass and Embeddable class.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface VariableOneToOne {
- /**
- * (Optional) The interface class that is the target of the
- * association. If not specified it will be inferred from the type
- * of the object being referenced.
- */
- Class targetInterface() default void.class;
-
- /**
- * (Optional) The operations that must be cascaded to the target of
- * the association.
- */
- CascadeType[] cascade() default {};
-
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) Whether the association is optional. If set to false
- * then a non-null relationship must always exist.
- */
- boolean optional() default true;
-
- /**
- * (Optional) The discriminator column will hold the type
- * indicators. If the DiscriminatorColumn is not specified, the name
- * of the discriminator column defaults to "DTYPE" and the
- * discriminator type to STRING.
- */
- DiscriminatorColumn discriminatorColumn() default @DiscriminatorColumn;
-
- /**
- * (Optional) The list of discriminator types that can be used with
- * this VariableOneToOne. If none are specified then those entities
- * within the persistence unit that implement the target interface
- * will be added to the list of types. The discriminator type will
- * default as follows:
- * - If DiscriminatorColumn type is STRING: Entity.name()
- * - If DiscriminatorColumn type is CHAR: First letter of the
- * Entity class
- * - If DiscriminatorColumn type is INTEGER: The next integer after
- * the highest integer explicitly added.
- */
- DiscriminatorClass[] discriminatorClasses() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/>
- <xsd:element name="discriminator-class" type="orm:discriminator-class" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-interface" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-class">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A DiscriminatorClass is used within a VariableOneToOne annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface DiscriminatorClass {
- /**
- * (Required) The discriminator to be stored on the database.
- */
- String discriminator();
-
- /**
- * (Required) The class to the instantiated with the given
- * discriminator.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="discriminator" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="existence-type">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * The ExistenceChecking annotation is used to specify the type of
- * checking EclipseLink should use when updating entities.
- *
- * An existence-checking specification is supported on an Entity or
- * MappedSuperclass annotation.
- */
- public @interface ExistenceChecking {
- /**
- * (Optional) Set the existence check for determining
- * if an insert or update should occur for an object.
- */
- ExistenceType value() default CHECK_CACHE;
- }
-
- /**
- * Assume that if the objects primary key does not include null and
- * it is in the cache, then it must exist.
- */
- CHECK_CACHE,
-
- /**
- * Perform does exist check on the database.
- */
- CHECK_DATABASE,
-
- /**
- * Assume that if the objects primary key does not include null then
- * it must exist. This may be used if the application guarantees or
- * does not care about the existence check.
- */
- ASSUME_EXISTENCE,
-
- /**
- * Assume that the object does not exist. This may be used if the
- * application guarantees or does not care about the existence check.
- * This will always force an insert to be called.
- */
- ASSUME_NON_EXISTENCE
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="CHECK_CACHE" />
- <xsd:enumeration value="CHECK_DATABASE" />
- <xsd:enumeration value="ASSUME_EXISTENCE" />
- <xsd:enumeration value="ASSUME_NON_EXISTENCE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-</xsd:schema>
-
-
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_2.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_2.xsd
deleted file mode 100644
index f7c2b26770..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_1_2.xsd
+++ /dev/null
@@ -1,3519 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-******************************************************************************
- Copyright (c) 1998, 2009 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- which accompanies this distribution.
- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- and the Eclipse Distribution License is available at
- http://www.eclipse.org/org/documents/edl-v10.php.
-
- Contributors:
- Oracle - initial API and implementation from Oracle TopLink
-*****************************************************************************/
--->
-
-<!-- Java Persistence API object-relational mapping file schema -->
-<xsd:schema targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:orm="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="1.2">
-
- <xsd:annotation>
- <xsd:documentation>
- @(#)eclipselink_orm_1_2.xsd 1.0 February 1 2008
- </xsd:documentation>
- </xsd:annotation>
- <xsd:annotation>
- <xsd:documentation><![CDATA[
-
- This is the XML Schema for the native Eclipselink XML mapping file
- The file may be named "META-INF/eclipselink-orm.xml" in the persistence
- archive or it may be named some other name which would be
- used to locate the file as resource on the classpath.
- Object/relational mapping files must indicate the object/relational
- mapping file schema by using the persistence namespace:
-
- http://www.eclipse.org/eclipselink/xsds/persistence/orm
-
- and indicate the version of the schema by using the version element as shown below:
-
- <entity-mappings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm
- eclipselink_orm_1_2.xsd
- version="1.2">
- ...
- </entity-mappings>
-
- ]]></xsd:documentation>
- </xsd:annotation>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="emptyType"/>
- <xsd:simpleType name="versionType">
- <xsd:restriction base="xsd:token">
- <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="access-methods">
- <xsd:annotation>
- <xsd:documentation>
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="get-method" type="xsd:string" use="required"/>
- <xsd:attribute name="set-method" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cache">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Cache annotation is used to set an
- * org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy
- * which sets objects in EclipseLink's identity maps to be invalid
- * following given rules. By default in EclipseLink, objects do not
- * expire in the cache. Several different policies are available to
- * allow objects to expire.
- *
- * @see org.eclipse.persistence.annotations.CacheType
- *
- * A Cache anotation may be defined on an Entity or MappedSuperclass.
- * In the case of inheritance, a Cache annotation should only be defined
- * on the root of the inheritance hierarchy.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Cache {
- /**
- * (Optional) The type of cache to use.
- */
- CacheType type() default SOFT_WEAK;
-
- /**
- * (Optional) The size of cache to use.
- */
- int size() default 100;
-
- /**
- * (Optional) Cached instances in the shared cache or a client
- * isolated cache.
- */
- boolean shared() default true;
-
- /**
- * (Optional) Expire cached instance after a fix period of time (ms).
- * Queries executed against the cache after this will be forced back
- * to the database for a refreshed copy
- */
- int expiry() default -1; // minus one is no expiry.
-
- /**
- * (Optional) Expire cached instance a specific time of day. Queries
- * executed against the cache after this will be forced back to the
- * database for a refreshed copy
- */
- TimeOfDay expiryTimeOfDay() default @TimeOfDay(specified=false);
-
- /**
- * (Optional) Force all queries that go to the database to always
- * refresh the cache.
- */
- boolean alwaysRefresh() default false;
-
- /**
- * (Optional) For all queries that go to the database, refresh the
- * cache only if the data received from the database by a query is
- * newer than the data in the cache (as determined by the optimistic
- * locking field)
- */
- boolean refreshOnlyIfNewer() default false;
-
- /**
- * (Optional) Setting to true will force all queries to bypass the
- * cache for hits but still resolve against the cache for identity.
- * This forces all queries to hit the database.
- */
- boolean disableHits() default false;
-
- /**
- * (Optional) The cache coordination mode.
- */
- CacheCoordinationType coordinationType() default SEND_OBJECT_CHANGES;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:choice>
- <xsd:element name="expiry" type="xsd:integer" minOccurs="0"/>
- <xsd:element name="expiry-time-of-day" type="orm:time-of-day" minOccurs="0"/>
- </xsd:choice>
- <xsd:attribute name="size" type="xsd:integer"/>
- <xsd:attribute name="shared" type="xsd:boolean"/>
- <xsd:attribute name="type" type="orm:cache-type"/>
- <xsd:attribute name="always-refresh" type="xsd:boolean"/>
- <xsd:attribute name="refresh-only-if-newer" type="xsd:boolean"/>
- <xsd:attribute name="disable-hits" type="xsd:boolean"/>
- <xsd:attribute name="coordination-type" type="orm:cache-coordination-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The CacheType enum is used with the Cache annotation for a
- * persistent class. It defines the type of IdentityMap/Cache used for
- * the class. By default the SOFT_WEAK cache type is used.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheType {
- /**
- * Provides full caching and guaranteed identity. Caches all objects
- * and does not remove them.
- * WARNING: This method may be memory intensive when many objects are
- * read.
- */
- FULL,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using weak references. This method allows full garbage
- * collection and provides full caching and guaranteed identity.
- */
- WEAK,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using soft references. This method allows full garbage
- * collection when memory is low and provides full caching and
- * guaranteed identity.
- */
- SOFT,
-
- /**
- * Similar to the WEAK identity map except that it maintains a
- * most-frequently-used sub-cache. The size of the sub-cache is
- * proportional to the size of the identity map as specified by
- * descriptor's setIdentityMapSize() method. The sub-cache
- * uses soft references to ensure that these objects are
- * garbage-collected only if the system is low on memory.
- */
- SOFT_WEAK,
-
- /**
- * Identical to the soft cache weak (SOFT_WEAK) identity map except
- * that it uses hard references in the sub-cache. Use this identity
- * map if soft references do not behave properly on your platform.
- */
- HARD_WEAK,
-
- /**
- * A cache identity map maintains a fixed number of objects
- * specified by the application. Objects are removed from the cache
- * on a least-recently-used basis. This method allows object
- * identity for the most commonly used objects.
- * WARNING: Furnishes caching and identity, but does not guarantee
- * identity.
- */
- CACHE,
-
- /**
- * WARNING: Does not preserve object identity and does not cache
- * objects.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="FULL"/>
- <xsd:enumeration value="WEAK"/>
- <xsd:enumeration value="SOFT"/>
- <xsd:enumeration value="SOFT_WEAK"/>
- <xsd:enumeration value="HARD_WEAK"/>
- <xsd:enumeration value="CACHE"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-coordination-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the Cache annotation.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheCoordinationType {
- /**
- * Sends a list of changed objects including data about the changes.
- * This data is merged into the receiving cache.
- */
- SEND_OBJECT_CHANGES,
-
- /**
- * Sends a list of the identities of the objects that have changed.
- * The receiving cache invalidates the objects (rather than changing
- * any of the data)
- */
- INVALIDATE_CHANGED_OBJECTS,
-
- /**
- * Same as SEND_OBJECT_CHANGES except it also includes any newly
- * created objects from the transaction.
- */
- SEND_NEW_OBJECTS_WITH_CHANGES,
-
- /**
- * Does no cache coordination.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SEND_OBJECT_CHANGES"/>
- <xsd:enumeration value="INVALIDATE_CHANGED_OBJECTS"/>
- <xsd:enumeration value="SEND_NEW_OBJECTS_WITH_CHANGES"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="change-tracking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The ChangeTracking annotation is used to specify the
- * org.eclipse.persistence.descriptors.changetracking.ObjectChangePolicy
- * which computes changes sets for EclipseLink's UnitOfWork commit
- * process. An ObjectChangePolicy is stored on an Entity's descriptor.
- *
- * A ChangeTracking annotation may be specified on an Entity,
- * MappedSuperclass or Embeddable.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface ChangeTracking {
- /**
- * (Optional) The type of change tracking to use.
- */
- ChangeTrackingType value() default AUTO;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="type" type="orm:change-tracking-type" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="change-tracking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the ChangeTracking annotation.
- */
- public enum ChangeTrackingType {
- /**
- * An ATTRIBUTE change tracking type allows change tracking at the
- * attribute level of an object. Objects with changed attributes will
- * be processed in the commit process to include any changes in the
- * results of the commit. Unchanged objects will be ignored.
- */
- ATTRIBUTE,
-
- /**
- * An OBJECT change tracking policy allows an object to calculate for
- * itself whether it has changed. Changed objects will be processed in
- * the commit process to include any changes in the results of the
- * commit. Unchanged objects will be ignored.
- */
- OBJECT,
-
- /**
- * A DEFERRED change tracking policy defers all change detection to
- * the UnitOfWork's change detection process. Essentially, the
- * calculateChanges() method will run for all objects in a UnitOfWork.
- * This is the default ObjectChangePolicy
- */
- DEFERRED,
-
- /**
- * Will not set any change tracking policy.
- */
- AUTO
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ATTRIBUTE"/>
- <xsd:enumeration value="OBJECT"/>
- <xsd:enumeration value="DEFERRED"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="customizer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Customizer annotation is used to specify a class that implements
- * the org.eclipse.persistence.config.DescriptorCustomizer
- * interface and is to run against an enetity's class descriptor after all
- * metadata processing has been completed.
- *
- * The Customizer annotation may be defined on an Entity, MappedSuperclass
- * or Embeddable class. In the case of inheritance, a Customizer is not
- * inherited from its parent classes.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Customizer {
- /**
- * (Required) Defines the name of the descriptor customizer class that
- * should be applied for the related entity or embeddable class.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="direction-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the StoredProcedureParameter annotation.
- * It is used to specify the direction of the stored procedure
- * parameters of a named stored procedure query.
- */
- public enum Direction {
- /**
- * Input parameter
- */
- IN,
-
- /**
- * Output parameter
- */
- OUT,
-
- /**
- * Input and output parameter
- */
- IN_OUT,
-
- /**
- * Output cursor
- */
- OUT_CURSOR
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="IN"/>
- <xsd:enumeration value="OUT"/>
- <xsd:enumeration value="IN_OUT"/>
- <xsd:enumeration value="OUT_CURSOR"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:element name="entity-mappings">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
-
- The entity-mappings element is the root element of an mapping
- file. It contains the following four types of elements:
-
- 1. The persistence-unit-metadata element contains metadata
- for the entire persistence unit. It is undefined if this element
- occurs in multiple mapping files within the same persistence unit.
-
- 2. The package, schema, catalog and access elements apply to all of
- the entity, mapped-superclass and embeddable elements defined in
- the same file in which they occur.
-
- 3. The sequence-generator, table-generator, named-query,
- named-native-query and sql-result-set-mapping elements are global
- to the persistence unit. It is undefined to have more than one
- sequence-generator or table-generator of the same name in the same
- or different mapping files in a persistence unit. It is also
- undefined to have more than one named-query, named-native-query, or
- result-set-mapping of the same name in the same or different mapping
- files in a persistence unit.
-
- 4. The entity, mapped-superclass and embeddable elements each define
- the mapping information for a managed persistent class. The mapping
- information contained in these elements may be complete or it may
- be partial.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="persistence-unit-metadata" type="orm:persistence-unit-metadata" minOccurs="0"/>
- <xsd:element name="package" type="xsd:string" minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string" minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string" minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-query" type="orm:named-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping" type="orm:sql-result-set-mapping" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="mapped-superclass" type="orm:mapped-superclass" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="entity" type="orm:entity" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embeddable" type="orm:embeddable" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="version" type="orm:versionType" fixed="1.2" use="required"/>
- </xsd:complexType>
- </xsd:element>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="existence-type">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * The ExistenceChecking annotation is used to specify the type of
- * checking EclipseLink should use when updating entities.
- *
- * An existence-checking specification is supported on an Entity or
- * MappedSuperclass annotation.
- */
- public @interface ExistenceChecking {
-
- /**
- * (Optional) Set the existence check for determining
- * if an insert or update should occur for an object.
- */
- ExistenceType value() default CHECK_CACHE;
- }
-
- /**
- * Assume that if the objects primary key does not include null and
- * it is in the cache, then it must exist.
- */
- CHECK_CACHE,
-
- /**
- * Perform does exist check on the database.
- */
- CHECK_DATABASE,
-
- /**
- * Assume that if the objects primary key does not include null then
- * it must exist. This may be used if the application guarantees or
- * does not care about the existence check.
- */
- ASSUME_EXISTENCE,
-
- /**
- * Assume that the object does not exist. This may be used if the
- * application guarantees or does not care about the existence check.
- * This will always force an insert to be called.
- */
- ASSUME_NON_EXISTENCE
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="CHECK_CACHE"/>
- <xsd:enumeration value="CHECK_DATABASE"/>
- <xsd:enumeration value="ASSUME_EXISTENCE"/>
- <xsd:enumeration value="ASSUME_NON_EXISTENCE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-metadata">
- <xsd:annotation>
- <xsd:documentation>
-
- Metadata that applies to the persistence unit and not just to
- the mapping file in which it is contained.
-
- If the xml-mapping-metadata-complete element is specified,
- the complete set of mapping metadata for the persistence unit
- is contained in the XML mapping files for the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="xml-mapping-metadata-complete" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="exclude-default-mappings" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="persistence-unit-defaults" type="orm:persistence-unit-defaults" minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-defaults">
- <xsd:annotation>
- <xsd:documentation>
-
- These defaults are applied to the persistence unit as a whole
- unless they are overridden by local annotation or XML
- element settings.
-
- schema - Used as the schema for all tables, secondary tables,
- collection tables, sequence generators, and table generators
- that apply to the persistence unit
- catalog - Used as the catalog for all tables, secondary tables,
- collection tables, sequence generators, and table generators
- that apply to the persistence unit
- access - Used as the access type for all managed classes in
- the persistence unit
- cascade-persist - Adds cascade-persist to the set of cascade options
- in all entity relationships of the persistence unit
- entity-listeners - List of default entity listeners to be invoked
- on each entity in the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string" minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string" minOccurs="0"/>
- <xsd:element name="delimited-identifiers" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type" minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners" minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for an entity. Is allowed to be
- sparsely populated and used in conjunction with the annotations.
- Alternatively, the metadata-complete attribute can be used to
- indicate that no annotations on the entity class (and its fields
- or properties) are to be processed. If this is the case then
- the defaulting rules for the entity and its sub-elements will
- be recursively applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface Entity {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="table" type="orm:table" minOccurs="0"/>
- <xsd:element name="secondary-table" type="orm:secondary-table" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="inheritance" type="orm:inheritance" minOccurs="0"/>
- <xsd:element name="discriminator-value" type="orm:discriminator-value" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking" minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="named-query" type="orm:named-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping" type="orm:sql-result-set-mapping" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners" minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist" minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="cacheable" type="xsd:boolean"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="access-type">
- <xsd:annotation>
- <xsd:documentation>
-
- This element determines how the persistence provider accesses the
- state of an entity or embedded object.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="PROPERTY"/>
- <xsd:enumeration value="FIELD"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="association-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AssociationOverride {
- String name();
- JoinColumn[] joinColumns() default{};
- JoinTable joinTable() default @JoinTable;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="attribute-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AttributeOverride {
- String name();
- Column column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="attributes">
- <xsd:annotation>
- <xsd:documentation>
-
- This element contains the entity field or property mappings.
- It may be sparsely populated to include only a subset of the
- fields or properties. If metadata-complete for the entity is true
- then the remainder of the attributes will be defaulted according
- to the default rules.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="id" type="orm:id" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded-id" type="orm:embedded-id" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="basic" type="orm:basic" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-collection" type="orm:basic-collection" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-map" type="orm:basic-map" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="version" type="orm:version" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-one" type="orm:many-to-one" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-many" type="orm:one-to-many" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-one" type="orm:one-to-one" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="variable-one-to-one" type="orm:variable-one-to-one" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-many" type="orm:many-to-many" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="element-collection" type="orm:element-collection" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded" type="orm:embedded" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transformation" type="orm:transformation" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transient" type="orm:transient" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Basic {
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="lob" type="orm:lob"/>
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="enumerated" type="orm:enumerated"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicCollection {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the value column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:eclipselink-collection-table" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-map">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicMap {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the data column that holds the direct map
- * key. If the name on te key column is "", the name will default to:
- * the name of the property or field; "_KEY".
- */
- Column keyColumn() default @Column;
-
- /**
- * (Optional) Specify the key converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the direct map key.
- */
- Convert keyConverter() default @Convert;
-
- /**
- * (Optional) The name of the data column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
-
- /**
- * (Optional) Specify the value converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the value column mapping.
- */
- Convert valueConverter() default @Convert;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="key-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="key-converter" type="xsd:string" minOccurs="0"/>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="value-converter" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:eclipselink-collection-table" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cascade-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REFRESH};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade-all" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="cascade-merge" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="cascade-remove" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="cascade-refresh" type="orm:emptyType" minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="clone-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CloneCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.CloneCopyPolicy on an
- * Entity. A CloneCopyPolicy must specify at one or both of the "method"
- * or "workingCopyMethod". "workingCopyMethod" is used to clone objects
- * that will be returned to the user as they are registered in
- * EclipseLink's transactional mechanism, the UnitOfWork. "method" will
- * be used for the clone that is used for comparison in conjunction with
- * EclipseLink's DeferredChangeDetectionPolicy
- *
- * A CloneCopyPolicy should be specified on an Entity, MappedSuperclass
- * or Embeddable.
- *
- * Example:
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod", workingCopyMethod="myWorkingCopyCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(workingCopyMethodName="myWorkingCopyClone")
- */
- public @interface CloneCopyPolicy {
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified this defines
- * a method that will be used to create a clone that will be used
- * for comparison by
- * EclipseLink's DeferredChangeDetectionPolicy
- */
- String method();
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified
- * this defines a method that will be used to create a clone that
- * will be used to create the object returned when registering an
- * Object in an EclipseLink UnitOfWork
- */
- String workingCopyMethod();
-
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method" type="xsd:string"/>
- <xsd:attribute name="working-copy-method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface CollectionTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="eclipselink-collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface CollectionTable {
- /**
- * (Optional) The name of the collection table. If it is not
- * specified, it is defaulted to the concatenation of the following:
- * the name of the source entity; "_" ; the name of the relationship
- * property or field of the source entity.
- */
- String name() default "";
-
- /**
- * (Optional) The catalog of the table. It defaults to the persistence
- * unit default catalog.
- */
- String catalog() default "";
-
- /**
- * (Optional) The schema of the table. It defaults to the persistence
- * unit default schema.
- */
- String schema() default "";
-
- /**
- * (Optional) Used to specify a primary key column that is used as a
- * foreign key to join to another table. If the source entity uses a
- * composite primary key, a primary key join column must be specified
- * for each field of the composite primary key. In a single primary
- * key case, a primary key join column may optionally be specified.
- * Defaulting will apply otherwise as follows:
- * name, the same name as the primary key column of the primary table
- * of the source entity. referencedColumnName, the same name of
- * primary key column of the primary table of the source entity.
- */
- PrimaryKeyJoinColumn[] primaryKeyJoinColumns() default {};
-
- /**
- * (Optional) Unique constraints that are to be placed on the table.
- * These are only used if table generation is in effect.
- */
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Column {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="conversion-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface ConversionValue {
- /**
- * (Required) Specify the database value.
- */
- String dataValue();
-
- /**
- * (Required) Specify the object value.
- */
- String objectValue();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="data-value" type="xsd:string" use="required"/>
- <xsd:attribute name="object-value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Converter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must implement
- * the org.eclipse.persistence.mappings.converters.Converter interface.
- */
- Class converterClass();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface ColumnResult {
- String name();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CopyPolicy is used to set a
- * org.eclipse.persistence.descriptors.copying.CopyPolicy on an Entity.
- * It is required that a class that implements
- * org.eclipse.persistence.descriptors.copying.CopyPolicy be specified
- * as the argument.
- *
- * A CopyPolicy should be specified on an Entity, MappedSuperclass or
- * Embeddable.
- *
- * For instance:
- * @Entity
- * @CopyPolicy("example.MyCopyPolicy")
- */
- public @interface CopyPolicy {
-
- /*
- * (Required)
- * This defines the class of the copy policy. It must specify a class
- * that implements org.eclipse.persistence.descriptors.copying.CopyPolicy
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorColumn {
- String name() default "DTYPE";
- DiscriminatorType discriminatorType() default STRING;
- String columnDefinition() default "";
- int length() default 31;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="discriminator-type" type="orm:discriminator-type"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-class">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A DiscriminatorClass is used within a VariableOneToOne annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface DiscriminatorClass {
- /**
- * (Required) The discriminator to be stored on the database.
- */
- String discriminator();
-
- /**
- * (Required) The class to the instantiated with the given
- * discriminator.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="discriminator" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum DiscriminatorType { STRING, CHAR, INTEGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="STRING"/>
- <xsd:enumeration value="CHAR"/>
- <xsd:enumeration value="INTEGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorValue {
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="element-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ElementCollection {
- Class targetClass() default void.class;
- FetchType fetch() default LAZY;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by" minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column" minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key" minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal" type="orm:temporal" minOccurs="0"/>
- <xsd:element name="map-key-enumerated" type="orm:enumerated" minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column" minOccurs="0"/>
- <xsd:element name="map-key-join-column" type="orm:map-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="temporal" type="orm:temporal" minOccurs="0"/>
- <xsd:element name="enumerated" type="orm:enumerated" minOccurs="0"/>
- <xsd:element name="lob" type="orm:lob" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- </xsd:sequence>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:collection-table" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-class" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embeddable">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for embeddable objects. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- in the class. If this is the case then the defaulting rules will
- be recursively applied.
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Embeddable {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Embedded {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded-id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface EmbeddedId {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-listener">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines an entity listener to be invoked at lifecycle events
- for the entities that list this listener.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist" minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-listeners">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface EntityListeners {
- Class[] value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="entity-listener" type="orm:entity-listener" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface EntityResult {
- Class entityClass();
- FieldResult[] fields() default {};
- String discriminatorColumn() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field-result" type="orm:field-result" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="entity-class" type="xsd:string" use="required"/>
- <xsd:attribute name="discriminator-column" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="enum-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum EnumType {
- ORDINAL,
- STRING
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ORDINAL"/>
- <xsd:enumeration value="STRING"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="enumerated">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Enumerated {
- EnumType value() default ORDINAL;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:enum-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum FetchType { LAZY, EAGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="LAZY"/>
- <xsd:enumeration value="EAGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="field-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface FieldResult {
- String name();
- String column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="column" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="generated-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface GeneratedValue {
- GenerationType strategy() default AUTO;
- String generator() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:generation-type"/>
- <xsd:attribute name="generator" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="generation-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="TABLE"/>
- <xsd:enumeration value="SEQUENCE"/>
- <xsd:enumeration value="IDENTITY"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Id {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="id-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface IdClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="id-validation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The IdValidation enum determines the type value that are valid for an Id.
- * By default null is not allowed, and 0 is not allow for singleton ids of long or int type.
- * The default value is ZERO for singleton ids, and NULL for composite ids.
- * This can be set using the @PrimaryKey annotation, or ClassDescriptor API.
- *
- * @see PrimaryKey
- * @see org.eclipse.persistence.descriptors.ClassDescriptor#setIdValidation(IdValidation)
- * @author James Sutherland
- * @since EclipseLink 1.0
- */
- public enum IdValidation {
- /**
- * Only null is not allowed as an id value, 0 is allowed.
- */
- NULL,
-
- /**
- * null and 0 are not allowed, (only int and long).
- */
- ZERO,
-
- /**
- * No id validation is done.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="NULL"/>
- <xsd:enumeration value="ZERO"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="inheritance">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Inheritance {
- InheritanceType strategy() default SINGLE_TABLE;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:inheritance-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="inheritance-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum InheritanceType { SINGLE_TABLE, JOINED, TABLE_PER_CLASS };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SINGLE_TABLE"/>
- <xsd:enumeration value="JOINED"/>
- <xsd:enumeration value="TABLE_PER_CLASS"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="instantiation-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * An InstantiationCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.InstantiationCopyPolicy
- * on an Entity. InstantiationCopyPolicy is the default CopyPolicy in
- * EclipseLink and therefore this configuration option is only used to
- * override other types of copy policies
- *
- * An InstantiationCopyPolicy should be specified on an Entity,
- * MappedSuperclass or Embeddable.
- *
- * Example:
- * @Entity
- * @InstantiationCopyPolicy
- */
- public @interface InstantiationCopyPolicy {
- }
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum JoinFetchType {
- /**
- * An inner join is used to fetch the related object.
- * This does not allow for null/empty values.
- */
- INNER,
-
- /**
- * An inner join is used to fetch the related object.
- * This allows for null/empty values.
- */
- OUTER,
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="INNER"/>
- <xsd:enumeration value="OUTER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- JoinColumn[] inverseJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="inverse-join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="lob">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Lob {}
-
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="lock-mode-type">
- <xsd:annotation>
- <xsd:documentation>
- public enum LockModeType { READ, WRITE, OPTIMISTIC,
- OPTIMISTIC_FORCE_INCREMENT, PESSIMISTIC_READ, PESSIMISTIC_WRITE,
- PESSIMISTIC_FORCE_INCREMENT, NONE};
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="READ"/>
- <xsd:enumeration value="WRITE"/>
- <xsd:enumeration value="OPTIMISTIC"/>
- <xsd:enumeration value="OPTIMISTIC_FORCE_INCREMENT"/>
- <xsd:enumeration value="PESSIMISTIC_READ"/>
- <xsd:enumeration value="PESSIMISTIC_WRITE"/>
- <xsd:enumeration value="PESSIMISTIC_FORCE_INCREMENT"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="many-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by" minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column" minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key" minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal" type="orm:temporal" minOccurs="0"/>
- <xsd:element name="map-key-enumerated" type="orm:enumerated" minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column" minOccurs="0"/>
- <xsd:element name="map-key-join-column" type="orm:map-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="many-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by-id" type="xsd:string"/>
- <xsd:attribute name="id" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKey {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyColumn {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default false;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default false;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="mapped-superclass">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for a mapped superclass. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- If this is the case then the defaulting rules will be recursively
- applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface MappedSuperclass{}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking" minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners" minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist" minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="cacheable" type="xsd:boolean"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-native-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedNativeQuery {
- String name();
- String query();
- QueryHint[] hints() default {};
- Class resultClass() default void.class;
- String resultSetMapping() default ""; //named SqlResultSetMapping
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedQuery {
- String name();
- String query();
- QueryHint[] hints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="lock-mode" type="orm:lock-mode-type" minOccurs="0"/>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-stored-procedure-query">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A NamedStoredProcedureQuery annotation allows the definition of
- * queries that call stored procedures as named queries.
- * A NamedStoredProcedureQuery annotation may be defined on an Entity or
- * MappedSuperclass.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface NamedStoredProcedureQuery {
- /**
- * (Required) Unique name that references this stored procedure query.
- */
- String name();
-
- /**
- * (Optional) Query hints.
- */
- QueryHint[] hints() default {};
-
- /**
- * (Optional) Refers to the class of the result.
- */
- Class resultClass() default void.class;
-
- /**
- * (Optional) The name of the SQLResultMapping.
- */
- String resultSetMapping() default "";
-
- /**
- * (Required) The name of the stored procedure.
- */
- String procedureName();
-
- /**
- * (Optional) Whether the query should return a result set.
- */
- boolean returnsResultSet() default true;
-
- /**
- * (Optional) Defines arguments to the stored procedure.
- */
- StoredProcedureParameter[] parameters() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="parameter" type="orm:stored-procedure-parameter" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- <xsd:attribute name="procedure-name" type="xsd:string" use="required"/>
- <xsd:attribute name="returns-result-set" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="object-type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ObjectTypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence
- * field or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent
- * field or property.
- */
- Class objectType() default void.class;
-
- /**
- * (Required) Specify the conversion values to be used
- * with the object converter.
- */
- ConversionValue[] conversionValues();
-
- /**
- * (Optional) Specify a default object value. Used for
- * legacy data if the data value is missing.
- */
- String defaultObjectValue() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="conversion-value" type="orm:conversion-value" minOccurs="1" maxOccurs="unbounded"/>
- <xsd:element name="default-object-value" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="one-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by" minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column" minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key" minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal" type="orm:temporal" minOccurs="0"/>
- <xsd:element name="map-key-enumerated" type="orm:enumerated" minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column" minOccurs="0"/>
- <xsd:element name="map-key-join-column" type="orm:map-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="one-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- String mappedBy() default "";
- boolean orphanRemoval() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- <xsd:attribute name="mapped-by-id" type="xsd:string"/>
- <xsd:attribute name="id" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="optimistic-locking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An optimistic-locking element is used to specify the type of
- * optimistic locking EclipseLink should use when updating or deleting
- * entities. An optimistic-locking specification is supported on
- * an entity or mapped-superclass.
- *
- * It is used in conjunction with the optimistic-locking-type.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface OptimisticLocking {
- /**
- * (Optional) The type of optimistic locking policy to use.
- */
- OptimisticLockingType type() default VERSION_COLUMN;
-
- /**
- * (Optional) For an optimistic locking policy of type
- * SELECTED_COLUMNS, this annotation member becomes a (Required)
- * field.
- */
- Column[] selectedColumns() default {};
-
- /**
- * (Optional) Specify where the optimistic locking policy should
- * cascade lock. Currently only supported with VERSION_COLUMN locking.
- */
- boolean cascade() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="selected-column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="type" type="orm:optimistic-locking-type"/>
- <xsd:attribute name="cascade" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="optimistic-locking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A simple type that is used within an optimistic-locking
- * specification to specify the type of optimistic-locking that
- * EclipseLink should use when updating or deleting entities.
- */
- public enum OptimisticLockingType {
- /**
- * Using this type of locking policy compares every field in the table
- * in the WHERE clause when doing an update or a delete. If any field
- * has been changed, an optimistic locking exception will be thrown.
- */
- ALL_COLUMNS,
-
- /**
- * Using this type of locking policy compares only the changed fields
- * in the WHERE clause when doing an update. If any field has been
- * changed, an optimistic locking exception will be thrown. A delete
- * will only compare the primary key.
- */
- CHANGED_COLUMNS,
-
- /**
- * Using this type of locking compares selected fields in the WHERE
- * clause when doing an update or a delete. If any field has been
- * changed, an optimistic locking exception will be thrown. Note that
- * the fields specified must be mapped and not be primary keys.
- */
- SELECTED_COLUMNS,
-
- /**
- * Using this type of locking policy compares a single version number
- * in the where clause when doing an update. The version field must be
- * mapped and not be the primary key.
- */
- VERSION_COLUMN
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ALL_COLUMNS"/>
- <xsd:enumeration value="CHANGED_COLUMNS"/>
- <xsd:enumeration value="SELECTED_COLUMNS"/>
- <xsd:enumeration value="VERSION_COLUMN"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-by">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderBy {
- String value() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="order-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderColumn {
- String name() default "";
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="validation-mode" type="orm:order-column-validation-mode"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-column-validation-mode">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum OrderColumnValidationMode {
- NONE,
- CORRECTION,
- EXCEPTION
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="NONE"/>
- <xsd:enumeration value="CORRECTION"/>
- <xsd:enumeration value="EXCEPTION"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-load">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostLoad {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostPersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PrePersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="primary-key">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The PrimaryKey annotation allows advanced configuration of the Id.
- * A validation policy can be given that allows specifying if zero is a valid id value.
- * The set of primary key columns can also be specified precisely.
- *
- * @author James Sutherland
- * @since EclipseLink 1.1
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface PrimaryKey {
- /**
- * (Optional) Configures what id validation is done.
- * By default 0 is not a valid id value, this can be used to allow 0 id values.
- */
- IdValidation validation() default IdValidation.ZERO;
-
- /**
- * (Optional) Used to specify the primary key columns directly.
- * This can be used instead of @Id if the primary key includes a non basic field,
- * such as a foreign key, or a inheritance discriminator, embedded, or transformation mapped field.
- */
- Column[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="validation" type="orm:id-validation"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="primary-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface PrimaryKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="property">
- <xsd:annotation>
- <xsd:documentation>
-
- A user defined mapping's property.
- @Target({METHOD, FIELD, TYPE})
- @Retention(RUNTIME)
- public @interface Property {
- /**
- * Property name.
- */
- String name();
-
- /**
- * String representation of Property value,
- * converted to an instance of valueType.
- */
- String value();
-
- /**
- * Property value type.
- * The value converted to valueType by ConversionManager.
- * If specified must be a simple type that could be handled by
- * ConversionManager:
- * numerical, boolean, temporal.
- */
- Class valueType() default String.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- <xsd:attribute name="value-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="query-hint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface QueryHint {
- String name();
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="read-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * Unless the TransformationMapping is write-only, it should have a
- * ReadTransformer, it defines transformation of database column(s)
- * value(s)into attribute value.
- *
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReadTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.AttributeTransformer
- * interface. The class will be instantiated, its
- * buildAttributeValue will be used to create the value to be
- * assigned to the attribute.
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be assigned to the attribute (not assigns the value to
- * the attribute). Either transformerClass or method must be
- * specified, but not both.
- */
- String method() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="secondary-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SecondaryTable {
- String name();
- String catalog() default "";
- String schema() default "";
- PrimaryKeyJoinColumn[] pkJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="sequence-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface SequenceGenerator {
- String name();
- String sequenceName() default "";
- String catalog() default "";
- String schema() default "";
- int initialValue() default 1;
- int allocationSize() default 50;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="sequence-name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="sql-result-set-mapping">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SqlResultSetMapping {
- String name();
- EntityResult[] entities() default {};
- ColumnResult[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="entity-result" type="orm:entity-result" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="column-result" type="orm:column-result" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="stored-procedure-parameter">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A StoredProcedureParameter annotation is used within a
- * NamedStoredProcedureQuery annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface StoredProcedureParameter {
- /**
- * (Optional) The direction of the stored procedure parameter.
- */
- Direction direction() default IN;
-
- /**
- * (Optional) Stored procedure parameter name.
- */
- String name() default "";
-
- /**
- * (Required) The query parameter name.
- */
- String queryParameter();
-
- /**
- * (Optional) The type of Java class desired back from the procedure,
- * this is dependent on the type returned from the procedure.
- */
- Class type() default void.class;
-
- /**
- * (Optional) The JDBC type code, this dependent on the type returned
- * from the procedure.
- */
- int jdbcType() default -1;
-
- /**
- * (Optional) The JDBC type name, this may be required for ARRAY or
- * STRUCT types.
- */
- String jdbcTypeName() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="direction" type="orm:direction-type"/>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="query-parameter" type="xsd:string" use="required"/>
- <xsd:attribute name="type" type="xsd:string"/>
- <xsd:attribute name="jdbc-type" type="xsd:integer"/>
- <xsd:attribute name="jdbc-type-name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="struct-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface StructConverter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must
- * implement the EclipseLink interface
- * org.eclipse.persistence.mappings.converters.Converter
- */
- String converter();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="converter" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Table {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface TableGenerator {
- String name();
- String table() default "";
- String catalog() default "";
- String schema() default "";
- String pkColumnName() default "";
- String valueColumnName() default "";
- String pkColumnValue() default "";
- int initialValue() default 0;
- int allocationSize() default 50;
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="pk-column-name" type="xsd:string"/>
- <xsd:attribute name="value-column-name" type="xsd:string"/>
- <xsd:attribute name="pk-column-value" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Temporal {
- TemporalType value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:temporal-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum TemporalType {
- DATE, // java.sql.Date
- TIME, // java.sql.Time
- TIMESTAMP // java.sql.Timestamp
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="DATE"/>
- <xsd:enumeration value="TIME"/>
- <xsd:enumeration value="TIMESTAMP"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="time-of-day">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface TimeOfDay {
- /**
- * (Optional) Hour of the day.
- */
- int hour() default 0;
-
- /**
- * (Optional) Minute of the day.
- */
- int minute() default 0;
-
- /**
- * (Optional) Second of the day.
- */
- int second() default 0;
-
- /**
- * (Optional) Millisecond of the day.
- */
- int millisecond() default 0;
-
- /**
- * Internal use. Do not modify.
- */
- boolean specified() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="hour" type="xsd:integer"/>
- <xsd:attribute name="minute" type="xsd:integer"/>
- <xsd:attribute name="second" type="xsd:integer"/>
- <xsd:attribute name="millisecond" type="xsd:integer"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="transformation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Transformation is an optional annotation for
- * org.eclipse.persistence.mappings.TransformationMapping.
- * TransformationMapping allows to map an attribute to one or more
- * database columns.
- *
- * Transformation annotation is an optional part of
- * TransformationMapping definition. Unless the TransformationMapping is
- * write-only, it should have a ReadTransformer, it defines
- * transformation of database column(s) value(s)into attribute value.
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Transformation {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) The optional element is a hint as to whether the value
- * of the field or property may be null. It is disregarded
- * for primitive types, which are considered non-optional.
- */
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="read-transformer" type="orm:read-transformer"/>
- <xsd:element name="write-transformer" type="orm:write-transformer" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access" type="orm:access-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="transient">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Transient {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface TypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence field
- * or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent field
- * or property.
- */
- Class objectType() default void.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="unique-constraint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface UniqueConstraint {
- String name() default "";
- String[] columnNames();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" minOccurs="0"/>
- <xsd:element name="column-name" type="xsd:string" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="variable-one-to-one">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * Variable one to one mappings are used to represent a pointer
- * references between a java object and an implementer of an interface.
- * This mapping is usually represented by a single pointer (stored in an
- * instance variable) between the source and target objects. In the
- * relational database tables, these mappings are normally implemented
- * using a foreign key and a type code.
- *
- * A VariableOneToOne can be specified within an Entity,
- * MappedSuperclass and Embeddable class.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface VariableOneToOne {
- /**
- * (Optional) The interface class that is the target of the
- * association. If not specified it will be inferred from the type
- * of the object being referenced.
- */
- Class targetInterface() default void.class;
-
- /**
- * (Optional) The operations that must be cascaded to the target of
- * the association.
- */
- CascadeType[] cascade() default {};
-
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) Whether the association is optional. If set to false
- * then a non-null relationship must always exist.
- */
- boolean optional() default true;
-
- /**
- * (Optional) The discriminator column will hold the type
- * indicators. If the DiscriminatorColumn is not specified, the name
- * of the discriminator column defaults to "DTYPE" and the
- * discriminator type to STRING.
- */
- DiscriminatorColumn discriminatorColumn() default @DiscriminatorColumn;
-
- /**
- * (Optional) The list of discriminator types that can be used with
- * this VariableOneToOne. If none are specified then those entities
- * within the persistence unit that implement the target interface
- * will be added to the list of types. The discriminator type will
- * default as follows:
- * - If DiscriminatorColumn type is STRING: Entity.name()
- * - If DiscriminatorColumn type is CHAR: First letter of the
- * Entity class
- * - If DiscriminatorColumn type is INTEGER: The next integer after
- * the highest integer explicitly added.
- */
- DiscriminatorClass[] discriminatorClasses() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/>
- <xsd:element name="discriminator-class" type="orm:discriminator-class" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-interface" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="version">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Version {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="write-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- *
- * A single WriteTransformer may be specified directly on the method or
- * attribute. Multiple WriteTransformers should be wrapped into
- * WriteTransformers annotation. No WriteTransformers specified for
- * read-only mapping. Unless the TransformationMapping is write-only, it
- * should have a ReadTransformer, it defines transformation of database
- * column(s) value(s)into attribute value.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface WriteTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.FieldTransformer
- * interface. The class will be instantiated, its buildFieldValue
- * will be used to create the value to be written into the database
- * column. Note that for ddl generation and returning to be
- * supported the method buildFieldValue in the class should be
- * defined to return the relevant Java type, not just Object as
- * defined in the interface, for instance:
- * public Time buildFieldValue(Object instance, String fieldName, Session session).
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be written into the database column.
- * Note that for ddl generation and returning to be supported the
- * method should be defined to return a particular type, not just
- * Object, for instance:
- * public Time getStartTime().
- * The method may require a Transient annotation to avoid being
- * mapped as Basic by default.
- * Either transformerClass or method must be specified, but not both.
- */
- String method() default "";
-
- /**
- * Specify here the column into which the value should be written.
- * The only case when this could be skipped is if a single
- * WriteTransformer annotates an attribute - the attribute's name
- * will be used as a column name.
- */
- Column column() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
-</xsd:schema> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_0.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_0.xsd
deleted file mode 100644
index 2aa23acf3e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_0.xsd
+++ /dev/null
@@ -1,3625 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-******************************************************************************
- Copyright (c) 1998, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- which accompanies this distribution.
- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- and the Eclipse Distribution License is available at
- http://www.eclipse.org/org/documents/edl-v10.php.
-
- Contributors:
- Oracle - initial API and implementation from Oracle TopLink
- tware - update version number to 2.0
-*****************************************************************************/
--->
-
-<!-- Java Persistence API object-relational mapping file schema -->
-<xsd:schema targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:orm="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="2.0">
-
- <xsd:annotation>
- <xsd:documentation>
- @(#)eclipselink_orm_2_0.xsd 2.0 October 5 2008
- </xsd:documentation>
- </xsd:annotation>
- <xsd:annotation>
- <xsd:documentation><![CDATA[
-
- This is the XML Schema for the native Eclipselink XML mapping file
- The file may be named "META-INF/eclipselink-orm.xml" in the persistence
- archive or it may be named some other name which would be
- used to locate the file as resource on the classpath.
- Object/relational mapping files must indicate the object/relational
- mapping file schema by using the persistence namespace:
-
- http://www.eclipse.org/eclipselink/xsds/persistence/orm
-
- and indicate the version of the schema by using the version element as shown below:
-
- <entity-mappings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm
- eclipselink_orm_2_0.xsd
- version="2.0">
- ...
- </entity-mappings>
-
- ]]></xsd:documentation>
- </xsd:annotation>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="emptyType"/>
- <xsd:simpleType name="versionType">
- <xsd:restriction base="xsd:token">
- <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="access-methods">
- <xsd:annotation>
- <xsd:documentation>
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="get-method" type="xsd:string" use="required"/>
- <xsd:attribute name="set-method" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cache">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Cache annotation is used to set an
- * org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy
- * which sets objects in EclipseLink's identity maps to be invalid
- * following given rules. By default in EclipseLink, objects do not
- * expire in the cache. Several different policies are available to
- * allow objects to expire.
- *
- * @see org.eclipse.persistence.annotations.CacheType
- *
- * A Cache anotation may be defined on an Entity or MappedSuperclass.
- * In the case of inheritance, a Cache annotation should only be defined
- * on the root of the inheritance hierarchy.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Cache {
- /**
- * (Optional) The type of cache to use.
- */
- CacheType type() default SOFT_WEAK;
-
- /**
- * (Optional) The size of cache to use.
- */
- int size() default 100;
-
- /**
- * (Optional) Cached instances in the shared cache or a client
- * isolated cache.
- */
- boolean shared() default true;
-
- /**
- * (Optional) Expire cached instance after a fix period of time (ms).
- * Queries executed against the cache after this will be forced back
- * to the database for a refreshed copy
- */
- int expiry() default -1; // minus one is no expiry.
-
- /**
- * (Optional) Expire cached instance a specific time of day. Queries
- * executed against the cache after this will be forced back to the
- * database for a refreshed copy
- */
- TimeOfDay expiryTimeOfDay() default @TimeOfDay(specified=false);
-
- /**
- * (Optional) Force all queries that go to the database to always
- * refresh the cache.
- */
- boolean alwaysRefresh() default false;
-
- /**
- * (Optional) For all queries that go to the database, refresh the
- * cache only if the data received from the database by a query is
- * newer than the data in the cache (as determined by the optimistic
- * locking field)
- */
- boolean refreshOnlyIfNewer() default false;
-
- /**
- * (Optional) Setting to true will force all queries to bypass the
- * cache for hits but still resolve against the cache for identity.
- * This forces all queries to hit the database.
- */
- boolean disableHits() default false;
-
- /**
- * (Optional) The cache coordination mode.
- */
- CacheCoordinationType coordinationType() default SEND_OBJECT_CHANGES;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:choice>
- <xsd:element name="expiry" type="xsd:integer" minOccurs="0"/>
- <xsd:element name="expiry-time-of-day" type="orm:time-of-day" minOccurs="0"/>
- </xsd:choice>
- <xsd:attribute name="size" type="xsd:integer"/>
- <xsd:attribute name="shared" type="xsd:boolean"/>
- <xsd:attribute name="type" type="orm:cache-type"/>
- <xsd:attribute name="always-refresh" type="xsd:boolean"/>
- <xsd:attribute name="refresh-only-if-newer" type="xsd:boolean"/>
- <xsd:attribute name="disable-hits" type="xsd:boolean"/>
- <xsd:attribute name="coordination-type" type="orm:cache-coordination-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cache-interceptor">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface CacheInterceptor {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
- <!-- **************************************************** -->
-
-
- <xsd:simpleType name="cache-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The CacheType enum is used with the Cache annotation for a
- * persistent class. It defines the type of IdentityMap/Cache used for
- * the class. By default the SOFT_WEAK cache type is used.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheType {
- /**
- * Provides full caching and guaranteed identity. Caches all objects
- * and does not remove them.
- * WARNING: This method may be memory intensive when many objects are
- * read.
- */
- FULL,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using weak references. This method allows full garbage
- * collection and provides full caching and guaranteed identity.
- */
- WEAK,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using soft references. This method allows full garbage
- * collection when memory is low and provides full caching and
- * guaranteed identity.
- */
- SOFT,
-
- /**
- * Similar to the WEAK identity map except that it maintains a
- * most-frequently-used sub-cache. The size of the sub-cache is
- * proportional to the size of the identity map as specified by
- * descriptor's setIdentityMapSize() method. The sub-cache
- * uses soft references to ensure that these objects are
- * garbage-collected only if the system is low on memory.
- */
- SOFT_WEAK,
-
- /**
- * Identical to the soft cache weak (SOFT_WEAK) identity map except
- * that it uses hard references in the sub-cache. Use this identity
- * map if soft references do not behave properly on your platform.
- */
- HARD_WEAK,
-
- /**
- * A cache identity map maintains a fixed number of objects
- * specified by the application. Objects are removed from the cache
- * on a least-recently-used basis. This method allows object
- * identity for the most commonly used objects.
- * WARNING: Furnishes caching and identity, but does not guarantee
- * identity.
- */
- CACHE,
-
- /**
- * WARNING: Does not preserve object identity and does not cache
- * objects.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="FULL"/>
- <xsd:enumeration value="WEAK"/>
- <xsd:enumeration value="SOFT"/>
- <xsd:enumeration value="SOFT_WEAK"/>
- <xsd:enumeration value="HARD_WEAK"/>
- <xsd:enumeration value="CACHE"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-coordination-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the Cache annotation.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheCoordinationType {
- /**
- * Sends a list of changed objects including data about the changes.
- * This data is merged into the receiving cache.
- */
- SEND_OBJECT_CHANGES,
-
- /**
- * Sends a list of the identities of the objects that have changed.
- * The receiving cache invalidates the objects (rather than changing
- * any of the data)
- */
- INVALIDATE_CHANGED_OBJECTS,
-
- /**
- * Same as SEND_OBJECT_CHANGES except it also includes any newly
- * created objects from the transaction.
- */
- SEND_NEW_OBJECTS_WITH_CHANGES,
-
- /**
- * Does no cache coordination.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SEND_OBJECT_CHANGES"/>
- <xsd:enumeration value="INVALIDATE_CHANGED_OBJECTS"/>
- <xsd:enumeration value="SEND_NEW_OBJECTS_WITH_CHANGES"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="change-tracking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The ChangeTracking annotation is used to specify the
- * org.eclipse.persistence.descriptors.changetracking.ObjectChangePolicy
- * which computes changes sets for EclipseLink's UnitOfWork commit
- * process. An ObjectChangePolicy is stored on an Entity's descriptor.
- *
- * A ChangeTracking annotation may be specified on an Entity,
- * MappedSuperclass or Embeddable.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface ChangeTracking {
- /**
- * (Optional) The type of change tracking to use.
- */
- ChangeTrackingType value() default AUTO;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="type" type="orm:change-tracking-type" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="change-tracking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the ChangeTracking annotation.
- */
- public enum ChangeTrackingType {
- /**
- * An ATTRIBUTE change tracking type allows change tracking at the
- * attribute level of an object. Objects with changed attributes will
- * be processed in the commit process to include any changes in the
- * results of the commit. Unchanged objects will be ignored.
- */
- ATTRIBUTE,
-
- /**
- * An OBJECT change tracking policy allows an object to calculate for
- * itself whether it has changed. Changed objects will be processed in
- * the commit process to include any changes in the results of the
- * commit. Unchanged objects will be ignored.
- */
- OBJECT,
-
- /**
- * A DEFERRED change tracking policy defers all change detection to
- * the UnitOfWork's change detection process. Essentially, the
- * calculateChanges() method will run for all objects in a UnitOfWork.
- * This is the default ObjectChangePolicy
- */
- DEFERRED,
-
- /**
- * Will not set any change tracking policy.
- */
- AUTO
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ATTRIBUTE"/>
- <xsd:enumeration value="OBJECT"/>
- <xsd:enumeration value="DEFERRED"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="customizer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Customizer annotation is used to specify a class that implements
- * the org.eclipse.persistence.config.DescriptorCustomizer
- * interface and is to run against an enetity's class descriptor after all
- * metadata processing has been completed.
- *
- * The Customizer annotation may be defined on an Entity, MappedSuperclass
- * or Embeddable class. In the case of inheritance, a Customizer is not
- * inherited from its parent classes.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Customizer {
- /**
- * (Required) Defines the name of the descriptor customizer class that
- * should be applied for the related entity or embeddable class.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="direction-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the StoredProcedureParameter annotation.
- * It is used to specify the direction of the stored procedure
- * parameters of a named stored procedure query.
- */
- public enum Direction {
- /**
- * Input parameter
- */
- IN,
-
- /**
- * Output parameter
- */
- OUT,
-
- /**
- * Input and output parameter
- */
- IN_OUT,
-
- /**
- * Output cursor
- */
- OUT_CURSOR
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="IN"/>
- <xsd:enumeration value="OUT"/>
- <xsd:enumeration value="IN_OUT"/>
- <xsd:enumeration value="OUT_CURSOR"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:element name="entity-mappings">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
-
- The entity-mappings element is the root element of an mapping
- file. It contains the following four types of elements:
-
- 1. The persistence-unit-metadata element contains metadata
- for the entire persistence unit. It is undefined if this element
- occurs in multiple mapping files within the same persistence unit.
-
- 2. The package, schema, catalog and access elements apply to all of
- the entity, mapped-superclass and embeddable elements defined in
- the same file in which they occur.
-
- 3. The sequence-generator, table-generator, named-query,
- named-native-query and sql-result-set-mapping elements are global
- to the persistence unit. It is undefined to have more than one
- sequence-generator or table-generator of the same name in the same
- or different mapping files in a persistence unit. It is also
- undefined to have more than one named-query, named-native-query, or
- result-set-mapping of the same name in the same or different mapping
- files in a persistence unit.
-
- 4. The entity, mapped-superclass and embeddable elements each define
- the mapping information for a managed persistent class. The mapping
- information contained in these elements may be complete or it may
- be partial.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="persistence-unit-metadata" type="orm:persistence-unit-metadata" minOccurs="0"/>
- <xsd:element name="package" type="xsd:string" minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string" minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string" minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-query" type="orm:named-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping" type="orm:sql-result-set-mapping" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="mapped-superclass" type="orm:mapped-superclass" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="entity" type="orm:entity" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embeddable" type="orm:embeddable" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="version" type="orm:versionType" fixed="2.0" use="required"/>
- </xsd:complexType>
- </xsd:element>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="existence-type">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * The ExistenceChecking annotation is used to specify the type of
- * checking EclipseLink should use when updating entities.
- *
- * An existence-checking specification is supported on an Entity or
- * MappedSuperclass annotation.
- */
- public @interface ExistenceChecking {
-
- /**
- * (Optional) Set the existence check for determining
- * if an insert or update should occur for an object.
- */
- ExistenceType value() default CHECK_CACHE;
- }
-
- /**
- * Assume that if the objects primary key does not include null and
- * it is in the cache, then it must exist.
- */
- CHECK_CACHE,
-
- /**
- * Perform does exist check on the database.
- */
- CHECK_DATABASE,
-
- /**
- * Assume that if the objects primary key does not include null then
- * it must exist. This may be used if the application guarantees or
- * does not care about the existence check.
- */
- ASSUME_EXISTENCE,
-
- /**
- * Assume that the object does not exist. This may be used if the
- * application guarantees or does not care about the existence check.
- * This will always force an insert to be called.
- */
- ASSUME_NON_EXISTENCE
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="CHECK_CACHE"/>
- <xsd:enumeration value="CHECK_DATABASE"/>
- <xsd:enumeration value="ASSUME_EXISTENCE"/>
- <xsd:enumeration value="ASSUME_NON_EXISTENCE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-metadata">
- <xsd:annotation>
- <xsd:documentation>
-
- Metadata that applies to the persistence unit and not just to
- the mapping file in which it is contained.
-
- If the xml-mapping-metadata-complete element is specified,
- the complete set of mapping metadata for the persistence unit
- is contained in the XML mapping files for the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="xml-mapping-metadata-complete" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="exclude-default-mappings" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="persistence-unit-defaults" type="orm:persistence-unit-defaults" minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-defaults">
- <xsd:annotation>
- <xsd:documentation>
-
- These defaults are applied to the persistence unit as a whole
- unless they are overridden by local annotation or XML
- element settings.
-
- schema - Used as the schema for all tables, secondary tables,
- collection tables, sequence generators, and table generators
- that apply to the persistence unit
- catalog - Used as the catalog for all tables, secondary tables,
- collection tables, sequence generators, and table generators
- that apply to the persistence unit
- access - Used as the access type for all managed classes in
- the persistence unit
- cascade-persist - Adds cascade-persist to the set of cascade options
- in all entity relationships of the persistence unit
- entity-listeners - List of default entity listeners to be invoked
- on each entity in the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string" minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string" minOccurs="0"/>
- <xsd:element name="delimited-identifiers" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type" minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners" minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for an entity. Is allowed to be
- sparsely populated and used in conjunction with the annotations.
- Alternatively, the metadata-complete attribute can be used to
- indicate that no annotations on the entity class (and its fields
- or properties) are to be processed. If this is the case then
- the defaulting rules for the entity and its sub-elements will
- be recursively applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface Entity {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="table" type="orm:table" minOccurs="0"/>
- <xsd:element name="secondary-table" type="orm:secondary-table" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="inheritance" type="orm:inheritance" minOccurs="0"/>
- <xsd:element name="discriminator-value" type="orm:discriminator-value" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking" minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="cache-interceptor" type="orm:cache-interceptor" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="named-query" type="orm:named-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping" type="orm:sql-result-set-mapping" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="query-redirectors" type="orm:query-redirectors" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners" minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist" minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="cacheable" type="xsd:boolean"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="access-type">
- <xsd:annotation>
- <xsd:documentation>
-
- This element determines how the persistence provider accesses the
- state of an entity or embedded object.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="PROPERTY"/>
- <xsd:enumeration value="FIELD"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="association-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AssociationOverride {
- String name();
- JoinColumn[] joinColumns() default{};
- JoinTable joinTable() default @JoinTable;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="attribute-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AttributeOverride {
- String name();
- Column column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="attributes">
- <xsd:annotation>
- <xsd:documentation>
-
- This element contains the entity field or property mappings.
- It may be sparsely populated to include only a subset of the
- fields or properties. If metadata-complete for the entity is true
- then the remainder of the attributes will be defaulted according
- to the default rules.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="id" type="orm:id" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded-id" type="orm:embedded-id" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="basic" type="orm:basic" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-collection" type="orm:basic-collection" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-map" type="orm:basic-map" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="version" type="orm:version" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-one" type="orm:many-to-one" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-many" type="orm:one-to-many" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-one" type="orm:one-to-one" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="variable-one-to-one" type="orm:variable-one-to-one" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-many" type="orm:many-to-many" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="element-collection" type="orm:element-collection" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded" type="orm:embedded" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transformation" type="orm:transformation" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transient" type="orm:transient" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Basic {
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="lob" type="orm:lob"/>
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="enumerated" type="orm:enumerated"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicCollection {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the value column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:eclipselink-collection-table" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-map">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicMap {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the data column that holds the direct map
- * key. If the name on te key column is "", the name will default to:
- * the name of the property or field; "_KEY".
- */
- Column keyColumn() default @Column;
-
- /**
- * (Optional) Specify the key converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the direct map key.
- */
- Convert keyConverter() default @Convert;
-
- /**
- * (Optional) The name of the data column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
-
- /**
- * (Optional) Specify the value converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the value column mapping.
- */
- Convert valueConverter() default @Convert;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="key-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="key-converter" type="xsd:string" minOccurs="0"/>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="value-converter" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:eclipselink-collection-table" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cascade-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REFRESH};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade-all" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="cascade-merge" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="cascade-remove" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="cascade-refresh" type="orm:emptyType" minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="clone-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CloneCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.CloneCopyPolicy on an
- * Entity. A CloneCopyPolicy must specify at one or both of the "method"
- * or "workingCopyMethod". "workingCopyMethod" is used to clone objects
- * that will be returned to the user as they are registered in
- * EclipseLink's transactional mechanism, the UnitOfWork. "method" will
- * be used for the clone that is used for comparison in conjunction with
- * EclipseLink's DeferredChangeDetectionPolicy
- *
- * A CloneCopyPolicy should be specified on an Entity, MappedSuperclass
- * or Embeddable.
- *
- * Example:
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod", workingCopyMethod="myWorkingCopyCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(workingCopyMethodName="myWorkingCopyClone")
- */
- public @interface CloneCopyPolicy {
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified this defines
- * a method that will be used to create a clone that will be used
- * for comparison by
- * EclipseLink's DeferredChangeDetectionPolicy
- */
- String method();
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified
- * this defines a method that will be used to create a clone that
- * will be used to create the object returned when registering an
- * Object in an EclipseLink UnitOfWork
- */
- String workingCopyMethod();
-
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method" type="xsd:string"/>
- <xsd:attribute name="working-copy-method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface CollectionTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="eclipselink-collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface CollectionTable {
- /**
- * (Optional) The name of the collection table. If it is not
- * specified, it is defaulted to the concatenation of the following:
- * the name of the source entity; "_" ; the name of the relationship
- * property or field of the source entity.
- */
- String name() default "";
-
- /**
- * (Optional) The catalog of the table. It defaults to the persistence
- * unit default catalog.
- */
- String catalog() default "";
-
- /**
- * (Optional) The schema of the table. It defaults to the persistence
- * unit default schema.
- */
- String schema() default "";
-
- /**
- * (Optional) Used to specify a primary key column that is used as a
- * foreign key to join to another table. If the source entity uses a
- * composite primary key, a primary key join column must be specified
- * for each field of the composite primary key. In a single primary
- * key case, a primary key join column may optionally be specified.
- * Defaulting will apply otherwise as follows:
- * name, the same name as the primary key column of the primary table
- * of the source entity. referencedColumnName, the same name of
- * primary key column of the primary table of the source entity.
- */
- PrimaryKeyJoinColumn[] primaryKeyJoinColumns() default {};
-
- /**
- * (Optional) Unique constraints that are to be placed on the table.
- * These are only used if table generation is in effect.
- */
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Column {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="conversion-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface ConversionValue {
- /**
- * (Required) Specify the database value.
- */
- String dataValue();
-
- /**
- * (Required) Specify the object value.
- */
- String objectValue();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="data-value" type="xsd:string" use="required"/>
- <xsd:attribute name="object-value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Converter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must implement
- * the org.eclipse.persistence.mappings.converters.Converter interface.
- */
- Class converterClass();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface ColumnResult {
- String name();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CopyPolicy is used to set a
- * org.eclipse.persistence.descriptors.copying.CopyPolicy on an Entity.
- * It is required that a class that implements
- * org.eclipse.persistence.descriptors.copying.CopyPolicy be specified
- * as the argument.
- *
- * A CopyPolicy should be specified on an Entity, MappedSuperclass or
- * Embeddable.
- *
- * For instance:
- * @Entity
- * @CopyPolicy("example.MyCopyPolicy")
- */
- public @interface CopyPolicy {
-
- /*
- * (Required)
- * This defines the class of the copy policy. It must specify a class
- * that implements org.eclipse.persistence.descriptors.copying.CopyPolicy
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorColumn {
- String name() default "DTYPE";
- DiscriminatorType discriminatorType() default STRING;
- String columnDefinition() default "";
- int length() default 31;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="discriminator-type" type="orm:discriminator-type"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-class">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A DiscriminatorClass is used within a VariableOneToOne annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface DiscriminatorClass {
- /**
- * (Required) The discriminator to be stored on the database.
- */
- String discriminator();
-
- /**
- * (Required) The class to the instantiated with the given
- * discriminator.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="discriminator" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum DiscriminatorType { STRING, CHAR, INTEGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="STRING"/>
- <xsd:enumeration value="CHAR"/>
- <xsd:enumeration value="INTEGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorValue {
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="element-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ElementCollection {
- Class targetClass() default void.class;
- FetchType fetch() default LAZY;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by" minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column" minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key" minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal" type="orm:temporal" minOccurs="0"/>
- <xsd:element name="map-key-enumerated" type="orm:enumerated" minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column" minOccurs="0"/>
- <xsd:element name="map-key-join-column" type="orm:map-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="temporal" type="orm:temporal" minOccurs="0"/>
- <xsd:element name="enumerated" type="orm:enumerated" minOccurs="0"/>
- <xsd:element name="lob" type="orm:lob" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- </xsd:sequence>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:collection-table" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-class" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embeddable">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for embeddable objects. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- in the class. If this is the case then the defaulting rules will
- be recursively applied.
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Embeddable {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Embedded {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded-id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface EmbeddedId {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-listener">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines an entity listener to be invoked at lifecycle events
- for the entities that list this listener.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist" minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-listeners">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface EntityListeners {
- Class[] value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="entity-listener" type="orm:entity-listener" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface EntityResult {
- Class entityClass();
- FieldResult[] fields() default {};
- String discriminatorColumn() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field-result" type="orm:field-result" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="entity-class" type="xsd:string" use="required"/>
- <xsd:attribute name="discriminator-column" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="enum-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum EnumType {
- ORDINAL,
- STRING
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ORDINAL"/>
- <xsd:enumeration value="STRING"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="enumerated">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Enumerated {
- EnumType value() default ORDINAL;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:enum-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum FetchType { LAZY, EAGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="LAZY"/>
- <xsd:enumeration value="EAGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="field-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface FieldResult {
- String name();
- String column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="column" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="generated-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface GeneratedValue {
- GenerationType strategy() default AUTO;
- String generator() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:generation-type"/>
- <xsd:attribute name="generator" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="generation-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="TABLE"/>
- <xsd:enumeration value="SEQUENCE"/>
- <xsd:enumeration value="IDENTITY"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Id {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="id-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface IdClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="id-validation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The IdValidation enum determines the type value that are valid for an Id.
- * By default null is not allowed, and 0 is not allow for singleton ids of long or int type.
- * The default value is ZERO for singleton ids, and NULL for composite ids.
- * This can be set using the @PrimaryKey annotation, or ClassDescriptor API.
- *
- * @see PrimaryKey
- * @see org.eclipse.persistence.descriptors.ClassDescriptor#setIdValidation(IdValidation)
- * @author James Sutherland
- * @since EclipseLink 1.0
- */
- public enum IdValidation {
- /**
- * Only null is not allowed as an id value, 0 is allowed.
- */
- NULL,
-
- /**
- * null and 0 are not allowed, (only int and long).
- */
- ZERO,
-
- /**
- * No id validation is done.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="NULL"/>
- <xsd:enumeration value="ZERO"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="inheritance">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Inheritance {
- InheritanceType strategy() default SINGLE_TABLE;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:inheritance-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="inheritance-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum InheritanceType { SINGLE_TABLE, JOINED, TABLE_PER_CLASS };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SINGLE_TABLE"/>
- <xsd:enumeration value="JOINED"/>
- <xsd:enumeration value="TABLE_PER_CLASS"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="instantiation-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * An InstantiationCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.InstantiationCopyPolicy
- * on an Entity. InstantiationCopyPolicy is the default CopyPolicy in
- * EclipseLink and therefore this configuration option is only used to
- * override other types of copy policies
- *
- * An InstantiationCopyPolicy should be specified on an Entity,
- * MappedSuperclass or Embeddable.
- *
- * Example:
- * @Entity
- * @InstantiationCopyPolicy
- */
- public @interface InstantiationCopyPolicy {
- }
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum JoinFetchType {
- /**
- * An inner join is used to fetch the related object.
- * This does not allow for null/empty values.
- */
- INNER,
-
- /**
- * An inner join is used to fetch the related object.
- * This allows for null/empty values.
- */
- OUTER,
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="INNER"/>
- <xsd:enumeration value="OUTER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- JoinColumn[] inverseJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="inverse-join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="lob">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Lob {}
-
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="lock-mode-type">
- <xsd:annotation>
- <xsd:documentation>
- public enum LockModeType { READ, WRITE, OPTIMISTIC,
- OPTIMISTIC_FORCE_INCREMENT, PESSIMISTIC_READ, PESSIMISTIC_WRITE,
- PESSIMISTIC_FORCE_INCREMENT, NONE};
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="READ"/>
- <xsd:enumeration value="WRITE"/>
- <xsd:enumeration value="OPTIMISTIC"/>
- <xsd:enumeration value="OPTIMISTIC_FORCE_INCREMENT"/>
- <xsd:enumeration value="PESSIMISTIC_READ"/>
- <xsd:enumeration value="PESSIMISTIC_WRITE"/>
- <xsd:enumeration value="PESSIMISTIC_FORCE_INCREMENT"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="many-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by" minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column" minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key" minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal" type="orm:temporal" minOccurs="0"/>
- <xsd:element name="map-key-enumerated" type="orm:enumerated" minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column" minOccurs="0"/>
- <xsd:element name="map-key-join-column" type="orm:map-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="many-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="maps-id" type="xsd:string"/>
- <xsd:attribute name="id" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKey {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyColumn {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default false;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default false;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="mapped-superclass">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for a mapped superclass. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- If this is the case then the defaulting rules will be recursively
- applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface MappedSuperclass{}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking" minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="cache-interceptor" type="orm:cache-interceptor" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners" minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist" minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="cacheable" type="xsd:boolean"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-native-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedNativeQuery {
- String name();
- String query();
- QueryHint[] hints() default {};
- Class resultClass() default void.class;
- String resultSetMapping() default ""; //named SqlResultSetMapping
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedQuery {
- String name();
- String query();
- QueryHint[] hints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="lock-mode" type="orm:lock-mode-type" minOccurs="0"/>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-stored-procedure-query">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A NamedStoredProcedureQuery annotation allows the definition of
- * queries that call stored procedures as named queries.
- * A NamedStoredProcedureQuery annotation may be defined on an Entity or
- * MappedSuperclass.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface NamedStoredProcedureQuery {
- /**
- * (Required) Unique name that references this stored procedure query.
- */
- String name();
-
- /**
- * (Optional) Query hints.
- */
- QueryHint[] hints() default {};
-
- /**
- * (Optional) Refers to the class of the result.
- */
- Class resultClass() default void.class;
-
- /**
- * (Optional) The name of the SQLResultMapping.
- */
- String resultSetMapping() default "";
-
- /**
- * (Required) The name of the stored procedure.
- */
- String procedureName();
-
- /**
- * (Optional) Whether the query should return a result set.
- */
- boolean returnsResultSet() default true;
-
- /**
- * (Optional) Defines arguments to the stored procedure.
- */
- StoredProcedureParameter[] parameters() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="parameter" type="orm:stored-procedure-parameter" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- <xsd:attribute name="procedure-name" type="xsd:string" use="required"/>
- <xsd:attribute name="returns-result-set" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="object-type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ObjectTypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence
- * field or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent
- * field or property.
- */
- Class objectType() default void.class;
-
- /**
- * (Required) Specify the conversion values to be used
- * with the object converter.
- */
- ConversionValue[] conversionValues();
-
- /**
- * (Optional) Specify a default object value. Used for
- * legacy data if the data value is missing.
- */
- String defaultObjectValue() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="conversion-value" type="orm:conversion-value" minOccurs="1" maxOccurs="unbounded"/>
- <xsd:element name="default-object-value" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="one-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by" minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column" minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key" minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal" type="orm:temporal" minOccurs="0"/>
- <xsd:element name="map-key-enumerated" type="orm:enumerated" minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column" minOccurs="0"/>
- <xsd:element name="map-key-join-column" type="orm:map-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="one-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- String mappedBy() default "";
- boolean orphanRemoval() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- <xsd:attribute name="maps-id" type="xsd:string"/>
- <xsd:attribute name="id" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="optimistic-locking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An optimistic-locking element is used to specify the type of
- * optimistic locking EclipseLink should use when updating or deleting
- * entities. An optimistic-locking specification is supported on
- * an entity or mapped-superclass.
- *
- * It is used in conjunction with the optimistic-locking-type.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface OptimisticLocking {
- /**
- * (Optional) The type of optimistic locking policy to use.
- */
- OptimisticLockingType type() default VERSION_COLUMN;
-
- /**
- * (Optional) For an optimistic locking policy of type
- * SELECTED_COLUMNS, this annotation member becomes a (Required)
- * field.
- */
- Column[] selectedColumns() default {};
-
- /**
- * (Optional) Specify where the optimistic locking policy should
- * cascade lock. Currently only supported with VERSION_COLUMN locking.
- */
- boolean cascade() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="selected-column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="type" type="orm:optimistic-locking-type"/>
- <xsd:attribute name="cascade" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="optimistic-locking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A simple type that is used within an optimistic-locking
- * specification to specify the type of optimistic-locking that
- * EclipseLink should use when updating or deleting entities.
- */
- public enum OptimisticLockingType {
- /**
- * Using this type of locking policy compares every field in the table
- * in the WHERE clause when doing an update or a delete. If any field
- * has been changed, an optimistic locking exception will be thrown.
- */
- ALL_COLUMNS,
-
- /**
- * Using this type of locking policy compares only the changed fields
- * in the WHERE clause when doing an update. If any field has been
- * changed, an optimistic locking exception will be thrown. A delete
- * will only compare the primary key.
- */
- CHANGED_COLUMNS,
-
- /**
- * Using this type of locking compares selected fields in the WHERE
- * clause when doing an update or a delete. If any field has been
- * changed, an optimistic locking exception will be thrown. Note that
- * the fields specified must be mapped and not be primary keys.
- */
- SELECTED_COLUMNS,
-
- /**
- * Using this type of locking policy compares a single version number
- * in the where clause when doing an update. The version field must be
- * mapped and not be the primary key.
- */
- VERSION_COLUMN
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ALL_COLUMNS"/>
- <xsd:enumeration value="CHANGED_COLUMNS"/>
- <xsd:enumeration value="SELECTED_COLUMNS"/>
- <xsd:enumeration value="VERSION_COLUMN"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-by">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderBy {
- String value() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="order-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderColumn {
- String name() default "";
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="correction-type" type="orm:order-column-correction-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-column-correction-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum OrderCorrectionType {
- READ,
- READ_WRITE,
- EXCEPTION
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="READ"/>
- <xsd:enumeration value="READ_WRITE"/>
- <xsd:enumeration value="EXCEPTION"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-load">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostLoad {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostPersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PrePersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="primary-key">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The PrimaryKey annotation allows advanced configuration of the Id.
- * A validation policy can be given that allows specifying if zero is a valid id value.
- * The set of primary key columns can also be specified precisely.
- *
- * @author James Sutherland
- * @since EclipseLink 1.1
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface PrimaryKey {
- /**
- * (Optional) Configures what id validation is done.
- * By default 0 is not a valid id value, this can be used to allow 0 id values.
- */
- IdValidation validation() default IdValidation.ZERO;
-
- /**
- * (Optional) Used to specify the primary key columns directly.
- * This can be used instead of @Id if the primary key includes a non basic field,
- * such as a foreign key, or a inheritance discriminator, embedded, or transformation mapped field.
- */
- Column[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="validation" type="orm:id-validation"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="primary-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface PrimaryKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="property">
- <xsd:annotation>
- <xsd:documentation>
-
- A user defined mapping's property.
- @Target({METHOD, FIELD, TYPE})
- @Retention(RUNTIME)
- public @interface Property {
- /**
- * Property name.
- */
- String name();
-
- /**
- * String representation of Property value,
- * converted to an instance of valueType.
- */
- String value();
-
- /**
- * Property value type.
- * The value converted to valueType by ConversionManager.
- * If specified must be a simple type that could be handled by
- * ConversionManager:
- * numerical, boolean, temporal.
- */
- Class valueType() default String.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- <xsd:attribute name="value-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="query-hint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface QueryHint {
- String name();
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="query-redirectors">
- <xsd:annotation>
- <xsd:documentation>
-
-@Target({TYPE}) @Retention(RUNTIME)
-public @interface QueryRedirectors {
-
- /**
- * This AllQueries Query Redirector will be applied to any executing object query
- * that does not have a more precise redirector (like the
- * ReadObjectQuery Redirector) or a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- *
- */
- Class allQueries() default void.class;
-
- /**
- * A Default ReadAll Query Redirector will be applied to any executing
- * ReadAllQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query through the getResultList() API this is the redirector that will be invoked
- */
- Class readAll() default void.class;
-
- /**
- * A Default ReadObject Query Redirector will be applied to any executing
- * ReadObjectQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query through the getSingleResult() API or EntityManager.find() this is the redirector that will be invoked
- */
- Class readObject() default void.class;
-
- /**
- * A Default ReportQuery Redirector will be applied to any executing
- * ReportQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query that contains agregate functions or selects multiple entities this is the redirector that will be invoked
- */
- Class report() default void.class;
-
- /**
- * A Default Update Query Redirector will be applied to any executing
- * UpdateObjectQuery or UpdateAllQuery that does not have a redirector set directly on the query.
- * In EclipseLink an UpdateObjectQuery is executed whenever flushing changes to the datasource.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class update() default void.class;
-
- /**
- * A Default Insert Query Redirector will be applied to any executing
- * InsertObjectQuery that does not have a redirector set directly on the query.
- * In EclipseLink an InsertObjectQuery is executed when persisting an object to the datasource.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class insert() default void.class;
-
- /**
- * A Default Delete Object Query Redirector will be applied to any executing
- * DeleteObjectQuery or DeleteAllQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class delete() default void.class;
-
-}
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="all-queries" type="xsd:string"/>
- <xsd:attribute name="read-all" type="xsd:string"/>
- <xsd:attribute name="read-object" type="xsd:string"/>
- <xsd:attribute name="report" type="xsd:string"/>
- <xsd:attribute name="update" type="xsd:string"/>
- <xsd:attribute name="insert" type="xsd:string"/>
- <xsd:attribute name="delete" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="read-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * Unless the TransformationMapping is write-only, it should have a
- * ReadTransformer, it defines transformation of database column(s)
- * value(s)into attribute value.
- *
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReadTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.AttributeTransformer
- * interface. The class will be instantiated, its
- * buildAttributeValue will be used to create the value to be
- * assigned to the attribute.
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be assigned to the attribute (not assigns the value to
- * the attribute). Either transformerClass or method must be
- * specified, but not both.
- */
- String method() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="secondary-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SecondaryTable {
- String name();
- String catalog() default "";
- String schema() default "";
- PrimaryKeyJoinColumn[] pkJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="sequence-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface SequenceGenerator {
- String name();
- String sequenceName() default "";
- String catalog() default "";
- String schema() default "";
- int initialValue() default 1;
- int allocationSize() default 50;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="sequence-name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="sql-result-set-mapping">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SqlResultSetMapping {
- String name();
- EntityResult[] entities() default {};
- ColumnResult[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="entity-result" type="orm:entity-result" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="column-result" type="orm:column-result" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="stored-procedure-parameter">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A StoredProcedureParameter annotation is used within a
- * NamedStoredProcedureQuery annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface StoredProcedureParameter {
- /**
- * (Optional) The direction of the stored procedure parameter.
- */
- Direction direction() default IN;
-
- /**
- * (Optional) Stored procedure parameter name.
- */
- String name() default "";
-
- /**
- * (Required) The query parameter name.
- */
- String queryParameter();
-
- /**
- * (Optional) The type of Java class desired back from the procedure,
- * this is dependent on the type returned from the procedure.
- */
- Class type() default void.class;
-
- /**
- * (Optional) The JDBC type code, this dependent on the type returned
- * from the procedure.
- */
- int jdbcType() default -1;
-
- /**
- * (Optional) The JDBC type name, this may be required for ARRAY or
- * STRUCT types.
- */
- String jdbcTypeName() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="direction" type="orm:direction-type"/>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="query-parameter" type="xsd:string" use="required"/>
- <xsd:attribute name="type" type="xsd:string"/>
- <xsd:attribute name="jdbc-type" type="xsd:integer"/>
- <xsd:attribute name="jdbc-type-name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="struct-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface StructConverter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must
- * implement the EclipseLink interface
- * org.eclipse.persistence.mappings.converters.Converter
- */
- String converter();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="converter" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Table {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface TableGenerator {
- String name();
- String table() default "";
- String catalog() default "";
- String schema() default "";
- String pkColumnName() default "";
- String valueColumnName() default "";
- String pkColumnValue() default "";
- int initialValue() default 0;
- int allocationSize() default 50;
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="pk-column-name" type="xsd:string"/>
- <xsd:attribute name="value-column-name" type="xsd:string"/>
- <xsd:attribute name="pk-column-value" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Temporal {
- TemporalType value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:temporal-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum TemporalType {
- DATE, // java.sql.Date
- TIME, // java.sql.Time
- TIMESTAMP // java.sql.Timestamp
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="DATE"/>
- <xsd:enumeration value="TIME"/>
- <xsd:enumeration value="TIMESTAMP"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="time-of-day">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface TimeOfDay {
- /**
- * (Optional) Hour of the day.
- */
- int hour() default 0;
-
- /**
- * (Optional) Minute of the day.
- */
- int minute() default 0;
-
- /**
- * (Optional) Second of the day.
- */
- int second() default 0;
-
- /**
- * (Optional) Millisecond of the day.
- */
- int millisecond() default 0;
-
- /**
- * Internal use. Do not modify.
- */
- boolean specified() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="hour" type="xsd:integer"/>
- <xsd:attribute name="minute" type="xsd:integer"/>
- <xsd:attribute name="second" type="xsd:integer"/>
- <xsd:attribute name="millisecond" type="xsd:integer"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="transformation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Transformation is an optional annotation for
- * org.eclipse.persistence.mappings.TransformationMapping.
- * TransformationMapping allows to map an attribute to one or more
- * database columns.
- *
- * Transformation annotation is an optional part of
- * TransformationMapping definition. Unless the TransformationMapping is
- * write-only, it should have a ReadTransformer, it defines
- * transformation of database column(s) value(s)into attribute value.
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Transformation {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) The optional element is a hint as to whether the value
- * of the field or property may be null. It is disregarded
- * for primitive types, which are considered non-optional.
- */
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="read-transformer" type="orm:read-transformer"/>
- <xsd:element name="write-transformer" type="orm:write-transformer" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access" type="orm:access-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="transient">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Transient {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface TypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence field
- * or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent field
- * or property.
- */
- Class objectType() default void.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="unique-constraint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface UniqueConstraint {
- String name() default "";
- String[] columnNames();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column-name" type="xsd:string" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="variable-one-to-one">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * Variable one to one mappings are used to represent a pointer
- * references between a java object and an implementer of an interface.
- * This mapping is usually represented by a single pointer (stored in an
- * instance variable) between the source and target objects. In the
- * relational database tables, these mappings are normally implemented
- * using a foreign key and a type code.
- *
- * A VariableOneToOne can be specified within an Entity,
- * MappedSuperclass and Embeddable class.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface VariableOneToOne {
- /**
- * (Optional) The interface class that is the target of the
- * association. If not specified it will be inferred from the type
- * of the object being referenced.
- */
- Class targetInterface() default void.class;
-
- /**
- * (Optional) The operations that must be cascaded to the target of
- * the association.
- */
- CascadeType[] cascade() default {};
-
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) Whether the association is optional. If set to false
- * then a non-null relationship must always exist.
- */
- boolean optional() default true;
-
- /**
- * (Optional) The discriminator column will hold the type
- * indicators. If the DiscriminatorColumn is not specified, the name
- * of the discriminator column defaults to "DTYPE" and the
- * discriminator type to STRING.
- */
- DiscriminatorColumn discriminatorColumn() default @DiscriminatorColumn;
-
- /**
- * (Optional) The list of discriminator types that can be used with
- * this VariableOneToOne. If none are specified then those entities
- * within the persistence unit that implement the target interface
- * will be added to the list of types. The discriminator type will
- * default as follows:
- * - If DiscriminatorColumn type is STRING: Entity.name()
- * - If DiscriminatorColumn type is CHAR: First letter of the
- * Entity class
- * - If DiscriminatorColumn type is INTEGER: The next integer after
- * the highest integer explicitly added.
- */
- DiscriminatorClass[] discriminatorClasses() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/>
- <xsd:element name="discriminator-class" type="orm:discriminator-class" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-interface" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="version">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Version {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="write-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- *
- * A single WriteTransformer may be specified directly on the method or
- * attribute. Multiple WriteTransformers should be wrapped into
- * WriteTransformers annotation. No WriteTransformers specified for
- * read-only mapping. Unless the TransformationMapping is write-only, it
- * should have a ReadTransformer, it defines transformation of database
- * column(s) value(s)into attribute value.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface WriteTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.FieldTransformer
- * interface. The class will be instantiated, its buildFieldValue
- * will be used to create the value to be written into the database
- * column. Note that for ddl generation and returning to be
- * supported the method buildFieldValue in the class should be
- * defined to return the relevant Java type, not just Object as
- * defined in the interface, for instance:
- * public Time buildFieldValue(Object instance, String fieldName, Session session).
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be written into the database column.
- * Note that for ddl generation and returning to be supported the
- * method should be defined to return a particular type, not just
- * Object, for instance:
- * public Time getStartTime().
- * The method may require a Transient annotation to avoid being
- * mapped as Basic by default.
- * Either transformerClass or method must be specified, but not both.
- */
- String method() default "";
-
- /**
- * Specify here the column into which the value should be written.
- * The only case when this could be skipped is if a single
- * WriteTransformer annotates an attribute - the attribute's name
- * will be used as a column name.
- */
- Column column() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
-</xsd:schema>
-
-
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_1.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_1.xsd
deleted file mode 100644
index 5e3ce57249..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_1.xsd
+++ /dev/null
@@ -1,4108 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ************************************************************************************************************************** -->
-<!-- Copyright (c) 1998, 2010 Oracle. All rights reserved. -->
-<!-- This program and the accompanying materials are made available under the -->
-<!-- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 -->
-<!-- which accompanies this distribution. -->
-<!-- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html -->
-<!-- and the Eclipse Distribution License is available at -->
-<!-- http://www.eclipse.org/org/documents/edl-v10.php. -->
-<!-- -->
-<!-- Contributors: -->
-<!-- Oracle - initial API and implementation from Oracle TopLink -->
-<!-- tware - update version number to 2.0 -->
-<!-- 12/2/2009-2.1 Guy Pelletier -->
-<!-- - 296289: Add current annotation metadata support on mapped superclasses to EclipseLink-ORM.XML Schema -->
-<!-- - 296612: Add current annotation only metadata support of return insert/update to the EclipseLink-ORM.XML Schema -->
-<!-- - formatted to match orm_2_0.xsd so that users can easily compare the two schemas -->
-<!-- 5/4/2010-2.1 Guy Pelletier -->
-<!-- - 227219: Expand EclipseLink-ORM.XML schema functionality for 2.1 release (update version to 2.1) -->
-<!-- ************************************************************************************************************************** -->
-
-<!-- Java Persistence API object-relational mapping file schema -->
-<xsd:schema targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:orm="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="2.1">
-
- <xsd:annotation>
- <xsd:documentation>
- @(#)eclipselink_orm_2_1.xsd 2.1 April 05 2010
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:annotation>
- <xsd:documentation><![CDATA[
-
- This is the XML Schema for the native Eclipselink XML mapping file
- The file may be named "META-INF/eclipselink-orm.xml" in the persistence
- archive or it may be named some other name which would be
- used to locate the file as resource on the classpath.
- Object/relational mapping files must indicate the object/relational
- mapping file schema by using the persistence namespace:
-
- http://www.eclipse.org/eclipselink/xsds/persistence/orm
-
- and indicate the version of the schema by using the version element as shown below:
-
- <entity-mappings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm
- eclipselink_orm_2_1.xsd
- version="2.1">
- ...
- </entity-mappings>
-
- ]]></xsd:documentation>
- </xsd:annotation>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="emptyType"/>
- <xsd:simpleType name="versionType">
- <xsd:restriction base="xsd:token">
- <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="access-methods">
- <xsd:annotation>
- <xsd:documentation>
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="get-method" type="xsd:string" use="required"/>
- <xsd:attribute name="set-method" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cache">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Cache annotation is used to set an
- * org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy
- * which sets objects in EclipseLink's identity maps to be invalid
- * following given rules. By default in EclipseLink, objects do not
- * expire in the cache. Several different policies are available to
- * allow objects to expire.
- *
- * @see org.eclipse.persistence.annotations.CacheType
- *
- * A Cache anotation may be defined on an Entity or MappedSuperclass.
- * In the case of inheritance, a Cache annotation should only be defined
- * on the root of the inheritance hierarchy.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Cache {
- /**
- * (Optional) The type of cache to use.
- */
- CacheType type() default SOFT_WEAK;
-
- /**
- * (Optional) The size of cache to use.
- */
- int size() default 100;
-
- /**
- * (Optional) Cached instances in the shared cache or a client
- * isolated cache.
- */
- boolean shared() default true;
-
- /**
- * (Optional) Expire cached instance after a fix period of time (ms).
- * Queries executed against the cache after this will be forced back
- * to the database for a refreshed copy
- */
- int expiry() default -1; // minus one is no expiry.
-
- /**
- * (Optional) Expire cached instance a specific time of day. Queries
- * executed against the cache after this will be forced back to the
- * database for a refreshed copy
- */
- TimeOfDay expiryTimeOfDay() default @TimeOfDay(specified=false);
-
- /**
- * (Optional) Force all queries that go to the database to always
- * refresh the cache.
- */
- boolean alwaysRefresh() default false;
-
- /**
- * (Optional) For all queries that go to the database, refresh the
- * cache only if the data received from the database by a query is
- * newer than the data in the cache (as determined by the optimistic
- * locking field)
- */
- boolean refreshOnlyIfNewer() default false;
-
- /**
- * (Optional) Setting to true will force all queries to bypass the
- * cache for hits but still resolve against the cache for identity.
- * This forces all queries to hit the database.
- */
- boolean disableHits() default false;
-
- /**
- * (Optional) The cache coordination mode.
- */
- CacheCoordinationType coordinationType() default SEND_OBJECT_CHANGES;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:choice>
- <xsd:element name="expiry" type="xsd:integer" minOccurs="0"/>
- <xsd:element name="expiry-time-of-day" type="orm:time-of-day" minOccurs="0"/>
- </xsd:choice>
- <xsd:attribute name="size" type="xsd:integer"/>
- <xsd:attribute name="shared" type="xsd:boolean"/>
- <xsd:attribute name="type" type="orm:cache-type"/>
- <xsd:attribute name="always-refresh" type="xsd:boolean"/>
- <xsd:attribute name="refresh-only-if-newer" type="xsd:boolean"/>
- <xsd:attribute name="disable-hits" type="xsd:boolean"/>
- <xsd:attribute name="coordination-type" type="orm:cache-coordination-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cache-interceptor">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface CacheInterceptor {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
-
- <xsd:simpleType name="cache-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The CacheType enum is used with the Cache annotation for a
- * persistent class. It defines the type of IdentityMap/Cache used for
- * the class. By default the SOFT_WEAK cache type is used.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheType {
- /**
- * Provides full caching and guaranteed identity. Caches all objects
- * and does not remove them.
- * WARNING: This method may be memory intensive when many objects are
- * read.
- */
- FULL,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using weak references. This method allows full garbage
- * collection and provides full caching and guaranteed identity.
- */
- WEAK,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using soft references. This method allows full garbage
- * collection when memory is low and provides full caching and
- * guaranteed identity.
- */
- SOFT,
-
- /**
- * Similar to the WEAK identity map except that it maintains a
- * most-frequently-used sub-cache. The size of the sub-cache is
- * proportional to the size of the identity map as specified by
- * descriptor's setIdentityMapSize() method. The sub-cache
- * uses soft references to ensure that these objects are
- * garbage-collected only if the system is low on memory.
- */
- SOFT_WEAK,
-
- /**
- * Identical to the soft cache weak (SOFT_WEAK) identity map except
- * that it uses hard references in the sub-cache. Use this identity
- * map if soft references do not behave properly on your platform.
- */
- HARD_WEAK,
-
- /**
- * A cache identity map maintains a fixed number of objects
- * specified by the application. Objects are removed from the cache
- * on a least-recently-used basis. This method allows object
- * identity for the most commonly used objects.
- * WARNING: Furnishes caching and identity, but does not guarantee
- * identity.
- */
- CACHE,
-
- /**
- * WARNING: Does not preserve object identity and does not cache
- * objects.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="FULL"/>
- <xsd:enumeration value="WEAK"/>
- <xsd:enumeration value="SOFT"/>
- <xsd:enumeration value="SOFT_WEAK"/>
- <xsd:enumeration value="HARD_WEAK"/>
- <xsd:enumeration value="CACHE"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-coordination-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the Cache annotation.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheCoordinationType {
- /**
- * Sends a list of changed objects including data about the changes.
- * This data is merged into the receiving cache.
- */
- SEND_OBJECT_CHANGES,
-
- /**
- * Sends a list of the identities of the objects that have changed.
- * The receiving cache invalidates the objects (rather than changing
- * any of the data)
- */
- INVALIDATE_CHANGED_OBJECTS,
-
- /**
- * Same as SEND_OBJECT_CHANGES except it also includes any newly
- * created objects from the transaction.
- */
- SEND_NEW_OBJECTS_WITH_CHANGES,
-
- /**
- * Does no cache coordination.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SEND_OBJECT_CHANGES"/>
- <xsd:enumeration value="INVALIDATE_CHANGED_OBJECTS"/>
- <xsd:enumeration value="SEND_NEW_OBJECTS_WITH_CHANGES"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="change-tracking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The ChangeTracking annotation is used to specify the
- * org.eclipse.persistence.descriptors.changetracking.ObjectChangePolicy
- * which computes changes sets for EclipseLink's UnitOfWork commit
- * process. An ObjectChangePolicy is stored on an Entity's descriptor.
- *
- * A ChangeTracking annotation may be specified on an Entity,
- * MappedSuperclass or Embeddable.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface ChangeTracking {
- /**
- * (Optional) The type of change tracking to use.
- */
- ChangeTrackingType value() default AUTO;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="type" type="orm:change-tracking-type" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="change-tracking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the ChangeTracking annotation.
- */
- public enum ChangeTrackingType {
- /**
- * An ATTRIBUTE change tracking type allows change tracking at the
- * attribute level of an object. Objects with changed attributes will
- * be processed in the commit process to include any changes in the
- * results of the commit. Unchanged objects will be ignored.
- */
- ATTRIBUTE,
-
- /**
- * An OBJECT change tracking policy allows an object to calculate for
- * itself whether it has changed. Changed objects will be processed in
- * the commit process to include any changes in the results of the
- * commit. Unchanged objects will be ignored.
- */
- OBJECT,
-
- /**
- * A DEFERRED change tracking policy defers all change detection to
- * the UnitOfWork's change detection process. Essentially, the
- * calculateChanges() method will run for all objects in a UnitOfWork.
- * This is the default ObjectChangePolicy
- */
- DEFERRED,
-
- /**
- * Will not set any change tracking policy.
- */
- AUTO
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ATTRIBUTE"/>
- <xsd:enumeration value="OBJECT"/>
- <xsd:enumeration value="DEFERRED"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="customizer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Customizer annotation is used to specify a class that implements
- * the org.eclipse.persistence.config.DescriptorCustomizer
- * interface and is to run against an enetity's class descriptor after all
- * metadata processing has been completed.
- *
- * The Customizer annotation may be defined on an Entity, MappedSuperclass
- * or Embeddable class. In the case of inheritance, a Customizer is not
- * inherited from its parent classes.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Customizer {
- /**
- * (Required) Defines the name of the descriptor customizer class that
- * should be applied for the related entity or embeddable class.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="direction-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the StoredProcedureParameter annotation.
- * It is used to specify the direction of the stored procedure
- * parameters of a named stored procedure query.
- */
- public enum Direction {
- /**
- * Input parameter
- */
- IN,
-
- /**
- * Output parameter
- */
- OUT,
-
- /**
- * Input and output parameter
- */
- IN_OUT,
-
- /**
- * Output cursor
- */
- OUT_CURSOR
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="IN"/>
- <xsd:enumeration value="OUT"/>
- <xsd:enumeration value="IN_OUT"/>
- <xsd:enumeration value="OUT_CURSOR"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:element name="entity-mappings">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
-
- The entity-mappings element is the root element of a mapping
- file. It contains the following four types of elements:
-
- 1. The persistence-unit-metadata element contains metadata
- for the entire persistence unit. It is undefined if this element
- occurs in multiple mapping files within the same persistence unit.
-
- 2. The package, schema, catalog and access elements apply to all of
- the entity, mapped-superclass and embeddable elements defined in
- the same file in which they occur.
-
- 3. The sequence-generator, table-generator, named-query,
- named-native-query and sql-result-set-mapping elements are global
- to the persistence unit. It is undefined to have more than one
- sequence-generator or table-generator of the same name in the same
- or different mapping files in a persistence unit. It is also
- undefined to have more than one named-query, named-native-query, or
- result-set-mapping of the same name in the same or different mapping
- files in a persistence unit.
-
- 4. The entity, mapped-superclass and embeddable elements each define
- the mapping information for a managed persistent class. The mapping
- information contained in these elements may be complete or it may
- be partial.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="persistence-unit-metadata"
- type="orm:persistence-unit-metadata"
- minOccurs="0"/>
- <xsd:element name="package" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type"
- minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="mapped-superclass" type="orm:mapped-superclass"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="entity" type="orm:entity"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embeddable" type="orm:embeddable"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="version" type="orm:versionType"
- fixed="2.1" use="required"/>
- </xsd:complexType>
- </xsd:element>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="existence-type">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * The ExistenceChecking annotation is used to specify the type of
- * checking EclipseLink should use when updating entities.
- *
- * An existence-checking specification is supported on an Entity or
- * MappedSuperclass annotation.
- */
- public @interface ExistenceChecking {
-
- /**
- * (Optional) Set the existence check for determining
- * if an insert or update should occur for an object.
- */
- ExistenceType value() default CHECK_CACHE;
- }
-
- /**
- * Assume that if the objects primary key does not include null and
- * it is in the cache, then it must exist.
- */
- CHECK_CACHE,
-
- /**
- * Perform does exist check on the database.
- */
- CHECK_DATABASE,
-
- /**
- * Assume that if the objects primary key does not include null then
- * it must exist. This may be used if the application guarantees or
- * does not care about the existence check.
- */
- ASSUME_EXISTENCE,
-
- /**
- * Assume that the object does not exist. This may be used if the
- * application guarantees or does not care about the existence check.
- * This will always force an insert to be called.
- */
- ASSUME_NON_EXISTENCE
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="CHECK_CACHE"/>
- <xsd:enumeration value="CHECK_DATABASE"/>
- <xsd:enumeration value="ASSUME_EXISTENCE"/>
- <xsd:enumeration value="ASSUME_NON_EXISTENCE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-metadata">
- <xsd:annotation>
- <xsd:documentation>
-
- Metadata that applies to the persistence unit and not just to
- the mapping file in which it is contained.
-
- If the xml-mapping-metadata-complete element is specified,
- the complete set of mapping metadata for the persistence unit
- is contained in the XML mapping files for the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="xml-mapping-metadata-complete" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-default-mappings" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="persistence-unit-defaults"
- type="orm:persistence-unit-defaults"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-defaults">
- <xsd:annotation>
- <xsd:documentation>
-
- These defaults are applied to the persistence unit as a whole
- unless they are overridden by local annotation or XML
- element settings.
-
- schema - Used as the schema for all tables, secondary tables, join
- tables, collection tables, sequence generators, and table
- generators that apply to the persistence unit
- catalog - Used as the catalog for all tables, secondary tables, join
- tables, collection tables, sequence generators, and table
- generators that apply to the persistence unit
- delimited-identifiers - Used to treat database identifiers as
- delimited identifiers.
- access - Used as the access type for all managed classes in
- the persistence unit
- cascade-persist - Adds cascade-persist to the set of cascade options
- in all entity relationships of the persistence unit
- entity-listeners - List of default entity listeners to be invoked
- on each entity in the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="delimited-identifiers" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type"
- minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for an entity. Is allowed to be
- sparsely populated and used in conjunction with the annotations.
- Alternatively, the metadata-complete attribute can be used to
- indicate that no annotations on the entity class (and its fields
- or properties) are to be processed. If this is the case then
- the defaulting rules for the entity and its subelements will
- be recursively applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface Entity {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="table" type="orm:table"
- minOccurs="0"/>
- <xsd:element name="secondary-table" type="orm:secondary-table"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="inheritance" type="orm:inheritance" minOccurs="0"/>
- <xsd:choice>
- <xsd:sequence>
- <xsd:element name="discriminator-value" type="orm:discriminator-value" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/>
- </xsd:sequence>
- <xsd:element name="class-extractor" type="orm:class-extractor" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking" minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="cache-interceptor" type="orm:cache-interceptor" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="fetch-group" type="orm:fetch-group" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="query-redirectors" type="orm:query-redirectors" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="parent-class" type="xsd:string"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="cacheable" type="xsd:boolean"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="access-type">
- <xsd:annotation>
- <xsd:documentation>
-
- This element determines how the persistence provider accesses the
- state of an entity or embedded object.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="PROPERTY"/>
- <xsd:enumeration value="FIELD"/>
- <xsd:enumeration value="VIRTUAL"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="association-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AssociationOverride {
- String name();
- JoinColumn[] joinColumns() default{};
- JoinTable joinTable() default @JoinTable;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- </xsd:choice>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="attribute-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AttributeOverride {
- String name();
- Column column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="attributes">
- <xsd:annotation>
- <xsd:documentation>
-
- This element contains the entity field or property mappings.
- It may be sparsely populated to include only a subset of the
- fields or properties. If metadata-complete for the entity is true
- then the remainder of the attributes will be defaulted according
- to the default rules.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="id" type="orm:id"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded-id" type="orm:embedded-id"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="basic" type="orm:basic"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-collection" type="orm:basic-collection" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-map" type="orm:basic-map" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="version" type="orm:version"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-one" type="orm:many-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-many" type="orm:one-to-many"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-one" type="orm:one-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="variable-one-to-one" type="orm:variable-one-to-one" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-many" type="orm:many-to-many"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="element-collection" type="orm:element-collection"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded" type="orm:embedded"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transformation" type="orm:transformation" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transient" type="orm:transient"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="basic">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Basic {
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="lob" type="orm:lob"/>
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="enumerated" type="orm:enumerated"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="return-insert" type="orm:return-insert" minOccurs="0"/>
- <xsd:element name="return-update" type="orm:emptyType" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="basic-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicCollection {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the value column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:eclipselink-collection-table" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-map">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicMap {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the data column that holds the direct map
- * key. If the name on te key column is "", the name will default to:
- * the name of the property or field; "_KEY".
- */
- Column keyColumn() default @Column;
-
- /**
- * (Optional) Specify the key converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the direct map key.
- */
- Convert keyConverter() default @Convert;
-
- /**
- * (Optional) The name of the data column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
-
- /**
- * (Optional) Specify the value converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the value column mapping.
- */
- Convert valueConverter() default @Convert;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="key-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="key-converter" type="xsd:string" minOccurs="0"/>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="value-converter" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:eclipselink-collection-table" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cascade-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REFRESH, DETACH};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade-all" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-merge" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-remove" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-refresh" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-detach" type="orm:emptyType"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="class-extractor">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A ClassExtractor allows for a user defined class indicator in place of
- * providing a discriminator column. The class has the following restrictions:
-
- * - It must extend the org.eclipse.persistence.descriptors.ClassExtractor
- * class and implement the extractClassFromRow(Record, Session) method.
- * - That method must take a database row (a Record/Map) as an argument and
- * must return the class to use for that row.
- *
- * This method will be used to decide which class to instantiate when reading
- * from the database. It is the application's responsibility to populate any
- * typing information in the database required to determine the class from the
- * row.
- *
- * The ClassExtractor must only be set on the root of an entity class or
- * sub-hierarchy in which a different inheritance strategy is applied. The
- * ClassExtractor can only be used with the SINGLE_TABLE and JOINED inheritance
- * strategies.
- *
- * If a ClassExtractor is used then a DiscriminatorColumn cannot be used. A
- * ClassExtractor also cannot be used on either the root or its subclasses.
- *
- * In addition, for more complex configurations using a ClassExtractor and a
- * SINGLE_TABLE strategy, the descriptor's withAllSubclasses and onlyInstances
- * expressions should be set through the ClassExtractor's initialize method.
- *
- * @see org.eclipse.persistence.descriptors.InheritancePolicy.setWithAllSubclassesExpression(Expression)
- * @see org.eclipse.persistence.descriptors.InheritancePolicy.setOnlyInstancesExpression(Expression)
- *
- * @author Guy Pelletier
- * @since EclipseLink 2.1
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface ClassExtractor {
- /**
- * (Required) Defines the name of the class extractor that should be
- * applied to this entity's descriptor.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="clone-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CloneCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.CloneCopyPolicy on an
- * Entity. A CloneCopyPolicy must specify at one or both of the "method"
- * or "workingCopyMethod". "workingCopyMethod" is used to clone objects
- * that will be returned to the user as they are registered in
- * EclipseLink's transactional mechanism, the UnitOfWork. "method" will
- * be used for the clone that is used for comparison in conjunction with
- * EclipseLink's DeferredChangeDetectionPolicy
- *
- * A CloneCopyPolicy should be specified on an Entity, MappedSuperclass
- * or Embeddable.
- *
- * Example:
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod", workingCopyMethod="myWorkingCopyCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(workingCopyMethodName="myWorkingCopyClone")
- */
- public @interface CloneCopyPolicy {
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified this defines
- * a method that will be used to create a clone that will be used
- * for comparison by
- * EclipseLink's DeferredChangeDetectionPolicy
- */
- String method();
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified
- * this defines a method that will be used to create a clone that
- * will be used to create the object returned when registering an
- * Object in an EclipseLink UnitOfWork
- */
- String workingCopyMethod();
-
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method" type="xsd:string"/>
- <xsd:attribute name="working-copy-method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface CollectionTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="eclipselink-collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface CollectionTable {
- /**
- * (Optional) The name of the collection table. If it is not
- * specified, it is defaulted to the concatenation of the following:
- * the name of the source entity; "_" ; the name of the relationship
- * property or field of the source entity.
- */
- String name() default "";
-
- /**
- * (Optional) The catalog of the table. It defaults to the persistence
- * unit default catalog.
- */
- String catalog() default "";
-
- /**
- * (Optional) The schema of the table. It defaults to the persistence
- * unit default schema.
- */
- String schema() default "";
-
- /**
- * (Optional) Used to specify a primary key column that is used as a
- * foreign key to join to another table. If the source entity uses a
- * composite primary key, a primary key join column must be specified
- * for each field of the composite primary key. In a single primary
- * key case, a primary key join column may optionally be specified.
- * Defaulting will apply otherwise as follows:
- * name, the same name as the primary key column of the primary table
- * of the source entity. referencedColumnName, the same name of
- * primary key column of the primary table of the source entity.
- */
- PrimaryKeyJoinColumn[] primaryKeyJoinColumns() default {};
-
- /**
- * (Optional) Unique constraints that are to be placed on the table.
- * These are only used if table generation is in effect.
- */
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Column {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="conversion-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface ConversionValue {
- /**
- * (Required) Specify the database value.
- */
- String dataValue();
-
- /**
- * (Required) Specify the object value.
- */
- String objectValue();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="data-value" type="xsd:string" use="required"/>
- <xsd:attribute name="object-value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Converter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must implement
- * the org.eclipse.persistence.mappings.converters.Converter interface.
- */
- Class converterClass();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface ColumnResult {
- String name();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CopyPolicy is used to set a
- * org.eclipse.persistence.descriptors.copying.CopyPolicy on an Entity.
- * It is required that a class that implements
- * org.eclipse.persistence.descriptors.copying.CopyPolicy be specified
- * as the argument.
- *
- * A CopyPolicy should be specified on an Entity, MappedSuperclass or
- * Embeddable.
- *
- * For instance:
- * @Entity
- * @CopyPolicy("example.MyCopyPolicy")
- */
- public @interface CopyPolicy {
-
- /*
- * (Required)
- * This defines the class of the copy policy. It must specify a class
- * that implements org.eclipse.persistence.descriptors.copying.CopyPolicy
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorColumn {
- String name() default "DTYPE";
- DiscriminatorType discriminatorType() default STRING;
- String columnDefinition() default "";
- int length() default 31;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="discriminator-type" type="orm:discriminator-type"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-class">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A DiscriminatorClass is used within a VariableOneToOne annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface DiscriminatorClass {
- /**
- * (Required) The discriminator to be stored on the database.
- */
- String discriminator();
-
- /**
- * (Required) The class to the instantiated with the given
- * discriminator.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="discriminator" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum DiscriminatorType { STRING, CHAR, INTEGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="STRING"/>
- <xsd:enumeration value="CHAR"/>
- <xsd:enumeration value="INTEGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorValue {
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
-<xsd:complexType name="element-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ElementCollection {
- Class targetClass() default void.class;
- FetchType fetch() default LAZY;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by"
- minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key"
- minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class"
- minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="map-key-enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column"
- type="orm:map-key-column"
- minOccurs="0"/>
- <xsd:element name="map-key-join-column"
- type="orm:map-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="lob"
- type="orm:lob"
- minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- </xsd:choice>
- </xsd:sequence>
- <xsd:sequence>
- <xsd:element name="attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:collection-table"
- minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-class" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
-</xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="embeddable">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for embeddable objects. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- in the class. If this is the case then the defaulting rules will
- be recursively applied.
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Embeddable {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Embedded {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="embedded-id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface EmbeddedId {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="entity-listener">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines an entity listener to be invoked at lifecycle events
- for the entities that list this listener.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="entity-listeners">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface EntityListeners {
- Class[] value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="entity-listener" type="orm:entity-listener"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="entity-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface EntityResult {
- Class entityClass();
- FieldResult[] fields() default {};
- String discriminatorColumn() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field-result" type="orm:field-result"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="entity-class" type="xsd:string" use="required"/>
- <xsd:attribute name="discriminator-column" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="enum-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum EnumType {
- ORDINAL,
- STRING
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ORDINAL"/>
- <xsd:enumeration value="STRING"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="enumerated">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Enumerated {
- EnumType value() default ORDINAL;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:enum-type"/>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="fetch-attribute">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface FetchAttribute {
- /**
- * (Required) The fetch attribute name.
- */
- String name();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="fetch-group">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface FetchGroup {
- /**
- * (Required) The fetch group name.
- */
- String name();
-
- /**
- * (Optional) Indicates whether all relationship attributes
- * specified in the fetch group should be loaded.
- */
- boolean load() default true;
-
- /**
- * (Required) The list of attributes to fetch.
- */
- FetchAttribute[] attributes();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute" type="orm:fetch-attribute" minOccurs="1" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="load" type="xsd:boolean"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum FetchType { LAZY, EAGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="LAZY"/>
- <xsd:enumeration value="EAGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="field-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface FieldResult {
- String name();
- String column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="column" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="generated-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface GeneratedValue {
- GenerationType strategy() default AUTO;
- String generator() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:generation-type"/>
- <xsd:attribute name="generator" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="generation-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="TABLE"/>
- <xsd:enumeration value="SEQUENCE"/>
- <xsd:enumeration value="IDENTITY"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Id {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"
- minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value"
- minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="id-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface IdClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="id-validation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The IdValidation enum determines the type value that are valid for an Id.
- * By default null is not allowed, and 0 is not allow for singleton ids of long or int type.
- * The default value is ZERO for singleton ids, and NULL for composite ids.
- * This can be set using the @PrimaryKey annotation, or ClassDescriptor API.
- *
- * @see PrimaryKey
- * @see org.eclipse.persistence.descriptors.ClassDescriptor#setIdValidation(IdValidation)
- * @author James Sutherland
- * @since EclipseLink 1.0
- */
- public enum IdValidation {
- /**
- * Only null is not allowed as an id value, 0 is allowed.
- */
- NULL,
-
- /**
- * null and 0 are not allowed, (only int and long).
- */
- ZERO,
-
- /**
- * No id validation is done.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="NULL"/>
- <xsd:enumeration value="ZERO"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <xsd:simpleType name="cache-key-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Configures what type of Id value is used to store the object in the cache.
- * This can either be the basic Id value for simple singleton Ids,
- * or an optimized CacheKey type.
- *
- * @see PrimaryKey#cacheKeyType()
- * @see ClassDescriptor#setCacheKeyType(CacheKeyType)
- * @author James Sutherland
- * @since EclipseLink 2.1
- */
- public enum CacheKeyType {
- /**
- * This can only be used for simple singleton Ids, such as long/int/String.
- * This is the default for simple singleton Ids.
- */
- ID_VALUE,
-
- /**
- * Optimized cache key type that allows composite and complex values.
- * This is the default for composite or complex Ids.
- */
- CACHE_KEY,
-
- /**
- * The cache key type is automatically configured depending on what is optimal for the class.
- */
- AUTO
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ID_VALUE"/>
- <xsd:enumeration value="CACHE_KEY"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="inheritance">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Inheritance {
- InheritanceType strategy() default SINGLE_TABLE;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:inheritance-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="inheritance-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum InheritanceType
- { SINGLE_TABLE, JOINED, TABLE_PER_CLASS};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SINGLE_TABLE"/>
- <xsd:enumeration value="JOINED"/>
- <xsd:enumeration value="TABLE_PER_CLASS"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="instantiation-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * An InstantiationCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.InstantiationCopyPolicy
- * on an Entity. InstantiationCopyPolicy is the default CopyPolicy in
- * EclipseLink and therefore this configuration option is only used to
- * override other types of copy policies
- *
- * An InstantiationCopyPolicy should be specified on an Entity,
- * MappedSuperclass or Embeddable.
- *
- * Example:
- * @Entity
- * @InstantiationCopyPolicy
- */
- public @interface InstantiationCopyPolicy {
- }
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum JoinFetchType {
- /**
- * An inner join is used to fetch the related object.
- * This does not allow for null/empty values.
- */
- INNER,
-
- /**
- * An inner join is used to fetch the related object.
- * This allows for null/empty values.
- */
- OUTER,
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="INNER"/>
- <xsd:enumeration value="OUTER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="batch-fetch-type">
- <xsd:annotation>
- <xsd:documentation>
- public enum BatchFetchType {
- /**
- * This is the default form of batch reading.
- * The original query's selection criteria is joined with the batch query.
- */
- JOIN,
-
- /**
- * This uses an SQL EXISTS and a sub-select in the batch query instead of a join.
- * This has the advantage of not requiring an SQL DISTINCT which can have issues
- * with LOBs, or may be more efficient for some types of queries or on some databases.
- */
- EXISTS,
-
- /**
- * This uses an SQL IN clause in the batch query passing in the source object Ids.
- * This has the advantage of only selecting the objects not already contained in the cache,
- * and can work better with cursors, or if joins cannot be used.
- * This may only work for singleton Ids on some databases.
- */
- IN
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="JOIN"/>
- <xsd:enumeration value="EXISTS"/>
- <xsd:enumeration value="IN"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- JoinColumn[] inverseJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="inverse-join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="lob">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Lob {}
-
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="lock-mode-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum LockModeType { READ, WRITE, OPTIMISTIC, OPTIMISTIC_FORCE_INCREMENT, PESSIMISTIC_READ, PESSIMISTIC_WRITE, PESSIMISTIC_FORCE_INCREMENT, NONE};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="READ"/>
- <xsd:enumeration value="WRITE"/>
- <xsd:enumeration value="OPTIMISTIC"/>
- <xsd:enumeration value="OPTIMISTIC_FORCE_INCREMENT"/>
- <xsd:enumeration value="PESSIMISTIC_READ"/>
- <xsd:enumeration value="PESSIMISTIC_WRITE"/>
- <xsd:enumeration value="PESSIMISTIC_FORCE_INCREMENT"/>
- <xsd:enumeration value="NONE"/>
-
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
-<xsd:complexType name="many-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by"
- minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key"
- minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class"
- minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="map-key-enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column"
- minOccurs="0"/>
- <xsd:element name="map-key-join-column"
- type="orm:map-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="many-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="maps-id" type="xsd:string"/>
- <xsd:attribute name="id" type="xsd:boolean"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="map-key">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKey {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="map-key-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="map-key-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyColumn {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default false;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="map-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default false;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="mapped-superclass">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for a mapped superclass. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- If this is the case then the defaulting rules will be recursively
- applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface MappedSuperclass{}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking" minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="cache-interceptor" type="orm:cache-interceptor" minOccurs="0"/>
- <xsd:element name="fetch-group" type="orm:fetch-group" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="query-redirectors" type="orm:query-redirectors" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="parent-class" type="xsd:string"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="cacheable" type="xsd:boolean"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="named-native-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedNativeQuery {
- String name();
- String query();
- QueryHint[] hints() default {};
- Class resultClass() default void.class;
- String resultSetMapping() default ""; //named SqlResultSetMapping
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="hint" type="orm:query-hint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="named-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedQuery {
- String name();
- String query();
- LockModeType lockMode() default NONE;
- QueryHint[] hints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="lock-mode" type="orm:lock-mode-type" minOccurs="0"/>
- <xsd:element name="hint" type="orm:query-hint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
-</xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="named-stored-procedure-query">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A NamedStoredProcedureQuery annotation allows the definition of
- * queries that call stored procedures as named queries.
- * A NamedStoredProcedureQuery annotation may be defined on an Entity or
- * MappedSuperclass.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface NamedStoredProcedureQuery {
- /**
- * (Required) Unique name that references this stored procedure query.
- */
- String name();
-
- /**
- * (Optional) Query hints.
- */
- QueryHint[] hints() default {};
-
- /**
- * (Optional) Refers to the class of the result.
- */
- Class resultClass() default void.class;
-
- /**
- * (Optional) The name of the SQLResultMapping.
- */
- String resultSetMapping() default "";
-
- /**
- * (Required) The name of the stored procedure.
- */
- String procedureName();
-
- /**
- * (Optional) Whether the query should return a result set.
- */
- boolean returnsResultSet() default true;
-
- /**
- * (Optional) Defines arguments to the stored procedure.
- */
- StoredProcedureParameter[] parameters() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="parameter" type="orm:stored-procedure-parameter" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- <xsd:attribute name="procedure-name" type="xsd:string" use="required"/>
- <xsd:attribute name="returns-result-set" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="object-type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ObjectTypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence
- * field or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent
- * field or property.
- */
- Class objectType() default void.class;
-
- /**
- * (Required) Specify the conversion values to be used
- * with the object converter.
- */
- ConversionValue[] conversionValues();
-
- /**
- * (Optional) Specify a default object value. Used for
- * legacy data if the data value is missing.
- */
- String defaultObjectValue() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="conversion-value" type="orm:conversion-value" minOccurs="1" maxOccurs="unbounded"/>
- <xsd:element name="default-object-value" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
-<xsd:complexType name="one-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by"
- minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key"
- minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class"
- minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="map-key-enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column"
- minOccurs="0"/>
- <xsd:element name="map-key-join-column"
- type="orm:map-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="one-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- String mappedBy() default "";
- boolean orphanRemoval() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- <xsd:attribute name="maps-id" type="xsd:string"/>
- <xsd:attribute name="id" type="xsd:boolean"/>
-</xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="optimistic-locking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An optimistic-locking element is used to specify the type of
- * optimistic locking EclipseLink should use when updating or deleting
- * entities. An optimistic-locking specification is supported on
- * an entity or mapped-superclass.
- *
- * It is used in conjunction with the optimistic-locking-type.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface OptimisticLocking {
- /**
- * (Optional) The type of optimistic locking policy to use.
- */
- OptimisticLockingType type() default VERSION_COLUMN;
-
- /**
- * (Optional) For an optimistic locking policy of type
- * SELECTED_COLUMNS, this annotation member becomes a (Required)
- * field.
- */
- Column[] selectedColumns() default {};
-
- /**
- * (Optional) Specify where the optimistic locking policy should
- * cascade lock. Currently only supported with VERSION_COLUMN locking.
- */
- boolean cascade() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="selected-column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="type" type="orm:optimistic-locking-type"/>
- <xsd:attribute name="cascade" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="optimistic-locking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A simple type that is used within an optimistic-locking
- * specification to specify the type of optimistic-locking that
- * EclipseLink should use when updating or deleting entities.
- */
- public enum OptimisticLockingType {
- /**
- * Using this type of locking policy compares every field in the table
- * in the WHERE clause when doing an update or a delete. If any field
- * has been changed, an optimistic locking exception will be thrown.
- */
- ALL_COLUMNS,
-
- /**
- * Using this type of locking policy compares only the changed fields
- * in the WHERE clause when doing an update. If any field has been
- * changed, an optimistic locking exception will be thrown. A delete
- * will only compare the primary key.
- */
- CHANGED_COLUMNS,
-
- /**
- * Using this type of locking compares selected fields in the WHERE
- * clause when doing an update or a delete. If any field has been
- * changed, an optimistic locking exception will be thrown. Note that
- * the fields specified must be mapped and not be primary keys.
- */
- SELECTED_COLUMNS,
-
- /**
- * Using this type of locking policy compares a single version number
- * in the where clause when doing an update. The version field must be
- * mapped and not be the primary key.
- */
- VERSION_COLUMN
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ALL_COLUMNS"/>
- <xsd:enumeration value="CHANGED_COLUMNS"/>
- <xsd:enumeration value="SELECTED_COLUMNS"/>
- <xsd:enumeration value="VERSION_COLUMN"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-by">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderBy {
- String value() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="order-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderColumn {
- String name() default "";
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="correction-type" type="orm:order-column-correction-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-column-correction-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum OrderCorrectionType {
- READ,
- READ_WRITE,
- EXCEPTION
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="READ"/>
- <xsd:enumeration value="READ_WRITE"/>
- <xsd:enumeration value="EXCEPTION"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="post-load">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostLoad {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="post-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostPersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="post-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="post-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="pre-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PrePersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="pre-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="pre-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="primary-key">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The PrimaryKey annotation allows advanced configuration of the Id.
- * A validation policy can be given that allows specifying if zero is a valid id value.
- * The set of primary key columns can also be specified precisely.
- *
- * @author James Sutherland
- * @since EclipseLink 1.1
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface PrimaryKey {
- /**
- * (Optional) Configures what id validation is done.
- * By default 0 is not a valid id value, this can be used to allow 0 id values.
- */
- IdValidation validation() default IdValidation.ZERO;
-
- /**
- * (Optional) Configures what cache key type is used to store the object in the cache.
- * By default the type is determined by what type is optimal for the class.
- */
- CacheKeyType cacheKeyType() default CacheKeyType.AUTO;
-
- /**
- * (Optional) Used to specify the primary key columns directly.
- * This can be used instead of @Id if the primary key includes a non basic field,
- * such as a foreign key, or a inheritance discriminator, embedded, or transformation mapped field.
- */
- Column[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="validation" type="orm:id-validation"/>
- <xsd:attribute name="cache-key-type" type="orm:cache-key-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="primary-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface PrimaryKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="property">
- <xsd:annotation>
- <xsd:documentation>
-
- A user defined mapping's property.
- @Target({METHOD, FIELD, TYPE})
- @Retention(RUNTIME)
- public @interface Property {
- /**
- * Property name.
- */
- String name();
-
- /**
- * String representation of Property value,
- * converted to an instance of valueType.
- */
- String value();
-
- /**
- * Property value type.
- * The value converted to valueType by ConversionManager.
- * If specified must be a simple type that could be handled by
- * ConversionManager:
- * numerical, boolean, temporal.
- */
- Class valueType() default String.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- <xsd:attribute name="value-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="query-hint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface QueryHint {
- String name();
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="query-redirectors">
- <xsd:annotation>
- <xsd:documentation>
-
-@Target({TYPE}) @Retention(RUNTIME)
-public @interface QueryRedirectors {
-
- /**
- * This AllQueries Query Redirector will be applied to any executing object query
- * that does not have a more precise redirector (like the
- * ReadObjectQuery Redirector) or a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- *
- */
- Class allQueries() default void.class;
-
- /**
- * A Default ReadAll Query Redirector will be applied to any executing
- * ReadAllQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query through the getResultList() API this is the redirector that will be invoked
- */
- Class readAll() default void.class;
-
- /**
- * A Default ReadObject Query Redirector will be applied to any executing
- * ReadObjectQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query through the getSingleResult() API or EntityManager.find() this is the redirector that will be invoked
- */
- Class readObject() default void.class;
-
- /**
- * A Default ReportQuery Redirector will be applied to any executing
- * ReportQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query that contains agregate functions or selects multiple entities this is the redirector that will be invoked
- */
- Class report() default void.class;
-
- /**
- * A Default Update Query Redirector will be applied to any executing
- * UpdateObjectQuery or UpdateAllQuery that does not have a redirector set directly on the query.
- * In EclipseLink an UpdateObjectQuery is executed whenever flushing changes to the datasource.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class update() default void.class;
-
- /**
- * A Default Insert Query Redirector will be applied to any executing
- * InsertObjectQuery that does not have a redirector set directly on the query.
- * In EclipseLink an InsertObjectQuery is executed when persisting an object to the datasource.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class insert() default void.class;
-
- /**
- * A Default Delete Object Query Redirector will be applied to any executing
- * DeleteObjectQuery or DeleteAllQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class delete() default void.class;
-
-}
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="all-queries" type="xsd:string"/>
- <xsd:attribute name="read-all" type="xsd:string"/>
- <xsd:attribute name="read-object" type="xsd:string"/>
- <xsd:attribute name="report" type="xsd:string"/>
- <xsd:attribute name="update" type="xsd:string"/>
- <xsd:attribute name="insert" type="xsd:string"/>
- <xsd:attribute name="delete" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="read-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * Unless the TransformationMapping is write-only, it should have a
- * ReadTransformer, it defines transformation of database column(s)
- * value(s)into attribute value.
- *
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReadTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.AttributeTransformer
- * interface. The class will be instantiated, its
- * buildAttributeValue will be used to create the value to be
- * assigned to the attribute.
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be assigned to the attribute (not assigns the value to
- * the attribute). Either transformerClass or method must be
- * specified, but not both.
- */
- String method() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="return-insert">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReturnInsert {
- /**
- * A ReturnInsert annotation allows for INSERT operations to return
- * values back into the object being written. This allows for table
- * default values, trigger or stored procedures computed values to
- * be set back into the object.
- */
- boolean returnOnly() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="return-only" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="secondary-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SecondaryTable {
- String name();
- String catalog() default "";
- String schema() default "";
- PrimaryKeyJoinColumn[] pkJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="sequence-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface SequenceGenerator {
- String name();
- String sequenceName() default "";
- String catalog() default "";
- String schema() default "";
- int initialValue() default 1;
- int allocationSize() default 50;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="sequence-name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="sql-result-set-mapping">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SqlResultSetMapping {
- String name();
- EntityResult[] entities() default {};
- ColumnResult[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="entity-result" type="orm:entity-result"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="column-result" type="orm:column-result"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="stored-procedure-parameter">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A StoredProcedureParameter annotation is used within a
- * NamedStoredProcedureQuery annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface StoredProcedureParameter {
- /**
- * (Optional) The direction of the stored procedure parameter.
- */
- Direction direction() default IN;
-
- /**
- * (Optional) Stored procedure parameter name.
- */
- String name() default "";
-
- /**
- * (Required) The query parameter name.
- */
- String queryParameter();
-
- /**
- * (Optional) The type of Java class desired back from the procedure,
- * this is dependent on the type returned from the procedure.
- */
- Class type() default void.class;
-
- /**
- * (Optional) The JDBC type code, this dependent on the type returned
- * from the procedure.
- */
- int jdbcType() default -1;
-
- /**
- * (Optional) The JDBC type name, this may be required for ARRAY or
- * STRUCT types.
- */
- String jdbcTypeName() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="direction" type="orm:direction-type"/>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="query-parameter" type="xsd:string" use="required"/>
- <xsd:attribute name="type" type="xsd:string"/>
- <xsd:attribute name="jdbc-type" type="xsd:integer"/>
- <xsd:attribute name="jdbc-type-name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="struct-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface StructConverter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must
- * implement the EclipseLink interface
- * org.eclipse.persistence.mappings.converters.Converter
- */
- String converter();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="converter" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Table {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="table-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface TableGenerator {
- String name();
- String table() default "";
- String catalog() default "";
- String schema() default "";
- String pkColumnName() default "";
- String valueColumnName() default "";
- String pkColumnValue() default "";
- int initialValue() default 0;
- int allocationSize() default 50;
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="pk-column-name" type="xsd:string"/>
- <xsd:attribute name="value-column-name" type="xsd:string"/>
- <xsd:attribute name="pk-column-value" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="temporal">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Temporal {
- TemporalType value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:temporal-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum TemporalType {
- DATE, // java.sql.Date
- TIME, // java.sql.Time
- TIMESTAMP // java.sql.Timestamp
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="DATE"/>
- <xsd:enumeration value="TIME"/>
- <xsd:enumeration value="TIMESTAMP"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="time-of-day">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface TimeOfDay {
- /**
- * (Optional) Hour of the day.
- */
- int hour() default 0;
-
- /**
- * (Optional) Minute of the day.
- */
- int minute() default 0;
-
- /**
- * (Optional) Second of the day.
- */
- int second() default 0;
-
- /**
- * (Optional) Millisecond of the day.
- */
- int millisecond() default 0;
-
- /**
- * Internal use. Do not modify.
- */
- boolean specified() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="hour" type="xsd:integer"/>
- <xsd:attribute name="minute" type="xsd:integer"/>
- <xsd:attribute name="second" type="xsd:integer"/>
- <xsd:attribute name="millisecond" type="xsd:integer"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="transformation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Transformation is an optional annotation for
- * org.eclipse.persistence.mappings.TransformationMapping.
- * TransformationMapping allows to map an attribute to one or more
- * database columns.
- *
- * Transformation annotation is an optional part of
- * TransformationMapping definition. Unless the TransformationMapping is
- * write-only, it should have a ReadTransformer, it defines
- * transformation of database column(s) value(s)into attribute value.
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Transformation {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) The optional element is a hint as to whether the value
- * of the field or property may be null. It is disregarded
- * for primitive types, which are considered non-optional.
- */
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="read-transformer" type="orm:read-transformer"/>
- <xsd:element name="write-transformer" type="orm:write-transformer" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access" type="orm:access-type" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="transient">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Transient {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface TypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence field
- * or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent field
- * or property.
- */
- Class objectType() default void.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="unique-constraint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface UniqueConstraint {
- String name() default "";
- String[] columnNames();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column-name" type="xsd:string"
- maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="variable-one-to-one">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * Variable one to one mappings are used to represent a pointer
- * references between a java object and an implementer of an interface.
- * This mapping is usually represented by a single pointer (stored in an
- * instance variable) between the source and target objects. In the
- * relational database tables, these mappings are normally implemented
- * using a foreign key and a type code.
- *
- * A VariableOneToOne can be specified within an Entity,
- * MappedSuperclass and Embeddable class.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface VariableOneToOne {
- /**
- * (Optional) The interface class that is the target of the
- * association. If not specified it will be inferred from the type
- * of the object being referenced.
- */
- Class targetInterface() default void.class;
-
- /**
- * (Optional) The operations that must be cascaded to the target of
- * the association.
- */
- CascadeType[] cascade() default {};
-
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) Whether the association is optional. If set to false
- * then a non-null relationship must always exist.
- */
- boolean optional() default true;
-
- /**
- * (Optional) The discriminator column will hold the type
- * indicators. If the DiscriminatorColumn is not specified, the name
- * of the discriminator column defaults to "DTYPE" and the
- * discriminator type to STRING.
- */
- DiscriminatorColumn discriminatorColumn() default @DiscriminatorColumn;
-
- /**
- * (Optional) The list of discriminator types that can be used with
- * this VariableOneToOne. If none are specified then those entities
- * within the persistence unit that implement the target interface
- * will be added to the list of types. The discriminator type will
- * default as follows:
- * - If DiscriminatorColumn type is STRING: Entity.name()
- * - If DiscriminatorColumn type is CHAR: First letter of the
- * Entity class
- * - If DiscriminatorColumn type is INTEGER: The next integer after
- * the highest integer explicitly added.
- */
- DiscriminatorClass[] discriminatorClasses() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/>
- <xsd:element name="discriminator-class" type="orm:discriminator-class" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-interface" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="version">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Version {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="write-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- *
- * A single WriteTransformer may be specified directly on the method or
- * attribute. Multiple WriteTransformers should be wrapped into
- * WriteTransformers annotation. No WriteTransformers specified for
- * read-only mapping. Unless the TransformationMapping is write-only, it
- * should have a ReadTransformer, it defines transformation of database
- * column(s) value(s)into attribute value.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface WriteTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.FieldTransformer
- * interface. The class will be instantiated, its buildFieldValue
- * will be used to create the value to be written into the database
- * column. Note that for ddl generation and returning to be
- * supported the method buildFieldValue in the class should be
- * defined to return the relevant Java type, not just Object as
- * defined in the interface, for instance:
- * public Time buildFieldValue(Object instance, String fieldName, Session session).
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be written into the database column.
- * Note that for ddl generation and returning to be supported the
- * method should be defined to return a particular type, not just
- * Object, for instance:
- * public Time getStartTime().
- * The method may require a Transient annotation to avoid being
- * mapped as Basic by default.
- * Either transformerClass or method must be specified, but not both.
- */
- String method() default "";
-
- /**
- * Specify here the column into which the value should be written.
- * The only case when this could be skipped is if a single
- * WriteTransformer annotates an attribute - the attribute's name
- * will be used as a column name.
- */
- Column column() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="batch-fetch">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A BatchFetch annotation can be used on any relationship mapping,
- * (OneToOne, ManyToOne, OneToMany, ManyToMany, ElementCollection, BasicCollection, BasicMap).
- * It allows the related objects to be batch read in a single query.
- * Batch fetching can also be set at the query level, and it is
- * normally recommended to do so as all queries may not require batching.
- *
- * @author James Sutherland
- * @since EclipseLink 2.1
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BatchFetch {
- /**
- * (Optional) The type of batch-fetch to use.
- * Either JOIN, EXISTS or IN.
- * JOIN is the default.
- */
- BatchFetchType value() default BatchFetchType.JOIN;
-
- /**
- * Define the default batch fetch size.
- * This is only used for IN type batch reading and defines
- * the number of keys used in each IN clause.
- * The default size is 256, or the query's pageSize for cursor queries.
- */
- int size() default -1;
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="type" type="orm:batch-fetch-type"/>
- <xsd:attribute name="size" type="xsd:integer"/>
- </xsd:complexType>
-
-</xsd:schema>
-
-
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_2.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_2.xsd
deleted file mode 100644
index 223029e12a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_2.xsd
+++ /dev/null
@@ -1,4778 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ******************************************************************************************************************************* -->
-<!-- Copyright (c) 1998, 2010 Oracle. All rights reserved. -->
-<!-- This program and the accompanying materials are made available under the -->
-<!-- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 -->
-<!-- which accompanies this distribution. -->
-<!-- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html -->
-<!-- and the Eclipse Distribution License is available at -->
-<!-- http://www.eclipse.org/org/documents/edl-v10.php. -->
-<!-- -->
-<!-- Contributors: -->
-<!-- Oracle - initial API and implementation from Oracle TopLink -->
-<!-- tware - update version number to 2.0 -->
-<!-- 12/2/2009-2.1 Guy Pelletier -->
-<!-- - 296289: Add current annotation metadata support on mapped superclasses to EclipseLink-ORM.XML Schema -->
-<!-- - 296612: Add current annotation only metadata support of return insert/update to the EclipseLink-ORM.XML Schema -->
-<!-- - formatted to match orm_2_0.xsd so that users can easily compare the two schemas -->
-<!-- 5/4/2010-2.1 Guy Pelletier -->
-<!-- - 227219: Expand EclipseLink-ORM.XML schema functionality for 2.1 release (update version to 2.1) -->
-<!-- 6/14/2010-2.2 Guy Pelletier -->
-<!-- - 247078: eclipselink-orm.xml schema should allow lob and enumerated on version and id mappings (update version to 2.2) -->
-<!-- 10/15/2010-2.2 Guy Pelletier -->
-<!-- - 322008: Improve usability of additional criteria applied to queries at the session/EM -->
-<!-- ******************************************************************************************************************************* -->
-
-<!-- Java Persistence API object-relational mapping file schema -->
-<xsd:schema targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:orm="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="2.2">
-
- <xsd:annotation>
- <xsd:documentation>
- @(#)eclipselink_orm_2_2.xsd 2.2 June 14 2010
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:annotation>
- <xsd:documentation><![CDATA[
-
- This is the XML Schema for the native Eclipselink XML mapping file
- The file may be named "META-INF/eclipselink-orm.xml" in the persistence
- archive or it may be named some other name which would be
- used to locate the file as resource on the classpath.
- Object/relational mapping files must indicate the object/relational
- mapping file schema by using the persistence namespace:
-
- http://www.eclipse.org/eclipselink/xsds/persistence/orm
-
- and indicate the version of the schema by using the version element as shown below:
-
- <entity-mappings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm
- eclipselink_orm_2_2.xsd
- version="2.2">
- ...
- </entity-mappings>
-
- ]]></xsd:documentation>
- </xsd:annotation>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="emptyType"/>
- <xsd:simpleType name="versionType">
- <xsd:restriction base="xsd:token">
- <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="access-methods">
- <xsd:annotation>
- <xsd:documentation>
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="get-method" type="xsd:string" use="required"/>
- <xsd:attribute name="set-method" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="additional-criteria">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An additional criteria can be specified at the Entity or MappedSuperclass
- * level. When specified at the mapped superclass level, it applies to all
- * inheriting entities unless those entities define their own additional
- * criteria, at which point the additional criteria from the mapped superclass
- * is ignored.
- *
- * The additional criteria supports any valid JPQL string and must use 'this'
- * as an alias to form your additional criteria. E.G.,
- *
- * @Entity
- * @AdditionalCriteria("this.nut.size = :NUT_SIZE and this.nut.color = :NUT_COLOR")
- * public class Bolt {...}
- *
- * Additional criteria parameters are also accepted and are set through
- * properties on the entity manager factory, or on an entity manager. When set
- * on the entity manager, the properties must be set before any query execution
- * and should not be changed for the life span of that entity manager.
- *
- * Properties set on the entity manager will override those similarly named
- * properties set on the entity manager factory.
- *
- * Additional criteria is not supported with any native queries.
- *
- * @author Guy Pelletier
- * @since EclipseLink 2.2
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface AdditionalCriteria {
- /**
- * (Required) The JPQL fragment to use as the additional criteria.
- */
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="criteria" type="xsd:string"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cache">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Cache annotation is used to set an
- * org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy
- * which sets objects in EclipseLink's identity maps to be invalid
- * following given rules. By default in EclipseLink, objects do not
- * expire in the cache. Several different policies are available to
- * allow objects to expire.
- *
- * @see org.eclipse.persistence.annotations.CacheType
- *
- * A Cache anotation may be defined on an Entity or MappedSuperclass.
- * In the case of inheritance, a Cache annotation should only be defined
- * on the root of the inheritance hierarchy.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Cache {
- /**
- * (Optional) The type of cache to use.
- */
- CacheType type() default SOFT_WEAK;
-
- /**
- * (Optional) The size of cache to use.
- */
- int size() default 100;
-
- /**
- * (Optional) Cached instances in the shared cache,
- * or only a per EntityManager isolated cache.
- * The default is shared.
- * @deprecated As of Eclipselink 2.2. See the attribute 'isolation'
- */
- @Deprecated
- boolean shared() default true;
-
- /**
- * (Optional) Controls the level of caching this Entity will use.
- * The default is CacheIsolationType.SHARED which has EclipseLink
- * Caching all Entities in the Shared Cache.
- * @see org.eclipse.persistence.config.CacheIsolationType
- */
- CacheIsolationType isolation() default SHARED;
-
- /**
- * (Optional) Expire cached instance after a fix period of time (ms).
- * Queries executed against the cache after this will be forced back
- * to the database for a refreshed copy
- */
- int expiry() default -1; // minus one is no expiry.
-
- /**
- * (Optional) Expire cached instance a specific time of day. Queries
- * executed against the cache after this will be forced back to the
- * database for a refreshed copy
- */
- TimeOfDay expiryTimeOfDay() default @TimeOfDay(specified=false);
-
- /**
- * (Optional) Force all queries that go to the database to always
- * refresh the cache.
- */
- boolean alwaysRefresh() default false;
-
- /**
- * (Optional) For all queries that go to the database, refresh the
- * cache only if the data received from the database by a query is
- * newer than the data in the cache (as determined by the optimistic
- * locking field)
- */
- boolean refreshOnlyIfNewer() default false;
-
- /**
- * (Optional) Setting to true will force all queries to bypass the
- * cache for hits but still resolve against the cache for identity.
- * This forces all queries to hit the database.
- */
- boolean disableHits() default false;
-
- /**
- * (Optional) The cache coordination mode.
- */
- CacheCoordinationType coordinationType() default SEND_OBJECT_CHANGES;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:choice>
- <xsd:element name="expiry" type="xsd:integer" minOccurs="0"/>
- <xsd:element name="expiry-time-of-day" type="orm:time-of-day" minOccurs="0"/>
- </xsd:choice>
- <xsd:attribute name="size" type="xsd:integer"/>
- <xsd:attribute name="shared" type="xsd:boolean"/>
- <xsd:attribute name="isolation" type="orm:cache-isolation-type"/>
- <xsd:attribute name="type" type="orm:cache-type"/>
- <xsd:attribute name="always-refresh" type="xsd:boolean"/>
- <xsd:attribute name="refresh-only-if-newer" type="xsd:boolean"/>
- <xsd:attribute name="disable-hits" type="xsd:boolean"/>
- <xsd:attribute name="coordination-type" type="orm:cache-coordination-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cache-interceptor">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface CacheInterceptor {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
-
- <xsd:simpleType name="cache-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The CacheType enum is used with the Cache annotation for a
- * persistent class. It defines the type of IdentityMap/Cache used for
- * the class. By default the SOFT_WEAK cache type is used.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheType {
- /**
- * Provides full caching and guaranteed identity. Caches all objects
- * and does not remove them.
- * WARNING: This method may be memory intensive when many objects are
- * read.
- */
- FULL,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using weak references. This method allows full garbage
- * collection and provides full caching and guaranteed identity.
- */
- WEAK,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using soft references. This method allows full garbage
- * collection when memory is low and provides full caching and
- * guaranteed identity.
- */
- SOFT,
-
- /**
- * Similar to the WEAK identity map except that it maintains a
- * most-frequently-used sub-cache. The size of the sub-cache is
- * proportional to the size of the identity map as specified by
- * descriptor's setIdentityMapSize() method. The sub-cache
- * uses soft references to ensure that these objects are
- * garbage-collected only if the system is low on memory.
- */
- SOFT_WEAK,
-
- /**
- * Identical to the soft cache weak (SOFT_WEAK) identity map except
- * that it uses hard references in the sub-cache. Use this identity
- * map if soft references do not behave properly on your platform.
- */
- HARD_WEAK,
-
- /**
- * A cache identity map maintains a fixed number of objects
- * specified by the application. Objects are removed from the cache
- * on a least-recently-used basis. This method allows object
- * identity for the most commonly used objects.
- * WARNING: Furnishes caching and identity, but does not guarantee
- * identity.
- */
- CACHE,
-
- /**
- * WARNING: Does not preserve object identity and does not cache
- * objects.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="FULL"/>
- <xsd:enumeration value="WEAK"/>
- <xsd:enumeration value="SOFT"/>
- <xsd:enumeration value="SOFT_WEAK"/>
- <xsd:enumeration value="HARD_WEAK"/>
- <xsd:enumeration value="CACHE"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
- <xsd:simpleType name="cache-isolation-type">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * Options for how Entity instances should be shared within an EclipseLink Persistence Unit / ServerSession
- * @see ClassDescriptor#setCacheIsolationType(CacheIsolationType)
- * @author Gordon Yorke
- * @since EclipseLink 2.2
- */
- public enum CacheIsolationType {
-
- /**
- * Entity instances will be cached within the EntityManagerFactory/ServerSession level.
- * Any user queries for shared cache instances (ie Read-Only query hint) will return an Entity
- * instance that may be shared by multiple clients.
- *
- * This setting is the default isolation level.
- */
- SHARED,
-
- /**
- * Entity state information will be cached in the shared cache but Entity
- * instances will not be shared. Any user queries for shared cache instances
- * (ie Read-Only query hint) will return a new Entity instance with the cached state.
- * This will ensure the instance is <i>protected</i> from any concurrent
- * state change.
- */
- PROTECTED,
-
- /**
- * The Entity and its data is not stored in the shared cache but is
- * <i>isolated</i> to the Persistence Context/UnitOfWork or
- * IsolatedClientSession. This setting effectively disables second level
- * caching for this entity and should be used when users do not want caching for
- * a particular Entity.
- */
- ISOLATED;
-
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SHARED"/>
- <xsd:enumeration value="PROTECTED"/>
- <xsd:enumeration value="ISOLATED"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-coordination-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the Cache annotation.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheCoordinationType {
- /**
- * Sends a list of changed objects including data about the changes.
- * This data is merged into the receiving cache.
- */
- SEND_OBJECT_CHANGES,
-
- /**
- * Sends a list of the identities of the objects that have changed.
- * The receiving cache invalidates the objects (rather than changing
- * any of the data)
- */
- INVALIDATE_CHANGED_OBJECTS,
-
- /**
- * Same as SEND_OBJECT_CHANGES except it also includes any newly
- * created objects from the transaction.
- */
- SEND_NEW_OBJECTS_WITH_CHANGES,
-
- /**
- * Does no cache coordination.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SEND_OBJECT_CHANGES"/>
- <xsd:enumeration value="INVALIDATE_CHANGED_OBJECTS"/>
- <xsd:enumeration value="SEND_NEW_OBJECTS_WITH_CHANGES"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="change-tracking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The ChangeTracking annotation is used to specify the
- * org.eclipse.persistence.descriptors.changetracking.ObjectChangePolicy
- * which computes changes sets for EclipseLink's UnitOfWork commit
- * process. An ObjectChangePolicy is stored on an Entity's descriptor.
- *
- * A ChangeTracking annotation may be specified on an Entity,
- * MappedSuperclass or Embeddable.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface ChangeTracking {
- /**
- * (Optional) The type of change tracking to use.
- */
- ChangeTrackingType value() default AUTO;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="type" type="orm:change-tracking-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="change-tracking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the ChangeTracking annotation.
- */
- public enum ChangeTrackingType {
- /**
- * An ATTRIBUTE change tracking type allows change tracking at the
- * attribute level of an object. Objects with changed attributes will
- * be processed in the commit process to include any changes in the
- * results of the commit. Unchanged objects will be ignored.
- */
- ATTRIBUTE,
-
- /**
- * An OBJECT change tracking policy allows an object to calculate for
- * itself whether it has changed. Changed objects will be processed in
- * the commit process to include any changes in the results of the
- * commit. Unchanged objects will be ignored.
- */
- OBJECT,
-
- /**
- * A DEFERRED change tracking policy defers all change detection to
- * the UnitOfWork's change detection process. Essentially, the
- * calculateChanges() method will run for all objects in a UnitOfWork.
- * This is the default ObjectChangePolicy
- */
- DEFERRED,
-
- /**
- * Will not set any change tracking policy.
- */
- AUTO
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ATTRIBUTE"/>
- <xsd:enumeration value="OBJECT"/>
- <xsd:enumeration value="DEFERRED"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="customizer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Customizer annotation is used to specify a class that implements
- * the org.eclipse.persistence.config.DescriptorCustomizer
- * interface and is to run against an enetity's class descriptor after all
- * metadata processing has been completed.
- *
- * The Customizer annotation may be defined on an Entity, MappedSuperclass
- * or Embeddable class. In the case of inheritance, a Customizer is not
- * inherited from its parent classes.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Customizer {
- /**
- * (Required) Defines the name of the descriptor customizer class that
- * should be applied for the related entity or embeddable class.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="direction-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the StoredProcedureParameter annotation.
- * It is used to specify the direction of the stored procedure
- * parameters of a named stored procedure query.
- */
- public enum Direction {
- /**
- * Input parameter
- */
- IN,
-
- /**
- * Output parameter
- */
- OUT,
-
- /**
- * Input and output parameter
- */
- IN_OUT,
-
- /**
- * Output cursor
- */
- OUT_CURSOR
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="IN"/>
- <xsd:enumeration value="OUT"/>
- <xsd:enumeration value="IN_OUT"/>
- <xsd:enumeration value="OUT_CURSOR"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:element name="entity-mappings">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
-
- The entity-mappings element is the root element of a mapping
- file. It contains the following four types of elements:
-
- 1. The persistence-unit-metadata element contains metadata
- for the entire persistence unit. It is undefined if this element
- occurs in multiple mapping files within the same persistence unit.
-
- 2. The package, schema, catalog and access elements apply to all of
- the entity, mapped-superclass and embeddable elements defined in
- the same file in which they occur.
-
- 3. The sequence-generator, table-generator, named-query,
- named-native-query and sql-result-set-mapping elements are global
- to the persistence unit. It is undefined to have more than one
- sequence-generator or table-generator of the same name in the same
- or different mapping files in a persistence unit. It is also
- undefined to have more than one named-query, named-native-query, or
- result-set-mapping of the same name in the same or different mapping
- files in a persistence unit.
-
- 4. The entity, mapped-superclass and embeddable elements each define
- the mapping information for a managed persistent class. The mapping
- information contained in these elements may be complete or it may
- be partial.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="persistence-unit-metadata"
- type="orm:persistence-unit-metadata"
- minOccurs="0"/>
- <xsd:element name="package" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type"
- minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="partitioning" type="orm:partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="replication-partitioning" type="orm:replication-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="round-robin-partitioning" type="orm:round-robin-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="pinned-partitioning" type="orm:pinned-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="range-partitioning" type="orm:range-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="value-partitioning" type="orm:value-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="hash-partitioning" type="orm:hash-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="union-partitioning" type="orm:union-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="mapped-superclass" type="orm:mapped-superclass"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="entity" type="orm:entity"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embeddable" type="orm:embeddable"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="version" type="orm:versionType"
- fixed="2.2" use="required"/>
- </xsd:complexType>
- </xsd:element>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="existence-type">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * The ExistenceChecking annotation is used to specify the type of
- * checking EclipseLink should use when updating entities.
- *
- * An existence-checking specification is supported on an Entity or
- * MappedSuperclass annotation.
- */
- public @interface ExistenceChecking {
-
- /**
- * (Optional) Set the existence check for determining
- * if an insert or update should occur for an object.
- */
- ExistenceType value() default CHECK_CACHE;
- }
-
- /**
- * Assume that if the objects primary key does not include null and
- * it is in the cache, then it must exist.
- */
- CHECK_CACHE,
-
- /**
- * Perform does exist check on the database.
- */
- CHECK_DATABASE,
-
- /**
- * Assume that if the objects primary key does not include null then
- * it must exist. This may be used if the application guarantees or
- * does not care about the existence check.
- */
- ASSUME_EXISTENCE,
-
- /**
- * Assume that the object does not exist. This may be used if the
- * application guarantees or does not care about the existence check.
- * This will always force an insert to be called.
- */
- ASSUME_NON_EXISTENCE
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="CHECK_CACHE"/>
- <xsd:enumeration value="CHECK_DATABASE"/>
- <xsd:enumeration value="ASSUME_EXISTENCE"/>
- <xsd:enumeration value="ASSUME_NON_EXISTENCE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-metadata">
- <xsd:annotation>
- <xsd:documentation>
-
- Metadata that applies to the persistence unit and not just to
- the mapping file in which it is contained.
-
- If the xml-mapping-metadata-complete element is specified,
- the complete set of mapping metadata for the persistence unit
- is contained in the XML mapping files for the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="xml-mapping-metadata-complete" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-default-mappings" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="persistence-unit-defaults"
- type="orm:persistence-unit-defaults"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-defaults">
- <xsd:annotation>
- <xsd:documentation>
-
- These defaults are applied to the persistence unit as a whole
- unless they are overridden by local annotation or XML
- element settings.
-
- schema - Used as the schema for all tables, secondary tables, join
- tables, collection tables, sequence generators, and table
- generators that apply to the persistence unit
- catalog - Used as the catalog for all tables, secondary tables, join
- tables, collection tables, sequence generators, and table
- generators that apply to the persistence unit
- delimited-identifiers - Used to treat database identifiers as
- delimited identifiers.
- access - Used as the access type for all managed classes in
- the persistence unit
- cascade-persist - Adds cascade-persist to the set of cascade options
- in all entity relationships of the persistence unit
- entity-listeners - List of default entity listeners to be invoked
- on each entity in the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="delimited-identifiers" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type"
- minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for an entity. Is allowed to be
- sparsely populated and used in conjunction with the annotations.
- Alternatively, the metadata-complete attribute can be used to
- indicate that no annotations on the entity class (and its fields
- or properties) are to be processed. If this is the case then
- the defaulting rules for the entity and its subelements will
- be recursively applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface Entity {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="additional-criteria" type="orm:additional-criteria" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="table" type="orm:table" minOccurs="0"/>
- <xsd:element name="secondary-table" type="orm:secondary-table"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="index" type="orm:index" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="inheritance" type="orm:inheritance" minOccurs="0"/>
- <xsd:choice>
- <xsd:sequence>
- <xsd:element name="discriminator-value" type="orm:discriminator-value" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/>
- </xsd:sequence>
- <xsd:element name="class-extractor" type="orm:class-extractor" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking" minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="cache-interceptor" type="orm:cache-interceptor" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="fetch-group" type="orm:fetch-group" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="query-redirectors" type="orm:query-redirectors" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="parent-class" type="xsd:string"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="cacheable" type="xsd:boolean"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:group name="partitioning-group">
- <xsd:sequence>
- <xsd:element name="partitioning" type="orm:partitioning" minOccurs="0"/>
- <xsd:element name="replication-partitioning" type="orm:replication-partitioning" minOccurs="0"/>
- <xsd:element name="round-robin-partitioning" type="orm:round-robin-partitioning" minOccurs="0"/>
- <xsd:element name="pinned-partitioning" type="orm:pinned-partitioning" minOccurs="0"/>
- <xsd:element name="range-partitioning" type="orm:range-partitioning" minOccurs="0"/>
- <xsd:element name="value-partitioning" type="orm:value-partitioning" minOccurs="0"/>
- <xsd:element name="hash-partitioning" type="orm:hash-partitioning" minOccurs="0"/>
- <xsd:element name="union-partitioning" type="orm:union-partitioning" minOccurs="0"/>
- <xsd:element name="partitioned" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- </xsd:group>
-
- <xsd:simpleType name="access-type">
- <xsd:annotation>
- <xsd:documentation>
-
- This element determines how the persistence provider accesses the
- state of an entity or embedded object.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="PROPERTY"/>
- <xsd:enumeration value="FIELD"/>
- <xsd:enumeration value="VIRTUAL"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="association-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AssociationOverride {
- String name();
- JoinColumn[] joinColumns() default{};
- JoinTable joinTable() default @JoinTable;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- </xsd:choice>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="attribute-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AttributeOverride {
- String name();
- Column column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="attributes">
- <xsd:annotation>
- <xsd:documentation>
-
- This element contains the entity field or property mappings.
- It may be sparsely populated to include only a subset of the
- fields or properties. If metadata-complete for the entity is true
- then the remainder of the attributes will be defaulted according
- to the default rules.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="id" type="orm:id"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded-id" type="orm:embedded-id"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="basic" type="orm:basic"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-collection" type="orm:basic-collection" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-map" type="orm:basic-map" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="version" type="orm:version"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-one" type="orm:many-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-many" type="orm:one-to-many"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-one" type="orm:one-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="variable-one-to-one" type="orm:variable-one-to-one" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-many" type="orm:many-to-many"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="element-collection" type="orm:element-collection"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded" type="orm:embedded"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transformation" type="orm:transformation" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transient" type="orm:transient"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="basic">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Basic {
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="index" type="orm:index" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="lob" type="orm:lob"/>
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="enumerated" type="orm:enumerated"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="return-insert" type="orm:return-insert" minOccurs="0"/>
- <xsd:element name="return-update" type="orm:emptyType" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="basic-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicCollection {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the value column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:eclipselink-collection-table" minOccurs="0"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-map">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicMap {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the data column that holds the direct map
- * key. If the name on te key column is "", the name will default to:
- * the name of the property or field; "_KEY".
- */
- Column keyColumn() default @Column;
-
- /**
- * (Optional) Specify the key converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the direct map key.
- */
- Convert keyConverter() default @Convert;
-
- /**
- * (Optional) The name of the data column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
-
- /**
- * (Optional) Specify the value converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the value column mapping.
- */
- Convert valueConverter() default @Convert;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="key-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="key-converter" type="xsd:string" minOccurs="0"/>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="value-converter" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:eclipselink-collection-table" minOccurs="0"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cascade-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REFRESH, DETACH};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade-all" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-merge" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-remove" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-refresh" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-detach" type="orm:emptyType"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="class-extractor">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A ClassExtractor allows for a user defined class indicator in place of
- * providing a discriminator column. The class has the following restrictions:
-
- * - It must extend the org.eclipse.persistence.descriptors.ClassExtractor
- * class and implement the extractClassFromRow(Record, Session) method.
- * - That method must take a database row (a Record/Map) as an argument and
- * must return the class to use for that row.
- *
- * This method will be used to decide which class to instantiate when reading
- * from the database. It is the application's responsibility to populate any
- * typing information in the database required to determine the class from the
- * row.
- *
- * The ClassExtractor must only be set on the root of an entity class or
- * sub-hierarchy in which a different inheritance strategy is applied. The
- * ClassExtractor can only be used with the SINGLE_TABLE and JOINED inheritance
- * strategies.
- *
- * If a ClassExtractor is used then a DiscriminatorColumn cannot be used. A
- * ClassExtractor also cannot be used on either the root or its subclasses.
- *
- * In addition, for more complex configurations using a ClassExtractor and a
- * SINGLE_TABLE strategy, the descriptor's withAllSubclasses and onlyInstances
- * expressions should be set through the ClassExtractor's initialize method.
- *
- * @see org.eclipse.persistence.descriptors.InheritancePolicy.setWithAllSubclassesExpression(Expression)
- * @see org.eclipse.persistence.descriptors.InheritancePolicy.setOnlyInstancesExpression(Expression)
- *
- * @author Guy Pelletier
- * @since EclipseLink 2.1
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface ClassExtractor {
- /**
- * (Required) Defines the name of the class extractor that should be
- * applied to this entity's descriptor.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="clone-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CloneCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.CloneCopyPolicy on an
- * Entity. A CloneCopyPolicy must specify at one or both of the "method"
- * or "workingCopyMethod". "workingCopyMethod" is used to clone objects
- * that will be returned to the user as they are registered in
- * EclipseLink's transactional mechanism, the UnitOfWork. "method" will
- * be used for the clone that is used for comparison in conjunction with
- * EclipseLink's DeferredChangeDetectionPolicy
- *
- * A CloneCopyPolicy should be specified on an Entity, MappedSuperclass
- * or Embeddable.
- *
- * Example:
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod", workingCopyMethod="myWorkingCopyCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(workingCopyMethodName="myWorkingCopyClone")
- */
- public @interface CloneCopyPolicy {
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified this defines
- * a method that will be used to create a clone that will be used
- * for comparison by
- * EclipseLink's DeferredChangeDetectionPolicy
- */
- String method();
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified
- * this defines a method that will be used to create a clone that
- * will be used to create the object returned when registering an
- * Object in an EclipseLink UnitOfWork
- */
- String workingCopyMethod();
-
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method" type="xsd:string"/>
- <xsd:attribute name="working-copy-method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface CollectionTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string" />
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="eclipselink-collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface CollectionTable {
- /**
- * (Optional) The name of the collection table. If it is not
- * specified, it is defaulted to the concatenation of the following:
- * the name of the source entity; "_" ; the name of the relationship
- * property or field of the source entity.
- */
- String name() default "";
-
- /**
- * (Optional) The catalog of the table. It defaults to the persistence
- * unit default catalog.
- */
- String catalog() default "";
-
- /**
- * (Optional) The schema of the table. It defaults to the persistence
- * unit default schema.
- */
- String schema() default "";
-
- /**
- * (Optional) Used to specify a primary key column that is used as a
- * foreign key to join to another table. If the source entity uses a
- * composite primary key, a primary key join column must be specified
- * for each field of the composite primary key. In a single primary
- * key case, a primary key join column may optionally be specified.
- * Defaulting will apply otherwise as follows:
- * name, the same name as the primary key column of the primary table
- * of the source entity. referencedColumnName, the same name of
- * primary key column of the primary table of the source entity.
- */
- PrimaryKeyJoinColumn[] primaryKeyJoinColumns() default {};
-
- /**
- * (Optional) Unique constraints that are to be placed on the table.
- * These are only used if table generation is in effect.
- */
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string" />
- </xsd:complexType>
-
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Column {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="conversion-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface ConversionValue {
- /**
- * (Required) Specify the database value.
- */
- String dataValue();
-
- /**
- * (Required) Specify the object value.
- */
- String objectValue();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="data-value" type="xsd:string" use="required"/>
- <xsd:attribute name="object-value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Converter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must implement
- * the org.eclipse.persistence.mappings.converters.Converter interface.
- */
- Class converterClass();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A Partitioning is used to partition the data for a class across multiple difference databases
- * or across a database cluster such as Oracle RAC.
- * Partitioning can provide improved scalability by allowing multiple database machines to service requests.
- * This annotation configures a custom PartitioningPolicy.
- *
- * If multiple partitions are used to process a single transaction, JTA should be used for proper XA transaction support.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- * Partition policies are globally named to allow reuse,
- * the partitioning policy must also be set using the @Partitioned annotation to be used.
- *
- * @see Partitioned
- * @see org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Partitioning {
- String name();
-
- /**
- * (Required) Full package.class name of a subclass of PartitioningPolicy.
- */
- Class partitioningClass();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="hash-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * HashPartitioning partitions access to a database cluster by the hash of a field value from the object,
- * such as the object's location, or tenant.
- * The hash indexes into the list of connection pools.
- * All write or read request for object's with that hash value are sent to the server.
- * If a query does not include the field as a parameter, then it can either be sent
- * to all server's and unioned, or left to the sesion's default behavior.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.HashPartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface HashPartitioning {
- String name();
-
- /**
- * The database column or query parameter to partition queries by.
- * This is the table column name, not the class attribute name.
- * The column value must be included in the query and should normally be part of the object's Id.
- * This can also be the name of a query parameter.
- * If a query does not contain the field the query will not be partitioned.
- */
- Column partitionColumn();
-
- /**
- * List of connection pool names to partition across.
- */
- String[] connectionPools();
-
- /**
- * Defines if queries that do not contain the partition field should be sent
- * to every database and have the result unioned.
- */
- boolean unionUnpartitionableQueries() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="partition-column" type="orm:column"/>
- <xsd:element name="connection-pool" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="union-unpartitionable-queries" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="range-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * RangePartitioningPolicy partitions access to a database cluster by a field value from the object,
- * such as the object's id, location, or tenant.
- * Each server is assigned a range of values.
- * All write or read request for object's with that value are sent to the server.
- * If a query does not include the field as a parameter, then it can either be sent
- * to all server's and unioned, or left to the sesion's default behavior.
- *
- * If multiple partitions are used to process a single transaction, JTA should be used for proper XA transaction support.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- * Partition policies are globally named to allow reuse,
- * the partitioning policy must also be set using the @Partitioned annotation to be used.
- *
- * @see Partitioned
- * @see org.eclipse.persistence.descriptors.partitioning.RangePartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface RangePartitioning {
- String name();
-
- /**
- * The database column or query parameter to partition queries by.
- * This is the table column name, not the class attribute name.
- * The column value must be included in the query and should normally be part of the object's Id.
- * This can also be the name of a query parameter.
- * If a query does not contain the field the query will not be partitioned.
- */
- Column partitionColumn();
-
- /**
- * (Required) List of connection pool names to load balance across.
- */
- RangePartition[] partitions();
-
- /**
- * Defines if queries that do not contain the partition field should be sent
- * to every database and have the result unioned.
- */
- boolean unionUnpartitionableQueries() default false;
-
- /** The type of the start and end values. */
- Class partitionValueType() default String.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="partition-column" type="orm:column"/>
- <xsd:element name="partition" type="orm:range-partition" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="union-unpartitionable-queries" type="xsd:boolean"/>
- <xsd:attribute name="partition-value-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="range-partition">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Represent a specific range partition.
- * Values = startValue and = endValue will be routed to the connection pool.
- *
- * @see RangePartitioningPolicy
- * @see org.eclipse.persistence.descriptors.partitioning.RangePartitioningPolicy
- * @see org.eclipse.persistence.descriptors.partitioning.RangePartition
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface RangePartition {
- /** The String representation of the range start value. */
- String startValue() default "";
- /** The String representation of the range start value. */
- String endValue() default "";
- /** The connection pool to route queries to for this range. */
- String connectionPool();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="start-value" type="xsd:string"/>
- <xsd:attribute name="end-value" type="xsd:string"/>
- <xsd:attribute name="connection-pool" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="value-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * ValuePartitioning partitions access to a database cluster by a field value from the object,
- * such as the object's location, or tenant.
- * Each value is assigned a specific server.
- * All write or read request for object's with that value are sent to the server.
- * If a query does not include the field as a parameter, then it can either be sent
- * to all server's and unioned, or left to the sesion's default behavior.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.ValuePartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ValuePartitioning {
- String name();
-
- /**
- * The database column or query parameter to partition queries by.
- * This is the table column name, not the class attribute name.
- * The column value must be included in the query and should normally be part of the object's Id.
- * This can also be the name of a query parameter.
- * If a query does not contain the field the query will not be partitioned.
- */
- Column partitionColumn();
-
- /** Store the value partitions. Each partition maps a value to a connectionPool. */
- ValuePartition[] partitions();
-
- /** The type of the start and end values. */
- Class partitionValueType() default String.class;
-
- /** The default connection pool is used for any unmapped values. */
- String defaultConnectionPool();
-
- /**
- * Defines if queries that do not contain the partition field should be sent
- * to every database and have the result unioned.
- */
- boolean unionUnpartitionableQueries() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="partition-column" type="orm:column"/>
- <xsd:element name="partition" type="orm:value-partition" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="union-unpartitionable-queries" type="xsd:boolean"/>
- <xsd:attribute name="default-connection-pool" type="xsd:string"/>
- <xsd:attribute name="partition-value-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="value-partition">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Represent a specific value partition.
- * The value will be routed to the connection pool.
- *
- * @see ValuePartitioningPolicy
- * @see org.eclipse.persistence.descriptors.partitioning.ValuePartitioningPolicy
- * @see org.eclipse.persistence.descriptors.partitioning.ValuePartition
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ValuePartition {
- /** The String representation of the range start value. */
- String value() default "";
-
- /** The connection pool to route queries to for this value. */
- String connectionPool();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- <xsd:attribute name="connection-pool" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="round-robin-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * RoundRobinPartitioning sends requests in a round robin fashion to the set of connection pools.
- * It is for load-balancing read queries across a cluster of database machines.
- * It requires that the full database be replicated on each machine, so does not support partitioning.
- * The data should either be read-only, or writes should be replicated on the database.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.RoundRobinPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface RoundRobinPartitioning {
- String name();
-
- /**
- * (Required) List of connection pool names to load balance across.
- */
- String[] connectionPools();
-
- /**
- * This allows for a set of database to be written to and kept in synch,
- * and have reads load-balanced across the databases.
- */
- boolean replicateWrites() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="connection-pool" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="replicate-writes" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="replication-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * ReplicationPartitioning sends requests to a set of connection pools.
- * It is for replicating data across a cluster of database machines.
- * Only modification queries are replicated.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.ReplicationPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReplicationPartitioning {
- String name();
-
- /**
- * (Required) List of connection pool names to load balance across.
- */
- String[] connectionPools();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="connection-pool" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="union-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * UnionPartitioning sends queries to all connection pools and unions the results.
- * This is for queries or relationships that span partitions when partitioning is used,
- * such as on a ManyToMany cross partition relationship.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.UnionPartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface UnionPartitioning {
- String name();
-
- /**
- * (Required) List of connection pool names to load balance across.
- */
- String[] connectionPools();
-
- /**
- * Defines if write queries should be replicated.
- * Writes are normally not replicated when unioning,
- * but can be for ManyToMany relationships, when the join table needs to be replicated.
- */
- boolean replicateWrites() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="connection-pool" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="replicate-writes" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pinned-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * PinnedPartitioning pins requests to a single connection pool.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.PinnedPartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface PinnedPartitioning {
- String name();
-
- /**
- * The connection pool name to pin queries to.
- */
- String connectionPool();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="connection-pool" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface ColumnResult {
- String name();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CopyPolicy is used to set a
- * org.eclipse.persistence.descriptors.copying.CopyPolicy on an Entity.
- * It is required that a class that implements
- * org.eclipse.persistence.descriptors.copying.CopyPolicy be specified
- * as the argument.
- *
- * A CopyPolicy should be specified on an Entity, MappedSuperclass or
- * Embeddable.
- *
- * For instance:
- * @Entity
- * @CopyPolicy("example.MyCopyPolicy")
- */
- public @interface CopyPolicy {
-
- /*
- * (Required)
- * This defines the class of the copy policy. It must specify a class
- * that implements org.eclipse.persistence.descriptors.copying.CopyPolicy
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorColumn {
- String name() default "DTYPE";
- DiscriminatorType discriminatorType() default STRING;
- String columnDefinition() default "";
- int length() default 31;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="discriminator-type" type="orm:discriminator-type"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-class">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A DiscriminatorClass is used within a VariableOneToOne annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface DiscriminatorClass {
- /**
- * (Required) The discriminator to be stored on the database.
- */
- String discriminator();
-
- /**
- * (Required) The class to the instantiated with the given
- * discriminator.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="discriminator" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum DiscriminatorType { STRING, CHAR, INTEGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="STRING"/>
- <xsd:enumeration value="CHAR"/>
- <xsd:enumeration value="INTEGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorValue {
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
-<xsd:complexType name="element-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ElementCollection {
- Class targetClass() default void.class;
- FetchType fetch() default LAZY;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by"
- minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key"
- minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class"
- minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="map-key-enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column"
- type="orm:map-key-column"
- minOccurs="0"/>
- <xsd:element name="map-key-join-column"
- type="orm:map-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="lob"
- type="orm:lob"
- minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- </xsd:choice>
- </xsd:sequence>
- <xsd:sequence>
- <xsd:element name="attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:collection-table"
- minOccurs="0"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
-
-
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-class" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
-</xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="embeddable">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for embeddable objects. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- in the class. If this is the case then the defaulting rules will
- be recursively applied.
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Embeddable {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="parent-class" type="xsd:string"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Embedded {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="embedded-id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface EmbeddedId {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="entity-listener">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines an entity listener to be invoked at lifecycle events
- for the entities that list this listener.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="entity-listeners">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface EntityListeners {
- Class[] value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="entity-listener" type="orm:entity-listener"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="entity-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface EntityResult {
- Class entityClass();
- FieldResult[] fields() default {};
- String discriminatorColumn() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field-result" type="orm:field-result"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="entity-class" type="xsd:string" use="required"/>
- <xsd:attribute name="discriminator-column" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="enum-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum EnumType {
- ORDINAL,
- STRING
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ORDINAL"/>
- <xsd:enumeration value="STRING"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="enumerated">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Enumerated {
- EnumType value() default ORDINAL;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:enum-type"/>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="fetch-attribute">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface FetchAttribute {
- /**
- * (Required) The fetch attribute name.
- */
- String name();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="fetch-group">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface FetchGroup {
- /**
- * (Required) The fetch group name.
- */
- String name();
-
- /**
- * (Optional) Indicates whether all relationship attributes
- * specified in the fetch group should be loaded.
- */
- boolean load() default true;
-
- /**
- * (Required) The list of attributes to fetch.
- */
- FetchAttribute[] attributes();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute" type="orm:fetch-attribute" minOccurs="1" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="load" type="xsd:boolean"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum FetchType { LAZY, EAGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="LAZY"/>
- <xsd:enumeration value="EAGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="field-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface FieldResult {
- String name();
- String column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="column" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="generated-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface GeneratedValue {
- GenerationType strategy() default AUTO;
- String generator() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:generation-type"/>
- <xsd:attribute name="generator" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="generation-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="TABLE"/>
- <xsd:enumeration value="SEQUENCE"/>
- <xsd:enumeration value="IDENTITY"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Id {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"
- minOccurs="0"/>
- <xsd:element name="index" type="orm:index" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value"
- minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="enumerated" type="orm:enumerated"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="id-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface IdClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="id-validation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The IdValidation enum determines the type value that are valid for an Id.
- * By default null is not allowed, and 0 is not allow for singleton ids of long or int type.
- * The default value is ZERO for singleton ids, and NULL for composite ids.
- * This can be set using the @PrimaryKey annotation, or ClassDescriptor API.
- *
- * @see PrimaryKey
- * @see org.eclipse.persistence.descriptors.ClassDescriptor#setIdValidation(IdValidation)
- * @author James Sutherland
- * @since EclipseLink 1.0
- */
- public enum IdValidation {
- /**
- * Only null is not allowed as an id value, 0 is allowed.
- */
- NULL,
-
- /**
- * null and 0 are not allowed, (only int and long).
- */
- ZERO,
-
- /**
- * No id validation is done.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="NULL"/>
- <xsd:enumeration value="ZERO"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <xsd:simpleType name="cache-key-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Configures what type of Id value is used to store the object in the cache.
- * This can either be the basic Id value for simple singleton Ids,
- * or an optimized CacheKey type.
- *
- * @see PrimaryKey#cacheKeyType()
- * @see ClassDescriptor#setCacheKeyType(CacheKeyType)
- * @author James Sutherland
- * @since EclipseLink 2.1
- */
- public enum CacheKeyType {
- /**
- * This can only be used for simple singleton Ids, such as long/int/String.
- * This is the default for simple singleton Ids.
- */
- ID_VALUE,
-
- /**
- * Optimized cache key type that allows composite and complex values.
- * This is the default for composite or complex Ids.
- */
- CACHE_KEY,
-
- /**
- * The cache key type is automatically configured depending on what is optimal for the class.
- */
- AUTO
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ID_VALUE"/>
- <xsd:enumeration value="CACHE_KEY"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="inheritance">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Inheritance {
- InheritanceType strategy() default SINGLE_TABLE;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:inheritance-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="inheritance-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum InheritanceType
- { SINGLE_TABLE, JOINED, TABLE_PER_CLASS};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SINGLE_TABLE"/>
- <xsd:enumeration value="JOINED"/>
- <xsd:enumeration value="TABLE_PER_CLASS"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="instantiation-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * An InstantiationCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.InstantiationCopyPolicy
- * on an Entity. InstantiationCopyPolicy is the default CopyPolicy in
- * EclipseLink and therefore this configuration option is only used to
- * override other types of copy policies
- *
- * An InstantiationCopyPolicy should be specified on an Entity,
- * MappedSuperclass or Embeddable.
- *
- * Example:
- * @Entity
- * @InstantiationCopyPolicy
- */
- public @interface InstantiationCopyPolicy {
- }
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum JoinFetchType {
- /**
- * An inner join is used to fetch the related object.
- * This does not allow for null/empty values.
- */
- INNER,
-
- /**
- * An inner join is used to fetch the related object.
- * This allows for null/empty values.
- */
- OUTER,
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="INNER"/>
- <xsd:enumeration value="OUTER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="batch-fetch-type">
- <xsd:annotation>
- <xsd:documentation>
- public enum BatchFetchType {
- /**
- * This is the default form of batch reading.
- * The original query's selection criteria is joined with the batch query.
- */
- JOIN,
-
- /**
- * This uses an SQL EXISTS and a sub-select in the batch query instead of a join.
- * This has the advantage of not requiring an SQL DISTINCT which can have issues
- * with LOBs, or may be more efficient for some types of queries or on some databases.
- */
- EXISTS,
-
- /**
- * This uses an SQL IN clause in the batch query passing in the source object Ids.
- * This has the advantage of only selecting the objects not already contained in the cache,
- * and can work better with cursors, or if joins cannot be used.
- * This may only work for singleton Ids on some databases.
- */
- IN
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="JOIN"/>
- <xsd:enumeration value="EXISTS"/>
- <xsd:enumeration value="IN"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- JoinColumn[] inverseJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="inverse-join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string" />
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="lob">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Lob {}
-
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="lock-mode-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum LockModeType { READ, WRITE, OPTIMISTIC, OPTIMISTIC_FORCE_INCREMENT, PESSIMISTIC_READ, PESSIMISTIC_WRITE, PESSIMISTIC_FORCE_INCREMENT, NONE};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="READ"/>
- <xsd:enumeration value="WRITE"/>
- <xsd:enumeration value="OPTIMISTIC"/>
- <xsd:enumeration value="OPTIMISTIC_FORCE_INCREMENT"/>
- <xsd:enumeration value="PESSIMISTIC_READ"/>
- <xsd:enumeration value="PESSIMISTIC_WRITE"/>
- <xsd:enumeration value="PESSIMISTIC_FORCE_INCREMENT"/>
- <xsd:enumeration value="NONE"/>
-
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
-<xsd:complexType name="many-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by"
- minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key"
- minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class"
- minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="map-key-enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column"
- minOccurs="0"/>
- <xsd:element name="map-key-join-column"
- type="orm:map-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="many-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="maps-id" type="xsd:string"/>
- <xsd:attribute name="id" type="xsd:boolean"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="map-key">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKey {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="map-key-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="map-key-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyColumn {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default false;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="map-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default false;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="mapped-superclass">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for a mapped superclass. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- If this is the case then the defaulting rules will be recursively
- applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface MappedSuperclass{}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="additional-criteria" type="orm:additional-criteria" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking" minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="cache-interceptor" type="orm:cache-interceptor" minOccurs="0"/>
- <xsd:element name="fetch-group" type="orm:fetch-group" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="query-redirectors" type="orm:query-redirectors" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="parent-class" type="xsd:string"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="cacheable" type="xsd:boolean"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="named-native-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedNativeQuery {
- String name();
- String query();
- QueryHint[] hints() default {};
- Class resultClass() default void.class;
- String resultSetMapping() default ""; //named SqlResultSetMapping
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="hint" type="orm:query-hint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="named-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedQuery {
- String name();
- String query();
- LockModeType lockMode() default NONE;
- QueryHint[] hints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="lock-mode" type="orm:lock-mode-type" minOccurs="0"/>
- <xsd:element name="hint" type="orm:query-hint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
-</xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="named-stored-procedure-query">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A NamedStoredProcedureQuery annotation allows the definition of
- * queries that call stored procedures as named queries.
- * A NamedStoredProcedureQuery annotation may be defined on an Entity or
- * MappedSuperclass.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface NamedStoredProcedureQuery {
- /**
- * (Required) Unique name that references this stored procedure query.
- */
- String name();
-
- /**
- * (Optional) Query hints.
- */
- QueryHint[] hints() default {};
-
- /**
- * (Optional) Refers to the class of the result.
- */
- Class resultClass() default void.class;
-
- /**
- * (Optional) The name of the SQLResultMapping.
- */
- String resultSetMapping() default "";
-
- /**
- * (Required) The name of the stored procedure.
- */
- String procedureName();
-
- /**
- * (Optional) Whether the query should return a result set.
- */
- boolean returnsResultSet() default true;
-
- /**
- * (Optional) Defines arguments to the stored procedure.
- */
- StoredProcedureParameter[] parameters() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="parameter" type="orm:stored-procedure-parameter" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- <xsd:attribute name="procedure-name" type="xsd:string" use="required"/>
- <xsd:attribute name="returns-result-set" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="object-type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ObjectTypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence
- * field or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent
- * field or property.
- */
- Class objectType() default void.class;
-
- /**
- * (Required) Specify the conversion values to be used
- * with the object converter.
- */
- ConversionValue[] conversionValues();
-
- /**
- * (Optional) Specify a default object value. Used for
- * legacy data if the data value is missing.
- */
- String defaultObjectValue() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="conversion-value" type="orm:conversion-value" minOccurs="1" maxOccurs="unbounded"/>
- <xsd:element name="default-object-value" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
-<xsd:complexType name="one-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by"
- minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key"
- minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class"
- minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="map-key-enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column"
- minOccurs="0"/>
- <xsd:element name="map-key-join-column"
- type="orm:map-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="one-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- String mappedBy() default "";
- boolean orphanRemoval() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- <xsd:attribute name="maps-id" type="xsd:string"/>
- <xsd:attribute name="id" type="xsd:boolean"/>
-</xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="optimistic-locking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An optimistic-locking element is used to specify the type of
- * optimistic locking EclipseLink should use when updating or deleting
- * entities. An optimistic-locking specification is supported on
- * an entity or mapped-superclass.
- *
- * It is used in conjunction with the optimistic-locking-type.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface OptimisticLocking {
- /**
- * (Optional) The type of optimistic locking policy to use.
- */
- OptimisticLockingType type() default VERSION_COLUMN;
-
- /**
- * (Optional) For an optimistic locking policy of type
- * SELECTED_COLUMNS, this annotation member becomes a (Required)
- * field.
- */
- Column[] selectedColumns() default {};
-
- /**
- * (Optional) Specify where the optimistic locking policy should
- * cascade lock. Currently only supported with VERSION_COLUMN locking.
- */
- boolean cascade() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="selected-column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="type" type="orm:optimistic-locking-type"/>
- <xsd:attribute name="cascade" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="optimistic-locking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A simple type that is used within an optimistic-locking
- * specification to specify the type of optimistic-locking that
- * EclipseLink should use when updating or deleting entities.
- */
- public enum OptimisticLockingType {
- /**
- * Using this type of locking policy compares every field in the table
- * in the WHERE clause when doing an update or a delete. If any field
- * has been changed, an optimistic locking exception will be thrown.
- */
- ALL_COLUMNS,
-
- /**
- * Using this type of locking policy compares only the changed fields
- * in the WHERE clause when doing an update. If any field has been
- * changed, an optimistic locking exception will be thrown. A delete
- * will only compare the primary key.
- */
- CHANGED_COLUMNS,
-
- /**
- * Using this type of locking compares selected fields in the WHERE
- * clause when doing an update or a delete. If any field has been
- * changed, an optimistic locking exception will be thrown. Note that
- * the fields specified must be mapped and not be primary keys.
- */
- SELECTED_COLUMNS,
-
- /**
- * Using this type of locking policy compares a single version number
- * in the where clause when doing an update. The version field must be
- * mapped and not be the primary key.
- */
- VERSION_COLUMN
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ALL_COLUMNS"/>
- <xsd:enumeration value="CHANGED_COLUMNS"/>
- <xsd:enumeration value="SELECTED_COLUMNS"/>
- <xsd:enumeration value="VERSION_COLUMN"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-by">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderBy {
- String value() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="order-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderColumn {
- String name() default "";
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="correction-type" type="orm:order-column-correction-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-column-correction-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum OrderCorrectionType {
- READ,
- READ_WRITE,
- EXCEPTION
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="READ"/>
- <xsd:enumeration value="READ_WRITE"/>
- <xsd:enumeration value="EXCEPTION"/>
- </xsd:restriction>
- </xsd:simpleType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="post-load">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostLoad {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="post-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostPersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="post-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="post-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="pre-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PrePersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="pre-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="pre-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="primary-key">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The PrimaryKey annotation allows advanced configuration of the Id.
- * A validation policy can be given that allows specifying if zero is a valid id value.
- * The set of primary key columns can also be specified precisely.
- *
- * @author James Sutherland
- * @since EclipseLink 1.1
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface PrimaryKey {
- /**
- * (Optional) Configures what id validation is done.
- * By default 0 is not a valid id value, this can be used to allow 0 id values.
- */
- IdValidation validation() default IdValidation.ZERO;
-
- /**
- * (Optional) Configures what cache key type is used to store the object in the cache.
- * By default the type is determined by what type is optimal for the class.
- */
- CacheKeyType cacheKeyType() default CacheKeyType.AUTO;
-
- /**
- * (Optional) Used to specify the primary key columns directly.
- * This can be used instead of @Id if the primary key includes a non basic field,
- * such as a foreign key, or a inheritance discriminator, embedded, or transformation mapped field.
- */
- Column[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="validation" type="orm:id-validation"/>
- <xsd:attribute name="cache-key-type" type="orm:cache-key-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="primary-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface PrimaryKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="property">
- <xsd:annotation>
- <xsd:documentation>
-
- A user defined mapping's property.
- @Target({METHOD, FIELD, TYPE})
- @Retention(RUNTIME)
- public @interface Property {
- /**
- * Property name.
- */
- String name();
-
- /**
- * String representation of Property value,
- * converted to an instance of valueType.
- */
- String value();
-
- /**
- * Property value type.
- * The value converted to valueType by ConversionManager.
- * If specified must be a simple type that could be handled by
- * ConversionManager:
- * numerical, boolean, temporal.
- */
- Class valueType() default String.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- <xsd:attribute name="value-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="query-hint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface QueryHint {
- String name();
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="query-redirectors">
- <xsd:annotation>
- <xsd:documentation>
-
-@Target({TYPE}) @Retention(RUNTIME)
-public @interface QueryRedirectors {
-
- /**
- * This AllQueries Query Redirector will be applied to any executing object query
- * that does not have a more precise redirector (like the
- * ReadObjectQuery Redirector) or a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- *
- */
- Class allQueries() default void.class;
-
- /**
- * A Default ReadAll Query Redirector will be applied to any executing
- * ReadAllQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query through the getResultList() API this is the redirector that will be invoked
- */
- Class readAll() default void.class;
-
- /**
- * A Default ReadObject Query Redirector will be applied to any executing
- * ReadObjectQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query through the getSingleResult() API or EntityManager.find() this is the redirector that will be invoked
- */
- Class readObject() default void.class;
-
- /**
- * A Default ReportQuery Redirector will be applied to any executing
- * ReportQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query that contains agregate functions or selects multiple entities this is the redirector that will be invoked
- */
- Class report() default void.class;
-
- /**
- * A Default Update Query Redirector will be applied to any executing
- * UpdateObjectQuery or UpdateAllQuery that does not have a redirector set directly on the query.
- * In EclipseLink an UpdateObjectQuery is executed whenever flushing changes to the datasource.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class update() default void.class;
-
- /**
- * A Default Insert Query Redirector will be applied to any executing
- * InsertObjectQuery that does not have a redirector set directly on the query.
- * In EclipseLink an InsertObjectQuery is executed when persisting an object to the datasource.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class insert() default void.class;
-
- /**
- * A Default Delete Object Query Redirector will be applied to any executing
- * DeleteObjectQuery or DeleteAllQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class delete() default void.class;
-
-}
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="all-queries" type="xsd:string"/>
- <xsd:attribute name="read-all" type="xsd:string"/>
- <xsd:attribute name="read-object" type="xsd:string"/>
- <xsd:attribute name="report" type="xsd:string"/>
- <xsd:attribute name="update" type="xsd:string"/>
- <xsd:attribute name="insert" type="xsd:string"/>
- <xsd:attribute name="delete" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="read-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * Unless the TransformationMapping is write-only, it should have a
- * ReadTransformer, it defines transformation of database column(s)
- * value(s)into attribute value.
- *
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReadTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.AttributeTransformer
- * interface. The class will be instantiated, its
- * buildAttributeValue will be used to create the value to be
- * assigned to the attribute.
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be assigned to the attribute (not assigns the value to
- * the attribute). Either transformerClass or method must be
- * specified, but not both.
- */
- String method() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="return-insert">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReturnInsert {
- /**
- * A ReturnInsert annotation allows for INSERT operations to return
- * values back into the object being written. This allows for table
- * default values, trigger or stored procedures computed values to
- * be set back into the object.
- */
- boolean returnOnly() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="return-only" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="secondary-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SecondaryTable {
- String name();
- String catalog() default "";
- String schema() default "";
- PrimaryKeyJoinColumn[] pkJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string" />
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="sequence-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface SequenceGenerator {
- String name();
- String sequenceName() default "";
- String catalog() default "";
- String schema() default "";
- int initialValue() default 1;
- int allocationSize() default 50;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="sequence-name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="sql-result-set-mapping">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SqlResultSetMapping {
- String name();
- EntityResult[] entities() default {};
- ColumnResult[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="entity-result" type="orm:entity-result"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="column-result" type="orm:column-result"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="stored-procedure-parameter">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A StoredProcedureParameter annotation is used within a
- * NamedStoredProcedureQuery annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface StoredProcedureParameter {
- /**
- * (Optional) The direction of the stored procedure parameter.
- */
- Direction direction() default IN;
-
- /**
- * (Optional) Stored procedure parameter name.
- */
- String name() default "";
-
- /**
- * (Required) The query parameter name.
- */
- String queryParameter();
-
- /**
- * (Optional) The type of Java class desired back from the procedure,
- * this is dependent on the type returned from the procedure.
- */
- Class type() default void.class;
-
- /**
- * (Optional) The JDBC type code, this dependent on the type returned
- * from the procedure.
- */
- int jdbcType() default -1;
-
- /**
- * (Optional) The JDBC type name, this may be required for ARRAY or
- * STRUCT types.
- */
- String jdbcTypeName() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="direction" type="orm:direction-type"/>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="query-parameter" type="xsd:string" use="required"/>
- <xsd:attribute name="type" type="xsd:string"/>
- <xsd:attribute name="jdbc-type" type="xsd:integer"/>
- <xsd:attribute name="jdbc-type-name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="struct-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface StructConverter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must
- * implement the EclipseLink interface
- * org.eclipse.persistence.mappings.converters.Converter
- */
- String converter();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="converter" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Table {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string" />
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="index">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Allow a database INDEX to be define when generating DDL.
- * The @Index can be defined on a Entity class, or on an attribute.
- * The column is defaulted when defined on a attribute.
- *
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({METHOD, FIELD, TYPE})
- @Retention(RUNTIME)
- public @interface Index {
- /** The name of the INDEX, defaults to INDEX_(table-name) */
- String name() default "";
-
- /** The schema of the INDEX */
- String schema() default "";
-
- /** The catalog of the INDEX */
- String catalog() default "";
-
- /** The table to define the index on, defaults to entities primary table. */
- String table() default "";
-
- boolean unique() default false;
-
- /**
- * Specify the set of columns to define the index on.
- * Not required when annotated on a field/method.
- */
- String[] columnNames() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column-name" type="xsd:string"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="table-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface TableGenerator {
- String name();
- String table() default "";
- String catalog() default "";
- String schema() default "";
- String pkColumnName() default "";
- String valueColumnName() default "";
- String pkColumnValue() default "";
- int initialValue() default 0;
- int allocationSize() default 50;
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string"/>
- <xsd:attribute name="pk-column-name" type="xsd:string"/>
- <xsd:attribute name="value-column-name" type="xsd:string"/>
- <xsd:attribute name="pk-column-value" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:simpleType name="temporal">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Temporal {
- TemporalType value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:temporal-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum TemporalType {
- DATE, // java.sql.Date
- TIME, // java.sql.Time
- TIMESTAMP // java.sql.Timestamp
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="DATE"/>
- <xsd:enumeration value="TIME"/>
- <xsd:enumeration value="TIMESTAMP"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="time-of-day">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface TimeOfDay {
- /**
- * (Optional) Hour of the day.
- */
- int hour() default 0;
-
- /**
- * (Optional) Minute of the day.
- */
- int minute() default 0;
-
- /**
- * (Optional) Second of the day.
- */
- int second() default 0;
-
- /**
- * (Optional) Millisecond of the day.
- */
- int millisecond() default 0;
-
- /**
- * Internal use. Do not modify.
- */
- boolean specified() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="hour" type="xsd:integer"/>
- <xsd:attribute name="minute" type="xsd:integer"/>
- <xsd:attribute name="second" type="xsd:integer"/>
- <xsd:attribute name="millisecond" type="xsd:integer"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="transformation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Transformation is an optional annotation for
- * org.eclipse.persistence.mappings.TransformationMapping.
- * TransformationMapping allows to map an attribute to one or more
- * database columns.
- *
- * Transformation annotation is an optional part of
- * TransformationMapping definition. Unless the TransformationMapping is
- * write-only, it should have a ReadTransformer, it defines
- * transformation of database column(s) value(s)into attribute value.
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Transformation {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) The optional element is a hint as to whether the value
- * of the field or property may be null. It is disregarded
- * for primitive types, which are considered non-optional.
- */
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="read-transformer" type="orm:read-transformer"/>
- <xsd:element name="write-transformer" type="orm:write-transformer" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="transient">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Transient {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface TypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence field
- * or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent field
- * or property.
- */
- Class objectType() default void.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="unique-constraint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface UniqueConstraint {
- String name() default "";
- String[] columnNames();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column-name" type="xsd:string"
- maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
-<!-- **************************************************** -->
-
- <xsd:complexType name="variable-one-to-one">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * Variable one to one mappings are used to represent a pointer
- * references between a java object and an implementer of an interface.
- * This mapping is usually represented by a single pointer (stored in an
- * instance variable) between the source and target objects. In the
- * relational database tables, these mappings are normally implemented
- * using a foreign key and a type code.
- *
- * A VariableOneToOne can be specified within an Entity,
- * MappedSuperclass and Embeddable class.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface VariableOneToOne {
- /**
- * (Optional) The interface class that is the target of the
- * association. If not specified it will be inferred from the type
- * of the object being referenced.
- */
- Class targetInterface() default void.class;
-
- /**
- * (Optional) The operations that must be cascaded to the target of
- * the association.
- */
- CascadeType[] cascade() default {};
-
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) Whether the association is optional. If set to false
- * then a non-null relationship must always exist.
- */
- boolean optional() default true;
-
- /**
- * (Optional) The discriminator column will hold the type
- * indicators. If the DiscriminatorColumn is not specified, the name
- * of the discriminator column defaults to "DTYPE" and the
- * discriminator type to STRING.
- */
- DiscriminatorColumn discriminatorColumn() default @DiscriminatorColumn;
-
- /**
- * (Optional) The list of discriminator types that can be used with
- * this VariableOneToOne. If none are specified then those entities
- * within the persistence unit that implement the target interface
- * will be added to the list of types. The discriminator type will
- * default as follows:
- * - If DiscriminatorColumn type is STRING: Entity.name()
- * - If DiscriminatorColumn type is CHAR: First letter of the
- * Entity class
- * - If DiscriminatorColumn type is INTEGER: The next integer after
- * the highest integer explicitly added.
- */
- DiscriminatorClass[] discriminatorClasses() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/>
- <xsd:element name="discriminator-class" type="orm:discriminator-class" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-interface" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="version">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Version {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="index" type="orm:index" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="write-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- *
- * A single WriteTransformer may be specified directly on the method or
- * attribute. Multiple WriteTransformers should be wrapped into
- * WriteTransformers annotation. No WriteTransformers specified for
- * read-only mapping. Unless the TransformationMapping is write-only, it
- * should have a ReadTransformer, it defines transformation of database
- * column(s) value(s)into attribute value.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface WriteTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.FieldTransformer
- * interface. The class will be instantiated, its buildFieldValue
- * will be used to create the value to be written into the database
- * column. Note that for ddl generation and returning to be
- * supported the method buildFieldValue in the class should be
- * defined to return the relevant Java type, not just Object as
- * defined in the interface, for instance:
- * public Time buildFieldValue(Object instance, String fieldName, Session session).
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be written into the database column.
- * Note that for ddl generation and returning to be supported the
- * method should be defined to return a particular type, not just
- * Object, for instance:
- * public Time getStartTime().
- * The method may require a Transient annotation to avoid being
- * mapped as Basic by default.
- * Either transformerClass or method must be specified, but not both.
- */
- String method() default "";
-
- /**
- * Specify here the column into which the value should be written.
- * The only case when this could be skipped is if a single
- * WriteTransformer annotates an attribute - the attribute's name
- * will be used as a column name.
- */
- Column column() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <xsd:complexType name="batch-fetch">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A BatchFetch annotation can be used on any relationship mapping,
- * (OneToOne, ManyToOne, OneToMany, ManyToMany, ElementCollection, BasicCollection, BasicMap).
- * It allows the related objects to be batch read in a single query.
- * Batch fetching can also be set at the query level, and it is
- * normally recommended to do so as all queries may not require batching.
- *
- * @author James Sutherland
- * @since EclipseLink 2.1
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BatchFetch {
- /**
- * (Optional) The type of batch-fetch to use.
- * Either JOIN, EXISTS or IN.
- * JOIN is the default.
- */
- BatchFetchType value() default BatchFetchType.JOIN;
-
- /**
- * Define the default batch fetch size.
- * This is only used for IN type batch reading and defines
- * the number of keys used in each IN clause.
- * The default size is 256, or the query's pageSize for cursor queries.
- */
- int size() default -1;
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="type" type="orm:batch-fetch-type"/>
- <xsd:attribute name="size" type="xsd:integer"/>
- </xsd:complexType>
-
-</xsd:schema>
-
-
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_3.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_3.xsd
deleted file mode 100644
index fb0521a52f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_orm_2_3.xsd
+++ /dev/null
@@ -1,5479 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ******************************************************************************************************************************* -->
-<!-- Copyright (c) 1998, 2010 Oracle. All rights reserved. -->
-<!-- This program and the accompanying materials are made available under the -->
-<!-- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 -->
-<!-- which accompanies this distribution. -->
-<!-- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html -->
-<!-- and the Eclipse Distribution License is available at -->
-<!-- http://www.eclipse.org/org/documents/edl-v10.php. -->
-<!-- -->
-<!-- Contributors: -->
-<!-- Oracle - initial API and implementation from Oracle TopLink -->
-<!-- tware - update version number to 2.0 -->
-<!-- 12/2/2009-2.1 Guy Pelletier -->
-<!-- - 296289: Add current annotation metadata support on mapped superclasses to EclipseLink-ORM.XML Schema -->
-<!-- - 296612: Add current annotation only metadata support of return insert/update to the EclipseLink-ORM.XML Schema -->
-<!-- - formatted to match orm_2_0.xsd so that users can easily compare the two schemas -->
-<!-- 5/4/2010-2.1 Guy Pelletier -->
-<!-- - 227219: Expand EclipseLink-ORM.XML schema functionality for 2.1 release (update version to 2.1) -->
-<!-- 6/14/2010-2.2 Guy Pelletier -->
-<!-- - 247078: eclipselink-orm.xml schema should allow lob and enumerated on version and id mappings (update version to 2.2) -->
-<!-- 10/15/2010-2.2 Guy Pelletier -->
-<!-- - 322008: Improve usability of additional criteria applied to queries at the session/EM -->
-<!-- 03/23/2011-2.3 Guy Pelletier -->
-<!-- - 337323: Multi-tenant with shared schema support (part 1) -->
-<!-- ******************************************************************************************************************************* -->
-
-<!-- Java Persistence API object-relational mapping file schema -->
-<xsd:schema targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:orm="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="2.3">
-
- <xsd:annotation>
- <xsd:documentation>
- @(#)eclipselink_orm_2_3.xsd 2.3 March 23 2011
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:annotation>
- <xsd:documentation><![CDATA[
-
- This is the XML Schema for the native Eclipselink XML mapping file
- The file may be named "META-INF/eclipselink-orm.xml" in the persistence
- archive or it may be named some other name which would be
- used to locate the file as resource on the classpath.
- Object/relational mapping files must indicate the object/relational
- mapping file schema by using the persistence namespace:
-
- http://www.eclipse.org/eclipselink/xsds/persistence/orm
-
- and indicate the version of the schema by using the version element as shown below:
-
- <entity-mappings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm
- eclipselink_orm_2_3.xsd
- version="2.3">
- ...
- </entity-mappings>
-
- ]]></xsd:documentation>
- </xsd:annotation>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="emptyType"/>
-
- <xsd:simpleType name="versionType">
- <xsd:restriction base="xsd:token">
- <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <xsd:simpleType name="supported-versions-type">
- <xsd:restriction base="orm:versionType">
- <xsd:enumeration value="2.0"/>
- <xsd:enumeration value="2.1"/>
- <xsd:enumeration value="2.2"/>
- <xsd:enumeration value="2.3"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="access-methods">
- <xsd:annotation>
- <xsd:documentation>
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="get-method" type="xsd:string" use="required"/>
- <xsd:attribute name="set-method" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="additional-criteria">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An additional criteria can be specified at the Entity or MappedSuperclass
- * level. When specified at the mapped superclass level, it applies to all
- * inheriting entities unless those entities define their own additional
- * criteria, at which point the additional criteria from the mapped superclass
- * is ignored.
- *
- * The additional criteria supports any valid JPQL string and must use 'this'
- * as an alias to form your additional criteria. E.G.,
- *
- * @Entity
- * @AdditionalCriteria("this.nut.size = :NUT_SIZE and this.nut.color = :NUT_COLOR")
- * public class Bolt {...}
- *
- * Additional criteria parameters are also accepted and are set through
- * properties on the entity manager factory, or on an entity manager. When set
- * on the entity manager, the properties must be set before any query execution
- * and should not be changed for the life span of that entity manager.
- *
- * Properties set on the entity manager will override those similarly named
- * properties set on the entity manager factory.
- *
- * Additional criteria is not supported with any native queries.
- *
- * @author Guy Pelletier
- * @since EclipseLink 2.2
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface AdditionalCriteria {
- /**
- * (Required) The JPQL fragment to use as the additional criteria.
- */
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="criteria" type="xsd:string"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cache">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Cache annotation is used to set an
- * org.eclipse.persistence.descriptors.invalidation.CacheInvalidationPolicy
- * which sets objects in EclipseLink's identity maps to be invalid
- * following given rules. By default in EclipseLink, objects do not
- * expire in the cache. Several different policies are available to
- * allow objects to expire.
- *
- * @see org.eclipse.persistence.annotations.CacheType
- *
- * A Cache anotation may be defined on an Entity or MappedSuperclass.
- * In the case of inheritance, a Cache annotation should only be defined
- * on the root of the inheritance hierarchy.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Cache {
- /**
- * (Optional) The type of cache to use.
- */
- CacheType type() default SOFT_WEAK;
-
- /**
- * (Optional) The size of cache to use.
- */
- int size() default 100;
-
- /**
- * (Optional) Cached instances in the shared cache,
- * or only a per EntityManager isolated cache.
- * The default is shared.
- * @deprecated As of Eclipselink 2.2. See the attribute 'isolation'
- */
- @Deprecated
- boolean shared() default true;
-
- /**
- * (Optional) Controls the level of caching this Entity will use.
- * The default is CacheIsolationType.SHARED which has EclipseLink
- * Caching all Entities in the Shared Cache.
- * @see org.eclipse.persistence.config.CacheIsolationType
- */
- CacheIsolationType isolation() default SHARED;
-
- /**
- * (Optional) Expire cached instance after a fix period of time (ms).
- * Queries executed against the cache after this will be forced back
- * to the database for a refreshed copy
- */
- int expiry() default -1; // minus one is no expiry.
-
- /**
- * (Optional) Expire cached instance a specific time of day. Queries
- * executed against the cache after this will be forced back to the
- * database for a refreshed copy
- */
- TimeOfDay expiryTimeOfDay() default @TimeOfDay(specified=false);
-
- /**
- * (Optional) Force all queries that go to the database to always
- * refresh the cache.
- */
- boolean alwaysRefresh() default false;
-
- /**
- * (Optional) For all queries that go to the database, refresh the
- * cache only if the data received from the database by a query is
- * newer than the data in the cache (as determined by the optimistic
- * locking field)
- */
- boolean refreshOnlyIfNewer() default false;
-
- /**
- * (Optional) Setting to true will force all queries to bypass the
- * cache for hits but still resolve against the cache for identity.
- * This forces all queries to hit the database.
- */
- boolean disableHits() default false;
-
- /**
- * (Optional) The cache coordination mode.
- */
- CacheCoordinationType coordinationType() default SEND_OBJECT_CHANGES;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:choice>
- <xsd:element name="expiry" type="xsd:integer" minOccurs="0"/>
- <xsd:element name="expiry-time-of-day" type="orm:time-of-day" minOccurs="0"/>
- </xsd:choice>
- <xsd:attribute name="size" type="xsd:integer"/>
- <xsd:attribute name="shared" type="xsd:boolean"/>
- <xsd:attribute name="isolation" type="orm:cache-isolation-type"/>
- <xsd:attribute name="type" type="orm:cache-type"/>
- <xsd:attribute name="always-refresh" type="xsd:boolean"/>
- <xsd:attribute name="refresh-only-if-newer" type="xsd:boolean"/>
- <xsd:attribute name="disable-hits" type="xsd:boolean"/>
- <xsd:attribute name="coordination-type" type="orm:cache-coordination-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cache-interceptor">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface CacheInterceptor {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The CacheType enum is used with the Cache annotation for a
- * persistent class. It defines the type of IdentityMap/Cache used for
- * the class. By default the SOFT_WEAK cache type is used.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheType {
- /**
- * Provides full caching and guaranteed identity. Caches all objects
- * and does not remove them.
- * WARNING: This method may be memory intensive when many objects are
- * read.
- */
- FULL,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using weak references. This method allows full garbage
- * collection and provides full caching and guaranteed identity.
- */
- WEAK,
-
- /**
- * Similar to the FULL identity map except that the map holds the
- * objects using soft references. This method allows full garbage
- * collection when memory is low and provides full caching and
- * guaranteed identity.
- */
- SOFT,
-
- /**
- * Similar to the WEAK identity map except that it maintains a
- * most-frequently-used sub-cache. The size of the sub-cache is
- * proportional to the size of the identity map as specified by
- * descriptor's setIdentityMapSize() method. The sub-cache
- * uses soft references to ensure that these objects are
- * garbage-collected only if the system is low on memory.
- */
- SOFT_WEAK,
-
- /**
- * Identical to the soft cache weak (SOFT_WEAK) identity map except
- * that it uses hard references in the sub-cache. Use this identity
- * map if soft references do not behave properly on your platform.
- */
- HARD_WEAK,
-
- /**
- * A cache identity map maintains a fixed number of objects
- * specified by the application. Objects are removed from the cache
- * on a least-recently-used basis. This method allows object
- * identity for the most commonly used objects.
- * WARNING: Furnishes caching and identity, but does not guarantee
- * identity.
- */
- CACHE,
-
- /**
- * WARNING: Does not preserve object identity and does not cache
- * objects.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="FULL"/>
- <xsd:enumeration value="WEAK"/>
- <xsd:enumeration value="SOFT"/>
- <xsd:enumeration value="SOFT_WEAK"/>
- <xsd:enumeration value="HARD_WEAK"/>
- <xsd:enumeration value="CACHE"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-isolation-type">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * Options for how Entity instances should be shared within an EclipseLink Persistence Unit / ServerSession
- * @see ClassDescriptor#setCacheIsolationType(CacheIsolationType)
- * @author Gordon Yorke
- * @since EclipseLink 2.2
- */
- public enum CacheIsolationType {
-
- /**
- * Entity instances will be cached within the EntityManagerFactory/ServerSession level.
- * Any user queries for shared cache instances (ie Read-Only query hint) will return an Entity
- * instance that may be shared by multiple clients.
- *
- * This setting is the default isolation level.
- */
- SHARED,
-
- /**
- * Entity state information will be cached in the shared cache but Entity
- * instances will not be shared. Any user queries for shared cache instances
- * (ie Read-Only query hint) will return a new Entity instance with the cached state.
- * This will ensure the instance is <i>protected</i> from any concurrent
- * state change.
- */
- PROTECTED,
-
- /**
- * The Entity and its data is not stored in the shared cache but is
- * <i>isolated</i> to the Persistence Context/UnitOfWork or
- * IsolatedClientSession. This setting effectively disables second level
- * caching for this entity and should be used when users do not want caching for
- * a particular Entity.
- */
- ISOLATED;
-
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SHARED"/>
- <xsd:enumeration value="PROTECTED"/>
- <xsd:enumeration value="ISOLATED"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-coordination-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the Cache annotation.
- *
- * @see org.eclipse.persistence.annotations.Cache
- */
- public enum CacheCoordinationType {
- /**
- * Sends a list of changed objects including data about the changes.
- * This data is merged into the receiving cache.
- */
- SEND_OBJECT_CHANGES,
-
- /**
- * Sends a list of the identities of the objects that have changed.
- * The receiving cache invalidates the objects (rather than changing
- * any of the data)
- */
- INVALIDATE_CHANGED_OBJECTS,
-
- /**
- * Same as SEND_OBJECT_CHANGES except it also includes any newly
- * created objects from the transaction.
- */
- SEND_NEW_OBJECTS_WITH_CHANGES,
-
- /**
- * Does no cache coordination.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SEND_OBJECT_CHANGES"/>
- <xsd:enumeration value="INVALIDATE_CHANGED_OBJECTS"/>
- <xsd:enumeration value="SEND_NEW_OBJECTS_WITH_CHANGES"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="change-tracking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The ChangeTracking annotation is used to specify the
- * org.eclipse.persistence.descriptors.changetracking.ObjectChangePolicy
- * which computes changes sets for EclipseLink's UnitOfWork commit
- * process. An ObjectChangePolicy is stored on an Entity's descriptor.
- *
- * A ChangeTracking annotation may be specified on an Entity,
- * MappedSuperclass or Embeddable.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface ChangeTracking {
- /**
- * (Optional) The type of change tracking to use.
- */
- ChangeTrackingType value() default AUTO;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="type" type="orm:change-tracking-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="change-tracking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the ChangeTracking annotation.
- */
- public enum ChangeTrackingType {
- /**
- * An ATTRIBUTE change tracking type allows change tracking at the
- * attribute level of an object. Objects with changed attributes will
- * be processed in the commit process to include any changes in the
- * results of the commit. Unchanged objects will be ignored.
- */
- ATTRIBUTE,
-
- /**
- * An OBJECT change tracking policy allows an object to calculate for
- * itself whether it has changed. Changed objects will be processed in
- * the commit process to include any changes in the results of the
- * commit. Unchanged objects will be ignored.
- */
- OBJECT,
-
- /**
- * A DEFERRED change tracking policy defers all change detection to
- * the UnitOfWork's change detection process. Essentially, the
- * calculateChanges() method will run for all objects in a UnitOfWork.
- * This is the default ObjectChangePolicy
- */
- DEFERRED,
-
- /**
- * Will not set any change tracking policy.
- */
- AUTO
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ATTRIBUTE"/>
- <xsd:enumeration value="OBJECT"/>
- <xsd:enumeration value="DEFERRED"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="customizer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The Customizer annotation is used to specify a class that implements
- * the org.eclipse.persistence.config.DescriptorCustomizer
- * interface and is to run against an enetity's class descriptor after all
- * metadata processing has been completed.
- *
- * The Customizer annotation may be defined on an Entity, MappedSuperclass
- * or Embeddable class. In the case of inheritance, a Customizer is not
- * inherited from its parent classes.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Customizer {
- /**
- * (Required) Defines the name of the descriptor customizer class that
- * should be applied for the related entity or embeddable class.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="direction-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An enum that is used within the StoredProcedureParameter annotation.
- * It is used to specify the direction of the stored procedure
- * parameters of a named stored procedure query.
- */
- public enum Direction {
- /**
- * Input parameter
- */
- IN,
-
- /**
- * Output parameter
- */
- OUT,
-
- /**
- * Input and output parameter
- */
- IN_OUT,
-
- /**
- * Output cursor
- */
- OUT_CURSOR
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="IN"/>
- <xsd:enumeration value="OUT"/>
- <xsd:enumeration value="IN_OUT"/>
- <xsd:enumeration value="OUT_CURSOR"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:element name="entity-mappings">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
-
- The entity-mappings element is the root element of a mapping
- file. It contains the following four types of elements:
-
- 1. The persistence-unit-metadata element contains metadata
- for the entire persistence unit. It is undefined if this element
- occurs in multiple mapping files within the same persistence unit.
-
- 2. The package, schema, catalog and access elements apply to all of
- the entity, mapped-superclass and embeddable elements defined in
- the same file in which they occur.
-
- 3. The sequence-generator, table-generator, named-query,
- named-native-query and sql-result-set-mapping elements are global
- to the persistence unit. It is undefined to have more than one
- sequence-generator or table-generator of the same name in the same
- or different mapping files in a persistence unit. It is also
- undefined to have more than one named-query, named-native-query, or
- result-set-mapping of the same name in the same or different mapping
- files in a persistence unit.
-
- 4. The entity, mapped-superclass and embeddable elements each define
- the mapping information for a managed persistent class. The mapping
- information contained in these elements may be complete or it may
- be partial.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="persistence-unit-metadata"
- type="orm:persistence-unit-metadata"
- minOccurs="0"/>
- <xsd:element name="package" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type"
- minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0"/>
- <xsd:element name="tenant-discriminator-column" type="orm:tenant-discriminator-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="partitioning" type="orm:partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="replication-partitioning" type="orm:replication-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="round-robin-partitioning" type="orm:round-robin-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="pinned-partitioning" type="orm:pinned-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="range-partitioning" type="orm:range-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="value-partitioning" type="orm:value-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="hash-partitioning" type="orm:hash-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="union-partitioning" type="orm:union-partitioning" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-function-query" type="orm:named-stored-function-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-plsql-stored-procedure-query" type="orm:named-plsql-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-plsql-stored-function-query" type="orm:named-plsql-stored-function-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="plsql-record" type="orm:plsql-record" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="plsql-table" type="orm:plsql-table" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="mapped-superclass" type="orm:mapped-superclass"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="entity" type="orm:entity"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embeddable" type="orm:embeddable"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="version" type="orm:supported-versions-type"
- default="2.3" use="optional"/>
- </xsd:complexType>
- </xsd:element>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="existence-type">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * The ExistenceChecking annotation is used to specify the type of
- * checking EclipseLink should use when updating entities.
- *
- * An existence-checking specification is supported on an Entity or
- * MappedSuperclass annotation.
- */
- public @interface ExistenceChecking {
-
- /**
- * (Optional) Set the existence check for determining
- * if an insert or update should occur for an object.
- */
- ExistenceType value() default CHECK_CACHE;
- }
-
- /**
- * Assume that if the objects primary key does not include null and
- * it is in the cache, then it must exist.
- */
- CHECK_CACHE,
-
- /**
- * Perform does exist check on the database.
- */
- CHECK_DATABASE,
-
- /**
- * Assume that if the objects primary key does not include null then
- * it must exist. This may be used if the application guarantees or
- * does not care about the existence check.
- */
- ASSUME_EXISTENCE,
-
- /**
- * Assume that the object does not exist. This may be used if the
- * application guarantees or does not care about the existence check.
- * This will always force an insert to be called.
- */
- ASSUME_NON_EXISTENCE
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="CHECK_CACHE"/>
- <xsd:enumeration value="CHECK_DATABASE"/>
- <xsd:enumeration value="ASSUME_EXISTENCE"/>
- <xsd:enumeration value="ASSUME_NON_EXISTENCE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-metadata">
- <xsd:annotation>
- <xsd:documentation>
-
- Metadata that applies to the persistence unit and not just to
- the mapping file in which it is contained.
-
- If the xml-mapping-metadata-complete element is specified,
- the complete set of mapping metadata for the persistence unit
- is contained in the XML mapping files for the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="xml-mapping-metadata-complete" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-default-mappings" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="persistence-unit-defaults"
- type="orm:persistence-unit-defaults"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="persistence-unit-defaults">
- <xsd:annotation>
- <xsd:documentation>
-
- These defaults are applied to the persistence unit as a whole
- unless they are overridden by local annotation or XML
- element settings.
-
- schema - Used as the schema for all tables, secondary tables, join
- tables, collection tables, sequence generators, and table
- generators that apply to the persistence unit
- catalog - Used as the catalog for all tables, secondary tables, join
- tables, collection tables, sequence generators, and table
- generators that apply to the persistence unit
- delimited-identifiers - Used to treat database identifiers as
- delimited identifiers.
- access - Used as the access type for all managed classes in
- the persistence unit
- cascade-persist - Adds cascade-persist to the set of cascade options
- in all entity relationships of the persistence unit
- entity-listeners - List of default entity listeners to be invoked
- on each entity in the persistence unit.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="schema" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="catalog" type="xsd:string"
- minOccurs="0"/>
- <xsd:element name="delimited-identifiers" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="access" type="orm:access-type"
- minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods"
- minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="tenant-discriminator-column" type="orm:tenant-discriminator-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for an entity. Is allowed to be
- sparsely populated and used in conjunction with the annotations.
- Alternatively, the metadata-complete attribute can be used to
- indicate that no annotations on the entity class (and its fields
- or properties) are to be processed. If this is the case then
- the defaulting rules for the entity and its subelements will
- be recursively applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface Entity {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="multitenant" type="orm:multitenant" minOccurs="0"/>
- <xsd:element name="additional-criteria" type="orm:additional-criteria" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="table" type="orm:table" minOccurs="0"/>
- <xsd:element name="secondary-table" type="orm:secondary-table" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct" type="orm:struct" minOccurs="0"/>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="index" type="orm:index" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="inheritance" type="orm:inheritance" minOccurs="0"/>
- <xsd:choice>
- <xsd:sequence>
- <xsd:element name="discriminator-value" type="orm:discriminator-value" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/>
- </xsd:sequence>
- <xsd:element name="class-extractor" type="orm:class-extractor" minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking" minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="cache-interceptor" type="orm:cache-interceptor" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="fetch-group" type="orm:fetch-group" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-function-query" type="orm:named-stored-function-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-plsql-stored-procedure-query" type="orm:named-plsql-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-plsql-stored-function-query" type="orm:named-plsql-stored-function-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="plsql-record" type="orm:plsql-record" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="plsql-table" type="orm:plsql-table" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="query-redirectors" type="orm:query-redirectors" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="parent-class" type="xsd:string"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="cacheable" type="xsd:boolean"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:group name="partitioning-group">
- <xsd:sequence>
- <xsd:element name="partitioning" type="orm:partitioning" minOccurs="0"/>
- <xsd:element name="replication-partitioning" type="orm:replication-partitioning" minOccurs="0"/>
- <xsd:element name="round-robin-partitioning" type="orm:round-robin-partitioning" minOccurs="0"/>
- <xsd:element name="pinned-partitioning" type="orm:pinned-partitioning" minOccurs="0"/>
- <xsd:element name="range-partitioning" type="orm:range-partitioning" minOccurs="0"/>
- <xsd:element name="value-partitioning" type="orm:value-partitioning" minOccurs="0"/>
- <xsd:element name="hash-partitioning" type="orm:hash-partitioning" minOccurs="0"/>
- <xsd:element name="union-partitioning" type="orm:union-partitioning" minOccurs="0"/>
- <xsd:element name="partitioned" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- </xsd:group>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="access-type">
- <xsd:annotation>
- <xsd:documentation>
-
- This element determines how the persistence provider accesses the
- state of an entity or embedded object.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="PROPERTY"/>
- <xsd:enumeration value="FIELD"/>
- <xsd:enumeration value="VIRTUAL"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="association-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AssociationOverride {
- String name();
- JoinColumn[] joinColumns() default{};
- JoinTable joinTable() default @JoinTable;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- </xsd:choice>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="attribute-override">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface AttributeOverride {
- String name();
- Column column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="attributes">
- <xsd:annotation>
- <xsd:documentation>
-
- This element contains the entity field or property mappings.
- It may be sparsely populated to include only a subset of the
- fields or properties. If metadata-complete for the entity is true
- then the remainder of the attributes will be defaulted according
- to the default rules.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="id" type="orm:id"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded-id" type="orm:embedded-id"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="basic" type="orm:basic"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-collection" type="orm:basic-collection" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="basic-map" type="orm:basic-map" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="version" type="orm:version"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-one" type="orm:many-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-many" type="orm:one-to-many"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="one-to-one" type="orm:one-to-one"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="variable-one-to-one" type="orm:variable-one-to-one" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="many-to-many" type="orm:many-to-many"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="element-collection" type="orm:element-collection"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="embedded" type="orm:embedded"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transformation" type="orm:transformation" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="transient" type="orm:transient" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="structure" type="orm:structure" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="array" type="orm:array" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Basic {
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="index" type="orm:index" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="lob" type="orm:lob"/>
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="enumerated" type="orm:enumerated"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator" minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="return-insert" type="orm:return-insert" minOccurs="0"/>
- <xsd:element name="return-update" type="orm:emptyType" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicCollection {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the value column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:eclipselink-collection-table" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="basic-map">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BasicMap {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime that
- * the value must be eagerly fetched. The LAZY strategy is a hint to
- * the persistence provider runtime. If not specified, defaults to
- * LAZY.
- */
- FetchType fetch() default LAZY;
-
- /**
- * (Optional) The name of the data column that holds the direct map
- * key. If the name on te key column is "", the name will default to:
- * the name of the property or field; "_KEY".
- */
- Column keyColumn() default @Column;
-
- /**
- * (Optional) Specify the key converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the direct map key.
- */
- Convert keyConverter() default @Convert;
-
- /**
- * (Optional) The name of the data column that holds the direct
- * collection data. Defaults to the property or field name.
- */
- Column valueColumn() default @Column;
-
- /**
- * (Optional) Specify the value converter. Default is equivalent to
- * specifying @Convert("none"), meaning no converter will be added to
- * the value column mapping.
- */
- Convert valueConverter() default @Convert;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="key-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="key-converter" type="xsd:string" minOccurs="0"/>
- <xsd:element name="value-column" type="orm:column" minOccurs="0"/>
- <xsd:element name="value-converter" type="xsd:string" minOccurs="0"/>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:eclipselink-collection-table" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="cascade-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REFRESH, DETACH};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade-all" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-persist" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-merge" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-remove" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-refresh" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="cascade-detach" type="orm:emptyType"
- minOccurs="0"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="class-extractor">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A ClassExtractor allows for a user defined class indicator in place of
- * providing a discriminator column. The class has the following restrictions:
-
- * - It must extend the org.eclipse.persistence.descriptors.ClassExtractor
- * class and implement the extractClassFromRow(Record, Session) method.
- * - That method must take a database row (a Record/Map) as an argument and
- * must return the class to use for that row.
- *
- * This method will be used to decide which class to instantiate when reading
- * from the database. It is the application's responsibility to populate any
- * typing information in the database required to determine the class from the
- * row.
- *
- * The ClassExtractor must only be set on the root of an entity class or
- * sub-hierarchy in which a different inheritance strategy is applied. The
- * ClassExtractor can only be used with the SINGLE_TABLE and JOINED inheritance
- * strategies.
- *
- * If a ClassExtractor is used then a DiscriminatorColumn cannot be used. A
- * ClassExtractor also cannot be used on either the root or its subclasses.
- *
- * In addition, for more complex configurations using a ClassExtractor and a
- * SINGLE_TABLE strategy, the descriptor's withAllSubclasses and onlyInstances
- * expressions should be set through the ClassExtractor's initialize method.
- *
- * @see org.eclipse.persistence.descriptors.InheritancePolicy.setWithAllSubclassesExpression(Expression)
- * @see org.eclipse.persistence.descriptors.InheritancePolicy.setOnlyInstancesExpression(Expression)
- *
- * @author Guy Pelletier
- * @since EclipseLink 2.1
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface ClassExtractor {
- /**
- * (Required) Defines the name of the class extractor that should be
- * applied to this entity's descriptor.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="clone-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CloneCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.CloneCopyPolicy on an
- * Entity. A CloneCopyPolicy must specify at one or both of the "method"
- * or "workingCopyMethod". "workingCopyMethod" is used to clone objects
- * that will be returned to the user as they are registered in
- * EclipseLink's transactional mechanism, the UnitOfWork. "method" will
- * be used for the clone that is used for comparison in conjunction with
- * EclipseLink's DeferredChangeDetectionPolicy
- *
- * A CloneCopyPolicy should be specified on an Entity, MappedSuperclass
- * or Embeddable.
- *
- * Example:
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(method="myCloneMethod", workingCopyMethod="myWorkingCopyCloneMethod")
- *
- * or:
- *
- * @Entity
- * @CloneCopyPolicy(workingCopyMethodName="myWorkingCopyClone")
- */
- public @interface CloneCopyPolicy {
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified this defines
- * a method that will be used to create a clone that will be used
- * for comparison by
- * EclipseLink's DeferredChangeDetectionPolicy
- */
- String method();
-
- /**
- * (Optional)
- * Either method or workingCopyMethod must be specified
- * this defines a method that will be used to create a clone that
- * will be used to create the object returned when registering an
- * Object in an EclipseLink UnitOfWork
- */
- String workingCopyMethod();
-
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="method" type="xsd:string"/>
- <xsd:attribute name="working-copy-method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface CollectionTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string" />
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="eclipselink-collection-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface CollectionTable {
- /**
- * (Optional) The name of the collection table. If it is not
- * specified, it is defaulted to the concatenation of the following:
- * the name of the source entity; "_" ; the name of the relationship
- * property or field of the source entity.
- */
- String name() default "";
-
- /**
- * (Optional) The catalog of the table. It defaults to the persistence
- * unit default catalog.
- */
- String catalog() default "";
-
- /**
- * (Optional) The schema of the table. It defaults to the persistence
- * unit default schema.
- */
- String schema() default "";
-
- /**
- * (Optional) Used to specify a primary key column that is used as a
- * foreign key to join to another table. If the source entity uses a
- * composite primary key, a primary key join column must be specified
- * for each field of the composite primary key. In a single primary
- * key case, a primary key join column may optionally be specified.
- * Defaulting will apply otherwise as follows:
- * name, the same name as the primary key column of the primary table
- * of the source entity. referencedColumnName, the same name of
- * primary key column of the primary table of the source entity.
- */
- PrimaryKeyJoinColumn[] primaryKeyJoinColumns() default {};
-
- /**
- * (Optional) Unique constraints that are to be placed on the table.
- * These are only used if table generation is in effect.
- */
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column" type="orm:primary-key-join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string" />
- </xsd:complexType>
-
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Column {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="conversion-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface ConversionValue {
- /**
- * (Required) Specify the database value.
- */
- String dataValue();
-
- /**
- * (Required) Specify the object value.
- */
- String objectValue();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="data-value" type="xsd:string" use="required"/>
- <xsd:attribute name="object-value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Converter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must implement
- * the org.eclipse.persistence.mappings.converters.Converter interface.
- */
- Class converterClass();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A Partitioning is used to partition the data for a class across multiple difference databases
- * or across a database cluster such as Oracle RAC.
- * Partitioning can provide improved scalability by allowing multiple database machines to service requests.
- * This annotation configures a custom PartitioningPolicy.
- *
- * If multiple partitions are used to process a single transaction, JTA should be used for proper XA transaction support.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- * Partition policies are globally named to allow reuse,
- * the partitioning policy must also be set using the @Partitioned annotation to be used.
- *
- * @see Partitioned
- * @see org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Partitioning {
- String name();
-
- /**
- * (Required) Full package.class name of a subclass of PartitioningPolicy.
- */
- Class partitioningClass();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="hash-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * HashPartitioning partitions access to a database cluster by the hash of a field value from the object,
- * such as the object's location, or tenant.
- * The hash indexes into the list of connection pools.
- * All write or read request for object's with that hash value are sent to the server.
- * If a query does not include the field as a parameter, then it can either be sent
- * to all server's and unioned, or left to the sesion's default behavior.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.HashPartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface HashPartitioning {
- String name();
-
- /**
- * The database column or query parameter to partition queries by.
- * This is the table column name, not the class attribute name.
- * The column value must be included in the query and should normally be part of the object's Id.
- * This can also be the name of a query parameter.
- * If a query does not contain the field the query will not be partitioned.
- */
- Column partitionColumn();
-
- /**
- * List of connection pool names to partition across.
- */
- String[] connectionPools();
-
- /**
- * Defines if queries that do not contain the partition field should be sent
- * to every database and have the result unioned.
- */
- boolean unionUnpartitionableQueries() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="partition-column" type="orm:column"/>
- <xsd:element name="connection-pool" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="union-unpartitionable-queries" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="range-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * RangePartitioningPolicy partitions access to a database cluster by a field value from the object,
- * such as the object's id, location, or tenant.
- * Each server is assigned a range of values.
- * All write or read request for object's with that value are sent to the server.
- * If a query does not include the field as a parameter, then it can either be sent
- * to all server's and unioned, or left to the sesion's default behavior.
- *
- * If multiple partitions are used to process a single transaction, JTA should be used for proper XA transaction support.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- * Partition policies are globally named to allow reuse,
- * the partitioning policy must also be set using the @Partitioned annotation to be used.
- *
- * @see Partitioned
- * @see org.eclipse.persistence.descriptors.partitioning.RangePartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface RangePartitioning {
- String name();
-
- /**
- * The database column or query parameter to partition queries by.
- * This is the table column name, not the class attribute name.
- * The column value must be included in the query and should normally be part of the object's Id.
- * This can also be the name of a query parameter.
- * If a query does not contain the field the query will not be partitioned.
- */
- Column partitionColumn();
-
- /**
- * (Required) List of connection pool names to load balance across.
- */
- RangePartition[] partitions();
-
- /**
- * Defines if queries that do not contain the partition field should be sent
- * to every database and have the result unioned.
- */
- boolean unionUnpartitionableQueries() default false;
-
- /** The type of the start and end values. */
- Class partitionValueType() default String.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="partition-column" type="orm:column"/>
- <xsd:element name="partition" type="orm:range-partition" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="union-unpartitionable-queries" type="xsd:boolean"/>
- <xsd:attribute name="partition-value-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="range-partition">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Represent a specific range partition.
- * Values = startValue and = endValue will be routed to the connection pool.
- *
- * @see RangePartitioningPolicy
- * @see org.eclipse.persistence.descriptors.partitioning.RangePartitioningPolicy
- * @see org.eclipse.persistence.descriptors.partitioning.RangePartition
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface RangePartition {
- /** The String representation of the range start value. */
- String startValue() default "";
- /** The String representation of the range start value. */
- String endValue() default "";
- /** The connection pool to route queries to for this range. */
- String connectionPool();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="start-value" type="xsd:string"/>
- <xsd:attribute name="end-value" type="xsd:string"/>
- <xsd:attribute name="connection-pool" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="value-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * ValuePartitioning partitions access to a database cluster by a field value from the object,
- * such as the object's location, or tenant.
- * Each value is assigned a specific server.
- * All write or read request for object's with that value are sent to the server.
- * If a query does not include the field as a parameter, then it can either be sent
- * to all server's and unioned, or left to the sesion's default behavior.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.ValuePartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ValuePartitioning {
- String name();
-
- /**
- * The database column or query parameter to partition queries by.
- * This is the table column name, not the class attribute name.
- * The column value must be included in the query and should normally be part of the object's Id.
- * This can also be the name of a query parameter.
- * If a query does not contain the field the query will not be partitioned.
- */
- Column partitionColumn();
-
- /** Store the value partitions. Each partition maps a value to a connectionPool. */
- ValuePartition[] partitions();
-
- /** The type of the start and end values. */
- Class partitionValueType() default String.class;
-
- /** The default connection pool is used for any unmapped values. */
- String defaultConnectionPool();
-
- /**
- * Defines if queries that do not contain the partition field should be sent
- * to every database and have the result unioned.
- */
- boolean unionUnpartitionableQueries() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="partition-column" type="orm:column"/>
- <xsd:element name="partition" type="orm:value-partition" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="union-unpartitionable-queries" type="xsd:boolean"/>
- <xsd:attribute name="default-connection-pool" type="xsd:string"/>
- <xsd:attribute name="partition-value-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="value-partition">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Represent a specific value partition.
- * The value will be routed to the connection pool.
- *
- * @see ValuePartitioningPolicy
- * @see org.eclipse.persistence.descriptors.partitioning.ValuePartitioningPolicy
- * @see org.eclipse.persistence.descriptors.partitioning.ValuePartition
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ValuePartition {
- /** The String representation of the range start value. */
- String value() default "";
-
- /** The connection pool to route queries to for this value. */
- String connectionPool();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- <xsd:attribute name="connection-pool" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="round-robin-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * RoundRobinPartitioning sends requests in a round robin fashion to the set of connection pools.
- * It is for load-balancing read queries across a cluster of database machines.
- * It requires that the full database be replicated on each machine, so does not support partitioning.
- * The data should either be read-only, or writes should be replicated on the database.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.RoundRobinPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface RoundRobinPartitioning {
- String name();
-
- /**
- * (Required) List of connection pool names to load balance across.
- */
- String[] connectionPools();
-
- /**
- * This allows for a set of database to be written to and kept in synch,
- * and have reads load-balanced across the databases.
- */
- boolean replicateWrites() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="connection-pool" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="replicate-writes" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="replication-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * ReplicationPartitioning sends requests to a set of connection pools.
- * It is for replicating data across a cluster of database machines.
- * Only modification queries are replicated.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.ReplicationPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReplicationPartitioning {
- String name();
-
- /**
- * (Required) List of connection pool names to load balance across.
- */
- String[] connectionPools();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="connection-pool" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="union-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * UnionPartitioning sends queries to all connection pools and unions the results.
- * This is for queries or relationships that span partitions when partitioning is used,
- * such as on a ManyToMany cross partition relationship.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.UnionPartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface UnionPartitioning {
- String name();
-
- /**
- * (Required) List of connection pool names to load balance across.
- */
- String[] connectionPools();
-
- /**
- * Defines if write queries should be replicated.
- * Writes are normally not replicated when unioning,
- * but can be for ManyToMany relationships, when the join table needs to be replicated.
- */
- boolean replicateWrites() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="connection-pool" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="replicate-writes" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pinned-partitioning">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * PinnedPartitioning pins requests to a single connection pool.
- *
- * Partitioning can be enabled on an Entity, relationship, query, or session/persistence unit.
- *
- * @see org.eclipse.persistence.descriptors.partitioning.PinnedPartitioningPolicy
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface PinnedPartitioning {
- String name();
-
- /**
- * The connection pool name to pin queries to.
- */
- String connectionPool();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="connection-pool" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="column-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface ColumnResult {
- String name();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A CopyPolicy is used to set a
- * org.eclipse.persistence.descriptors.copying.CopyPolicy on an Entity.
- * It is required that a class that implements
- * org.eclipse.persistence.descriptors.copying.CopyPolicy be specified
- * as the argument.
- *
- * A CopyPolicy should be specified on an Entity, MappedSuperclass or
- * Embeddable.
- *
- * For instance:
- * @Entity
- * @CopyPolicy("example.MyCopyPolicy")
- */
- public @interface CopyPolicy {
-
- /*
- * (Required)
- * This defines the class of the copy policy. It must specify a class
- * that implements org.eclipse.persistence.descriptors.copying.CopyPolicy
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorColumn {
- String name() default "DTYPE";
- DiscriminatorType discriminatorType() default STRING;
- String columnDefinition() default "";
- int length() default 31;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="discriminator-type" type="orm:discriminator-type"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="discriminator-class">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A DiscriminatorClass is used within a VariableOneToOne annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface DiscriminatorClass {
- /**
- * (Required) The discriminator to be stored on the database.
- */
- String discriminator();
-
- /**
- * (Required) The class to the instantiated with the given
- * discriminator.
- */
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="discriminator" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum DiscriminatorType { STRING, CHAR, INTEGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="STRING"/>
- <xsd:enumeration value="CHAR"/>
- <xsd:enumeration value="INTEGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="discriminator-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface DiscriminatorValue {
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="element-collection">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ElementCollection {
- Class targetClass() default void.class;
- FetchType fetch() default LAZY;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by"
- minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key"
- minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class"
- minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="map-key-enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column"
- type="orm:map-key-column"
- minOccurs="0"/>
- <xsd:element name="map-key-join-column"
- type="orm:map-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="lob"
- type="orm:lob"
- minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- </xsd:choice>
- </xsd:sequence>
- <xsd:sequence>
- <xsd:element name="attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="collection-table" type="orm:collection-table"
- minOccurs="0"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-class" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- <xsd:attribute name="composite-member" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="array">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Array types are extended object-relational data-types supported by some databases.
- * Array types are user define types in the database such as VARRAY types on Oracle.
- * Arrays can contains basic types (VARCHAR) or other Struct types, and can be stored in
- * a column or in a Struct type.
- * This annotation can be defined on a collection attribute that is
- * persisted to an Array type. The collection can be of basic types, or embeddable
- * class mapped using a Struct.
- *
- * @see org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor
- * @see org.eclipse.persistence.mappings.structures.ArrayMapping
- * @see org.eclipse.persistence.mappings.structures.ObjectArrayMapping
- * @author James Sutherland
- * @since EclipseLink 2.3
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Array {
- /**
- * (Optional) The basic or embeddable class that is the element
- * type of the collection. This element is optional only if the
- * collection field or property is defined using Java generics,
- * and must be specified otherwise. It defaults to the
- * paramterized type of the collection when defined using
- * generics.
- */
- Class targetClass() default void.class;
-
- /**
- * (Required) The database name of the database array structure type.
- */
- String databaseType();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="lob"
- type="orm:lob"
- minOccurs="0"/>
- <xsd:element name="convert" type="xsd:string" minOccurs="0"/>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="2">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="database-type" type="xsd:string" use="required"/>
- <xsd:attribute name="target-class" type="xsd:string"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embeddable">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for embeddable objects. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- in the class. If this is the case then the defaulting rules will
- be recursively applied.
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Embeddable {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="struct" type="orm:struct" minOccurs="0"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="plsql-record" type="orm:plsql-record" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="plsql-table" type="orm:plsql-table" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="parent-class" type="xsd:string"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Embedded {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="embedded-id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface EmbeddedId {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-listener">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines an entity listener to be invoked at lifecycle events
- for the entities that list this listener.
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-listeners">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface EntityListeners {
- Class[] value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="entity-listener" type="orm:entity-listener"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="entity-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface EntityResult {
- Class entityClass();
- FieldResult[] fields() default {};
- String discriminatorColumn() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field-result" type="orm:field-result"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="entity-class" type="xsd:string" use="required"/>
- <xsd:attribute name="discriminator-column" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="enum-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum EnumType {
- ORDINAL,
- STRING
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ORDINAL"/>
- <xsd:enumeration value="STRING"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="enumerated">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Enumerated {
- EnumType value() default ORDINAL;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:enum-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="fetch-attribute">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface FetchAttribute {
- /**
- * (Required) The fetch attribute name.
- */
- String name();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="fetch-group">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface FetchGroup {
- /**
- * (Required) The fetch group name.
- */
- String name();
-
- /**
- * (Optional) Indicates whether all relationship attributes
- * specified in the fetch group should be loaded.
- */
- boolean load() default true;
-
- /**
- * (Required) The list of attributes to fetch.
- */
- FetchAttribute[] attributes();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="attribute" type="orm:fetch-attribute" minOccurs="1" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="load" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum FetchType { LAZY, EAGER };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="LAZY"/>
- <xsd:enumeration value="EAGER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="field-result">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface FieldResult {
- String name();
- String column();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="column" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="generated-value">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface GeneratedValue {
- GenerationType strategy() default AUTO;
- String generator() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:generation-type"/>
- <xsd:attribute name="generator" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="generation-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO };
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="TABLE"/>
- <xsd:enumeration value="SEQUENCE"/>
- <xsd:enumeration value="IDENTITY"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="id">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Id {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"
- minOccurs="0"/>
- <xsd:element name="index" type="orm:index" minOccurs="0"/>
- <xsd:element name="generated-value" type="orm:generated-value"
- minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="enumerated" type="orm:enumerated"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="id-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface IdClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="id-validation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The IdValidation enum determines the type value that are valid for an Id.
- * By default null is not allowed, and 0 is not allow for singleton ids of long or int type.
- * The default value is ZERO for singleton ids, and NULL for composite ids.
- * This can be set using the @PrimaryKey annotation, or ClassDescriptor API.
- *
- * @see PrimaryKey
- * @see org.eclipse.persistence.descriptors.ClassDescriptor#setIdValidation(IdValidation)
- * @author James Sutherland
- * @since EclipseLink 1.0
- */
- public enum IdValidation {
- /**
- * Only null is not allowed as an id value, 0 is allowed.
- */
- NULL,
-
- /**
- * null and 0 are not allowed, (only int and long).
- */
- ZERO,
-
- /**
- * No id validation is done.
- */
- NONE
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="NULL"/>
- <xsd:enumeration value="ZERO"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="cache-key-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Configures what type of Id value is used to store the object in the cache.
- * This can either be the basic Id value for simple singleton Ids,
- * or an optimized CacheKey type.
- *
- * @see PrimaryKey#cacheKeyType()
- * @see ClassDescriptor#setCacheKeyType(CacheKeyType)
- * @author James Sutherland
- * @since EclipseLink 2.1
- */
- public enum CacheKeyType {
- /**
- * This can only be used for simple singleton Ids, such as long/int/String.
- * This is the default for simple singleton Ids.
- */
- ID_VALUE,
-
- /**
- * Optimized cache key type that allows composite and complex values.
- * This is the default for composite or complex Ids.
- */
- CACHE_KEY,
-
- /**
- * The cache key type is automatically configured depending on what is optimal for the class.
- */
- AUTO
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ID_VALUE"/>
- <xsd:enumeration value="CACHE_KEY"/>
- <xsd:enumeration value="AUTO"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="inheritance">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Inheritance {
- InheritanceType strategy() default SINGLE_TABLE;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="strategy" type="orm:inheritance-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="inheritance-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum InheritanceType
- { SINGLE_TABLE, JOINED, TABLE_PER_CLASS};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SINGLE_TABLE"/>
- <xsd:enumeration value="JOINED"/>
- <xsd:enumeration value="TABLE_PER_CLASS"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="instantiation-copy-policy">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * An InstantiationCopyPolicy is used to set an
- * org.eclipse.persistence.descriptors.copying.InstantiationCopyPolicy
- * on an Entity. InstantiationCopyPolicy is the default CopyPolicy in
- * EclipseLink and therefore this configuration option is only used to
- * override other types of copy policies
- *
- * An InstantiationCopyPolicy should be specified on an Entity,
- * MappedSuperclass or Embeddable.
- *
- * Example:
- * @Entity
- * @InstantiationCopyPolicy
- */
- public @interface InstantiationCopyPolicy {
- }
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum JoinFetchType {
- /**
- * An inner join is used to fetch the related object.
- * This does not allow for null/empty values.
- */
- INNER,
-
- /**
- * An inner join is used to fetch the related object.
- * This allows for null/empty values.
- */
- OUTER,
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="INNER"/>
- <xsd:enumeration value="OUTER"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="batch-fetch-type">
- <xsd:annotation>
- <xsd:documentation>
- public enum BatchFetchType {
- /**
- * This is the default form of batch reading.
- * The original query's selection criteria is joined with the batch query.
- */
- JOIN,
-
- /**
- * This uses an SQL EXISTS and a sub-select in the batch query instead of a join.
- * This has the advantage of not requiring an SQL DISTINCT which can have issues
- * with LOBs, or may be more efficient for some types of queries or on some databases.
- */
- EXISTS,
-
- /**
- * This uses an SQL IN clause in the batch query passing in the source object Ids.
- * This has the advantage of only selecting the objects not already contained in the cache,
- * and can work better with cursors, or if joins cannot be used.
- * This may only work for singleton Ids on some databases.
- */
- IN
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="JOIN"/>
- <xsd:enumeration value="EXISTS"/>
- <xsd:enumeration value="IN"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="join-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface JoinTable {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- JoinColumn[] joinColumns() default {};
- JoinColumn[] inverseJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="inverse-join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string" />
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="lob">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Lob {}
-
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="lock-mode-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum LockModeType { READ, WRITE, OPTIMISTIC, OPTIMISTIC_FORCE_INCREMENT, PESSIMISTIC_READ, PESSIMISTIC_WRITE, PESSIMISTIC_FORCE_INCREMENT, NONE};
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="READ"/>
- <xsd:enumeration value="WRITE"/>
- <xsd:enumeration value="OPTIMISTIC"/>
- <xsd:enumeration value="OPTIMISTIC_FORCE_INCREMENT"/>
- <xsd:enumeration value="PESSIMISTIC_READ"/>
- <xsd:enumeration value="PESSIMISTIC_WRITE"/>
- <xsd:enumeration value="PESSIMISTIC_FORCE_INCREMENT"/>
- <xsd:enumeration value="NONE"/>
-
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="many-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by"
- minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key"
- minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class"
- minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="map-key-enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column"
- minOccurs="0"/>
- <xsd:element name="map-key-join-column"
- type="orm:map-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="many-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface ManyToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="maps-id" type="xsd:string"/>
- <xsd:attribute name="id" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKey {
- String name() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key-class">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyClass {
- Class value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyColumn {
- String name() default "";
- boolean unique() default false;
- boolean nullable() default false;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- int length() default 255;
- int precision() default 0; // decimal precision
- int scale() default 0; // decimal scale
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="precision" type="xsd:int"/>
- <xsd:attribute name="scale" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="map-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface MapKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- boolean unique() default false;
- boolean nullable() default false;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- String table() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="mapped-superclass">
- <xsd:annotation>
- <xsd:documentation>
-
- Defines the settings and mappings for a mapped superclass. Is
- allowed to be sparsely populated and used in conjunction with
- the annotations. Alternatively, the metadata-complete attribute
- can be used to indicate that no annotations are to be processed
- If this is the case then the defaulting rules will be recursively
- applied.
-
- @Target(TYPE) @Retention(RUNTIME)
- public @interface MappedSuperclass{}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="multitenant" type="orm:multitenant" minOccurs="0"/>
- <xsd:element name="additional-criteria" type="orm:additional-criteria" minOccurs="0"/>
- <xsd:element name="customizer" type="orm:customizer" minOccurs="0"/>
- <xsd:element name="change-tracking" type="orm:change-tracking" minOccurs="0"/>
- <xsd:element name="id-class" type="orm:id-class" minOccurs="0"/>
- <xsd:element name="primary-key" type="orm:primary-key" minOccurs="0"/>
- <xsd:element name="optimistic-locking" type="orm:optimistic-locking" minOccurs="0"/>
- <xsd:element name="cache" type="orm:cache" minOccurs="0"/>
- <xsd:element name="cache-interceptor" type="orm:cache-interceptor" minOccurs="0"/>
- <xsd:element name="fetch-group" type="orm:fetch-group" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="converter" type="orm:converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="type-converter" type="orm:type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="struct-converter" type="orm:struct-converter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="copy-policy" type="orm:copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="instantiation-copy-policy" type="orm:instantiation-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="clone-copy-policy" type="orm:clone-copy-policy" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="sequence-generator" type="orm:sequence-generator"
- minOccurs="0"/>
- <xsd:element name="table-generator" type="orm:table-generator"
- minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- <xsd:element name="named-query" type="orm:named-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-native-query" type="orm:named-native-query"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-procedure-query" type="orm:named-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-stored-function-query" type="orm:named-stored-function-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-plsql-stored-procedure-query" type="orm:named-plsql-stored-procedure-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="named-plsql-stored-function-query" type="orm:named-plsql-stored-function-query" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="plsql-record" type="orm:plsql-record" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="plsql-table" type="orm:plsql-table" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="sql-result-set-mapping"
- type="orm:sql-result-set-mapping"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="query-redirectors" type="orm:query-redirectors" minOccurs="0" maxOccurs="1"/>
- <xsd:element name="exclude-default-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="exclude-superclass-listeners" type="orm:emptyType"
- minOccurs="0"/>
- <xsd:element name="entity-listeners" type="orm:entity-listeners"
- minOccurs="0"/>
- <xsd:element name="pre-persist" type="orm:pre-persist" minOccurs="0"/>
- <xsd:element name="post-persist" type="orm:post-persist"
- minOccurs="0"/>
- <xsd:element name="pre-remove" type="orm:pre-remove" minOccurs="0"/>
- <xsd:element name="post-remove" type="orm:post-remove" minOccurs="0"/>
- <xsd:element name="pre-update" type="orm:pre-update" minOccurs="0"/>
- <xsd:element name="post-update" type="orm:post-update" minOccurs="0"/>
- <xsd:element name="post-load" type="orm:post-load" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attribute-override" type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="association-override"
- type="orm:association-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="attributes" type="orm:attributes" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="class" type="xsd:string" use="required"/>
- <xsd:attribute name="parent-class" type="xsd:string"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="cacheable" type="xsd:boolean"/>
- <xsd:attribute name="metadata-complete" type="xsd:boolean"/>
- <xsd:attribute name="read-only" type="xsd:boolean"/>
- <xsd:attribute name="existence-checking" type="orm:existence-type"/>
- <xsd:attribute name="exclude-default-mappings" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="multitenant">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface Multitenant {
- /**
- * (Optional) Specify the multi-tenant strategy to use.
- */
- MultitenantType value() default MultitenantType.SINGLE_TABLE;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="tenant-discriminator-column" type="orm:tenant-discriminator-column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="type" type="orm:multitenant-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="multitenant-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum MultitenantType {
- /**
- * Specifies that table(s) the entity maps to includes rows for multiple
- * tenants. The tenant discriminator column(s) are used with application
- * context values to limit what a persistence context can access.
- */
- SINGLE_TABLE,
-
- /**
- * Specifies that different tables are used for each tenant. The table scan
- * be uniquely identified by name, schema/tablespace.
- */
- TABLE_PER_TENANT,
-
- /**
- * Specifies that the DB will handle the tenant filtering on all SELECT,
- * UPDATE and DELETE queries. Using this type assumes that the platform
- * used with your persistence unit does indeed support VPD.
- */
- VPD
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="SINGLE_TABLE"/>
- <xsd:enumeration value="TABLE_PER_TENANT"/>
- <xsd:enumeration value="VPD"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-native-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedNativeQuery {
- String name();
- String query();
- QueryHint[] hints() default {};
- Class resultClass() default void.class;
- String resultSetMapping() default ""; //named SqlResultSetMapping
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="hint" type="orm:query-hint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-query">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface NamedQuery {
- String name();
- String query();
- LockModeType lockMode() default NONE;
- QueryHint[] hints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="query" type="xsd:string"/>
- <xsd:element name="lock-mode" type="orm:lock-mode-type" minOccurs="0"/>
- <xsd:element name="hint" type="orm:query-hint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-stored-procedure-query">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A NamedStoredProcedureQuery annotation allows the definition of
- * queries that call stored procedures as named queries.
- * A NamedStoredProcedureQuery annotation may be defined on an Entity or
- * MappedSuperclass.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface NamedStoredProcedureQuery {
- /**
- * (Required) Unique name that references this stored procedure query.
- */
- String name();
-
- /**
- * (Optional) Query hints.
- */
- QueryHint[] hints() default {};
-
- /**
- * (Optional) Refers to the class of the result.
- */
- Class resultClass() default void.class;
-
- /**
- * (Optional) The name of the SQLResultMapping.
- */
- String resultSetMapping() default "";
-
- /**
- * (Required) The name of the stored procedure.
- */
- String procedureName();
-
- /**
- * (Optional) Whether the query should return a result set.
- */
- boolean returnsResultSet() default true;
-
- /**
- * (Optional) Defines if the stored procedure returns multiple result sets.
- * This is only relevant on databases that support multiple result sets from stored procedures.
- */
- boolean multipleResultSets() default false;
-
- /**
- * (Optional) Defines if the stored procedure should be called by index or by name.
- * By index requires that the StoredProcedureParameter are defined in the same order as the procedure on the database.
- * By name requires the database platform support naming procedure parameters.
- */
- boolean callByIndex() default false;
-
- /**
- * (Optional) Defines arguments to the stored procedure.
- */
- StoredProcedureParameter[] parameters() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="parameter" type="orm:stored-procedure-parameter" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- <xsd:attribute name="procedure-name" type="xsd:string" use="required"/>
- <xsd:attribute name="returns-result-set" type="xsd:boolean"/>
- <xsd:attribute name="multiple-result-sets" type="xsd:boolean"/>
- <xsd:attribute name="call-by-index" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-stored-function-query">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A NamedStoredFunctionQuery annotation allows the definition of
- * queries that call stored function as named queries.
- * A NamedStoredFunctionQuery annotation may be defined on an Entity or
- * MappedSuperclass.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface NamedStoredFunctionQuery {
- /**
- * (Required) Unique name that references this stored procedure query.
- */
- String name();
-
- /**
- * (Optional) Query hints.
- */
- QueryHint[] hints() default {};
-
- /**
- * (Optional) The name of the SQLResultMapping.
- */
- String resultSetMapping() default "";
-
- /**
- * (Required) The name of the stored procedure.
- */
- String functionName();
-
- /**
- * (Optional) Defines if the stored procedure should be called by index or by name.
- * By index requires that the StoredProcedureParameter are defined in the same order as the procedure on the database.
- * By name requires the database platform support naming procedure parameters.
- */
- boolean callByIndex() default false;
-
- /**
- * (Optional) Defines arguments to the stored procedure.
- */
- StoredProcedureParameter[] parameters() default {};
-
- /**
- * (Required) Defines return of the stored function.
- */
- StoredProcedureParameter[] returnParameter();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="parameter" type="orm:stored-procedure-parameter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="return-parameter" type="orm:stored-procedure-parameter" minOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- <xsd:attribute name="function-name" type="xsd:string" use="required"/>
- <xsd:attribute name="call-by-index" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-plsql-stored-function-query">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A NamedPLSQLStoredFunctionQuery annotation allows the definition of queries that
- * call PLSQL stored functions as named queries.
- * The PLSQL support adds support for complex PLSQL types such as RECORD and TABLE types,
- * that are not accessible from JDBC.
- *
- * A NamedPLSQLStoredFunctionQuery annotation may be defined on an Entity or
- * MappedSuperclass.
- *
- * @author James Sutherland
- * @since EclipseLink 2.3
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface NamedPLSQLStoredFunctionQuery {
- /**
- * (Required) Unique name that references this stored procedure query.
- */
- String name();
-
- /**
- * (Optional) Query hints.
- */
- QueryHint[] hints() default {};
-
- /**
- * (Optional) The name of the SQLResultMapping.
- */
- String resultSetMapping() default "";
-
- /**
- * (Required) The name of the stored procedure.
- */
- String functionName();
-
- /**
- * (Optional) Defines the parameters to the stored procedure.
- */
- PLSQLParameter[] parameters() default {};
-
- /**
- * (Required) Defines the return value of the stored function.
- */
- PLSQLParameter returnParameter();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="parameter" type="orm:plsql-parameter" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="return-parameter" type="orm:plsql-parameter" minOccurs="1"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- <xsd:attribute name="function-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="named-plsql-stored-procedure-query">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A PLSQLNamedStoredProcedureQuery annotation allows the definition of queries that
- * call PLSQL stored procedures as named queries.
- * The PLSQL support adds support for complex PLSQL types such as RECORD and TABLE types,
- * that are not accessible from JDBC.
- *
- * A PLSQLNamedStoredProcedureQuery annotation may be defined on an Entity or
- * MappedSuperclass.
- *
- * @author James Sutherland
- * @since EclipseLink 2.3
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface NamedPLSQLStoredProcedureQuery {
- /**
- * (Required) Unique name that references this stored procedure query.
- */
- String name();
-
- /**
- * (Optional) Query hints.
- */
- QueryHint[] hints() default {};
-
- /**
- * (Optional) Refers to the class of the result.
- */
- Class resultClass() default void.class;
-
- /**
- * (Optional) The name of the SQLResultMapping.
- */
- String resultSetMapping() default "";
-
- /**
- * (Required) The name of the stored procedure.
- */
- String procedureName();
-
- /**
- * (Optional) Defines the parameters to the stored procedure.
- */
- PLSQLParameter[] parameters() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="hint" type="orm:query-hint" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="parameter" type="orm:plsql-parameter" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="result-class" type="xsd:string"/>
- <xsd:attribute name="result-set-mapping" type="xsd:string"/>
- <xsd:attribute name="procedure-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="plsql-record">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A PLSQLRecord annotation is used to define a database PLSQL RECORD type.
- * This type can be used within PLSQL procedure calls.
- *
- * @see NamedPLSQLStoredProcedureQuery
- * @author James Sutherland
- * @since EclipseLink 2.3
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface PLSQLRecord {
-
- /**
- * (Required) The name of the record type in the database.
- */
- String name();
-
- /**
- * (Required) The name of the database OBJECT TYPE that mirrors the record's structure.
- * The record will be converted to/from this type so it can be passed through JDBC.
- */
- String compatibleType();
-
- /**
- * (Optional) The Java class to map the object-type to.
- * This class must be mapped using a @Struct annotation.
- */
- Class javaType() default void.class;
-
- /**
- * (Required) Defines the fields in the record type.
- */
- PLSQLParameter[] fields();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field" type="orm:plsql-parameter" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="compatible-type" type="xsd:string"/>
- <xsd:attribute name="java-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="plsql-table">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A PLSQLRecord annotation is used to define a database PLSQL RECORD type.
- * This type can be used within PLSQL procedure calls.
- *
- * @see NamedPLSQLStoredProcedureQuery
- * @author James Sutherland
- * @since EclipseLink 2.3
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface PLSQLRecord {
-
- /**
- * (Required) The name of the record type in the database.
- */
- String name();
-
- /**
- * (Required) The name of the database OBJECT TYPE that mirrors the record's structure.
- * The record will be converted to/from this type so it can be passed through JDBC.
- */
- String compatibleType();
-
- /**
- * (Optional) The Java class to map the object-type to.
- * This class must be mapped using a @Struct annotation.
- */
- Class javaType() default void.class;
-
- /**
- * (Required) Defines the fields in the record type.
- */
- PLSQLParameter[] fields();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="compatible-type" type="xsd:string"/>
- <xsd:attribute name="java-type" type="xsd:string"/>
- <xsd:attribute name="nested-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="object-type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ObjectTypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence
- * field or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent
- * field or property.
- */
- Class objectType() default void.class;
-
- /**
- * (Required) Specify the conversion values to be used
- * with the object converter.
- */
- ConversionValue[] conversionValues();
-
- /**
- * (Optional) Specify a default object value. Used for
- * legacy data if the data value is missing.
- */
- String defaultObjectValue() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="conversion-value" type="orm:conversion-value" minOccurs="1" maxOccurs="unbounded"/>
- <xsd:element name="default-object-value" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="one-to-many">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToMany {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default LAZY;
- String mappedBy() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="order-by" type="orm:order-by"
- minOccurs="0"/>
- <xsd:element name="order-column" type="orm:order-column"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key" type="orm:map-key"
- minOccurs="0"/>
- <xsd:sequence>
- <xsd:element name="map-key-class" type="orm:map-key-class"
- minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-temporal"
- type="orm:temporal"
- minOccurs="0"/>
- <xsd:element name="map-key-enumerated"
- type="orm:enumerated"
- minOccurs="0"/>
- <xsd:element name="map-key-convert" type="xsd:string" minOccurs="0"/>
- <xsd:choice>
- <xsd:element name="map-key-attribute-override"
- type="orm:attribute-override"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="map-key-association-override" type="orm:association-override" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="map-key-column" type="orm:map-key-column"
- minOccurs="0"/>
- <xsd:element name="map-key-join-column"
- type="orm:map-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:choice>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:choice>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="one-to-one">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OneToOne {
- Class targetEntity() default void.class;
- CascadeType[] cascade() default {};
- FetchType fetch() default EAGER;
- boolean optional() default true;
- String mappedBy() default "";
- boolean orphanRemoval() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-table" type="orm:join-table"
- minOccurs="0"/>
- </xsd:choice>
- <xsd:element name="cascade" type="orm:cascade-type"
- minOccurs="0"/>
- <xsd:element name="cascade-on-delete" type="xsd:boolean" minOccurs="0"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="join-fetch" type="orm:join-fetch-type" minOccurs="0"/>
- <xsd:element name="batch-fetch" type="orm:batch-fetch" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-entity" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mapped-by" type="xsd:string"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- <xsd:attribute name="maps-id" type="xsd:string"/>
- <xsd:attribute name="id" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="optimistic-locking">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * An optimistic-locking element is used to specify the type of
- * optimistic locking EclipseLink should use when updating or deleting
- * entities. An optimistic-locking specification is supported on
- * an entity or mapped-superclass.
- *
- * It is used in conjunction with the optimistic-locking-type.
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface OptimisticLocking {
- /**
- * (Optional) The type of optimistic locking policy to use.
- */
- OptimisticLockingType type() default VERSION_COLUMN;
-
- /**
- * (Optional) For an optimistic locking policy of type
- * SELECTED_COLUMNS, this annotation member becomes a (Required)
- * field.
- */
- Column[] selectedColumns() default {};
-
- /**
- * (Optional) Specify where the optimistic locking policy should
- * cascade lock. Currently only supported with VERSION_COLUMN locking.
- */
- boolean cascade() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="selected-column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="type" type="orm:optimistic-locking-type"/>
- <xsd:attribute name="cascade" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="optimistic-locking-type">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A simple type that is used within an optimistic-locking
- * specification to specify the type of optimistic-locking that
- * EclipseLink should use when updating or deleting entities.
- */
- public enum OptimisticLockingType {
- /**
- * Using this type of locking policy compares every field in the table
- * in the WHERE clause when doing an update or a delete. If any field
- * has been changed, an optimistic locking exception will be thrown.
- */
- ALL_COLUMNS,
-
- /**
- * Using this type of locking policy compares only the changed fields
- * in the WHERE clause when doing an update. If any field has been
- * changed, an optimistic locking exception will be thrown. A delete
- * will only compare the primary key.
- */
- CHANGED_COLUMNS,
-
- /**
- * Using this type of locking compares selected fields in the WHERE
- * clause when doing an update or a delete. If any field has been
- * changed, an optimistic locking exception will be thrown. Note that
- * the fields specified must be mapped and not be primary keys.
- */
- SELECTED_COLUMNS,
-
- /**
- * Using this type of locking policy compares a single version number
- * in the where clause when doing an update. The version field must be
- * mapped and not be the primary key.
- */
- VERSION_COLUMN
- }
-
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ALL_COLUMNS"/>
- <xsd:enumeration value="CHANGED_COLUMNS"/>
- <xsd:enumeration value="SELECTED_COLUMNS"/>
- <xsd:enumeration value="VERSION_COLUMN"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-by">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderBy {
- String value() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="order-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface OrderColumn {
- String name() default "";
- boolean nullable() default true;
- boolean insertable() default true;
- boolean updatable() default true;
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="nullable" type="xsd:boolean"/>
- <xsd:attribute name="insertable" type="xsd:boolean"/>
- <xsd:attribute name="updatable" type="xsd:boolean"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="correction-type" type="orm:order-column-correction-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="order-column-correction-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum OrderCorrectionType {
- READ,
- READ_WRITE,
- EXCEPTION
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="READ"/>
- <xsd:enumeration value="READ_WRITE"/>
- <xsd:enumeration value="EXCEPTION"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-load">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostLoad {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostPersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="post-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PostUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-persist">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PrePersist {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-remove">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreRemove {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="pre-update">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD}) @Retention(RUNTIME)
- public @interface PreUpdate {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="method-name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="primary-key">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * The PrimaryKey annotation allows advanced configuration of the Id.
- * A validation policy can be given that allows specifying if zero is a valid id value.
- * The set of primary key columns can also be specified precisely.
- *
- * @author James Sutherland
- * @since EclipseLink 1.1
- */
- @Target({TYPE})
- @Retention(RUNTIME)
- public @interface PrimaryKey {
- /**
- * (Optional) Configures what id validation is done.
- * By default 0 is not a valid id value, this can be used to allow 0 id values.
- */
- IdValidation validation() default IdValidation.ZERO;
-
- /**
- * (Optional) Configures what cache key type is used to store the object in the cache.
- * By default the type is determined by what type is optimal for the class.
- */
- CacheKeyType cacheKeyType() default CacheKeyType.AUTO;
-
- /**
- * (Optional) Used to specify the primary key columns directly.
- * This can be used instead of @Id if the primary key includes a non basic field,
- * such as a foreign key, or a inheritance discriminator, embedded, or transformation mapped field.
- */
- Column[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="validation" type="orm:id-validation"/>
- <xsd:attribute name="cache-key-type" type="orm:cache-key-type"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="primary-key-join-column">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface PrimaryKeyJoinColumn {
- String name() default "";
- String referencedColumnName() default "";
- String columnDefinition() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="referenced-column-name" type="xsd:string"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="property">
- <xsd:annotation>
- <xsd:documentation>
-
- A user defined mapping's property.
- @Target({METHOD, FIELD, TYPE})
- @Retention(RUNTIME)
- public @interface Property {
- /**
- * Property name.
- */
- String name();
-
- /**
- * String representation of Property value,
- * converted to an instance of valueType.
- */
- String value();
-
- /**
- * Property value type.
- * The value converted to valueType by ConversionManager.
- * If specified must be a simple type that could be handled by
- * ConversionManager:
- * numerical, boolean, temporal.
- */
- Class valueType() default String.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- <xsd:attribute name="value-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="query-hint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface QueryHint {
- String name();
- String value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="value" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="query-redirectors">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface QueryRedirectors {
-
- /**
- * This AllQueries Query Redirector will be applied to any executing object query
- * that does not have a more precise redirector (like the
- * ReadObjectQuery Redirector) or a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- *
- */
- Class allQueries() default void.class;
-
- /**
- * A Default ReadAll Query Redirector will be applied to any executing
- * ReadAllQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query through the getResultList() API this is the redirector that will be invoked
- */
- Class readAll() default void.class;
-
- /**
- * A Default ReadObject Query Redirector will be applied to any executing
- * ReadObjectQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query through the getSingleResult() API or EntityManager.find() this is the redirector that will be invoked
- */
- Class readObject() default void.class;
-
- /**
- * A Default ReportQuery Redirector will be applied to any executing
- * ReportQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- * For users executing a JPA Query that contains agregate functions or selects multiple entities this is the redirector that will be invoked
- */
- Class report() default void.class;
-
- /**
- * A Default Update Query Redirector will be applied to any executing
- * UpdateObjectQuery or UpdateAllQuery that does not have a redirector set directly on the query.
- * In EclipseLink an UpdateObjectQuery is executed whenever flushing changes to the datasource.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class update() default void.class;
-
- /**
- * A Default Insert Query Redirector will be applied to any executing
- * InsertObjectQuery that does not have a redirector set directly on the query.
- * In EclipseLink an InsertObjectQuery is executed when persisting an object to the datasource.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class insert() default void.class;
-
- /**
- * A Default Delete Object Query Redirector will be applied to any executing
- * DeleteObjectQuery or DeleteAllQuery that does not have a redirector set directly on the query.
- * Query redirectors allow the user to intercept query execution preventing
- * it or alternately performing some side effect like auditing.
- */
- Class delete() default void.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="all-queries" type="xsd:string"/>
- <xsd:attribute name="read-all" type="xsd:string"/>
- <xsd:attribute name="read-object" type="xsd:string"/>
- <xsd:attribute name="report" type="xsd:string"/>
- <xsd:attribute name="update" type="xsd:string"/>
- <xsd:attribute name="insert" type="xsd:string"/>
- <xsd:attribute name="delete" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="read-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * Unless the TransformationMapping is write-only, it should have a
- * ReadTransformer, it defines transformation of database column(s)
- * value(s)into attribute value.
- *
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReadTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.AttributeTransformer
- * interface. The class will be instantiated, its
- * buildAttributeValue will be used to create the value to be
- * assigned to the attribute.
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be assigned to the attribute (not assigns the value to
- * the attribute). Either transformerClass or method must be
- * specified, but not both.
- */
- String method() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="return-insert">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface ReturnInsert {
- /**
- * A ReturnInsert annotation allows for INSERT operations to return
- * values back into the object being written. This allows for table
- * default values, trigger or stored procedures computed values to
- * be set back into the object.
- */
- boolean returnOnly() default false;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="return-only" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="secondary-table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SecondaryTable {
- String name();
- String catalog() default "";
- String schema() default "";
- PrimaryKeyJoinColumn[] pkJoinColumns() default {};
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="primary-key-join-column"
- type="orm:primary-key-join-column"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string" />
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="sequence-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface SequenceGenerator {
- String name();
- String sequenceName() default "";
- String catalog() default "";
- String schema() default "";
- int initialValue() default 1;
- int allocationSize() default 50;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="sequence-name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="sql-result-set-mapping">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface SqlResultSetMapping {
- String name();
- EntityResult[] entities() default {};
- ColumnResult[] columns() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="entity-result" type="orm:entity-result"
- minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="column-result" type="orm:column-result"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="stored-procedure-parameter">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A StoredProcedureParameter annotation is used within a
- * NamedStoredProcedureQuery annotation.
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface StoredProcedureParameter {
- /**
- * (Optional) The direction of the stored procedure parameter.
- */
- Direction direction() default IN;
-
- /**
- * (Optional) Stored procedure parameter name.
- */
- String name() default "";
-
- /**
- * (Required) The query parameter name.
- */
- String queryParameter();
-
- /**
- * (Optional) Define if the parameter is required, or optional and defaulted by the procedure.
- */
- boolean optional() default false;
-
- /**
- * (Optional) The type of Java class desired back from the procedure,
- * this is dependent on the type returned from the procedure.
- */
- Class type() default void.class;
-
- /**
- * (Optional) The JDBC type code, this dependent on the type returned
- * from the procedure.
- */
- int jdbcType() default -1;
-
- /**
- * (Optional) The JDBC type name, this may be required for ARRAY or
- * STRUCT types.
- */
- String jdbcTypeName() default "";
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="direction" type="orm:direction-type"/>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="query-parameter" type="xsd:string" use="required"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="type" type="xsd:string"/>
- <xsd:attribute name="jdbc-type" type="xsd:integer"/>
- <xsd:attribute name="jdbc-type-name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="plsql-parameter">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * A PLSQLParameter annotation is used within a
- * NamedPLSQLStoredProcedureQuery or PLSQLRecord annotation.
- *
- * @see NamedPLSQLStoredProcedureQuery
- * @see PLSQLRecord
- * @author James Sutherland
- * @since EclipseLink 2.3
- */
- @Target({})
- @Retention(RUNTIME)
- public @interface PLSQLParameter {
- /**
- * (Optional) The direction of the stored procedure parameter.
- */
- Direction direction() default IN;
-
- /**
- * (Required) Stored procedure parameter name.
- */
- String name() default "";
-
- /**
- * (Optional) The query parameter name.
- */
- String queryParameter();
-
- /**
- * (Optional) Define if the parameter is required, or optional and defaulted by the procedure.
- */
- boolean optional() default false;
-
- /**
- * (Optional) The database data-type for the paramter.
- * This either one of the type constants defined in OraclePLSQLTypes, or JDBCTypes,
- * or a custom record or table type name.
- * @see PLSQLRecord
- * @see OraclePLSQLTypes
- * @see JDBCTypes
- */
- String databaseType() default "VARCHAR";
-
- /**
- * (Optional) The max length of the field value.
- */
- int length() default 255;
-
- /**
- * (Optional) If a numeric, the max scale value.
- */
- int scale() default 0;
-
- /**
- * (Optional) If a numeric, the max precision value.
- */
- int precision() default 0;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="direction" type="orm:direction-type"/>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="query-parameter" type="xsd:string"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="database-type" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:integer"/>
- <xsd:attribute name="scale" type="xsd:integer"/>
- <xsd:attribute name="precision" type="xsd:integer"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="struct-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface StructConverter {
- /**
- * (Required) Name this converter. The name should be unique across
- * the whole persistence unit.
- */
- String name();
-
- /**
- * (Required) The converter class to be used. This class must
- * implement the EclipseLink interface
- * org.eclipse.persistence.mappings.converters.Converter
- */
- String converter();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="converter" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="struct">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Struct types are extended object-relational data-types supported by some databases.
- * Struct types are user define types in the database such as OBJECT types on Oracle.
- * Structs can normally contains Arrays (VARRAY) or other Struct types, and can be stored in
- * a column or a table.
- * This annotation define a class to map to a database Struct type.
- * The class should normally be an Embeddable, but could also be an Entity if stored in a object table.
- *
- * @see org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor
- * @see org.eclipse.persistence.mappings.structures.StructureMapping
- * @author James Sutherland
- * @since EclipseLink 2.3
- */
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Struct {
- /**
- * (Required) The database name of the database structure type.
- */
- String name();
-
- /**
- * (Optional) Defines the order of the fields contained in the database structure type.
- */
- String[] fields() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="structure">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Struct types are extended object-relational data-types supported by some databases.
- * Struct types are user define types in the database such as OBJECT types on Oracle.
- * Structs can normally contains Arrays (VARRAY) or other Struct types, and can be stored in
- * a column or a table.
- * This annotation can be defined on a field/method to define an StructureMapping to an embedded Struct type.
- * The target Embeddable must be mapped using the Struct annotation.
- *
- * @see Struct
- * @see org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor
- * @see org.eclipse.persistence.mappings.structures.StructureMapping
- * @author James Sutherland
- * @since EclipseLink 2.3
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Structure {
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE}) @Retention(RUNTIME)
- public @interface Table {
- String name() default "";
- String catalog() default "";
- String schema() default "";
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string" />
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="index">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Allow a database INDEX to be define when generating DDL.
- * The @Index can be defined on a Entity class, or on an attribute.
- * The column is defaulted when defined on a attribute.
- *
- * @author James Sutherland
- * @since EclipseLink 2.2
- */
- @Target({METHOD, FIELD, TYPE})
- @Retention(RUNTIME)
- public @interface Index {
- /** The name of the INDEX, defaults to INDEX_(table-name) */
- String name() default "";
-
- /** The schema of the INDEX */
- String schema() default "";
-
- /** The catalog of the INDEX */
- String catalog() default "";
-
- /** The table to define the index on, defaults to entities primary table. */
- String table() default "";
-
- boolean unique() default false;
-
- /**
- * Specify the set of columns to define the index on.
- * Not required when annotated on a field/method.
- */
- String[] columnNames() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column-name" type="xsd:string"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="unique" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="table-generator">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME)
- public @interface TableGenerator {
- String name();
- String table() default "";
- String catalog() default "";
- String schema() default "";
- String pkColumnName() default "";
- String valueColumnName() default "";
- String pkColumnValue() default "";
- int initialValue() default 0;
- int allocationSize() default 50;
- UniqueConstraint[] uniqueConstraints() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="description" type="xsd:string" minOccurs="0"/>
- <xsd:element name="unique-constraint" type="orm:unique-constraint"
- minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="catalog" type="xsd:string"/>
- <xsd:attribute name="schema" type="xsd:string"/>
- <xsd:attribute name="creation-suffix" type="xsd:string"/>
- <xsd:attribute name="pk-column-name" type="xsd:string"/>
- <xsd:attribute name="value-column-name" type="xsd:string"/>
- <xsd:attribute name="pk-column-value" type="xsd:string"/>
- <xsd:attribute name="initial-value" type="xsd:int"/>
- <xsd:attribute name="allocation-size" type="xsd:int"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Temporal {
- TemporalType value();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="orm:temporal-type"/>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:simpleType name="temporal-type">
- <xsd:annotation>
- <xsd:documentation>
-
- public enum TemporalType {
- DATE, // java.sql.Date
- TIME, // java.sql.Time
- TIMESTAMP // java.sql.Timestamp
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="DATE"/>
- <xsd:enumeration value="TIME"/>
- <xsd:enumeration value="TIMESTAMP"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="tenant-discriminator-column">
- <xsd:annotation>
- <xsd:documentation>
- @Target({})
- @Retention(RUNTIME)
- public @interface TenantDiscriminatorColumn {
- /**
- * (Optional) The name of column to be used for the tenant discriminator.
- */
- String name() default "TENANT_ID";
-
- /**
- * (Optional) The name of the context property to apply to the
- * tenant discriminator column.
- */
- String contextProperty() default "eclipselink.tenant-id";
-
- /**
- * (Optional) The type of object/column to use as a class discriminator.
- * Defaults to {@link DiscriminatorType#STRING DiscriminatorType.STRING}.
- */
- DiscriminatorType discriminatorType() default DiscriminatorType.STRING;
-
- /**
- * (Optional) The SQL fragment that is used when generating the DDL
- * for the discriminator column.
- * Defaults to the provider-generated SQL to create a column
- * of the specified discriminator type.
- */
- String columnDefinition() default "";
-
- /**
- * (Optional) The column length for String-based discriminator types.
- * Ignored for other discriminator types.
- */
- int length() default 31;
-
- /**
- * (Optional) The name of the table that contains the column.
- * If absent the column is assumed to be in the primary table.
- */
- String table() default "";
-
- /**
- * Specifies that the tenant discriminator column is part of the primary
- * key of the tables.
- */
- boolean primaryKey() default false;
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string"/>
- <xsd:attribute name="context-property" type="xsd:string"/>
- <xsd:attribute name="discriminator-type" type="orm:discriminator-type"/>
- <xsd:attribute name="column-definition" type="xsd:string"/>
- <xsd:attribute name="length" type="xsd:int"/>
- <xsd:attribute name="table" type="xsd:string"/>
- <xsd:attribute name="primary-key" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="time-of-day">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({})
- @Retention(RUNTIME)
- public @interface TimeOfDay {
- /**
- * (Optional) Hour of the day.
- */
- int hour() default 0;
-
- /**
- * (Optional) Minute of the day.
- */
- int minute() default 0;
-
- /**
- * (Optional) Second of the day.
- */
- int second() default 0;
-
- /**
- * (Optional) Millisecond of the day.
- */
- int millisecond() default 0;
-
- /**
- * Internal use. Do not modify.
- */
- boolean specified() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="hour" type="xsd:integer"/>
- <xsd:attribute name="minute" type="xsd:integer"/>
- <xsd:attribute name="second" type="xsd:integer"/>
- <xsd:attribute name="millisecond" type="xsd:integer"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="transformation">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Transformation is an optional annotation for
- * org.eclipse.persistence.mappings.TransformationMapping.
- * TransformationMapping allows to map an attribute to one or more
- * database columns.
- *
- * Transformation annotation is an optional part of
- * TransformationMapping definition. Unless the TransformationMapping is
- * write-only, it should have a ReadTransformer, it defines
- * transformation of database column(s) value(s)into attribute value.
- * Also unless it's a read-only mapping, either WriteTransformer
- * annotation or WriteTransformers annotation should be specified. Each
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface Transformation {
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) The optional element is a hint as to whether the value
- * of the field or property may be null. It is disregarded
- * for primitive types, which are considered non-optional.
- */
- boolean optional() default true;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="read-transformer" type="orm:read-transformer"/>
- <xsd:element name="write-transformer" type="orm:write-transformer" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="transient">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Transient {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="type-converter">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({TYPE, METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface TypeConverter {
- /**
- * (Required) Name this converter. The name should be unique
- * across the whole persistence unit.
- */
- String name();
-
- /**
- * (Optional) Specify the type stored on the database. The
- * default is inferred from the type of the persistence field
- * or property.
- */
- Class dataType() default void.class;
-
- /**
- * (Optional) Specify the type stored on the entity. The
- * default is inferred from the type of the persistent field
- * or property.
- */
- Class objectType() default void.class;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="data-type" type="xsd:string"/>
- <xsd:attribute name="object-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="unique-constraint">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({}) @Retention(RUNTIME)
- public @interface UniqueConstraint {
- String name() default "";
- String[] columnNames();
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column-name" type="xsd:string"
- maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="variable-one-to-one">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * Variable one to one mappings are used to represent a pointer
- * references between a java object and an implementer of an interface.
- * This mapping is usually represented by a single pointer (stored in an
- * instance variable) between the source and target objects. In the
- * relational database tables, these mappings are normally implemented
- * using a foreign key and a type code.
- *
- * A VariableOneToOne can be specified within an Entity,
- * MappedSuperclass and Embeddable class.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface VariableOneToOne {
- /**
- * (Optional) The interface class that is the target of the
- * association. If not specified it will be inferred from the type
- * of the object being referenced.
- */
- Class targetInterface() default void.class;
-
- /**
- * (Optional) The operations that must be cascaded to the target of
- * the association.
- */
- CascadeType[] cascade() default {};
-
- /**
- * (Optional) Defines whether the value of the field or property
- * should be lazily loaded or must be eagerly fetched. The EAGER
- * strategy is a requirement on the persistence provider runtime
- * that the value must be eagerly fetched. The LAZY strategy is a
- * hint to the persistence provider runtime. If not specified,
- * defaults to EAGER.
- */
- FetchType fetch() default EAGER;
-
- /**
- * (Optional) Whether the association is optional. If set to false
- * then a non-null relationship must always exist.
- */
- boolean optional() default true;
-
- /**
- * (Optional) The discriminator column will hold the type
- * indicators. If the DiscriminatorColumn is not specified, the name
- * of the discriminator column defaults to "DTYPE" and the
- * discriminator type to STRING.
- */
- DiscriminatorColumn discriminatorColumn() default @DiscriminatorColumn;
-
- /**
- * (Optional) The list of discriminator types that can be used with
- * this VariableOneToOne. If none are specified then those entities
- * within the persistence unit that implement the target interface
- * will be added to the list of types. The discriminator type will
- * default as follows:
- * - If DiscriminatorColumn type is STRING: Entity.name()
- * - If DiscriminatorColumn type is CHAR: First letter of the
- * Entity class
- * - If DiscriminatorColumn type is INTEGER: The next integer after
- * the highest integer explicitly added.
- */
- DiscriminatorClass[] discriminatorClasses() default {};
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
- <xsd:element name="discriminator-column" type="orm:discriminator-column" minOccurs="0"/>
- <xsd:element name="discriminator-class" type="orm:discriminator-class" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="join-column" type="orm:join-column" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="private-owned" type="orm:emptyType" minOccurs="0"/>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- <xsd:element name="noncacheable" type="orm:emptyType" minOccurs="0"/>
- <xsd:group ref="orm:partitioning-group"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="target-interface" type="xsd:string"/>
- <xsd:attribute name="fetch" type="orm:fetch-type"/>
- <xsd:attribute name="optional" type="xsd:boolean"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="orphan-removal" type="xsd:boolean"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="version">
- <xsd:annotation>
- <xsd:documentation>
-
- @Target({METHOD, FIELD}) @Retention(RUNTIME)
- public @interface Version {}
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column" minOccurs="0"/>
- <xsd:element name="index" type="orm:index" minOccurs="0"/>
- <xsd:choice minOccurs="0">
- <xsd:element name="temporal" type="orm:temporal"/>
- <xsd:element name="convert" type="xsd:string"/>
- </xsd:choice>
- <xsd:choice minOccurs="0">
- <xsd:element name="converter" type="orm:converter"/>
- <xsd:element name="type-converter" type="orm:type-converter"/>
- <xsd:element name="object-type-converter" type="orm:object-type-converter"/>
- <xsd:element name="struct-converter" type="orm:struct-converter"/>
- </xsd:choice>
- <xsd:element name="property" type="orm:property" minOccurs="0" maxOccurs="unbounded"/>
- <xsd:element name="access-methods" type="orm:access-methods" minOccurs="0"/>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required"/>
- <xsd:attribute name="access" type="orm:access-type"/>
- <xsd:attribute name="mutable" type="xsd:boolean"/>
- <xsd:attribute name="attribute-type" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="write-transformer">
- <xsd:annotation>
- <xsd:documentation>
-
- /**
- * Annotation for org.eclipse.persistence.mappings.TransformationMapping.
- * WriteTransformer defines transformation of the attribute value to a
- * single database column value (column is specified in the
- * WriteTransformer).
- *
- * A single WriteTransformer may be specified directly on the method or
- * attribute. Multiple WriteTransformers should be wrapped into
- * WriteTransformers annotation. No WriteTransformers specified for
- * read-only mapping. Unless the TransformationMapping is write-only, it
- * should have a ReadTransformer, it defines transformation of database
- * column(s) value(s)into attribute value.
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface WriteTransformer {
- /**
- * User-defined class that must implement the
- * org.eclipse.persistence.mappings.transformers.FieldTransformer
- * interface. The class will be instantiated, its buildFieldValue
- * will be used to create the value to be written into the database
- * column. Note that for ddl generation and returning to be
- * supported the method buildFieldValue in the class should be
- * defined to return the relevant Java type, not just Object as
- * defined in the interface, for instance:
- * public Time buildFieldValue(Object instance, String fieldName, Session session).
- * Either transformerClass or method must be specified, but not both.
- */
- Class transformerClass() default void.class;
-
- /**
- * The mapped class must have a method with this name which returns
- * a value to be written into the database column.
- * Note that for ddl generation and returning to be supported the
- * method should be defined to return a particular type, not just
- * Object, for instance:
- * public Time getStartTime().
- * The method may require a Transient annotation to avoid being
- * mapped as Basic by default.
- * Either transformerClass or method must be specified, but not both.
- */
- String method() default "";
-
- /**
- * Specify here the column into which the value should be written.
- * The only case when this could be skipped is if a single
- * WriteTransformer annotates an attribute - the attribute's name
- * will be used as a column name.
- */
- Column column() default @Column;
- }
-
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="column" type="orm:column"/>
- </xsd:sequence>
- <xsd:attribute name="transformer-class" type="xsd:string"/>
- <xsd:attribute name="method" type="xsd:string"/>
- </xsd:complexType>
-
- <!-- **************************************************** -->
-
- <xsd:complexType name="batch-fetch">
- <xsd:annotation>
- <xsd:documentation>
- /**
- * A BatchFetch annotation can be used on any relationship mapping,
- * (OneToOne, ManyToOne, OneToMany, ManyToMany, ElementCollection, BasicCollection, BasicMap).
- * It allows the related objects to be batch read in a single query.
- * Batch fetching can also be set at the query level, and it is
- * normally recommended to do so as all queries may not require batching.
- *
- * @author James Sutherland
- * @since EclipseLink 2.1
- */
- @Target({METHOD, FIELD})
- @Retention(RUNTIME)
- public @interface BatchFetch {
- /**
- * (Optional) The type of batch-fetch to use.
- * Either JOIN, EXISTS or IN.
- * JOIN is the default.
- */
- BatchFetchType value() default BatchFetchType.JOIN;
-
- /**
- * Define the default batch fetch size.
- * This is only used for IN type batch reading and defines
- * the number of keys used in each IN clause.
- * The default size is 256, or the query's pageSize for cursor queries.
- */
- int size() default -1;
- }
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="type" type="orm:batch-fetch-type"/>
- <xsd:attribute name="size" type="xsd:integer"/>
- </xsd:complexType>
-
-</xsd:schema>
-
-
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_0.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_0.xsd
deleted file mode 100644
index bb10ce4894..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_0.xsd
+++ /dev/null
@@ -1,260 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-******************************************************************************
- Copyright (c) 1998, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- which accompanies this distribution.
- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- and the Eclipse Distribution License is available at
- http://www.eclipse.org/org/documents/edl-v10.php.
-
- Contributors:
- dmccann - November 24/2009 - 2.0 - Initial implementation
-*****************************************************************************/
--->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
- targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="2.0">
-
- <xs:element name="xml-bindings">
- <xs:complexType>
- <xs:all>
- <xs:element ref="xml-schema" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapters" minOccurs="0"/>
- <xs:element name="java-types" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="java-type" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="xml-accessor-type" type="xml-access-type" default="PUBLIC_MEMBER" />
- <xs:attribute name="xml-accessor-order" type="xml-access-order" default="UNDEFINED" />
- </xs:complexType>
- </xs:element>
- <xs:element name="java-type">
- <xs:complexType>
- <xs:all>
- <xs:element ref="xml-type" minOccurs="0"/>
- <xs:element ref="xml-root-element" minOccurs="0"/>
- <xs:element ref="xml-see-also" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element name="java-attributes" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="java-attribute" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="name" type="xs:string" />
- <xs:attribute name="xml-transient" type="xs:boolean" default="false" />
- <xs:attribute name="xml-customizer" type="xs:string" />
- <xs:attribute name="xml-accessor-type" type="xml-access-type" default="PUBLIC_MEMBER" />
- <xs:attribute name="xml-accessor-order" type="xml-access-order" default="UNDEFINED" />
- </xs:complexType>
- </xs:element>
- <xs:element name="java-attribute" type="java-attribute" />
- <xs:complexType name="java-attribute" abstract="true">
- <xs:attribute name="java-attribute" type="xs:string" />
- </xs:complexType>
-
- <!-- Enums -->
- <xs:simpleType name="xml-access-order">
- <xs:restriction base="xs:string">
- <xs:enumeration value="ALPHABETICAL" />
- <xs:enumeration value="UNDEFINED" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="xml-access-type">
- <xs:restriction base="xs:string">
- <xs:enumeration value="FIELD" />
- <xs:enumeration value="NONE" />
- <xs:enumeration value="PROPERTY" />
- <xs:enumeration value="PUBLIC_MEMBER" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="xml-ns-form">
- <xs:restriction base="xs:string">
- <xs:enumeration value="UNQUALIFIED" />
- <xs:enumeration value="QUALIFIED" />
- <xs:enumeration value="UNSET" />
- </xs:restriction>
- </xs:simpleType>
-
- <!-- @Target(value=PACKAGE) -->
- <xs:element name="xml-schema">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="xml-ns" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="namespace-uri" type="xs:string" />
- <xs:attribute name="prefix" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="attribute-form-default" type="xml-ns-form" default="UNSET" />
- <xs:attribute name="element-form-default" type="xml-ns-form" default="UNSET" />
- <xs:attribute name="location" type="xs:string" />
- <xs:attribute name="namespace" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-java-type-adapters">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-java-type-adapter" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={FIELD,METHOD,PACKAGE}) -->
-
- <!-- @Target(value={PACKAGE,FIELD,METHOD,TYPE,PARAMETER}) -->
- <xs:element name="xml-java-type-adapter" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:attribute name="value" type="xs:string" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={FIELD,METHOD,TYPE}) -->
- <xs:element name="xml-transient" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute" />
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value=TYPE) -->
- <xs:element name="xml-type">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="prop-order">
- <xs:simpleType>
- <xs:list itemType="xs:string" />
- </xs:simpleType>
- </xs:attribute>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-root-element">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-see-also">
- <xs:simpleType>
- <xs:list itemType="xs:string" />
- </xs:simpleType>
- </xs:element>
-
- <!-- @Target(value={FIELD}) -->
-
- <!-- @Target(value={FIELD,METHOD}) -->
- <xs:element name="xml-any-attribute" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute" />
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-attribute" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- </xs:all>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- <xs:attribute name="xml-id" type="xs:boolean" default="false" />
- <xs:attribute name="xml-idref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-list" type="xs:boolean" default="false" />
- <xs:attribute name="xml-attachment-ref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-mime-type" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-any-element" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- </xs:all>
- <xs:attribute name="xml-mixed" type="xs:boolean" default="false" />
- <xs:attribute name="lax" type="xs:boolean" default="false" />
- <xs:attribute name="dom-handler" type="xs:string" default="javax.xml.bind.annotation.W3CDomHandler" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-element-wrapper" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element ref="xml-map" minOccurs="0"/>
- </xs:all>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="default-value" type="xs:string" />
- <xs:attribute name="nillable" type="xs:boolean" default="false" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.XmlElement.DEFAULT" />
- <xs:attribute name="xml-id" type="xs:boolean" default="false" />
- <xs:attribute name="xml-idref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-list" type="xs:boolean" default="false" />
- <xs:attribute name="xml-attachment-ref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-mime-type" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element-wrapper">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="nillable" type="xs:boolean" default="false" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-value" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute" />
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-map">
- <xs:complexType>
- <xs:all>
- <xs:element name="key" minOccurs="0">
- <xs:complexType>
- <xs:attribute name="type" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="value" minOccurs="0">
- <xs:complexType>
- <xs:attribute name="type" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:all>
- </xs:complexType>
- </xs:element>
-</xs:schema> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_1.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_1.xsd
deleted file mode 100644
index d4ea8426bb..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_1.xsd
+++ /dev/null
@@ -1,462 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-******************************************************************************
- Copyright (c) 1998, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- which accompanies this distribution.
- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- and the Eclipse Distribution License is available at
- http://www.eclipse.org/org/documents/edl-v10.php.
-
- Contributors:
- dmccann - December 08/2009 - 2.1 - Initial implementation
-*****************************************************************************/
--->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
- targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="2.1">
-
- <xs:element name="xml-bindings">
- <xs:complexType>
- <xs:all>
- <xs:element ref="xml-schema" minOccurs="0"/>
- <xs:element ref="xml-schema-type" minOccurs="0"/>
- <xs:element ref="xml-schema-types" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapters" minOccurs="0"/>
- <xs:element name="xml-registries" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-registry" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-enums" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-enum" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="java-types" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="java-type" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="xml-accessor-type" type="xml-access-type" default="PUBLIC_MEMBER" />
- <xs:attribute name="xml-accessor-order" type="xml-access-order" default="UNDEFINED" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-registry">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="xml-element-decl" maxOccurs="unbounded" >
- <xs:complexType>
- <xs:attribute name="java-method" type="xs:string" />
- <xs:attribute name="name" type="xs:string" />
- <xs:attribute name="defaultValue" type="xs:string" default="\u0000" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="scope" type="xs:string" default="javax.xml.bind.annotation.XmlElementDecl.GLOBAL" />
- <xs:attribute name="substitutionHeadName" type="xs:string" default="" />
- <xs:attribute name="substitutionHeadNamespace" type="xs:string" default="##default" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="java-type">
- <xs:complexType>
- <xs:all>
- <xs:element ref="xml-type" minOccurs="0"/>
- <xs:element ref="xml-root-element" minOccurs="0"/>
- <xs:element ref="xml-see-also" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element name="java-attributes" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="java-attribute" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="name" type="xs:string" />
- <xs:attribute name="xml-transient" type="xs:boolean" default="false" />
- <xs:attribute name="xml-customizer" type="xs:string" />
- <xs:attribute name="xml-accessor-type" type="xml-access-type" default="PUBLIC_MEMBER" />
- <xs:attribute name="xml-accessor-order" type="xml-access-order" default="UNDEFINED" />
- <xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" />
- </xs:complexType>
- </xs:element>
- <xs:element name="java-attribute" type="java-attribute" />
- <xs:complexType name="java-attribute" abstract="true">
- <xs:attribute name="java-attribute" type="xs:string" />
- </xs:complexType>
- <xs:element name="xml-access-methods" type="xml-access-methods" />
- <xs:complexType name="xml-access-methods">
- <xs:attribute name="get-method" type="xs:string" use="required"/>
- <xs:attribute name="set-method" type="xs:string" use="required"/>
- </xs:complexType>
-
- <!-- Enums -->
- <xs:simpleType name="xml-access-order">
- <xs:restriction base="xs:string">
- <xs:enumeration value="ALPHABETICAL" />
- <xs:enumeration value="UNDEFINED" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="xml-access-type">
- <xs:restriction base="xs:string">
- <xs:enumeration value="FIELD" />
- <xs:enumeration value="NONE" />
- <xs:enumeration value="PROPERTY" />
- <xs:enumeration value="PUBLIC_MEMBER" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="xml-ns-form">
- <xs:restriction base="xs:string">
- <xs:enumeration value="UNQUALIFIED" />
- <xs:enumeration value="QUALIFIED" />
- <xs:enumeration value="UNSET" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="xml-marshal-null-representation">
- <xs:restriction base="xs:string">
- <xs:enumeration value="XSI_NIL" />
- <xs:enumeration value="ABSENT_NODE" />
- <xs:enumeration value="EMPTY_NODE" />
- </xs:restriction>
- </xs:simpleType>
-
- <!-- @Target(value=PACKAGE) -->
- <xs:element name="xml-schema">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="xml-ns" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="namespace-uri" type="xs:string" />
- <xs:attribute name="prefix" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="attribute-form-default" type="xml-ns-form" default="UNSET" />
- <xs:attribute name="element-form-default" type="xml-ns-form" default="UNSET" />
- <xs:attribute name="location" type="xs:string" />
- <xs:attribute name="namespace" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-schema-types">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-schema-type" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-java-type-adapters">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-java-type-adapter" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={FIELD,METHOD,PACKAGE}) -->
- <xs:element name="xml-schema-type">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" use="required" />
- <xs:attribute name="namespace" type="xs:string" default="http://www.w3.org/2001/XMLSchema" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.XmlSchemaType.DEFAULT" />
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={PACKAGE,FIELD,METHOD,TYPE,PARAMETER}) -->
- <xs:element name="xml-java-type-adapter" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:attribute name="value" type="xs:string" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={FIELD,METHOD,TYPE}) -->
- <xs:element name="xml-transient" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute" />
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value=TYPE) -->
- <xs:element name="xml-enum">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-enum-value" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- <xs:attribute name="java-enum" type="xs:string" use="required" />
- <xs:attribute name="value" type="xs:string" default="java.lang.String" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-type">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="factory-class" type="xs:string" default="javax.xml.bind.annotation.XmlType.DEFAULT" />
- <xs:attribute name="factory-method" type="xs:string" />
- <xs:attribute name="prop-order">
- <xs:simpleType>
- <xs:list itemType="xs:string" />
- </xs:simpleType>
- </xs:attribute>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-root-element">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-see-also">
- <xs:simpleType>
- <xs:list itemType="xs:string" />
- </xs:simpleType>
- </xs:element>
-
- <!-- @Target(value={FIELD}) -->
- <xs:element name="xml-enum-value">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="java-enum-value" type="xs:string" use="required" />
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={FIELD,METHOD}) -->
- <xs:element name="xml-any-attribute" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- </xs:all>
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="xml-path" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-attribute" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-abstract-null-policy" minOccurs="0" />
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element ref="xml-schema-type" minOccurs="0"/>
- </xs:all>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- <xs:attribute name="xml-id" type="xs:boolean" default="false" />
- <xs:attribute name="xml-idref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-list" type="xs:boolean" default="false" />
- <xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" />
- <xs:attribute name="xml-attachment-ref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-mime-type" type="xs:string" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="xml-path" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-any-element" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- </xs:all>
- <xs:attribute name="xml-mixed" type="xs:boolean" default="false" />
- <xs:attribute name="lax" type="xs:boolean" default="false" />
- <xs:attribute name="dom-handler" type="xs:string" default="javax.xml.bind.annotation.W3CDomHandler" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="xml-path" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-abstract-null-policy" minOccurs="0" />
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-element-wrapper" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element ref="xml-map" minOccurs="0"/>
- <xs:element ref="xml-schema-type" minOccurs="0" />
- </xs:all>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="default-value" type="xs:string" />
- <xs:attribute name="nillable" type="xs:boolean" default="false" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.XmlElement.DEFAULT" />
- <xs:attribute name="xml-id" type="xs:boolean" default="false" />
- <xs:attribute name="xml-idref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-list" type="xs:boolean" default="false" />
- <xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" />
- <xs:attribute name="xml-attachment-ref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-mime-type" type="xs:string" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="cdata" type="xs:boolean" default="false" />
- <xs:attribute name="xml-path" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-elements" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:sequence>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-element" maxOccurs="unbounded" minOccurs="0"/>
- <xs:element ref="xml-element-wrapper" minOccurs="0"/>
- </xs:sequence>
- <xs:attribute name="xml-idref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-list" type="xs:boolean" default="false" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element-ref" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-element-wrapper" minOccurs="0"/>
- </xs:all>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.XmlElementRef.DEFAULT" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element-refs" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:sequence>
- <xs:element ref="xml-element-ref" minOccurs="0" maxOccurs="unbounded" />
- <xs:element ref="xml-element-wrapper" minOccurs="0" />
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-inverse-reference" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- </xs:all>
- <xs:attribute name="mapped-by" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element-wrapper">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="nillable" type="xs:boolean" default="false" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-value" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:sequence>
- <xs:element ref="xml-abstract-null-policy" minOccurs="0" />
- <xs:element ref="xml-access-methods" minOccurs="0" />
- </xs:sequence>
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="cdata" type="xs:boolean" default="false" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-map">
- <xs:complexType>
- <xs:all>
- <xs:element name="key" minOccurs="0">
- <xs:complexType>
- <xs:attribute name="type" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="value" minOccurs="0">
- <xs:complexType>
- <xs:attribute name="type" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:all>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-abstract-null-policy" type="xml-abstract-null-policy" />
- <xs:complexType name="xml-abstract-null-policy" abstract="true">
- <xs:attribute name="xsi-nil-represents-null" type="xs:boolean" default="false" />
- <xs:attribute name="empty-node-represents-null" type="xs:boolean" default="false" />
- <xs:attribute name="null-representation-for-xml" type="xml-marshal-null-representation" />
- </xs:complexType>
- <xs:element name="xml-null-policy" substitutionGroup="xml-abstract-null-policy">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="xml-abstract-null-policy">
- <xs:attribute name="is-set-performed-for-absent-node" type="xs:boolean" default="true" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-is-set-null-policy" substitutionGroup="xml-abstract-null-policy">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="xml-abstract-null-policy">
- <xs:sequence>
- <xs:element name="is-set-parameter" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="value" type="xs:string"/>
- <xs:attribute name="type" type="xs:string"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="is-set-method-name" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-</xs:schema> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_2.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_2.xsd
deleted file mode 100644
index 61e37c7daf..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_2.xsd
+++ /dev/null
@@ -1,562 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-******************************************************************************
- Copyright (c) 1998, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- which accompanies this distribution.
- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- and the Eclipse Distribution License is available at
- http://www.eclipse.org/org/documents/edl-v10.php.
-
- Contributors:
- dmccann - October 12/2010 - 2.2 - Initial implementation
-*****************************************************************************/
--->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
- targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="2.2">
-
- <xs:element name="xml-bindings">
- <xs:complexType>
- <xs:all>
- <xs:element ref="xml-schema" minOccurs="0"/>
- <xs:element ref="xml-schema-type" minOccurs="0"/>
- <xs:element ref="xml-schema-types" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapters" minOccurs="0"/>
- <xs:element name="xml-registries" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-registry" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-enums" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-enum" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="java-types" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="java-type" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="xml-accessor-type" type="xml-access-type" default="PUBLIC_MEMBER" />
- <xs:attribute name="xml-accessor-order" type="xml-access-order" default="UNDEFINED" />
- <xs:attribute name="xml-mapping-metadata-complete" type="xs:boolean" default="false" />
- <xs:attribute name="package-name" type="xs:string" default="##default" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-registry">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="xml-element-decl" maxOccurs="unbounded" >
- <xs:complexType>
- <xs:attribute name="java-method" type="xs:string" />
- <xs:attribute name="name" type="xs:string" use="required" />
- <xs:attribute name="defaultValue" type="xs:string" default="\u0000" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="scope" type="xs:string" default="javax.xml.bind.annotation.XmlElementDecl.GLOBAL" />
- <xs:attribute name="substitutionHeadName" type="xs:string" default="" />
- <xs:attribute name="substitutionHeadNamespace" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="##default" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="java-type">
- <xs:complexType>
- <xs:all>
- <xs:element ref="xml-type" minOccurs="0"/>
- <xs:element ref="xml-root-element" minOccurs="0"/>
- <xs:element ref="xml-see-also" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element ref="xml-class-extractor" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element name="java-attributes" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="java-attribute" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="name" type="xs:string" />
- <xs:attribute name="super-type" type="xs:string" default="##default" />
- <xs:attribute name="xml-accessor-order" type="xml-access-order" default="UNDEFINED" />
- <xs:attribute name="xml-accessor-type" type="xml-access-type" default="PUBLIC_MEMBER" />
- <xs:attribute name="xml-customizer" type="xs:string" />
- <xs:attribute name="xml-discriminator-node" type="xs:string" />
- <xs:attribute name="xml-discriminator-value" type="xs:string" />
- <xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" />
- <xs:attribute name="xml-transient" type="xs:boolean" default="false" />
- </xs:complexType>
- </xs:element>
- <xs:element name="java-attribute" type="java-attribute" />
- <xs:complexType name="java-attribute" abstract="true">
- <xs:attribute name="java-attribute" type="xs:string" />
- </xs:complexType>
- <xs:element name="xml-access-methods" type="xml-access-methods" />
- <xs:complexType name="xml-access-methods">
- <xs:attribute name="get-method" type="xs:string" use="required"/>
- <xs:attribute name="set-method" type="xs:string" use="required"/>
- </xs:complexType>
- <xs:element name="xml-class-extractor" type="xml-class-extractor" />
- <xs:complexType name="xml-class-extractor">
- <xs:attribute name="class" type="xs:string" use="required"/>
- </xs:complexType>
- <xs:element name="xml-properties" type="xml-properties" />
- <xs:complexType name="xml-properties">
- <xs:sequence>
- <xs:element name="xml-property" minOccurs="0" maxOccurs="unbounded" >
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" use="required" />
- <xs:attribute name="value" type="xs:string" use="required" />
- <xs:attribute name="value-type" type="xs:string" default="java.lang.String" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- <!-- Enums -->
- <xs:simpleType name="xml-access-order">
- <xs:restriction base="xs:string">
- <xs:enumeration value="ALPHABETICAL" />
- <xs:enumeration value="UNDEFINED" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="xml-access-type">
- <xs:restriction base="xs:string">
- <xs:enumeration value="FIELD" />
- <xs:enumeration value="NONE" />
- <xs:enumeration value="PROPERTY" />
- <xs:enumeration value="PUBLIC_MEMBER" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="xml-ns-form">
- <xs:restriction base="xs:string">
- <xs:enumeration value="UNQUALIFIED" />
- <xs:enumeration value="QUALIFIED" />
- <xs:enumeration value="UNSET" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="xml-marshal-null-representation">
- <xs:restriction base="xs:string">
- <xs:enumeration value="XSI_NIL" />
- <xs:enumeration value="ABSENT_NODE" />
- <xs:enumeration value="EMPTY_NODE" />
- </xs:restriction>
- </xs:simpleType>
-
- <!-- @Target(value=PACKAGE) -->
- <xs:element name="xml-schema">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="xml-ns" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="namespace-uri" type="xs:string" />
- <xs:attribute name="prefix" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="attribute-form-default" type="xml-ns-form" default="UNSET" />
- <xs:attribute name="element-form-default" type="xml-ns-form" default="UNSET" />
- <xs:attribute name="location" type="xs:string" />
- <xs:attribute name="namespace" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-schema-types">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-schema-type" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-java-type-adapters">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-java-type-adapter" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={FIELD,METHOD,PACKAGE}) -->
- <xs:element name="xml-schema-type">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" use="required" />
- <xs:attribute name="namespace" type="xs:string" default="http://www.w3.org/2001/XMLSchema" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.XmlSchemaType.DEFAULT" />
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={PACKAGE,FIELD,METHOD,TYPE,PARAMETER}) -->
- <xs:element name="xml-java-type-adapter" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:attribute name="value" type="xs:string" use="required" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={FIELD,METHOD,TYPE}) -->
- <xs:element name="xml-transient" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute" />
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value=TYPE) -->
- <xs:element name="xml-enum">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-enum-value" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- <xs:attribute name="java-enum" type="xs:string" use="required" />
- <xs:attribute name="value" type="xs:string" default="java.lang.String" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-type">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="factory-class" type="xs:string" default="javax.xml.bind.annotation.XmlType.DEFAULT" />
- <xs:attribute name="factory-method" type="xs:string" />
- <xs:attribute name="prop-order">
- <xs:simpleType>
- <xs:list itemType="xs:string" />
- </xs:simpleType>
- </xs:attribute>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-root-element">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-see-also">
- <xs:simpleType>
- <xs:list itemType="xs:string" />
- </xs:simpleType>
- </xs:element>
-
- <!-- @Target(value={FIELD}) -->
- <xs:element name="xml-enum-value">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="java-enum-value" type="xs:string" use="required" />
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={FIELD,METHOD}) -->
- <xs:element name="xml-any-attribute" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-properties" minOccurs="0" />
- </xs:all>
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="xml-path" type="xs:string" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-attribute" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-abstract-null-policy" minOccurs="0" />
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-schema-type" minOccurs="0"/>
- </xs:all>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- <xs:attribute name="xml-id" type="xs:boolean" default="false" />
- <xs:attribute name="xml-idref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-key" type="xs:boolean" default="false" />
- <xs:attribute name="xml-list" type="xs:boolean" default="false" />
- <xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" />
- <xs:attribute name="xml-attachment-ref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-mime-type" type="xs:string" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="##default" />
- <xs:attribute name="xml-path" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-any-element" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-element-refs" minOccurs="0" />
- </xs:all>
- <xs:attribute name="xml-mixed" type="xs:boolean" default="false" />
- <xs:attribute name="lax" type="xs:boolean" default="false" />
- <xs:attribute name="dom-handler" type="xs:string" default="javax.xml.bind.annotation.W3CDomHandler" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="xml-path" type="xs:string" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-abstract-null-policy" minOccurs="0" />
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-element-wrapper" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element ref="xml-map" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-schema-type" minOccurs="0" />
- </xs:all>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="default-value" type="xs:string" />
- <xs:attribute name="nillable" type="xs:boolean" default="false" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.XmlElement.DEFAULT" />
- <xs:attribute name="xml-id" type="xs:boolean" default="false" />
- <xs:attribute name="xml-idref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-key" type="xs:boolean" default="false" />
- <xs:attribute name="xml-list" type="xs:boolean" default="false" />
- <xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" />
- <xs:attribute name="xml-attachment-ref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-mime-type" type="xs:string" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="cdata" type="xs:boolean" default="false" />
- <xs:attribute name="xml-path" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-elements" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:sequence>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-element" minOccurs="0" maxOccurs="unbounded" />
- <xs:element ref="xml-element-wrapper" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-join-nodes" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- <xs:attribute name="xml-idref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-list" type="xs:boolean" default="false" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element-ref" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element name="xml-access-methods" type="xml-access-methods" minOccurs="0"/>
- <xs:element ref="xml-element-wrapper" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- </xs:all>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.XmlElementRef.DEFAULT" />
- <xs:attribute name="xml-mixed" type="xs:boolean" default="false" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element-refs" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:sequence>
- <xs:element name="xml-access-methods" type="xml-access-methods" minOccurs="0"/>
- <xs:element ref="xml-element-ref" minOccurs="0" maxOccurs="unbounded" />
- <xs:element ref="xml-element-wrapper" minOccurs="0" />
- <xs:element ref="xml-properties" minOccurs="0" />
- </xs:sequence>
- <xs:attribute name="xml-mixed" type="xs:boolean" default="false" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-inverse-reference" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-properties" minOccurs="0" />
- </xs:all>
- <xs:attribute name="mapped-by" type="xs:string" use="required" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element-wrapper">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="nillable" type="xs:boolean" default="false" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-value" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-abstract-null-policy" minOccurs="0" />
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- </xs:all>
- <xs:attribute name="cdata" type="xs:boolean" default="false" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="type" type="xs:string" default="##default" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-map">
- <xs:complexType>
- <xs:all>
- <xs:element name="key" minOccurs="0">
- <xs:complexType>
- <xs:attribute name="type" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="value" minOccurs="0">
- <xs:complexType>
- <xs:attribute name="type" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:all>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-abstract-null-policy" type="xml-abstract-null-policy" />
- <xs:complexType name="xml-abstract-null-policy" abstract="true">
- <xs:attribute name="xsi-nil-represents-null" type="xs:boolean" default="false" />
- <xs:attribute name="empty-node-represents-null" type="xs:boolean" default="false" />
- <xs:attribute name="null-representation-for-xml" type="xml-marshal-null-representation" default="ABSENT_NODE" />
- </xs:complexType>
- <xs:element name="xml-null-policy" substitutionGroup="xml-abstract-null-policy">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="xml-abstract-null-policy">
- <xs:attribute name="is-set-performed-for-absent-node" type="xs:boolean" default="true" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-is-set-null-policy" substitutionGroup="xml-abstract-null-policy">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="xml-abstract-null-policy">
- <xs:sequence>
- <xs:element name="is-set-parameter" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="value" type="xs:string" use="required" />
- <xs:attribute name="type" type="xs:string" use="required" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="is-set-method-name" type="xs:string" use="required" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-transformation" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:sequence>
- <xs:element name="xml-access-methods" type="xml-access-methods" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0"/>
- <xs:element name="xml-read-transformer">
- <xs:complexType>
- <xs:attribute name="method" type="xs:string" />
- <xs:attribute name="transformer-class" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-write-transformer" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="method" type="xs:string" />
- <xs:attribute name="xml-path" type="xs:string" use="required" />
- <xs:attribute name="transformer-class" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="optional" type="xs:boolean" default="true"/>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-join-nodes" substitutionGroup="java-attribute" >
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:sequence>
- <xs:element name="xml-join-node" minOccurs="1" maxOccurs="unbounded" >
- <xs:complexType>
- <xs:attribute name="xml-path" type="xs:string" use="required" />
- <xs:attribute name="referenced-xml-path" type="xs:string" use="required" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-</xs:schema> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_3.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_3.xsd
deleted file mode 100644
index 74a4d55db5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_oxm_2_3.xsd
+++ /dev/null
@@ -1,589 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-******************************************************************************
- Copyright (c) 1998, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- which accompanies this distribution.
- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- and the Eclipse Distribution License is available at
- http://www.eclipse.org/org/documents/edl-v10.php.
-
- Contributors:
- dmccann - December 22/2010 - 2.3 - Initial implementation
-*****************************************************************************/
--->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
- targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence/oxm"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="2.3">
-
- <xs:element name="xml-bindings">
- <xs:complexType>
- <xs:all>
- <xs:element ref="xml-schema" minOccurs="0"/>
- <xs:element ref="xml-schema-type" minOccurs="0"/>
- <xs:element ref="xml-schema-types" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapters" minOccurs="0"/>
- <xs:element name="xml-registries" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-registry" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-enums" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-enum" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="java-types" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="java-type" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="xml-accessor-type" type="xml-access-type" default="PUBLIC_MEMBER" />
- <xs:attribute name="xml-accessor-order" type="xml-access-order" default="UNDEFINED" />
- <xs:attribute name="xml-mapping-metadata-complete" type="xs:boolean" default="false" />
- <xs:attribute name="package-name" type="xs:string" default="##default" />
- <xs:attribute name="xml-name-transformer" type="xs:string" />
- <xs:attribute name="version" type="supported-versions" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-registry">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="xml-element-decl" maxOccurs="unbounded" >
- <xs:complexType>
- <xs:attribute name="java-method" type="xs:string" />
- <xs:attribute name="name" type="xs:string" use="required" />
- <xs:attribute name="defaultValue" type="xs:string" default="\u0000" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="scope" type="xs:string" default="javax.xml.bind.annotation.XmlElementDecl.GLOBAL" />
- <xs:attribute name="substitutionHeadName" type="xs:string" default="" />
- <xs:attribute name="substitutionHeadNamespace" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="##default" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="name" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="java-type">
- <xs:complexType>
- <xs:all>
- <xs:element ref="xml-type" minOccurs="0"/>
- <xs:element ref="xml-root-element" minOccurs="0"/>
- <xs:element ref="xml-virtual-access-methods" minOccurs="0"/>
- <xs:element ref="xml-see-also" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element ref="xml-class-extractor" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element name="java-attributes" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="java-attribute" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:all>
- <xs:attribute name="name" type="xs:string" />
- <xs:attribute name="super-type" type="xs:string" default="##default" />
- <xs:attribute name="xml-accessor-order" type="xml-access-order" default="UNDEFINED" />
- <xs:attribute name="xml-accessor-type" type="xml-access-type" default="PUBLIC_MEMBER" />
- <xs:attribute name="xml-customizer" type="xs:string" />
- <xs:attribute name="xml-discriminator-node" type="xs:string" />
- <xs:attribute name="xml-discriminator-value" type="xs:string" />
- <xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" />
- <xs:attribute name="xml-transient" type="xs:boolean" default="false" />
- <xs:attribute name="xml-name-transformer" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="java-attribute" type="java-attribute" />
- <xs:complexType name="java-attribute" abstract="true">
- <xs:attribute name="java-attribute" type="xs:string" />
- </xs:complexType>
- <xs:element name="xml-access-methods" type="xml-access-methods" />
- <xs:complexType name="xml-access-methods">
- <xs:attribute name="get-method" type="xs:string" />
- <xs:attribute name="set-method" type="xs:string" />
- </xs:complexType>
- <xs:element name="xml-class-extractor" type="xml-class-extractor" />
- <xs:complexType name="xml-class-extractor">
- <xs:attribute name="class" type="xs:string" use="required"/>
- </xs:complexType>
- <xs:element name="xml-properties" type="xml-properties" />
- <xs:complexType name="xml-properties">
- <xs:sequence>
- <xs:element name="xml-property" minOccurs="0" maxOccurs="unbounded" >
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" use="required" />
- <xs:attribute name="value" type="xs:string" use="required" />
- <xs:attribute name="value-type" type="xs:string" default="java.lang.String" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- <!-- Enums -->
- <xs:simpleType name="xml-access-order">
- <xs:restriction base="xs:string">
- <xs:enumeration value="ALPHABETICAL" />
- <xs:enumeration value="UNDEFINED" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="xml-access-type">
- <xs:restriction base="xs:string">
- <xs:enumeration value="FIELD" />
- <xs:enumeration value="NONE" />
- <xs:enumeration value="PROPERTY" />
- <xs:enumeration value="PUBLIC_MEMBER" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="xml-ns-form">
- <xs:restriction base="xs:string">
- <xs:enumeration value="UNQUALIFIED" />
- <xs:enumeration value="QUALIFIED" />
- <xs:enumeration value="UNSET" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="xml-marshal-null-representation">
- <xs:restriction base="xs:string">
- <xs:enumeration value="XSI_NIL" />
- <xs:enumeration value="ABSENT_NODE" />
- <xs:enumeration value="EMPTY_NODE" />
- </xs:restriction>
- </xs:simpleType>
- <xs:simpleType name="supported-versions">
- <xs:restriction base="xs:string">
- <xs:enumeration value="2.0"/>
- <xs:enumeration value="2.1"/>
- <xs:enumeration value="2.2"/>
- <xs:enumeration value="2.3"/>
- </xs:restriction>
- </xs:simpleType>
-
- <!-- @Target(value=PACKAGE) -->
- <xs:element name="xml-schema">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="xml-ns" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="namespace-uri" type="xs:string" />
- <xs:attribute name="prefix" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="attribute-form-default" type="xml-ns-form" default="UNSET" />
- <xs:attribute name="element-form-default" type="xml-ns-form" default="UNSET" />
- <xs:attribute name="location" type="xs:string" />
- <xs:attribute name="namespace" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-schema-types">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-schema-type" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-java-type-adapters">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-java-type-adapter" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={FIELD,METHOD,PACKAGE}) -->
- <xs:element name="xml-schema-type">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" use="required" />
- <xs:attribute name="namespace" type="xs:string" default="http://www.w3.org/2001/XMLSchema" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.XmlSchemaType.DEFAULT" />
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={PACKAGE,FIELD,METHOD,TYPE,PARAMETER}) -->
- <xs:element name="xml-java-type-adapter" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:attribute name="value" type="xs:string" use="required" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter.DEFAULT" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={FIELD,METHOD,TYPE}) -->
- <xs:element name="xml-transient" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute" />
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value=TYPE) -->
- <xs:element name="xml-enum">
- <xs:complexType>
- <xs:sequence>
- <xs:element ref="xml-enum-value" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- <xs:attribute name="java-enum" type="xs:string" use="required" />
- <xs:attribute name="value" type="xs:string" default="java.lang.String" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-type">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="factory-class" type="xs:string" default="javax.xml.bind.annotation.XmlType.DEFAULT" />
- <xs:attribute name="factory-method" type="xs:string" />
- <xs:attribute name="prop-order">
- <xs:simpleType>
- <xs:list itemType="xs:string" />
- </xs:simpleType>
- </xs:attribute>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-root-element">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-see-also">
- <xs:simpleType>
- <xs:list itemType="xs:string" />
- </xs:simpleType>
- </xs:element>
- <xs:element name="xml-virtual-access-methods">
- <xs:complexType>
- <xs:attribute name="get-method" type="xs:string" default="get" />
- <xs:attribute name="set-method" type="xs:string" default="set" />
- <xs:attribute name="schema" type="xml-virtual-access-methods-schema" default="NODES" />
- </xs:complexType>
- </xs:element>
- <xs:simpleType name="xml-virtual-access-methods-schema">
- <xs:restriction base="xs:string">
- <xs:enumeration value="NODES" />
- <xs:enumeration value="ANY" />
- </xs:restriction>
- </xs:simpleType>
-
- <!-- @Target(value={FIELD}) -->
- <xs:element name="xml-enum-value">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:string">
- <xs:attribute name="java-enum-value" type="xs:string" use="required" />
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
-
- <!-- @Target(value={FIELD,METHOD}) -->
- <xs:element name="xml-any-attribute" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-properties" minOccurs="0" />
- </xs:all>
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="xml-path" type="xs:string" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-attribute" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-abstract-null-policy" minOccurs="0" />
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-schema-type" minOccurs="0"/>
- </xs:all>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- <xs:attribute name="xml-id" type="xs:boolean" default="false" />
- <xs:attribute name="xml-idref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-key" type="xs:boolean" default="false" />
- <xs:attribute name="xml-list" type="xs:boolean" default="false" />
- <xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" />
- <xs:attribute name="xml-attachment-ref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-mime-type" type="xs:string" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="##default" />
- <xs:attribute name="xml-path" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-any-element" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-element-refs" minOccurs="0" />
- </xs:all>
- <xs:attribute name="xml-mixed" type="xs:boolean" default="false" />
- <xs:attribute name="lax" type="xs:boolean" default="false" />
- <xs:attribute name="dom-handler" type="xs:string" default="javax.xml.bind.annotation.W3CDomHandler" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="xml-path" type="xs:string" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-abstract-null-policy" minOccurs="0" />
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-element-wrapper" minOccurs="0"/>
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- <xs:element ref="xml-map" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-schema-type" minOccurs="0" />
- </xs:all>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="default-value" type="xs:string" />
- <xs:attribute name="nillable" type="xs:boolean" default="false" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.XmlElement.DEFAULT" />
- <xs:attribute name="xml-id" type="xs:boolean" default="false" />
- <xs:attribute name="xml-idref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-key" type="xs:boolean" default="false" />
- <xs:attribute name="xml-list" type="xs:boolean" default="false" />
- <xs:attribute name="xml-inline-binary-data" type="xs:boolean" default="false" />
- <xs:attribute name="xml-attachment-ref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-mime-type" type="xs:string" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="cdata" type="xs:boolean" default="false" />
- <xs:attribute name="xml-path" type="xs:string" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-elements" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:sequence>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-element" minOccurs="0" maxOccurs="unbounded" />
- <xs:element ref="xml-element-wrapper" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-join-nodes" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- <xs:attribute name="xml-idref" type="xs:boolean" default="false" />
- <xs:attribute name="xml-list" type="xs:boolean" default="false" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element-ref" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element name="xml-access-methods" type="xml-access-methods" minOccurs="0"/>
- <xs:element ref="xml-element-wrapper" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-java-type-adapter" minOccurs="0" />
- </xs:all>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="javax.xml.bind.annotation.XmlElementRef.DEFAULT" />
- <xs:attribute name="xml-mixed" type="xs:boolean" default="false" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element-refs" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:sequence>
- <xs:element name="xml-access-methods" type="xml-access-methods" minOccurs="0"/>
- <xs:element ref="xml-element-ref" minOccurs="0" maxOccurs="unbounded" />
- <xs:element ref="xml-element-wrapper" minOccurs="0" />
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-java-type-adapter" minOccurs="0" />
- </xs:sequence>
- <xs:attribute name="xml-mixed" type="xs:boolean" default="false" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-inverse-reference" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-properties" minOccurs="0" />
- </xs:all>
- <xs:attribute name="mapped-by" type="xs:string" use="required" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-element-wrapper">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" default="##default" />
- <xs:attribute name="namespace" type="xs:string" default="##default" />
- <xs:attribute name="nillable" type="xs:boolean" default="false" />
- <xs:attribute name="required" type="xs:boolean" default="false" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-value" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:all>
- <xs:element ref="xml-abstract-null-policy" minOccurs="0" />
- <xs:element ref="xml-access-methods" minOccurs="0" />
- <xs:element ref="xml-properties" minOccurs="0" />
- <xs:element ref="xml-java-type-adapter" minOccurs="0"/>
- </xs:all>
- <xs:attribute name="cdata" type="xs:boolean" default="false" />
- <xs:attribute name="read-only" type="xs:boolean" default="false" />
- <xs:attribute name="type" type="xs:string" default="##default" />
- <xs:attribute name="write-only" type="xs:boolean" default="false" />
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-map">
- <xs:complexType>
- <xs:all>
- <xs:element name="key" minOccurs="0">
- <xs:complexType>
- <xs:attribute name="type" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="value" minOccurs="0">
- <xs:complexType>
- <xs:attribute name="type" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:all>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-abstract-null-policy" type="xml-abstract-null-policy" />
- <xs:complexType name="xml-abstract-null-policy" abstract="true">
- <xs:attribute name="xsi-nil-represents-null" type="xs:boolean" default="false" />
- <xs:attribute name="empty-node-represents-null" type="xs:boolean" default="false" />
- <xs:attribute name="null-representation-for-xml" type="xml-marshal-null-representation" default="ABSENT_NODE" />
- </xs:complexType>
- <xs:element name="xml-null-policy" substitutionGroup="xml-abstract-null-policy">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="xml-abstract-null-policy">
- <xs:attribute name="is-set-performed-for-absent-node" type="xs:boolean" default="true" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-is-set-null-policy" substitutionGroup="xml-abstract-null-policy">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="xml-abstract-null-policy">
- <xs:sequence>
- <xs:element name="is-set-parameter" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="value" type="xs:string" use="required" />
- <xs:attribute name="type" type="xs:string" use="required" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="is-set-method-name" type="xs:string" use="required" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-transformation" substitutionGroup="java-attribute">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:sequence>
- <xs:element name="xml-access-methods" type="xml-access-methods" minOccurs="0"/>
- <xs:element ref="xml-properties" minOccurs="0"/>
- <xs:element name="xml-read-transformer">
- <xs:complexType>
- <xs:attribute name="method" type="xs:string" />
- <xs:attribute name="transformer-class" type="xs:string" />
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-write-transformer" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="method" type="xs:string" />
- <xs:attribute name="xml-path" type="xs:string" use="required" />
- <xs:attribute name="transformer-class" type="xs:string" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="optional" type="xs:boolean" default="true"/>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
- <xs:element name="xml-join-nodes" substitutionGroup="java-attribute" >
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="java-attribute">
- <xs:sequence>
- <xs:element name="xml-join-node" minOccurs="1" maxOccurs="unbounded" >
- <xs:complexType>
- <xs:attribute name="xml-path" type="xs:string" use="required" />
- <xs:attribute name="referenced-xml-path" type="xs:string" use="required" />
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="container-type" type="xs:string" default="##default" />
- <xs:attribute name="type" type="xs:string" default="##default" />
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-</xs:schema> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_1.1.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_1.1.xsd
deleted file mode 100644
index 3746ead644..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_1.1.xsd
+++ /dev/null
@@ -1,4183 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-******************************************************************************
- Copyright (c) 1998, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- which accompanies this distribution.
- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- and the Eclipse Distribution License is available at
- http://www.eclipse.org/org/documents/edl-v10.php.
-
- Contributors:
- Oracle - initial API and implementation from Oracle TopLink
-*****************************************************************************/
--->
-<!-- Eclipse Persistence Service Project :: Map Schema file for ORM/OXM/EIS -->
-<xsd:schema
- targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns="http://www.eclipse.org/eclipselink/xsds/persistence"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="1.1"
- >
- <xsd:element name="object-persistence" type="object-persistence" />
- <xsd:complexType name="object-persistence">
- <xsd:annotation>
- <xsd:documentation>An object-persistence mapping module, a set of class-mapping-descriptors.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>A name for the model being mapped.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-mapping-descriptors">
- <xsd:annotation>
- <xsd:documentation>The list of class mapping descriptors.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="class-mapping-descriptor" type="class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Information of how a class is persisted to its data-store.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="login" type="datasource-login">
- <xsd:annotation>
- <xsd:documentation>The datasource connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="default-temporal-mutable" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines the default for how Date and Calendar types are used with change tracking.</xsd:documentation>
- <xsd:documentation>By default they are assumed not to be changed directly (only replaced).</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute default="Eclipse Persistence Services - 1.1 (Build YYMMDD)" name="version" type="xsd:string" />
- </xsd:complexType>
- <xsd:complexType name="datasource-login">
- <xsd:annotation>
- <xsd:documentation>The datasource connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="platform-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the platform class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="user-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The datasource user-name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="password" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The datasource password, this is stored in encrypted form.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="external-connection-pooling" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines if the connections are managed by the datasource driver, and a new connection should be acquire per call.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="external-transaction-controller" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines if the transaction are managed by a transaction manager, and should not be managed by TopLink.</xsd:documentation>
- <xsd:documentation>This can also be used if the datasource does not support transactions.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="sequencing">
- <xsd:annotation>
- <xsd:documentation>Sequencing information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="default-sequence" type="sequence">
- <xsd:annotation>
- <xsd:documentation>Default sequence. The name is optional. If no name provided an empty string will be used as a name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="sequences">
- <xsd:annotation>
- <xsd:documentation>Non default sequences. Make sure each sequence has unique name.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="sequence" type="sequence" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="database-login">
- <xsd:annotation>
- <xsd:documentation>The JDBC driver and database connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="datasource-login">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="driver-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the JDBC driver class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="connection-url" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The full JDBC driver connection URL.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="bind-all-parameters" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if parameter binding should be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cache-all-statements" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if statement caching should be used. This should be used with parameter binding, this cannot be used with external connection pooling.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="byte-array-binding" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if byte array data-types should use binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="string-binding" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if string data-types should use binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="256" name="string-binding-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Configure the threshold string size for usage of string binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="streams-for-binding" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if large byte array and string data-types should be bound as streams.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="force-field-names-to-upper-case" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure to force all field names to upper-case.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="optimize-data-conversion" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure data optimization.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="trim-strings" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if string trailing blanks should be trimmed. This is normally required for CHAR data-types.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-writing" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if batch writing should be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="jdbc-batch-writing" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If using batch writing, configure if the JDBC drivers batch writing should be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-login">
- <xsd:annotation>
- <xsd:documentation>The JCA driver and EIS connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="datasource-login">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="connection-spec-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the TopLink platform specific connection spec class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="connection-factory-url" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The JNDI url for the managed JCA adapter's connection factory.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-login">
- <xsd:annotation>
- <xsd:documentation>The connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="datasource-login">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true"
- name="equal-namespace-resolvers" type="xsd:boolean" />
- <xsd:element name="document-preservation-policy"
- type="document-preservation-policy" maxOccurs="1"
- minOccurs="0">
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Information of how a class is persisted to its data-store.</xsd:documentation>
- <xsd:documentation>This is an abstract definition to allow flexibility in the types of classes and datastores persisted, i.e. interfaces, abstract classes, aggregates, non-relational persistence.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the implementation class being persisted. The class name must be full qualified with its package.</xsd:documentation>
- <xsd:documentation>Example: <class xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">example.employee.implementation.Employee</class></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="alias" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optionally an alias name can be given for the class. The alias is a string that can be used to refer to the class in place of its implementation name, such as in querying.</xsd:documentation>
- <xsd:documentation>Example: <alias xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">Employee</alias></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="primary-key">
- <xsd:annotation>
- <xsd:documentation>The list of fields/columns that make up the primary key or unique identifier of the class.</xsd:documentation>
- <xsd:documentation>This is used for caching, relationships, and for database operations.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The primary key field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="read-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines if the class is read-only.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="properties">
- <xsd:annotation>
- <xsd:documentation>Allow for user defined properties to be defined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="property" type="property">
- <xsd:annotation>
- <xsd:documentation>A user defined property.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="inheritance" type="inheritance-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class is related in inheritance and how this inheritance is persisted.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="events" type="event-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the persistent events for this class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="querying" type="query-policy">
- <xsd:annotation>
- <xsd:documentation>The list of defined queries for the class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="attribute-mappings">
- <xsd:annotation>
- <xsd:documentation>The list of mappings that define how the class' attributes are persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="attribute-mapping" type="attribute-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a attribute is persisted. The attribute mapping definition is extendable to allow for different types of mappings.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="descriptor-type" type="class-descriptor-type">
- <xsd:annotation>
- <xsd:documentation>Defines the descriptor type, such as aggregate or independent.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="interfaces" type="interface-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the interfaces that this class implements..</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="locking" type="locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the locking behavior for the class. Such as an optimistic locking policy based on version, timestamp or change set of columns.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="sequencing" type="sequencing-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how a generated unique id should be assigned to the class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="caching" type="caching-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class' instances should be cached.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="remote-caching" type="caching-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class' instances should be cached on remote clients.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="history-policy" type="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of objects are persisted to the data-store. By default there will be no history policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="returning-policy" type="returning-policy">
- <xsd:annotation>
- <xsd:documentation>Defines retuning policy. By default there will be no returning policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="amendment" type="amendment">
- <xsd:annotation>
- <xsd:documentation>Allow for the descriptor to be amended or customized through a class API after loading.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="instantiation" type="instantiation-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object instantiation behavoir to be customized</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="copying" type="copy-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object cloning/copying behavoir to be customized.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="query-keys">
- <xsd:annotation>
- <xsd:documentation>A list of query keys or aliases for database information. These can be used in queries instead of the database column names.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="query-key" type="query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for querying database information.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="cmp-policy" type="cmp-policy">
- <xsd:annotation>
- <xsd:documentation>Place holder of CMP information specific.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-groups" type="fetch-groups">
- <xsd:annotation>
- <xsd:documentation>Contains all pre-defined fetch groups at the descriptor level</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="1" name="change-policy" type="change-policy">
- <xsd:annotation>
- <xsd:documentation>Contains the Change Policy for this descriptor</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute fixed="10" name="schema-major-version" type="xsd:integer" />
- <xsd:attribute fixed="0" name="schema-minor-version" type="xsd:integer" />
- </xsd:complexType>
- <xsd:simpleType name="class-descriptor-type">
- <xsd:annotation>
- <xsd:documentation>Defines the class descriptor type.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="independent" />
- <xsd:enumeration value="aggregate" />
- <xsd:enumeration value="aggregate-collection" />
- <xsd:enumeration value="composite" />
- <xsd:enumeration value="composite" />
- <xsd:enumeration value="interface" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="interface-policy">
- <xsd:annotation>
- <xsd:documentation>Specify the interfaces that a class descriptor implements, or the implemention class for an interface descriptor.</xsd:documentation>
- <xsd:documentation>Optionally a set of public interfaces for the class can be specified. This allows the interface to be used to refer to the implementation class.</xsd:documentation>
- <xsd:documentation>If two classes implement the same interface, an interface descriptor should be defined for the interface.</xsd:documentation>
- <xsd:documentation>This can also be used to define inheritance between interface descriptors.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="interface" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified interface class name.</xsd:documentation>
- <xsd:documentation>Example: <class xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">example.employee.api.Employee</class></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="implementor-descriptor" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class name of the implementation class for which this interface is the public interface.</xsd:documentation>
- <xsd:documentation>This can be used if the interface has only a single implementor.</xsd:documentation>
- <xsd:documentation>Example: <class xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">example.employee.impl.Employee</class></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="copy-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object cloning/copying behavoir to be customized.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="instantiation-copy-policy">
- <xsd:annotation>
- <xsd:documentation>Creates a copying through creating a new instance to copy into.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="copy-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="clone-copy-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object cloning/copying behavoir to be customized through a clone method.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="copy-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the clone method on the object, i.e. 'clone'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="instantiation-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object instantiation behavoir to be customized.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the method on the factory to instantiate the object instance.'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="factory-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified factory class name.'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="factory-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the method to instantiate the factory class.'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="amendment">
- <xsd:annotation>
- <xsd:documentation>Specifies a class and static method to be called to allow for the descriptor to be amended or customized through a class API after loading.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="amendment-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation> The fully qualified name of the amendment class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="amendment-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the static amendment method on the class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="relational-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to a relational database table(s).</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="tables">
- <xsd:annotation>
- <xsd:documentation>The list of the tables the class is persisted to. Typically a class is persisted to a single table, but multiple tables can be defined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="table" type="table">
- <xsd:annotation>
- <xsd:documentation>The list of tables that the class is persisted to. This is typically a single table but can be multiple, or empty for inheritance or aggregated classes.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-keys-for-multiple-table" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>Allow the foreign key field references to be define for multiple table descriptors.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="multiple-table-join-criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>For complex multiple table join conditions an expression may be provided instead of the table foreign key information.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="version-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on a numeric version field/column that tracks changes and the version to an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy">
- <xsd:sequence>
- <xsd:element name="version-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The name and optionally the table of the column that the attribute is stored into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="store-version-in-cache" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the version value should be stored in the cache, or if it will be stored in the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="timestamp-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on timestamp version column that tracks changes and the version to an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="version-locking-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="server-time" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the timestamp should be obtained locally or from the database server.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="all-fields-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on comparing the original read values of all fields of the object with the current state of the values in the database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="changed-fields-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on comparing the original read values of only the changed fields of the object with the current state of the values in the database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="selected-fields-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on comparing the original read values of a specified set of fields of the object with the current state of the values in the database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy">
- <xsd:sequence>
- <xsd:element name="fields">
- <xsd:annotation>
- <xsd:documentation>Specify the set of fields to compare on update and delete.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="sequencing-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how a database generated unique id should be assigned to the class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="sequence-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the name of the sequence generator. This could be the name of a sequence object, or a row value in a sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="sequence-field" type="field">
- <xsd:annotation>
- <xsd:documentation>Specify the field/column that the generated sequence id is assigned to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:simpleType name="cache-type">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid caching types.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="none" />
- <xsd:enumeration value="full" />
- <xsd:enumeration value="cache" />
- <xsd:enumeration value="weak-reference" />
- <xsd:enumeration value="soft-reference" />
- <xsd:enumeration value="soft-cache-weak-reference" />
- <xsd:enumeration value="hard-cache-weak-reference" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="caching-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class' instances should be cached and how object identity should be maintained.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="soft-cache-weak-reference" name="cache-type" type="cache-type">
- <xsd:annotation>
- <xsd:documentation>Specify the type of caching, such as LRU, weak reference or none.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="100" name="cache-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specify the initial or maximum size of the cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="always-refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to always refresh cached objects on queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="only-refresh-cache-if-newer-version" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to refresh if the cached object is an older version.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="disable-cache-hits" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Disable obtaining cache hits on primary key queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="always-conform" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to always conform queries within a transaction.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="isolated" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if objects of this type should be isolated from the shared cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="isolate-new-data-after-transaction" name="unitofwork-isolation-level" type="unitofwork-isolation-level">
- <xsd:annotation>
- <xsd:documentation>Specify how the unit of work should be isolated to the session cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="cache-invalidation-policy" type="cache-invalidation">
- <xsd:annotation>
- <xsd:documentation>Defines the cache invalidation policy. By default there will be no cache invalidation policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="change-set" name="cache-sync-type" type="cache-sync-type">
- <xsd:annotation>
- <xsd:documentation>The type of cache synchronization to be used with this descripor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="cache-invalidation" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Abstract superclass for cache invalidation policies.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="update-read-time-on-update" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="no-expiry-cache-invalidation-policy">
- <xsd:annotation>
- <xsd:documentation>Cache invalidation policy where objects in the cache do not expire.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="cache-invalidation" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="time-to-live-cache-invalidation-policy">
- <xsd:annotation>
- <xsd:documentation>Cache invalidation policy where objects live a specific number of milliseconds after they are read.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="cache-invalidation">
- <xsd:sequence>
- <xsd:element name="time-to-live" type="xsd:long" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="daily-cache-invalidation-policy">
- <xsd:annotation>
- <xsd:documentation>Cache invalidation Policy where objects expire at a specific time every day</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="cache-invalidation">
- <xsd:sequence>
- <xsd:element name="expiry-time" type="xsd:dateTime" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of objects are to be persisted to the data-store.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true" name="handle-writes" type="xsd:boolean" />
- <xsd:element minOccurs="0" default="false" name="use-database-time" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="history-tables">
- <xsd:annotation>
- <xsd:documentation>Defines the names of the mirroring historical tables.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="history-table" type="history-table" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="start-fields">
- <xsd:annotation>
- <xsd:documentation>Defines the start fields for each historical table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="start-field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="end-fields">
- <xsd:annotation>
- <xsd:documentation>Defines the end fields for each historical table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="end-field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="history-table">
- <xsd:annotation>
- <xsd:documentation>Each entry is a source (descriptor) to history table name association.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="" name="source" type="xsd:string" />
- <xsd:element minOccurs="1" name="history" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="returning-policy">
- <xsd:annotation>
- <xsd:documentation>Defines retuning policy. By default there will be no returning policy.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="1" name="returning-field-infos">
- <xsd:annotation>
- <xsd:documentation>Lists the fields to be returned together with the flags defining returning options</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="returning-field-info" type="returning-field-info" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="returning-field-info">
- <xsd:annotation>
- <xsd:documentation>Field to be returned together with type and the flags defining returning options. At least one of insert, update should be true.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the target referenced class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field to be returned.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="insert" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates whether the field should be retuned after Insert.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="insert-mode-return-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If insert==true, indicates whether the field should not be inserted (true). If insert==false - ignored.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="update" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates whether the field should be retuned after Insert.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="inheritance-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class is related in inheritance and how this inheritance is persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="parent-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the parent/superclass of the class being persisted. The class name must be full qualified with its package.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="read-subclasses-on-queries" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Define if subclasses of the class should be returned on queries, or only the exact class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="all-subclasses-view" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optionally specify the name of a view that joins all of the subclass' tables.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="use-class-name-as-indicator" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the fully qualified class name should be used as the class type indicator.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-extraction-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of a method on the class that takes the class' row as argument a computed that class type to be used to instantiate from the row.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-indicator-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The name of the type field/column that the class type is stored into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-indicator-mappings" type="class-indicator-mappings">
- <xsd:annotation>
- <xsd:documentation>The set of class indicator values and the subclasses they map to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-extractor" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of a class that implements a class extractor interface.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="only-instances-criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The criteria that filters out all sibling and subclass instances on queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="all-subclasses-criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The criteria that filters out sibling instances on queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="outer-join-subclasses" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>For inheritance queries specify if all subclasses should be outer joined, instead of a query per subclass.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="qname-inheritance-policy">
- <xsd:annotation>
- <xsd:documentation>Extends inheritance policy. Allows for prefixed names to be resolved at runtime to find the approriate class</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="inheritance-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="class-indicator-mappings">
- <xsd:annotation>
- <xsd:documentation>The set of class indicator values and the subclasses they map to.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="class-indicator-mapping">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the class the type maps to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="class-indicator" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>The field value used to define the class type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="event-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the persistent events for this class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="event-listeners">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="event-listener" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of an event listener class that implements the descriptor event listener interface.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-build-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after building the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-write-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before writing the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-write-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after writing the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-insert-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before inserting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-insert-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after inserting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-update-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before updating the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-update-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after updating the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-delete-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before deleting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-delete-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after deleting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="about-to-insert-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before inserting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="about-to-update-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before updating the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-clone-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after cloning the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-merge-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after merging the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-refresh-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after refreshing the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="query-policy">
- <xsd:annotation>
- <xsd:documentation>The list of defined queries and query properties for the class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="queries">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="query" type="query">
- <xsd:annotation>
- <xsd:documentation>A query definition for the class' instances.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="timeout" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies a timeout to apply to all queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="check-cache" name="existence" type="existence-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the behavoir used to determine if an insert or update should occur for an object to be customized.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="insert-query" type="insert-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom insert query. This overide the default insert behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="update-query" type="update-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom update query. This overide the default update behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-query" type="delete-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom delete query. This overide the default delete behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="does-exist-query" type="does-exist-query">
- <xsd:annotation>
- <xsd:documentation>Custom does exist query. This overide the default delete behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="read-object-query" type="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom read object query. This overide the default read behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="read-all-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Custom read all query. This overide the default read all behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:simpleType name="existence-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid existence policies for determining if an insert or update should occur for an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="check-cache" />
- <xsd:enumeration value="check-database" />
- <xsd:enumeration value="assume-existence" />
- <xsd:enumeration value="assume-non-existence" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for querying database information.</xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query-key alias name.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:simpleType name="cache-sync-type">
- <xsd:annotation>
- <xsd:documentation>The type of cache synchronization to use with a descriptor.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="invalidation" />
- <xsd:enumeration value="no-changes" />
- <xsd:enumeration value="change-set-with-new-objects" />
- <xsd:enumeration value="change-set" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="unitofwork-isolation-level">
- <xsd:annotation>
- <xsd:documentation>Specify how the unit of work isolated from the session cache.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="use-session-cache-after-transaction" />
- <xsd:enumeration value="isolate-new-data-after-transaction" />
- <xsd:enumeration value="isolate-cache-after-transaction" />
- <xsd:enumeration value="isolate-cache-always" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="direct-query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a database column.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="query-key">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column being aliased.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="relationship-query-key" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a join to another class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="query-key">
- <xsd:sequence>
- <xsd:element name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the target referenced class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:choice>
- <xsd:element name="foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key join condition between the source and target class' tables.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The join criteria between the source and target class' tables.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:choice>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-one-query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a 1-1 join to another class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-query-key" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-many-query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a 1-m join from another class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="relationship-query-key" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping from an attirbute to a simple field datatype, i.e. String, Number, Date.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The name and optionally the table of the field/column that the attribute is stored into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="null-value" type="xsd:anySimpleType" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Optionally specify a value that null data values should be converted to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="converter" type="value-converter" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="attribute-classification" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="attribute-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a attribute is persisted. The attribute mapping definition is extendable to allow for different types of mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="attribute-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the attribute. This is the implementation class attribute name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="read-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the attribute is read-only.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="get-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the get method for the attribute.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="set-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the set method for the attribute.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="properties">
- <xsd:annotation>
- <xsd:documentation>Allow for user defined properties to be defined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="property" type="property">
- <xsd:annotation>
- <xsd:documentation>A user defined property.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a simple attribute is persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="abstract-direct-mapping">
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping from an attirbute to a simple field datatype, i.e. String, Number, Date.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="abstract-direct-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-cdata" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="null-policy" type="abstract-null-policy" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping from an attirbute to a simple field datatype, i.e. String, Number, Date.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-direct-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="field-transformation" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a field transformation for a transformation mapping</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="method-based-field-transformation">
- <xsd:complexContent mixed="false">
- <xsd:extension base="field-transformation">
- <xsd:sequence>
- <xsd:element name="method" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="transformer-based-field-transformation">
- <xsd:complexContent mixed="false">
- <xsd:extension base="field-transformation">
- <xsd:sequence>
- <xsd:element name="transformer-class" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a transformation mapping that uses Java code to transform between the data and object values.</xsd:documentation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="attribute-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the attribute transformation defined in the domain class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="attribute-transformer" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The class name of the attribute transformer. Used in place of attribute-transformation.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="mutable" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy" />
- <xsd:element minOccurs="0" name="field-transformations">
- <xsd:annotation>
- <xsd:documentation>The field transformations.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field-transformation" type="field-transformation" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-transformation-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-transformation-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-transformation-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="aggregate-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a relationship where the target object is strictly privately owned by the source object and stores within the source objects row</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class name of the target class of the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="allow-null" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if a row of all nulls should be interpreted as null.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="field-translations">
- <xsd:annotation>
- <xsd:documentation>Allow for the mapping to use different field names than the descriptor.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field-translation">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="source-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field in the source descriptor's table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field in the aggregate descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="relationship-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a relationship between two classes is persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class name of the target class of the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="private-owned" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the target objects are privately owned dependent objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-persist" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the create operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-merge" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the create operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the refresh operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-remove" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the remove operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-one-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source instance to the target instance.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the source class' table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-one-to-one-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source instance to the target instance.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="one-to-one-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-many-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m relationship from the source instance to the target instances.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="target-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the target class' table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the related objects can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-one-to-many-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m relationship from the source instance to the target instances.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="source-foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="target-foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-key-grouping-element" type="field" />
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the related objects can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a collection of simple types relationship from the source instance to a set of simple data values.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="data-read-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target data values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="reference-table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the reference table that stores the source primary key and the data values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="direct-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column in the reference table that stores the data values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="reference-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the reference table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="value-converter" type="value-converter">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="insert-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to insert a row into the reference table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete a row from the reference table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the rows from the reference table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="session-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name session that defines the reference table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="history-policy" type="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of this attribute are persisted to the data-store. By default there will be no history policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-map-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a map relationship from the source instance to a set of key values pairs of simple data values.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="direct-collection-mapping">
- <xsd:sequence>
- <xsd:element name="direct-key-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column in the reference table that sores the map key data value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="key-converter" type="value-converter">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the key data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="aggregate-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m relationship from the source instance to the target instances where the target instances are strictly privately owned by the source object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="target-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the target class' table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the related objects can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="many-to-many-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a m-m relationship from the source instance to the target instances.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="relation-table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the relation table that stores the source/target primary keys.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="source-relation-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key from the relational table to the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-relation-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key from the relational table to the target class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="insert-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to insert a row into the relation table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete a row from the relation table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the rows from the relation table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="history-policy" type="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of this attribute are persisted to the data-store. By default there will be no history policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="variable-one-to-one-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source instance to the target instance that may be of several types related through an interface.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="type-field" type="field">
- <xsd:annotation>
- <xsd:documentation>Specify the column to store the class type of the related object into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="foreign-key-to-query-key">
- <xsd:annotation>
- <xsd:documentation>The list of source/target column/query key references relating a foreign key in one table to the query keys defining a primary or unique key value in the other interface descriptor.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="query-key-reference">
- <xsd:annotation>
- <xsd:documentation>The reference of a source table foreign key and a target interface descriptor query key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="source-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The foreign key field/column name in the source table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-query-key" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query key name of the target interface descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-indicator-mappings" type="class-indicator-mappings">
- <xsd:annotation>
- <xsd:documentation>The set of class indicator values and the subclasses they map to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a container/collection type.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="collection-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the collection implementation class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="sorted-collection-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a sorted collection type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="comparator-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the comparitor, used to compare objects in sorting the collection.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="list-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a list collection type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="map-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a map container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="map-key-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the method to call on the target objects to get the key value for the map.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-map-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a direct map container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="scrollable-cursor-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a scrollable cursor container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="cursored-stream-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a cursored stream container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="indirection-policy" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a deferred read indirection mechanism.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="value-holder-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of value holders to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="proxy-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of proxies to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="transparent-collection-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of transparent collections to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="collection-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the collection interface to use, i.e. List, Set, Map.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="map-key-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the method to call on the target objects to get the key value for the map.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="container-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of a user defined container to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy">
- <xsd:sequence>
- <xsd:element name="container-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the container implementer to use.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="typesafe-enumeration-converter">
- <xsd:annotation>
- <xsd:documentation>Typesafe Enumeration conversion</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="type-conversion-converter">
- <xsd:annotation>
- <xsd:documentation>Specifies the data type and an object type of the attribute to convert between.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="object-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the attribute type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="data-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the attributes storage data type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="serialized-object-converter">
- <xsd:annotation>
- <xsd:documentation>Uses object serialization to convert between the object and data type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="data-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the attributes storage data type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-type-converter">
- <xsd:annotation>
- <xsd:documentation>Specifies a mapping of values from database values used in the field and object values used in the attribute.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="default-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>An optional default value can be specified. This value is used if a database type is not found in the type mapping.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="type-mappings">
- <xsd:annotation>
- <xsd:documentation>Specifies the mapping of values. Both the object and database values must be unique.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="type-mapping" type="type-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines the object and data value mapping.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="attribute-only-type-mappings">
- <xsd:annotation>
- <xsd:documentation>Specifies a mapping of additional values that map non-unique data values to a unique attribute value.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="type-mapping" type="type-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines the object and data value mapping.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="type-mapping">
- <xsd:annotation>
- <xsd:documentation>Define an object and data value mapping.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="object-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>Specifies the value to use in the object's attribute.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="data-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>Specifies the value to use in the database field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="database-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query/interaction against a database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="query">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true" name="maintain-cache" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should bypass the cache completely.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bind-all-parameters" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should use paramater binding for arguments, or print the arguments in-line.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="cache-statement" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the queries statement should be cached, this must be used with parameter binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="timeout" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies a timeout to cancel the query in if the request takes too long to complete.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="prepare" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should prepare and cache its generated SQL, or regenerate the SQL on each execution.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="call" type="criteria">
- <xsd:annotation>
- <xsd:documentation>For static calls the SQL or Stored Procedure call definition can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid join fetch options.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="none" />
- <xsd:enumeration value="inner-join" />
- <xsd:enumeration value="outer-join" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="cascade-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid cascade policies.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="none" />
- <xsd:enumeration value="private" />
- <xsd:enumeration value="all" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="value-read-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading a single value.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="direct-read-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-read-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading a collection of values.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="data-read-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="data-read-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading raw data.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="read-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="read-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="cache-query-results" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should cache the query results to avoid future executions.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="max-rows" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies the maximum number of rows to fetch, results will be trunctate on the database to this size.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="first-result" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies where to start the cursor in a result set returned from the database. Results prior to this number will not be built into objects</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifiess the number of rows to fetch from the database on each result set next operation.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="query-result-cache-policy" type="query-result-cache-policy">
- <xsd:annotation>
- <xsd:documentation>Specify how the query results should be cached.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="query-result-cache-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how a query's results should be cached.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="invalidation-policy" type="cache-invalidation">
- <xsd:annotation>
- <xsd:documentation>Defines the cache invalidation policy. By default there will be no cache invalidation policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="100" name="maximum-cached-results" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>This defines the number of query result sets that will be cached. The LRU query results will be discarded when the max size is reached.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for manipulating data.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-modify-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query for modifying an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="update-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for updating an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-modify-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="insert-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for inserting an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-modify-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="delete-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for deleting an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-modify-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="does-exist-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for determining if an object exists.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="existence-check" type="existence-check">
- <xsd:annotation>
- <xsd:documentation>The existence check option.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="existence-check">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid existence check options.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="check-cache" />
- <xsd:enumeration value="check-database" />
- <xsd:enumeration value="assume-existence" />
- <xsd:enumeration value="assume-non-existence" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for deleting a criteria of objects.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-level-read-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query for objects (as apposed to data).</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="read-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The full qualified name of the class of objects being queried.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should refresh any cached objects from the database.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="remote-refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should refresh any remotely cached objects from the server.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="cascade-policy" type="cascade-policy">
- <xsd:annotation>
- <xsd:documentation>Specifies if the queries settings (such as refresh, maintain-cache) should apply to the object's relationship queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="primary-key" name="cache-usage" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify how the query should interact with the cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="lock-mode" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should lock the resulting rows on the database.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="distinct-state" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should filter distinct results.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="in-memory-querying">
- <xsd:annotation>
- <xsd:documentation>The in memory querying policy.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element default="ignore-exceptions-return-conformed" name="policy" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify how indirection or unconformable expressions should be treating with in-memory querying and conforming.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="use-default-fetch-group" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the default fetch group should be used for the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-group" type="fetch-group">
- <xsd:annotation>
- <xsd:documentation>Allow the query to partially fetch the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-group-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify a pre-defined named fetch group to allow the query to partially fetch the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="use-exclusive-connection" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the exclusive connection (VPD) should be used for the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="joined-attribute-expressions">
- <xsd:annotation>
- <xsd:documentation>Specifies the attributes being joined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for joining</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="read-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if objects resulting from the query are read-only, and will not be registered in the unit of work.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="outer-join-subclasses" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>For inheritance queries specify if all subclasses should be outer joined, instead of a query per subclass.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for a set of objects.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-level-read-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="batch-read-attribute-expressions">
- <xsd:annotation>
- <xsd:documentation>Specifies all attributes for batch reading.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for batch reading</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="order-by-expressions">
- <xsd:annotation>
- <xsd:documentation>Sets the order expressions for the query.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for ordering</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for a single object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-level-read-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="report-query">
- <xsd:annotation>
- <xsd:documentation>Query for information about a set of objects instead of the objects themselves.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="read-all-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="return-choice" type="return-choice">
- <xsd:annotation>
- <xsd:documentation>Simplifies the result by only returning the first result, first value, or all attribute values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="retrieve-primary-keys" type="retrieve-primary-keys">
- <xsd:annotation>
- <xsd:documentation>Indicates wether the primary key values should also be retrieved for the reference class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="report-items">
- <xsd:annotation>
- <xsd:documentation>Items to be selected, these could be attributes or aggregate functions.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="item" type="report-item">
- <xsd:annotation>
- <xsd:documentation>Represents an item requested</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="group-by-expressions">
- <xsd:annotation>
- <xsd:documentation>Sets GROUP BY expressions for the query.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for grouping</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="return-choice">
- <xsd:annotation>
- <xsd:documentation>Simplifies the result by only returning the first result, first value, or all attribute values.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="return-single-result" />
- <xsd:enumeration value="return-single-value" />
- <xsd:enumeration value="return-single-attribute" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="retrieve-primary-keys">
- <xsd:annotation>
- <xsd:documentation>Indicates wether the primary key values should also be retrieved for the reference class.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="full-primary-key" />
- <xsd:enumeration value="first-primary-key" />
- <xsd:enumeration value="no-primary-key" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="report-item">
- <xsd:annotation>
- <xsd:documentation>Represents an item requested in ReportQuery.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Name given for item, can be used to retieve value from result.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="attribute-expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Expression (partial) that describes the attribute wanted.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="expression" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query filter expression tree.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="relation-expression">
- <xsd:annotation>
- <xsd:documentation>Defines a relation expression that compares to expressions through operators such as equal, lessThan, etc..</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="left" type="expression" />
- <xsd:element name="right" type="expression" />
- </xsd:sequence>
- <xsd:attribute name="operator" type="operator" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="logic-expression">
- <xsd:annotation>
- <xsd:documentation>Defines a expression composed of two sub-expressions joined through an operator such as AND, OR.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="left" type="expression" />
- <xsd:element name="right" type="expression" />
- </xsd:sequence>
- <xsd:attribute name="operator" type="operator" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="function-expression">
- <xsd:annotation>
- <xsd:documentation>Defines a expression composed of a function applied to a list of sub-expressions.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of function arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="expression">
- <xsd:annotation>
- <xsd:documentation>Defines an argument expression.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="function" type="operator" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="constant-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression value. If the value is null the value tag can is absent.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="value" type="xsd:anySimpleType" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="query-key-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression query-key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="base" type="expression" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" />
- <xsd:attribute name="any-of" type="xsd:boolean" />
- <xsd:attribute name="outer-join" type="xsd:boolean" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="field-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression field.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="field" type="field" />
- <xsd:element name="base" type="expression" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="parameter-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression parameter.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="parameter" type="field" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="base-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression builder/base.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="operator">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid operators.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string" />
- </xsd:simpleType>
- <xsd:complexType name="sql-call">
- <xsd:annotation>
- <xsd:documentation>Defines an SQL query language string.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="sql" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The full SQL query string. Arguments can be specified through #arg-name tokens in the string.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="ejbql-call">
- <xsd:annotation>
- <xsd:documentation>Defines an EJB-QL query language string.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="ejbql" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The EJB-QL query string.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="stored-procedure-call">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure invocation definition.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="procedure-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the stored procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="cursor-output-procedure" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Define the call to use a cursor output parameter to define the result set.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input and output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="procedure-argument">
- <xsd:annotation>
- <xsd:documentation>Defines an argument to the procedure. The order of the arguments must match the procedure arguments if not named.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="stored-function-call">
- <xsd:annotation>
- <xsd:documentation>Defines a stored function invocation definition.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="stored-procedure-call">
- <xsd:sequence>
- <xsd:element minOccurs="1" name="stored-function-result" type="procedure-output-argument">
- <xsd:annotation>
- <xsd:documentation>The return value of the stored-function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="procedure-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure call argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="procedure-argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The stored procedure name of the argument. For indexed argument the name is not required.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query name of the argument. This is the name of the argument as define in the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="procedure-argument-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the argument class type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="procedure-argument-sqltype" type="xsd:int">
- <xsd:annotation>
- <xsd:documentation>The JDBC int type of the argument, as defined in java.jdbc.Types</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="procedure-argument-sqltype-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the type if procedure-argument-sqltype is STRUCT or ARRAY</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="argument-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>The procedure argument value maybe be specified if not using a query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="procedure-output-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure call output argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="procedure-argument" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="procedure-inoutput-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure call output argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="procedure-argument">
- <xsd:sequence>
- <xsd:element name="output-argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query name of the argument. This is the name of the argument as define in the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-stored-procedure-call">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure invocation definition whose arguments contain at least one Oracle PL/SQL type that has no JDBC representation (e.g. BOOLEAN, PLS_INTEGER, PL/SQL record).</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="procedure-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the stored procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input and output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="plsql-procedure-argument-type">
- <xsd:annotation>
- <xsd:documentation>Defines an argument to the procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-procedure-argument-type" abstract="true">
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" />
- <xsd:element minOccurs="0" name="index" type="xsd:string" />
- <xsd:element minOccurs="0" name="direction" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="jdbc-type">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:sequence>
- <xsd:choice>
- <xsd:element minOccurs="0" name="length" type="xsd:string" />
- <xsd:sequence>
- <xsd:element name="precision" type="xsd:string" />
- <xsd:element name="scale" type="xsd:string" />
- </xsd:sequence>
- </xsd:choice>
- </xsd:sequence>
- <xsd:attribute name="type-name" type="xsd:string" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-type">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:attribute name="type-name" type="xsd:string" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-record">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:sequence>
- <xsd:element name="type-name" type="xsd:string" />
- <xsd:element minOccurs="0" name="compatible-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="java-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="fields">
- <xsd:annotation>
- <xsd:documentation>The list of fields.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="plsql-procedure-argument-type">
- <xsd:annotation>
- <xsd:documentation>Defines an argument to the procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-collection">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:sequence>
- <xsd:element name="type-name" type="xsd:string" />
- <xsd:element minOccurs="0" name="compatible-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="java-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="nested-type" type="plsql-procedure-argument-type" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to an EIS record data structure.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element name="datatype" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the record structure name the descriptor maps to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="namespace-resolver" type="namespace-resolver">
- <xsd:annotation>
- <xsd:documentation>The namespace resolver for the descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="mapped-interaction">
- <xsd:annotation>
- <xsd:documentation>Defines an EIS interaction utilizing MappedRecord.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="function-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the input result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the output result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-interaction">
- <xsd:annotation>
- <xsd:documentation>Defines an EIS interaction utilizing XML records.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="function-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-record-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name to use for the input record, if required by the adapter.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-root-element-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the output result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the input result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the output result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="indexed-interaction">
- <xsd:annotation>
- <xsd:documentation>Defines an EIS interaction utilizing Indexed records.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="function-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="interaction-argument">
- <xsd:annotation>
- <xsd:documentation>Defines an interaction argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="argument-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>The procedure argument value maybe be specified if not using a query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The interaction name of the argument. For indexed arguments the name is not required.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query name of the argumen. This is the name of the argument as define in the query, or the descriptor field name.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="object-relational-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to a Structure type in an object-relational database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relational-class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the object structure type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="field-order">
- <xsd:annotation>
- <xsd:documentation>The ordered list of the field defined in the structure.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="nested-table-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m/m-m relationship that makes use of the object-relational nested-table type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column in the source table that stores the nested-table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the object-relational type name of the nested-table type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="array-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a collection of primitive/simple type values using the object-relational array type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-direct-collection-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the object-relational type name of the structure type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-array-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a collection of object-types using the object-relational array type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping">
- <xsd:sequence>
- <xsd:element name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the object-relational type name of the structure type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="structure-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a structure of object-types using the object-relational structure type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-object-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="reference-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a reference to another object-type using the object-relational reference type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field in the source type that stores the reference.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-relational-field">
- <xsd:annotation>
- <xsd:documentation>Defines an ObjectRelationalDatabaseField</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="nested-type-field" type="field" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-xml-type-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct mapping to an Oracle XDB XML Type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="direct-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="read-whole-document" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-composite-direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct collection mapping for an XML list of elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field" />
- <xsd:element minOccurs="0" name="value-converter" type="value-converter">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="value-converter-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optionally specify a user defined converter class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-collection-reference-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-M relationship from the source XML element to the target XML element based on a key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="xml-object-reference-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="containerpolicy" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="uses-single-node" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-object-reference-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source XML element to the target XML element based on one or more keys.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="aggregate-object-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="source-to-target-key-field-association" type="foreign-key" />
- <xsd:element minOccurs="0" name="source-to-target-key-fields">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-composite-direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct collection mapping for an XML list of elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-direct-collection-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-cdata" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-composite-direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct collection mapping for an XML list of elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-direct-collection-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-composite-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite collection mapping for an XML list of nested elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string" />
- <xsd:element name="field" type="field" />
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-composite-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite collection mapping for an XML list of nested elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping">
- <xsd:sequence>
- <xsd:element name="container-attribute" minOccurs="0"/>
- <xsd:element name="container-get-method" minOccurs="0"/>
- <xsd:element name="container-set-method" minOccurs="0"/>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-composite-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite collection mapping for an XML list of nested elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-composite-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite object mapping for an XML nested element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string" />
- <xsd:element name="field" type="field" />
- <xsd:element name="container-attribute" minOccurs="0"/>
- <xsd:element name="container-get-method" minOccurs="0"/>
- <xsd:element name="container-set-method" minOccurs="0"/>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-composite-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite object mapping for an XML nested element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-object-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="null-policy" type="abstract-null-policy" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-composite-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite object mapping for an XML nested element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-object-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to an XML element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="default-root-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the element the descriptor maps to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="default-root-element-field" type="node">
- <xsd:annotation>
- <xsd:documentation>The XMLField representing the default root element of the descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="should-preserve-document" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates if nodes should be cached to preserve unmapped data</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="namespace-resolver" type="namespace-resolver">
- <xsd:annotation>
- <xsd:documentation>The namespace resolver for the descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="schema" type="schema-reference">
- <xsd:annotation>
- <xsd:documentation>The location of the XML Schema.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-any-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to an xs:any declaration or xs:anyType element</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="field" type="field" />
- <xsd:element minOccurs="0" name="container" type="container-policy" />
- <xsd:element minOccurs="0" default="false" name="use-xml-root" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="keep-as-element-policy" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-any-attribute-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to an xs:any declaration or xs:anyType element</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="field" type="field" />
- <xsd:element minOccurs="0" name="container" type="container-policy" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-any-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a single object to an xs:any declaration</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="field" type="field" />
- <xsd:element minOccurs="0" default="false" name="use-xml-root" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-fragment-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a single Node to a fragment of an XML document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="xml-direct-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-fragment-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection of Nodes to a fragment of an XML document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-binary-data-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a binary object to base64 binary</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="xml-direct-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-swa-ref" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="mime-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="should-inline-data" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-choice-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to a choice structure in an xml document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="container-policy" type="container-policy" />
- <xsd:element maxOccurs="unbounded" name="field-to-class-association" type="xml-choice-field-to-class-association" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-choice-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to a choice structure in an xml document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field-to-class-association" type="xml-choice-field-to-class-association" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-choice-field-to-class-association">
- <xsd:sequence>
- <xsd:element name="xml-field" type="node" />
- <xsd:element name="class-name" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="xml-conversion-pair">
- <xsd:sequence>
- <xsd:element name="qname" type="xsd:string" />
- <xsd:element name="class-name" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="node">
- <xsd:annotation>
- <xsd:documentation>Defines an XPath expression to an element or attribute in an XML document.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="position" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>The position of the node in the parent type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="typed-text-field" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If this is a typed text field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="single-node" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates if each item in the collection is in the same node instead of having one node per item in the collection</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="schema-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The schema type of the element.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="xml-to-java-conversion-pair" type="xml-conversion-pair" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="java-to-xml-conversion-pair" type="xml-conversion-pair" />
- <xsd:element minOccurs="0" name="leaf-element-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Indicates the elements type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="union-node">
- <xsd:annotation>
- <xsd:documentation>Use to represent nodes which are mapped to unions</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="typed-text-field" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If this is a typed text field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="single-node" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates if each item in the collection is in the same node instead of having one node per item in the collection</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="schema-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The schema type of the element.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="xml-to-java-conversion-pair" type="xml-conversion-pair" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="java-to-xml-conversion-pair" type="xml-conversion-pair" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="namespace-resolver">
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="1" name="namespaces">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="namespace" type="namespace" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="1" name="default-namespace-uri" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="namespace">
- <xsd:sequence>
- <xsd:element name="prefix" type="xsd:string" />
- <xsd:element name="namespace-uri" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="schema-reference">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="resource" type="xsd:string" />
- <xsd:element name="schema-context" type="xsd:string" />
- <xsd:element name="node-type" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="schema-class-path-reference">
- <xsd:complexContent mixed="false">
- <xsd:extension base="schema-reference" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="schema-file-reference">
- <xsd:complexContent mixed="false">
- <xsd:extension base="schema-reference" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="schema-url-reference">
- <xsd:complexContent mixed="false">
- <xsd:extension base="schema-reference" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="java-character">
- <xsd:restriction base="xsd:string" />
- </xsd:simpleType>
- <xsd:simpleType name="java-timestamp">
- <xsd:restriction base="xsd:dateTime" />
- </xsd:simpleType>
- <xsd:simpleType name="java-util-date">
- <xsd:restriction base="xsd:dateTime" />
- </xsd:simpleType>
- <xsd:complexType name="cmp-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="pessimistic-locking" type="pessimistic-locking">
- <xsd:annotation>
- <xsd:documentation>Defines the cmp bean-level pessimistic locking policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="defer-until-commit" type="defer-until-commit">
- <xsd:annotation>
- <xsd:documentation>Defines modification deferral level for non-deferred writes.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="non-deferred-create-time" type="non-deferred-create-time">
- <xsd:annotation>
- <xsd:documentation>Defines point at which insert will be issued to Database.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="pessimistic-locking">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="wait" name="locking-mode" type="locking-mode" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:simpleType name="defer-until-commit">
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="all-modifications" />
- <xsd:enumeration value="update-modifications" />
- <xsd:enumeration value="none" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="non-deferred-create-time">
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="after-ejbcreate" />
- <xsd:enumeration value="after-ejbpostcreate" />
- <xsd:enumeration value="undefined" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="locking-mode">
- <xsd:annotation>
- <xsd:documentation>Holds the pessimistic locking mode.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="wait" />
- <xsd:enumeration value="no-wait" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="sequence">
- <xsd:annotation>
- <xsd:documentation>Sequence object.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="" name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Sequence name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="50" name="preallocation-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Sequence preallocation size.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="default-sequence">
- <xsd:annotation>
- <xsd:documentation>References default sequence object, overriding its name and (optionally) preallocation size.</xsd:documentation>
- <xsd:documentation>To use preallocation size of default sequence object, set preallocation size to 0</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="native-sequence">
- <xsd:annotation>
- <xsd:documentation>Database sequence mechanism used.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="table-sequence">
- <xsd:annotation>
- <xsd:documentation>Table sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="SEQUENCE" name="table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_NAME" name="name-field" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence name field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_COUNT" name="counter-field" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence counter field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="unary-table-sequence">
- <xsd:annotation>
- <xsd:documentation>Unary table sequence - sequence name is a table name, table has a single field and a single row</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="SEQUENCE" name="counter-field" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence counter field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xmlfile-sequence">
- <xsd:annotation>
- <xsd:documentation>Xmlfile sequence.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-sequence">
- <xsd:annotation>
- <xsd:documentation>Xml sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="SEQUENCE" name="root-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_NAME" name="name-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence name field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_COUNT" name="counter-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence counter field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="fetch-groups">
- <xsd:annotation>
- <xsd:documentation>Contains all pre-defined fetch groups.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="default-fetch-group" type="fetch-group" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="fetch-group" type="fetch-group" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="fetch-group">
- <xsd:annotation>
- <xsd:documentation>Contains the fetch group attributes info.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="name" type="xsd:string" />
- <xsd:element name="fetch-group-attributes">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>Contains a fetch group's attribute list.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="fetch-group-attribute" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="change-policy">
- <xsd:annotation>
- <xsd:documentation>Describes the change tracking policy for this descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="deferred-detection-change-policy">
- <xsd:annotation>
- <xsd:documentation>Uses backup clone to detect changes.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="change-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-level-change-policy">
- <xsd:annotation>
- <xsd:documentation>Uses "mark dirty" to detect changes.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="change-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="attribute-level-change-policy">
- <xsd:annotation>
- <xsd:documentation>Uses a ChangeTracker firing PropertyChangeEvent's to detect changes.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="change-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-null-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the Null Policy in use for this relationship currently a choice of [NullPolicy and IsSetNullPolicy].</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="xsi-nil-represents-null" type="xsd:boolean" />
- <xsd:element minOccurs="0" default="false" name="empty-node-represents-null" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="null-representation-for-xml" type="marshal-null-representation" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="null-policy">
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-null-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true" name="is-set-performed-for-absent-node" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="is-set-null-policy">
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-null-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-set-method-name" type="xsd:string" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="is-set-parameter-type" type="xsd:string" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="is-set-parameter" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="marshal-null-representation">
- <xsd:annotation>
- <xsd:documentation>Write null, no tag(default) or an empty tag.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="XSI_NIL" />
- <xsd:enumeration value="ABSENT_NODE" />
- <xsd:enumeration value="EMPTY_NODE" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="field">
- <xsd:annotation>
- <xsd:documentation>Defines a generic field concept, such as a database column.</xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the field.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="column">
- <xsd:annotation>
- <xsd:documentation>Defines a column in a relational database table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:attribute name="table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the column's table. This table must be listed in the class' tables. If not specified the first table of the class will be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The list of source/target field/column references relating a foreign key in one table to the primary or unique key in another table.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field-reference">
- <xsd:annotation>
- <xsd:documentation>The reference of a source table foreign key and a target table primary key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="source-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The foreign key field/column name in the source table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The primary or unique key field/column name in the target table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="query">
- <xsd:annotation>
- <xsd:documentation>Defines a query specification for querying instances of the class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The selection criteria of the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of query arguments. The order of the argument must match the order of the argument value passed to the query.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="query-argument">
- <xsd:annotation>
- <xsd:documentation>The query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the query. This name can be used to reference and execute the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="criteria">
- <xsd:annotation>
- <xsd:documentation>Defines the filtering clause of a query.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="query-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a query argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class type name of the argument may be provided.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>Optional constant value for the argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="property">
- <xsd:annotation>
- <xsd:documentation>A user defined property.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:anyType" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- <xsd:complexType name="table">
- <xsd:annotation>
- <xsd:documentation>The list of tables that the class is persisted to. This is typically a single table but can be multiple, or empty for inheritance or aggregated classes.</xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the table. The name can be fully qualified with the schema, tablespace or link.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="value-converter">
- <xsd:annotation>
- <xsd:documentation>
- Specifies how the data value should be converted to the
- object value.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <xsd:complexType name="document-preservation-policy">
- <xsd:sequence>
- <xsd:element name="node-ordering-policy"
- type="node-ordering-policy" maxOccurs="1" minOccurs="0">
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:complexType name="node-ordering-policy"></xsd:complexType>
-
-
- <xsd:complexType
- name="descriptor-level-document-preservation-policy">
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="no-document-preservation-policy">
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="xml-binder-policy">
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="append-new-elements-ordering-policy">
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="ignore-new-elements-ordering-policy">
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="relative-position-ordering-policy">
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-</xsd:schema>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_1.2.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_1.2.xsd
deleted file mode 100644
index 22a56967a2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_1.2.xsd
+++ /dev/null
@@ -1,4253 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-******************************************************************************
- Copyright (c) 1998, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- which accompanies this distribution.
- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- and the Eclipse Distribution License is available at
- http://www.eclipse.org/org/documents/edl-v10.php.
-
- Contributors:
- Oracle - initial API and implementation from Oracle TopLink
-*****************************************************************************/
--->
-<!-- Eclipse Persistence Service Project :: Map Schema file for ORM/OXM/EIS -->
-<xsd:schema
- targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns="http://www.eclipse.org/eclipselink/xsds/persistence"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="1.2"
- >
- <xsd:element name="object-persistence" type="object-persistence" />
- <xsd:complexType name="object-persistence">
- <xsd:annotation>
- <xsd:documentation>An object-persistence mapping module, a set of class-mapping-descriptors.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>A name for the model being mapped.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-mapping-descriptors">
- <xsd:annotation>
- <xsd:documentation>The list of class mapping descriptors.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="class-mapping-descriptor" type="class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Information of how a class is persisted to its data-store.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="login" type="datasource-login">
- <xsd:annotation>
- <xsd:documentation>The datasource connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="default-temporal-mutable" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines the default for how Date and Calendar types are used with change tracking.</xsd:documentation>
- <xsd:documentation>By default they are assumed not to be changed directly (only replaced).</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="queries">
- <xsd:annotation>
- <xsd:documentation>A list of queries to be stored on the session.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="query" type="database-query">
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute default="Eclipse Persistence Services - 1.1 (Build YYMMDD)" name="version" type="xsd:string" />
- </xsd:complexType>
- <xsd:complexType name="datasource-login">
- <xsd:annotation>
- <xsd:documentation>The datasource connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="platform-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the platform class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="user-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The datasource user-name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="password" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The datasource password, this is stored in encrypted form.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="external-connection-pooling" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines if the connections are managed by the datasource driver, and a new connection should be acquire per call.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="external-transaction-controller" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines if the transaction are managed by a transaction manager, and should not be managed by TopLink.</xsd:documentation>
- <xsd:documentation>This can also be used if the datasource does not support transactions.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="sequencing">
- <xsd:annotation>
- <xsd:documentation>Sequencing information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="default-sequence" type="sequence">
- <xsd:annotation>
- <xsd:documentation>Default sequence. The name is optional. If no name provided an empty string will be used as a name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="sequences">
- <xsd:annotation>
- <xsd:documentation>Non default sequences. Make sure each sequence has unique name.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="sequence" type="sequence" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="database-login">
- <xsd:annotation>
- <xsd:documentation>The JDBC driver and database connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="datasource-login">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="driver-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the JDBC driver class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="connection-url" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The full JDBC driver connection URL.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="bind-all-parameters" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if parameter binding should be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cache-all-statements" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if statement caching should be used. This should be used with parameter binding, this cannot be used with external connection pooling.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="byte-array-binding" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if byte array data-types should use binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="string-binding" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if string data-types should use binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="256" name="string-binding-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Configure the threshold string size for usage of string binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="streams-for-binding" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if large byte array and string data-types should be bound as streams.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="force-field-names-to-upper-case" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure to force all field names to upper-case.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="optimize-data-conversion" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure data optimization.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="trim-strings" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if string trailing blanks should be trimmed. This is normally required for CHAR data-types.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-writing" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if batch writing should be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="jdbc-batch-writing" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If using batch writing, configure if the JDBC drivers batch writing should be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-login">
- <xsd:annotation>
- <xsd:documentation>The JCA driver and EIS connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="datasource-login">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="connection-spec-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the TopLink platform specific connection spec class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="connection-factory-url" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The JNDI url for the managed JCA adapter's connection factory.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-login">
- <xsd:annotation>
- <xsd:documentation>The connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="datasource-login">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true"
- name="equal-namespace-resolvers" type="xsd:boolean" />
- <xsd:element name="document-preservation-policy"
- type="document-preservation-policy" maxOccurs="1"
- minOccurs="0">
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Information of how a class is persisted to its data-store.</xsd:documentation>
- <xsd:documentation>This is an abstract definition to allow flexibility in the types of classes and datastores persisted, i.e. interfaces, abstract classes, aggregates, non-relational persistence.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the implementation class being persisted. The class name must be full qualified with its package.</xsd:documentation>
- <xsd:documentation>Example: <class xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">example.employee.implementation.Employee</class></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="alias" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optionally an alias name can be given for the class. The alias is a string that can be used to refer to the class in place of its implementation name, such as in querying.</xsd:documentation>
- <xsd:documentation>Example: <alias xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">Employee</alias></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="primary-key">
- <xsd:annotation>
- <xsd:documentation>The list of fields/columns that make up the primary key or unique identifier of the class.</xsd:documentation>
- <xsd:documentation>This is used for caching, relationships, and for database operations.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The primary key field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="read-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines if the class is read-only.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="properties">
- <xsd:annotation>
- <xsd:documentation>Allow for user defined properties to be defined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="property" type="property">
- <xsd:annotation>
- <xsd:documentation>A user defined property.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="inheritance" type="inheritance-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class is related in inheritance and how this inheritance is persisted.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="events" type="event-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the persistent events for this class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="querying" type="query-policy">
- <xsd:annotation>
- <xsd:documentation>The list of defined queries for the class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="attribute-mappings">
- <xsd:annotation>
- <xsd:documentation>The list of mappings that define how the class' attributes are persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="attribute-mapping" type="attribute-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a attribute is persisted. The attribute mapping definition is extendable to allow for different types of mappings.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="descriptor-type" type="class-descriptor-type">
- <xsd:annotation>
- <xsd:documentation>Defines the descriptor type, such as aggregate or independent.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="interfaces" type="interface-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the interfaces that this class implements..</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="locking" type="locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the locking behavior for the class. Such as an optimistic locking policy based on version, timestamp or change set of columns.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="sequencing" type="sequencing-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how a generated unique id should be assigned to the class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="caching" type="caching-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class' instances should be cached.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="remote-caching" type="caching-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class' instances should be cached on remote clients.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="history-policy" type="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of objects are persisted to the data-store. By default there will be no history policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="returning-policy" type="returning-policy">
- <xsd:annotation>
- <xsd:documentation>Defines retuning policy. By default there will be no returning policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="amendment" type="amendment">
- <xsd:annotation>
- <xsd:documentation>Allow for the descriptor to be amended or customized through a class API after loading.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="instantiation" type="instantiation-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object instantiation behavoir to be customized</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="copying" type="copy-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object cloning/copying behavoir to be customized.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="query-keys">
- <xsd:annotation>
- <xsd:documentation>A list of query keys or aliases for database information. These can be used in queries instead of the database column names.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="query-key" type="query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for querying database information.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="cmp-policy" type="cmp-policy">
- <xsd:annotation>
- <xsd:documentation>Place holder of CMP information specific.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-groups" type="fetch-groups">
- <xsd:annotation>
- <xsd:documentation>Contains all pre-defined fetch groups at the descriptor level</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="1" name="change-policy" type="change-policy">
- <xsd:annotation>
- <xsd:documentation>Contains the Change Policy for this descriptor</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute fixed="10" name="schema-major-version" type="xsd:integer" />
- <xsd:attribute fixed="0" name="schema-minor-version" type="xsd:integer" />
- </xsd:complexType>
- <xsd:simpleType name="class-descriptor-type">
- <xsd:annotation>
- <xsd:documentation>Defines the class descriptor type.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="independent" />
- <xsd:enumeration value="aggregate" />
- <xsd:enumeration value="aggregate-collection" />
- <xsd:enumeration value="composite" />
- <xsd:enumeration value="composite" />
- <xsd:enumeration value="interface" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="interface-policy">
- <xsd:annotation>
- <xsd:documentation>Specify the interfaces that a class descriptor implements, or the implemention class for an interface descriptor.</xsd:documentation>
- <xsd:documentation>Optionally a set of public interfaces for the class can be specified. This allows the interface to be used to refer to the implementation class.</xsd:documentation>
- <xsd:documentation>If two classes implement the same interface, an interface descriptor should be defined for the interface.</xsd:documentation>
- <xsd:documentation>This can also be used to define inheritance between interface descriptors.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="interface" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified interface class name.</xsd:documentation>
- <xsd:documentation>Example: <class xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">example.employee.api.Employee</class></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="implementor-descriptor" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class name of the implementation class for which this interface is the public interface.</xsd:documentation>
- <xsd:documentation>This can be used if the interface has only a single implementor.</xsd:documentation>
- <xsd:documentation>Example: <class xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">example.employee.impl.Employee</class></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="copy-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object cloning/copying behavoir to be customized.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="instantiation-copy-policy">
- <xsd:annotation>
- <xsd:documentation>Creates a copying through creating a new instance to copy into.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="copy-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="clone-copy-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object cloning/copying behavoir to be customized through a clone method.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="copy-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the clone method on the object, i.e. 'clone'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="instantiation-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object instantiation behavoir to be customized.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the method on the factory to instantiate the object instance.'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="factory-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified factory class name.'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="factory-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the method to instantiate the factory class.'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="amendment">
- <xsd:annotation>
- <xsd:documentation>Specifies a class and static method to be called to allow for the descriptor to be amended or customized through a class API after loading.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="amendment-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation> The fully qualified name of the amendment class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="amendment-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the static amendment method on the class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="relational-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to a relational database table(s).</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="tables">
- <xsd:annotation>
- <xsd:documentation>The list of the tables the class is persisted to. Typically a class is persisted to a single table, but multiple tables can be defined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="table" type="table">
- <xsd:annotation>
- <xsd:documentation>The list of tables that the class is persisted to. This is typically a single table but can be multiple, or empty for inheritance or aggregated classes.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-keys-for-multiple-table" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>Allow the foreign key field references to be define for multiple table descriptors.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="multiple-table-join-criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>For complex multiple table join conditions an expression may be provided instead of the table foreign key information.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="version-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on a numeric version field/column that tracks changes and the version to an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy">
- <xsd:sequence>
- <xsd:element name="version-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The name and optionally the table of the column that the attribute is stored into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="store-version-in-cache" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the version value should be stored in the cache, or if it will be stored in the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="timestamp-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on timestamp version column that tracks changes and the version to an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="version-locking-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="server-time" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the timestamp should be obtained locally or from the database server.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="all-fields-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on comparing the original read values of all fields of the object with the current state of the values in the database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="changed-fields-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on comparing the original read values of only the changed fields of the object with the current state of the values in the database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="selected-fields-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on comparing the original read values of a specified set of fields of the object with the current state of the values in the database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy">
- <xsd:sequence>
- <xsd:element name="fields">
- <xsd:annotation>
- <xsd:documentation>Specify the set of fields to compare on update and delete.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="sequencing-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how a database generated unique id should be assigned to the class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="sequence-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the name of the sequence generator. This could be the name of a sequence object, or a row value in a sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="sequence-field" type="field">
- <xsd:annotation>
- <xsd:documentation>Specify the field/column that the generated sequence id is assigned to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:simpleType name="cache-type">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid caching types.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="none" />
- <xsd:enumeration value="full" />
- <xsd:enumeration value="cache" />
- <xsd:enumeration value="weak-reference" />
- <xsd:enumeration value="soft-reference" />
- <xsd:enumeration value="soft-cache-weak-reference" />
- <xsd:enumeration value="hard-cache-weak-reference" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="caching-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class' instances should be cached and how object identity should be maintained.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="soft-cache-weak-reference" name="cache-type" type="cache-type">
- <xsd:annotation>
- <xsd:documentation>Specify the type of caching, such as LRU, weak reference or none.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="100" name="cache-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specify the initial or maximum size of the cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="always-refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to always refresh cached objects on queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="only-refresh-cache-if-newer-version" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to refresh if the cached object is an older version.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="disable-cache-hits" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Disable obtaining cache hits on primary key queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="always-conform" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to always conform queries within a transaction.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="isolated" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if objects of this type should be isolated from the shared cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="isolate-new-data-after-transaction" name="unitofwork-isolation-level" type="unitofwork-isolation-level">
- <xsd:annotation>
- <xsd:documentation>Specify how the unit of work should be isolated to the session cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="cache-invalidation-policy" type="cache-invalidation">
- <xsd:annotation>
- <xsd:documentation>Defines the cache invalidation policy. By default there will be no cache invalidation policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="change-set" name="cache-sync-type" type="cache-sync-type">
- <xsd:annotation>
- <xsd:documentation>The type of cache synchronization to be used with this descripor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="cache-invalidation" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Abstract superclass for cache invalidation policies.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="update-read-time-on-update" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="no-expiry-cache-invalidation-policy">
- <xsd:annotation>
- <xsd:documentation>Cache invalidation policy where objects in the cache do not expire.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="cache-invalidation" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="time-to-live-cache-invalidation-policy">
- <xsd:annotation>
- <xsd:documentation>Cache invalidation policy where objects live a specific number of milliseconds after they are read.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="cache-invalidation">
- <xsd:sequence>
- <xsd:element name="time-to-live" type="xsd:long" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="daily-cache-invalidation-policy">
- <xsd:annotation>
- <xsd:documentation>Cache invalidation Policy where objects expire at a specific time every day</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="cache-invalidation">
- <xsd:sequence>
- <xsd:element name="expiry-time" type="xsd:dateTime" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of objects are to be persisted to the data-store.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true" name="handle-writes" type="xsd:boolean" />
- <xsd:element minOccurs="0" default="false" name="use-database-time" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="history-tables">
- <xsd:annotation>
- <xsd:documentation>Defines the names of the mirroring historical tables.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="history-table" type="history-table" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="start-fields">
- <xsd:annotation>
- <xsd:documentation>Defines the start fields for each historical table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="start-field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="end-fields">
- <xsd:annotation>
- <xsd:documentation>Defines the end fields for each historical table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="end-field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="history-table">
- <xsd:annotation>
- <xsd:documentation>Each entry is a source (descriptor) to history table name association.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="" name="source" type="xsd:string" />
- <xsd:element minOccurs="1" name="history" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="returning-policy">
- <xsd:annotation>
- <xsd:documentation>Defines retuning policy. By default there will be no returning policy.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="1" name="returning-field-infos">
- <xsd:annotation>
- <xsd:documentation>Lists the fields to be returned together with the flags defining returning options</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="returning-field-info" type="returning-field-info" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="returning-field-info">
- <xsd:annotation>
- <xsd:documentation>Field to be returned together with type and the flags defining returning options. At least one of insert, update should be true.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the target referenced class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field to be returned.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="insert" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates whether the field should be retuned after Insert.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="insert-mode-return-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If insert==true, indicates whether the field should not be inserted (true). If insert==false - ignored.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="update" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates whether the field should be retuned after Insert.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="inheritance-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class is related in inheritance and how this inheritance is persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="parent-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the parent/superclass of the class being persisted. The class name must be full qualified with its package.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="read-subclasses-on-queries" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Define if subclasses of the class should be returned on queries, or only the exact class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="all-subclasses-view" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optionally specify the name of a view that joins all of the subclass' tables.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="use-class-name-as-indicator" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the fully qualified class name should be used as the class type indicator.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-extraction-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of a method on the class that takes the class' row as argument a computed that class type to be used to instantiate from the row.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-indicator-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The name of the type field/column that the class type is stored into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-indicator-mappings" type="class-indicator-mappings">
- <xsd:annotation>
- <xsd:documentation>The set of class indicator values and the subclasses they map to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-extractor" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of a class that implements a class extractor interface.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="only-instances-criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The criteria that filters out all sibling and subclass instances on queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="all-subclasses-criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The criteria that filters out sibling instances on queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="outer-join-subclasses" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>For inheritance queries specify if all subclasses should be outer joined, instead of a query per subclass.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="qname-inheritance-policy">
- <xsd:annotation>
- <xsd:documentation>Extends inheritance policy. Allows for prefixed names to be resolved at runtime to find the approriate class</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="inheritance-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="class-indicator-mappings">
- <xsd:annotation>
- <xsd:documentation>The set of class indicator values and the subclasses they map to.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="class-indicator-mapping">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the class the type maps to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="class-indicator" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>The field value used to define the class type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="event-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the persistent events for this class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="event-listeners">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="event-listener" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of an event listener class that implements the descriptor event listener interface.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-build-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after building the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-write-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before writing the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-write-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after writing the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-insert-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before inserting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-insert-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after inserting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-update-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before updating the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-update-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after updating the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-delete-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before deleting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-delete-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after deleting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="about-to-insert-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before inserting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="about-to-update-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before updating the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-clone-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after cloning the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-merge-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after merging the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-refresh-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after refreshing the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="query-policy">
- <xsd:annotation>
- <xsd:documentation>The list of defined queries and query properties for the class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="queries">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="query" type="query">
- <xsd:annotation>
- <xsd:documentation>A query definition for the class' instances.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="timeout" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies a timeout to apply to all queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="check-cache" name="existence" type="existence-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the behavoir used to determine if an insert or update should occur for an object to be customized.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="insert-query" type="insert-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom insert query. This overide the default insert behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="update-query" type="update-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom update query. This overide the default update behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-query" type="delete-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom delete query. This overide the default delete behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="does-exist-query" type="does-exist-query">
- <xsd:annotation>
- <xsd:documentation>Custom does exist query. This overide the default delete behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="read-object-query" type="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom read object query. This overide the default read behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="read-all-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Custom read all query. This overide the default read all behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:simpleType name="existence-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid existence policies for determining if an insert or update should occur for an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="check-cache" />
- <xsd:enumeration value="check-database" />
- <xsd:enumeration value="assume-existence" />
- <xsd:enumeration value="assume-non-existence" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for querying database information.</xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query-key alias name.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:simpleType name="cache-sync-type">
- <xsd:annotation>
- <xsd:documentation>The type of cache synchronization to use with a descriptor.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="invalidation" />
- <xsd:enumeration value="no-changes" />
- <xsd:enumeration value="change-set-with-new-objects" />
- <xsd:enumeration value="change-set" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="unitofwork-isolation-level">
- <xsd:annotation>
- <xsd:documentation>Specify how the unit of work isolated from the session cache.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="use-session-cache-after-transaction" />
- <xsd:enumeration value="isolate-new-data-after-transaction" />
- <xsd:enumeration value="isolate-cache-after-transaction" />
- <xsd:enumeration value="isolate-cache-always" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="direct-query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a database column.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="query-key">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column being aliased.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="relationship-query-key" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a join to another class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="query-key">
- <xsd:sequence>
- <xsd:element name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the target referenced class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:choice>
- <xsd:element name="foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key join condition between the source and target class' tables.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The join criteria between the source and target class' tables.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:choice>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-one-query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a 1-1 join to another class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-query-key" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-many-query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a 1-m join from another class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="relationship-query-key" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping from an attirbute to a simple field datatype, i.e. String, Number, Date.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The name and optionally the table of the field/column that the attribute is stored into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="null-value" type="xsd:anySimpleType" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Optionally specify a value that null data values should be converted to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="converter" type="value-converter" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="attribute-classification" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="attribute-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a attribute is persisted. The attribute mapping definition is extendable to allow for different types of mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="attribute-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the attribute. This is the implementation class attribute name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="read-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the attribute is read-only.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="get-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the get method for the attribute.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="set-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the set method for the attribute.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="properties">
- <xsd:annotation>
- <xsd:documentation>Allow for user defined properties to be defined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="property" type="property">
- <xsd:annotation>
- <xsd:documentation>A user defined property.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a simple attribute is persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="abstract-direct-mapping">
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping from an attirbute to a simple field datatype, i.e. String, Number, Date.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="abstract-direct-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-cdata" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="null-policy" type="abstract-null-policy" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping from an attirbute to a simple field datatype, i.e. String, Number, Date.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-direct-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="field-transformation" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a field transformation for a transformation mapping</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="method-based-field-transformation">
- <xsd:complexContent mixed="false">
- <xsd:extension base="field-transformation">
- <xsd:sequence>
- <xsd:element name="method" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="transformer-based-field-transformation">
- <xsd:complexContent mixed="false">
- <xsd:extension base="field-transformation">
- <xsd:sequence>
- <xsd:element name="transformer-class" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a transformation mapping that uses Java code to transform between the data and object values.</xsd:documentation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="attribute-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the attribute transformation defined in the domain class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="attribute-transformer" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The class name of the attribute transformer. Used in place of attribute-transformation.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="mutable" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy" />
- <xsd:element minOccurs="0" name="field-transformations">
- <xsd:annotation>
- <xsd:documentation>The field transformations.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field-transformation" type="field-transformation" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-transformation-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-transformation-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-transformation-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="aggregate-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a relationship where the target object is strictly privately owned by the source object and stores within the source objects row</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class name of the target class of the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="allow-null" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if a row of all nulls should be interpreted as null.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="field-translations">
- <xsd:annotation>
- <xsd:documentation>Allow for the mapping to use different field names than the descriptor.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field-translation">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="source-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field in the source descriptor's table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field in the aggregate descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="relationship-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a relationship between two classes is persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class name of the target class of the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="private-owned" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the target objects are privately owned dependent objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-persist" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the create operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-merge" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the create operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the refresh operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-remove" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the remove operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-one-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source instance to the target instance.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the source class' table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-one-to-one-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source instance to the target instance.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="one-to-one-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-many-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m relationship from the source instance to the target instances.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="target-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the target class' table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the related objects can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-one-to-many-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m relationship from the source instance to the target instances.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="source-foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="target-foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-key-grouping-element" type="field" />
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the related objects can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a collection of simple types relationship from the source instance to a set of simple data values.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="data-read-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target data values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="reference-table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the reference table that stores the source primary key and the data values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="direct-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column in the reference table that stores the data values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="reference-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the reference table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="value-converter" type="value-converter">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="insert-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to insert a row into the reference table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete a row from the reference table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the rows from the reference table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="session-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name session that defines the reference table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="history-policy" type="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of this attribute are persisted to the data-store. By default there will be no history policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-map-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a map relationship from the source instance to a set of key values pairs of simple data values.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="direct-collection-mapping">
- <xsd:sequence>
- <xsd:element name="direct-key-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column in the reference table that sores the map key data value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="key-converter" type="value-converter">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the key data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="aggregate-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m relationship from the source instance to the target instances where the target instances are strictly privately owned by the source object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="target-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the target class' table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the related objects can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="many-to-many-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a m-m relationship from the source instance to the target instances.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="relation-table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the relation table that stores the source/target primary keys.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="source-relation-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key from the relational table to the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-relation-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key from the relational table to the target class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="insert-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to insert a row into the relation table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete a row from the relation table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the rows from the relation table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="history-policy" type="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of this attribute are persisted to the data-store. By default there will be no history policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="variable-one-to-one-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source instance to the target instance that may be of several types related through an interface.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="type-field" type="field">
- <xsd:annotation>
- <xsd:documentation>Specify the column to store the class type of the related object into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="foreign-key-to-query-key">
- <xsd:annotation>
- <xsd:documentation>The list of source/target column/query key references relating a foreign key in one table to the query keys defining a primary or unique key value in the other interface descriptor.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="query-key-reference">
- <xsd:annotation>
- <xsd:documentation>The reference of a source table foreign key and a target interface descriptor query key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="source-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The foreign key field/column name in the source table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-query-key" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query key name of the target interface descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-indicator-mappings" type="class-indicator-mappings">
- <xsd:annotation>
- <xsd:documentation>The set of class indicator values and the subclasses they map to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a container/collection type.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="collection-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the collection implementation class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="sorted-collection-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a sorted collection type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="comparator-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the comparitor, used to compare objects in sorting the collection.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="list-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a list collection type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="map-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a map container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="map-key-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the method to call on the target objects to get the key value for the map.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-map-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a direct map container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="scrollable-cursor-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a scrollable cursor container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="cursored-stream-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a cursored stream container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="indirection-policy" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a deferred read indirection mechanism.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="value-holder-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of value holders to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="proxy-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of proxies to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="transparent-collection-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of transparent collections to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="collection-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the collection interface to use, i.e. List, Set, Map.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="map-key-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the method to call on the target objects to get the key value for the map.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="container-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of a user defined container to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy">
- <xsd:sequence>
- <xsd:element name="container-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the container implementer to use.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-list-converter">
- <xsd:annotation>
- <xsd:documentation>List converter</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="object-class-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the list's element type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="typesafe-enumeration-converter">
- <xsd:annotation>
- <xsd:documentation>Typesafe Enumeration conversion</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="type-conversion-converter">
- <xsd:annotation>
- <xsd:documentation>Specifies the data type and an object type of the attribute to convert between.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="object-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the attribute type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="data-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the attributes storage data type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="serialized-object-converter">
- <xsd:annotation>
- <xsd:documentation>Uses object serialization to convert between the object and data type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="data-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the attributes storage data type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-type-converter">
- <xsd:annotation>
- <xsd:documentation>Specifies a mapping of values from database values used in the field and object values used in the attribute.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="default-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>An optional default value can be specified. This value is used if a database type is not found in the type mapping.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="type-mappings">
- <xsd:annotation>
- <xsd:documentation>Specifies the mapping of values. Both the object and database values must be unique.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="type-mapping" type="type-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines the object and data value mapping.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="attribute-only-type-mappings">
- <xsd:annotation>
- <xsd:documentation>Specifies a mapping of additional values that map non-unique data values to a unique attribute value.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="type-mapping" type="type-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines the object and data value mapping.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="type-mapping">
- <xsd:annotation>
- <xsd:documentation>Define an object and data value mapping.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="object-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>Specifies the value to use in the object's attribute.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="data-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>Specifies the value to use in the database field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="database-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query/interaction against a database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="query">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true" name="maintain-cache" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should bypass the cache completely.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bind-all-parameters" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should use paramater binding for arguments, or print the arguments in-line.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="cache-statement" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the queries statement should be cached, this must be used with parameter binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="timeout" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies a timeout to cancel the query in if the request takes too long to complete.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="prepare" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should prepare and cache its generated SQL, or regenerate the SQL on each execution.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="call" type="criteria">
- <xsd:annotation>
- <xsd:documentation>For static calls the SQL or Stored Procedure call definition can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid join fetch options.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="none" />
- <xsd:enumeration value="inner-join" />
- <xsd:enumeration value="outer-join" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="cascade-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid cascade policies.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="none" />
- <xsd:enumeration value="private" />
- <xsd:enumeration value="all" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="value-read-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading a single value.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="direct-read-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-read-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading a collection of values.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="data-read-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="data-read-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading raw data.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="read-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="read-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="cache-query-results" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should cache the query results to avoid future executions.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="max-rows" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies the maximum number of rows to fetch, results will be trunctate on the database to this size.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="first-result" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies where to start the cursor in a result set returned from the database. Results prior to this number will not be built into objects</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifiess the number of rows to fetch from the database on each result set next operation.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="query-result-cache-policy" type="query-result-cache-policy">
- <xsd:annotation>
- <xsd:documentation>Specify how the query results should be cached.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="query-result-cache-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how a query's results should be cached.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="invalidation-policy" type="cache-invalidation">
- <xsd:annotation>
- <xsd:documentation>Defines the cache invalidation policy. By default there will be no cache invalidation policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="100" name="maximum-cached-results" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>This defines the number of query result sets that will be cached. The LRU query results will be discarded when the max size is reached.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for manipulating data.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-modify-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query for modifying an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="update-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for updating an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-modify-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="insert-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for inserting an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-modify-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="delete-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for deleting an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-modify-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="does-exist-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for determining if an object exists.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="existence-check" type="existence-check">
- <xsd:annotation>
- <xsd:documentation>The existence check option.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="existence-check">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid existence check options.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="check-cache" />
- <xsd:enumeration value="check-database" />
- <xsd:enumeration value="assume-existence" />
- <xsd:enumeration value="assume-non-existence" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for deleting a criteria of objects.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-level-read-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query for objects (as apposed to data).</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="read-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The full qualified name of the class of objects being queried.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should refresh any cached objects from the database.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="remote-refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should refresh any remotely cached objects from the server.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="cascade-policy" type="cascade-policy">
- <xsd:annotation>
- <xsd:documentation>Specifies if the queries settings (such as refresh, maintain-cache) should apply to the object's relationship queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="primary-key" name="cache-usage" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify how the query should interact with the cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="lock-mode" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should lock the resulting rows on the database.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="distinct-state" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should filter distinct results.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="in-memory-querying">
- <xsd:annotation>
- <xsd:documentation>The in memory querying policy.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element default="ignore-exceptions-return-conformed" name="policy" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify how indirection or unconformable expressions should be treating with in-memory querying and conforming.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="use-default-fetch-group" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the default fetch group should be used for the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-group" type="fetch-group">
- <xsd:annotation>
- <xsd:documentation>Allow the query to partially fetch the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-group-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify a pre-defined named fetch group to allow the query to partially fetch the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="use-exclusive-connection" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the exclusive connection (VPD) should be used for the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="joined-attribute-expressions">
- <xsd:annotation>
- <xsd:documentation>Specifies the attributes being joined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for joining</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="read-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if objects resulting from the query are read-only, and will not be registered in the unit of work.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="outer-join-subclasses" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>For inheritance queries specify if all subclasses should be outer joined, instead of a query per subclass.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for a set of objects.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-level-read-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="batch-read-attribute-expressions">
- <xsd:annotation>
- <xsd:documentation>Specifies all attributes for batch reading.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for batch reading</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="order-by-expressions">
- <xsd:annotation>
- <xsd:documentation>Sets the order expressions for the query.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for ordering</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for a single object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-level-read-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="report-query">
- <xsd:annotation>
- <xsd:documentation>Query for information about a set of objects instead of the objects themselves.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="read-all-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="return-choice" type="return-choice">
- <xsd:annotation>
- <xsd:documentation>Simplifies the result by only returning the first result, first value, or all attribute values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="retrieve-primary-keys" type="retrieve-primary-keys">
- <xsd:annotation>
- <xsd:documentation>Indicates wether the primary key values should also be retrieved for the reference class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="report-items">
- <xsd:annotation>
- <xsd:documentation>Items to be selected, these could be attributes or aggregate functions.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="item" type="report-item">
- <xsd:annotation>
- <xsd:documentation>Represents an item requested</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="group-by-expressions">
- <xsd:annotation>
- <xsd:documentation>Sets GROUP BY expressions for the query.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for grouping</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="return-choice">
- <xsd:annotation>
- <xsd:documentation>Simplifies the result by only returning the first result, first value, or all attribute values.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="return-single-result" />
- <xsd:enumeration value="return-single-value" />
- <xsd:enumeration value="return-single-attribute" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="retrieve-primary-keys">
- <xsd:annotation>
- <xsd:documentation>Indicates wether the primary key values should also be retrieved for the reference class.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="full-primary-key" />
- <xsd:enumeration value="first-primary-key" />
- <xsd:enumeration value="no-primary-key" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="report-item">
- <xsd:annotation>
- <xsd:documentation>Represents an item requested in ReportQuery.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Name given for item, can be used to retieve value from result.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="attribute-expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Expression (partial) that describes the attribute wanted.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="expression" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query filter expression tree.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="relation-expression">
- <xsd:annotation>
- <xsd:documentation>Defines a relation expression that compares to expressions through operators such as equal, lessThan, etc..</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="left" type="expression" />
- <xsd:element name="right" type="expression" />
- </xsd:sequence>
- <xsd:attribute name="operator" type="operator" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="logic-expression">
- <xsd:annotation>
- <xsd:documentation>Defines a expression composed of two sub-expressions joined through an operator such as AND, OR.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="left" type="expression" />
- <xsd:element name="right" type="expression" />
- </xsd:sequence>
- <xsd:attribute name="operator" type="operator" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="function-expression">
- <xsd:annotation>
- <xsd:documentation>Defines a expression composed of a function applied to a list of sub-expressions.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of function arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="expression">
- <xsd:annotation>
- <xsd:documentation>Defines an argument expression.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="function" type="operator" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="constant-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression value. If the value is null the value tag can is absent.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="value" type="xsd:anySimpleType" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="query-key-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression query-key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="base" type="expression" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" />
- <xsd:attribute name="any-of" type="xsd:boolean" />
- <xsd:attribute name="outer-join" type="xsd:boolean" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="field-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression field.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="field" type="field" />
- <xsd:element name="base" type="expression" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="parameter-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression parameter.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="parameter" type="field" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="base-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression builder/base.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="operator">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid operators.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string" />
- </xsd:simpleType>
- <xsd:complexType name="sql-call">
- <xsd:annotation>
- <xsd:documentation>Defines an SQL query language string.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="sql" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The full SQL query string. Arguments can be specified through #arg-name tokens in the string.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="ejbql-call">
- <xsd:annotation>
- <xsd:documentation>Defines an EJB-QL query language string.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="ejbql" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The EJB-QL query string.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="stored-procedure-call">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure invocation definition.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="procedure-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the stored procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="cursor-output-procedure" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Define the call to use a cursor output parameter to define the result set.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input and output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="procedure-argument">
- <xsd:annotation>
- <xsd:documentation>Defines an argument to the procedure. The order of the arguments must match the procedure arguments if not named.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="stored-function-call">
- <xsd:annotation>
- <xsd:documentation>Defines a stored function invocation definition.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="stored-procedure-call">
- <xsd:sequence>
- <xsd:element minOccurs="1" name="stored-function-result" type="procedure-output-argument">
- <xsd:annotation>
- <xsd:documentation>The return value of the stored-function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="procedure-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure call argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="procedure-argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The stored procedure name of the argument. For indexed argument the name is not required.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query name of the argument. This is the name of the argument as define in the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="procedure-argument-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the argument class type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="procedure-argument-sqltype" type="xsd:int">
- <xsd:annotation>
- <xsd:documentation>The JDBC int type of the argument, as defined in java.jdbc.Types</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="procedure-argument-sqltype-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the type if procedure-argument-sqltype is STRUCT or ARRAY</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="argument-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>The procedure argument value maybe be specified if not using a query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="procedure-output-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure call output argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="procedure-argument" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="procedure-inoutput-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure call output argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="procedure-argument">
- <xsd:sequence>
- <xsd:element name="output-argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query name of the argument. This is the name of the argument as define in the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-stored-procedure-call">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure invocation definition whose arguments contain at least one Oracle PL/SQL type that has no JDBC representation (e.g. BOOLEAN, PLS_INTEGER, PL/SQL record).</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="procedure-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the stored procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input and output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="plsql-procedure-argument-type">
- <xsd:annotation>
- <xsd:documentation>Defines an argument to the procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-procedure-argument-type" abstract="true">
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" />
- <xsd:element minOccurs="0" name="index" type="xsd:string" />
- <xsd:element minOccurs="0" name="direction" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="jdbc-type">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:sequence>
- <xsd:choice>
- <xsd:element minOccurs="0" name="length" type="xsd:string" />
- <xsd:sequence>
- <xsd:element name="precision" type="xsd:string" />
- <xsd:element name="scale" type="xsd:string" />
- </xsd:sequence>
- </xsd:choice>
- </xsd:sequence>
- <xsd:attribute name="type-name" type="xsd:string" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-type">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:attribute name="type-name" type="xsd:string" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-record">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:sequence>
- <xsd:element name="type-name" type="xsd:string" />
- <xsd:element minOccurs="0" name="compatible-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="java-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="fields">
- <xsd:annotation>
- <xsd:documentation>The list of fields.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="plsql-procedure-argument-type">
- <xsd:annotation>
- <xsd:documentation>Defines an argument to the procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-collection">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:sequence>
- <xsd:element name="type-name" type="xsd:string" />
- <xsd:element minOccurs="0" name="compatible-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="java-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="nested-type" type="plsql-procedure-argument-type" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to an EIS record data structure.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element name="datatype" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the record structure name the descriptor maps to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="namespace-resolver" type="namespace-resolver">
- <xsd:annotation>
- <xsd:documentation>The namespace resolver for the descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="mapped-interaction">
- <xsd:annotation>
- <xsd:documentation>Defines an EIS interaction utilizing MappedRecord.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="function-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the input result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the output result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-interaction">
- <xsd:annotation>
- <xsd:documentation>Defines an EIS interaction utilizing XML records.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="function-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-record-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name to use for the input record, if required by the adapter.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-root-element-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the output result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the input result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the output result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="indexed-interaction">
- <xsd:annotation>
- <xsd:documentation>Defines an EIS interaction utilizing Indexed records.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="function-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="interaction-argument">
- <xsd:annotation>
- <xsd:documentation>Defines an interaction argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="argument-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>The procedure argument value maybe be specified if not using a query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The interaction name of the argument. For indexed arguments the name is not required.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query name of the argumen. This is the name of the argument as define in the query, or the descriptor field name.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="object-relational-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to a Structure type in an object-relational database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relational-class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the object structure type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="field-order">
- <xsd:annotation>
- <xsd:documentation>The ordered list of the field defined in the structure.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="nested-table-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m/m-m relationship that makes use of the object-relational nested-table type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column in the source table that stores the nested-table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the object-relational type name of the nested-table type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="array-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a collection of primitive/simple type values using the object-relational array type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-direct-collection-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the object-relational type name of the structure type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-array-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a collection of object-types using the object-relational array type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping">
- <xsd:sequence>
- <xsd:element name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the object-relational type name of the structure type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="structure-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a structure of object-types using the object-relational structure type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-object-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="reference-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a reference to another object-type using the object-relational reference type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field in the source type that stores the reference.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-relational-field">
- <xsd:annotation>
- <xsd:documentation>Defines an ObjectRelationalDatabaseField</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="nested-type-field" type="field" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-xml-type-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct mapping to an Oracle XDB XML Type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="direct-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="read-whole-document" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-composite-direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct collection mapping for an XML list of elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field" />
- <xsd:element minOccurs="0" name="value-converter" type="value-converter">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="value-converter-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optionally specify a user defined converter class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-collection-reference-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-M relationship from the source XML element to the target XML element based on a key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="xml-object-reference-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="containerpolicy" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="uses-single-node" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-object-reference-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source XML element to the target XML element based on one or more keys.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="aggregate-object-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="source-to-target-key-field-association" type="foreign-key" />
- <xsd:element minOccurs="0" name="source-to-target-key-fields">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-composite-direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct collection mapping for an XML list of elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-direct-collection-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-cdata" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="null-policy" type="abstract-null-policy" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-composite-direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct collection mapping for an XML list of elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-direct-collection-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-composite-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite collection mapping for an XML list of nested elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string" />
- <xsd:element name="field" type="field" />
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-composite-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite collection mapping for an XML list of nested elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping">
- <xsd:sequence>
- <xsd:element name="container-attribute" minOccurs="0"/>
- <xsd:element name="container-get-method" minOccurs="0"/>
- <xsd:element name="container-set-method" minOccurs="0"/>
- <xsd:element name="keep-as-element-policy" type="xsd:string" minOccurs="0"/>
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-composite-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite collection mapping for an XML list of nested elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-composite-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite object mapping for an XML nested element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string" />
- <xsd:element name="field" type="field" />
- <xsd:element name="container-attribute" minOccurs="0"/>
- <xsd:element name="container-get-method" minOccurs="0"/>
- <xsd:element name="container-set-method" minOccurs="0"/>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-composite-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite object mapping for an XML nested element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-object-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="null-policy" type="abstract-null-policy" />
- <xsd:element minOccurs="0" name="keep-as-element-policy" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-composite-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite object mapping for an XML nested element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-object-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to an XML element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="default-root-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the element the descriptor maps to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="default-root-element-field" type="node">
- <xsd:annotation>
- <xsd:documentation>The XMLField representing the default root element of the descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="should-preserve-document" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates if nodes should be cached to preserve unmapped data</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="namespace-resolver" type="namespace-resolver">
- <xsd:annotation>
- <xsd:documentation>The namespace resolver for the descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="schema" type="schema-reference">
- <xsd:annotation>
- <xsd:documentation>The location of the XML Schema.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="result-always-xml-root" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-any-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to an xs:any declaration or xs:anyType element</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="field" type="field" />
- <xsd:element minOccurs="0" name="container" type="container-policy" />
- <xsd:element minOccurs="0" default="false" name="use-xml-root" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="keep-as-element-policy" type="xsd:string" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-any-attribute-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to an xs:any declaration or xs:anyType element</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="field" type="field" />
- <xsd:element minOccurs="0" name="container" type="container-policy" />
- <xsd:element minOccurs="0" name="include-namespace-declaration" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="include-schema-instance" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-any-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a single object to an xs:any declaration</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="field" type="field" />
- <xsd:element minOccurs="0" default="false" name="use-xml-root" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="keep-as-element-policy" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-fragment-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a single Node to a fragment of an XML document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="xml-direct-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-fragment-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection of Nodes to a fragment of an XML document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-binary-data-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a binary object to base64 binary</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="xml-direct-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-swa-ref" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="mime-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="should-inline-data" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-binary-data-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a binary object to base64 binary</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="xml-composite-direct-collection-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-swa-ref" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="mime-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="should-inline-data" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-choice-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to a choice structure in an xml document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="container-policy" type="container-policy" />
- <xsd:element maxOccurs="unbounded" name="field-to-class-association" type="xml-choice-field-to-class-association" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-choice-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to a choice structure in an xml document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field-to-class-association" type="xml-choice-field-to-class-association" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-choice-field-to-class-association">
- <xsd:sequence>
- <xsd:element name="xml-field" type="node" />
- <xsd:element name="class-name" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="xml-conversion-pair">
- <xsd:sequence>
- <xsd:element name="qname" type="xsd:string" />
- <xsd:element name="class-name" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="node">
- <xsd:annotation>
- <xsd:documentation>Defines an XPath expression to an element or attribute in an XML document.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="position" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>The position of the node in the parent type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="typed-text-field" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If this is a typed text field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="single-node" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates if each item in the collection is in the same node instead of having one node per item in the collection</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="schema-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The schema type of the element.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="xml-to-java-conversion-pair" type="xml-conversion-pair" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="java-to-xml-conversion-pair" type="xml-conversion-pair" />
- <xsd:element minOccurs="0" name="leaf-element-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Indicates the elements type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="is-required" type="xsd:boolean"/>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="union-node">
- <xsd:annotation>
- <xsd:documentation>Use to represent nodes which are mapped to unions</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="typed-text-field" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If this is a typed text field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="single-node" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates if each item in the collection is in the same node instead of having one node per item in the collection</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="schema-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The schema type of the element.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="xml-to-java-conversion-pair" type="xml-conversion-pair" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="java-to-xml-conversion-pair" type="xml-conversion-pair" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="namespace-resolver">
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="1" name="namespaces">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="namespace" type="namespace" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="1" name="default-namespace-uri" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="namespace">
- <xsd:sequence>
- <xsd:element name="prefix" type="xsd:string" />
- <xsd:element name="namespace-uri" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="schema-reference">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="resource" type="xsd:string" />
- <xsd:element name="schema-context" type="xsd:string" />
- <xsd:element name="node-type" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="schema-class-path-reference">
- <xsd:complexContent mixed="false">
- <xsd:extension base="schema-reference" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="schema-file-reference">
- <xsd:complexContent mixed="false">
- <xsd:extension base="schema-reference" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="schema-url-reference">
- <xsd:complexContent mixed="false">
- <xsd:extension base="schema-reference" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="java-character">
- <xsd:restriction base="xsd:string" />
- </xsd:simpleType>
- <xsd:simpleType name="java-timestamp">
- <xsd:restriction base="xsd:dateTime" />
- </xsd:simpleType>
- <xsd:simpleType name="java-util-date">
- <xsd:restriction base="xsd:dateTime" />
- </xsd:simpleType>
- <xsd:complexType name="cmp-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="pessimistic-locking" type="pessimistic-locking">
- <xsd:annotation>
- <xsd:documentation>Defines the cmp bean-level pessimistic locking policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="defer-until-commit" type="defer-until-commit">
- <xsd:annotation>
- <xsd:documentation>Defines modification deferral level for non-deferred writes.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="non-deferred-create-time" type="non-deferred-create-time">
- <xsd:annotation>
- <xsd:documentation>Defines point at which insert will be issued to Database.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="pessimistic-locking">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="wait" name="locking-mode" type="locking-mode" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:simpleType name="defer-until-commit">
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="all-modifications" />
- <xsd:enumeration value="update-modifications" />
- <xsd:enumeration value="none" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="non-deferred-create-time">
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="after-ejbcreate" />
- <xsd:enumeration value="after-ejbpostcreate" />
- <xsd:enumeration value="undefined" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="locking-mode">
- <xsd:annotation>
- <xsd:documentation>Holds the pessimistic locking mode.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="wait" />
- <xsd:enumeration value="no-wait" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="sequence">
- <xsd:annotation>
- <xsd:documentation>Sequence object.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="" name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Sequence name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="50" name="preallocation-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Sequence preallocation size.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="default-sequence">
- <xsd:annotation>
- <xsd:documentation>References default sequence object, overriding its name and (optionally) preallocation size.</xsd:documentation>
- <xsd:documentation>To use preallocation size of default sequence object, set preallocation size to 0</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="native-sequence">
- <xsd:annotation>
- <xsd:documentation>Database sequence mechanism used.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="table-sequence">
- <xsd:annotation>
- <xsd:documentation>Table sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="SEQUENCE" name="table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_NAME" name="name-field" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence name field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_COUNT" name="counter-field" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence counter field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="unary-table-sequence">
- <xsd:annotation>
- <xsd:documentation>Unary table sequence - sequence name is a table name, table has a single field and a single row</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="SEQUENCE" name="counter-field" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence counter field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xmlfile-sequence">
- <xsd:annotation>
- <xsd:documentation>Xmlfile sequence.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-sequence">
- <xsd:annotation>
- <xsd:documentation>Xml sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="SEQUENCE" name="root-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_NAME" name="name-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence name field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_COUNT" name="counter-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence counter field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="fetch-groups">
- <xsd:annotation>
- <xsd:documentation>Contains all pre-defined fetch groups.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="default-fetch-group" type="fetch-group" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="fetch-group" type="fetch-group" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="fetch-group">
- <xsd:annotation>
- <xsd:documentation>Contains the fetch group attributes info.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="name" type="xsd:string" />
- <xsd:element name="fetch-group-attributes">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>Contains a fetch group's attribute list.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="fetch-group-attribute" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="change-policy">
- <xsd:annotation>
- <xsd:documentation>Describes the change tracking policy for this descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="deferred-detection-change-policy">
- <xsd:annotation>
- <xsd:documentation>Uses backup clone to detect changes.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="change-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-level-change-policy">
- <xsd:annotation>
- <xsd:documentation>Uses "mark dirty" to detect changes.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="change-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="attribute-level-change-policy">
- <xsd:annotation>
- <xsd:documentation>Uses a ChangeTracker firing PropertyChangeEvent's to detect changes.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="change-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-null-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the Null Policy in use for this relationship currently a choice of [NullPolicy and IsSetNullPolicy].</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="xsi-nil-represents-null" type="xsd:boolean" />
- <xsd:element minOccurs="0" default="false" name="empty-node-represents-null" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="null-representation-for-xml" type="marshal-null-representation" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="null-policy">
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-null-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true" name="is-set-performed-for-absent-node" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="is-set-null-policy">
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-null-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-set-method-name" type="xsd:string" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="is-set-parameter-type" type="xsd:string" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="is-set-parameter" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="marshal-null-representation">
- <xsd:annotation>
- <xsd:documentation>Write null, no tag(default) or an empty tag.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="XSI_NIL" />
- <xsd:enumeration value="ABSENT_NODE" />
- <xsd:enumeration value="EMPTY_NODE" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="field">
- <xsd:annotation>
- <xsd:documentation>Defines a generic field concept, such as a database column.</xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the field.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="column">
- <xsd:annotation>
- <xsd:documentation>Defines a column in a relational database table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:attribute name="table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the column's table. This table must be listed in the class' tables. If not specified the first table of the class will be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="sql-typecode" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>(optional field) The JDBC typecode of this column</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="column-definition" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>(optional field) Name of the JDBC typecode for this column</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The list of source/target field/column references relating a foreign key in one table to the primary or unique key in another table.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field-reference">
- <xsd:annotation>
- <xsd:documentation>The reference of a source table foreign key and a target table primary key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="source-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The foreign key field/column name in the source table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The primary or unique key field/column name in the target table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="query">
- <xsd:annotation>
- <xsd:documentation>Defines a query specification for querying instances of the class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The selection criteria of the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of query arguments. The order of the argument must match the order of the argument value passed to the query.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="query-argument">
- <xsd:annotation>
- <xsd:documentation>The query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the query. This name can be used to reference and execute the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="criteria">
- <xsd:annotation>
- <xsd:documentation>Defines the filtering clause of a query.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="query-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a query argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class type name of the argument may be provided.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>Optional constant value for the argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="property">
- <xsd:annotation>
- <xsd:documentation>A user defined property.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:anyType" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- <xsd:complexType name="table">
- <xsd:annotation>
- <xsd:documentation>The list of tables that the class is persisted to. This is typically a single table but can be multiple, or empty for inheritance or aggregated classes.</xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the table. The name can be fully qualified with the schema, tablespace or link.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="value-converter">
- <xsd:annotation>
- <xsd:documentation>
- Specifies how the data value should be converted to the
- object value.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <xsd:complexType name="document-preservation-policy">
- <xsd:sequence>
- <xsd:element name="node-ordering-policy"
- type="node-ordering-policy" maxOccurs="1" minOccurs="0">
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:complexType name="node-ordering-policy"></xsd:complexType>
-
-
- <xsd:complexType
- name="descriptor-level-document-preservation-policy">
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="no-document-preservation-policy">
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="xml-binder-policy">
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="append-new-elements-ordering-policy">
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="ignore-new-elements-ordering-policy">
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="relative-position-ordering-policy">
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-</xsd:schema>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_2.0.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_2.0.xsd
deleted file mode 100644
index a93b9ea08e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_persistence_map_2.0.xsd
+++ /dev/null
@@ -1,4253 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-******************************************************************************
- Copyright (c) 1998, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- which accompanies this distribution.
- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- and the Eclipse Distribution License is available at
- http://www.eclipse.org/org/documents/edl-v10.php.
-
- Contributors:
- Oracle - initial API and implementation from Oracle TopLink
-*****************************************************************************/
--->
-<!-- Eclipse Persistence Service Project :: Map Schema file for ORM/OXM/EIS -->
-<xsd:schema
- targetNamespace="http://www.eclipse.org/eclipselink/xsds/persistence"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns="http://www.eclipse.org/eclipselink/xsds/persistence"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="2.0"
- >
- <xsd:element name="object-persistence" type="object-persistence" />
- <xsd:complexType name="object-persistence">
- <xsd:annotation>
- <xsd:documentation>An object-persistence mapping module, a set of class-mapping-descriptors.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>A name for the model being mapped.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-mapping-descriptors">
- <xsd:annotation>
- <xsd:documentation>The list of class mapping descriptors.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="class-mapping-descriptor" type="class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Information of how a class is persisted to its data-store.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="login" type="datasource-login">
- <xsd:annotation>
- <xsd:documentation>The datasource connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="default-temporal-mutable" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines the default for how Date and Calendar types are used with change tracking.</xsd:documentation>
- <xsd:documentation>By default they are assumed not to be changed directly (only replaced).</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="queries">
- <xsd:annotation>
- <xsd:documentation>A list of queries to be stored on the session.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="query" type="database-query">
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute default="Eclipse Persistence Services - 2.0 (Build YYMMDD)" name="version" type="xsd:string" />
- </xsd:complexType>
- <xsd:complexType name="datasource-login">
- <xsd:annotation>
- <xsd:documentation>The datasource connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="platform-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the platform class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="user-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The datasource user-name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="password" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The datasource password, this is stored in encrypted form.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="external-connection-pooling" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines if the connections are managed by the datasource driver, and a new connection should be acquire per call.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="external-transaction-controller" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines if the transaction are managed by a transaction manager, and should not be managed by TopLink.</xsd:documentation>
- <xsd:documentation>This can also be used if the datasource does not support transactions.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="sequencing">
- <xsd:annotation>
- <xsd:documentation>Sequencing information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="default-sequence" type="sequence">
- <xsd:annotation>
- <xsd:documentation>Default sequence. The name is optional. If no name provided an empty string will be used as a name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="sequences">
- <xsd:annotation>
- <xsd:documentation>Non default sequences. Make sure each sequence has unique name.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="sequence" type="sequence" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="database-login">
- <xsd:annotation>
- <xsd:documentation>The JDBC driver and database connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="datasource-login">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="driver-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the JDBC driver class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="connection-url" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The full JDBC driver connection URL.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="bind-all-parameters" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if parameter binding should be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cache-all-statements" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if statement caching should be used. This should be used with parameter binding, this cannot be used with external connection pooling.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="byte-array-binding" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if byte array data-types should use binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="string-binding" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if string data-types should use binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="256" name="string-binding-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Configure the threshold string size for usage of string binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="streams-for-binding" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if large byte array and string data-types should be bound as streams.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="force-field-names-to-upper-case" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure to force all field names to upper-case.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="optimize-data-conversion" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure data optimization.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="trim-strings" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if string trailing blanks should be trimmed. This is normally required for CHAR data-types.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-writing" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Configure if batch writing should be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="jdbc-batch-writing" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If using batch writing, configure if the JDBC drivers batch writing should be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-login">
- <xsd:annotation>
- <xsd:documentation>The JCA driver and EIS connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="datasource-login">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="connection-spec-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the TopLink platform specific connection spec class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="connection-factory-url" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The JNDI url for the managed JCA adapter's connection factory.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-login">
- <xsd:annotation>
- <xsd:documentation>The connection and configuration information.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="datasource-login">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true"
- name="equal-namespace-resolvers" type="xsd:boolean" />
- <xsd:element name="document-preservation-policy"
- type="document-preservation-policy" maxOccurs="1"
- minOccurs="0">
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Information of how a class is persisted to its data-store.</xsd:documentation>
- <xsd:documentation>This is an abstract definition to allow flexibility in the types of classes and datastores persisted, i.e. interfaces, abstract classes, aggregates, non-relational persistence.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the implementation class being persisted. The class name must be full qualified with its package.</xsd:documentation>
- <xsd:documentation>Example: <class xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">example.employee.implementation.Employee</class></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="alias" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optionally an alias name can be given for the class. The alias is a string that can be used to refer to the class in place of its implementation name, such as in querying.</xsd:documentation>
- <xsd:documentation>Example: <alias xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">Employee</alias></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="primary-key">
- <xsd:annotation>
- <xsd:documentation>The list of fields/columns that make up the primary key or unique identifier of the class.</xsd:documentation>
- <xsd:documentation>This is used for caching, relationships, and for database operations.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The primary key field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="read-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Defines if the class is read-only.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="properties">
- <xsd:annotation>
- <xsd:documentation>Allow for user defined properties to be defined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="property" type="property">
- <xsd:annotation>
- <xsd:documentation>A user defined property.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="inheritance" type="inheritance-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class is related in inheritance and how this inheritance is persisted.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="events" type="event-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the persistent events for this class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="querying" type="query-policy">
- <xsd:annotation>
- <xsd:documentation>The list of defined queries for the class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="attribute-mappings">
- <xsd:annotation>
- <xsd:documentation>The list of mappings that define how the class' attributes are persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="attribute-mapping" type="attribute-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a attribute is persisted. The attribute mapping definition is extendable to allow for different types of mappings.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="descriptor-type" type="class-descriptor-type">
- <xsd:annotation>
- <xsd:documentation>Defines the descriptor type, such as aggregate or independent.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="interfaces" type="interface-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the interfaces that this class implements..</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="locking" type="locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the locking behavior for the class. Such as an optimistic locking policy based on version, timestamp or change set of columns.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="sequencing" type="sequencing-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how a generated unique id should be assigned to the class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="caching" type="caching-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class' instances should be cached.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="remote-caching" type="caching-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class' instances should be cached on remote clients.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="history-policy" type="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of objects are persisted to the data-store. By default there will be no history policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="returning-policy" type="returning-policy">
- <xsd:annotation>
- <xsd:documentation>Defines retuning policy. By default there will be no returning policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="amendment" type="amendment">
- <xsd:annotation>
- <xsd:documentation>Allow for the descriptor to be amended or customized through a class API after loading.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="instantiation" type="instantiation-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object instantiation behavoir to be customized</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="copying" type="copy-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object cloning/copying behavoir to be customized.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="query-keys">
- <xsd:annotation>
- <xsd:documentation>A list of query keys or aliases for database information. These can be used in queries instead of the database column names.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="query-key" type="query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for querying database information.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="cmp-policy" type="cmp-policy">
- <xsd:annotation>
- <xsd:documentation>Place holder of CMP information specific.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-groups" type="fetch-groups">
- <xsd:annotation>
- <xsd:documentation>Contains all pre-defined fetch groups at the descriptor level</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="1" name="change-policy" type="change-policy">
- <xsd:annotation>
- <xsd:documentation>Contains the Change Policy for this descriptor</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute fixed="10" name="schema-major-version" type="xsd:integer" />
- <xsd:attribute fixed="0" name="schema-minor-version" type="xsd:integer" />
- </xsd:complexType>
- <xsd:simpleType name="class-descriptor-type">
- <xsd:annotation>
- <xsd:documentation>Defines the class descriptor type.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="independent" />
- <xsd:enumeration value="aggregate" />
- <xsd:enumeration value="aggregate-collection" />
- <xsd:enumeration value="composite" />
- <xsd:enumeration value="composite" />
- <xsd:enumeration value="interface" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="interface-policy">
- <xsd:annotation>
- <xsd:documentation>Specify the interfaces that a class descriptor implements, or the implemention class for an interface descriptor.</xsd:documentation>
- <xsd:documentation>Optionally a set of public interfaces for the class can be specified. This allows the interface to be used to refer to the implementation class.</xsd:documentation>
- <xsd:documentation>If two classes implement the same interface, an interface descriptor should be defined for the interface.</xsd:documentation>
- <xsd:documentation>This can also be used to define inheritance between interface descriptors.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="interface" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified interface class name.</xsd:documentation>
- <xsd:documentation>Example: <class xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">example.employee.api.Employee</class></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="implementor-descriptor" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class name of the implementation class for which this interface is the public interface.</xsd:documentation>
- <xsd:documentation>This can be used if the interface has only a single implementor.</xsd:documentation>
- <xsd:documentation>Example: <class xmlns="http://www.eclipse.org/eclipselink/xsds/persistence">example.employee.impl.Employee</class></xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="copy-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object cloning/copying behavoir to be customized.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="instantiation-copy-policy">
- <xsd:annotation>
- <xsd:documentation>Creates a copying through creating a new instance to copy into.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="copy-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="clone-copy-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object cloning/copying behavoir to be customized through a clone method.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="copy-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the clone method on the object, i.e. 'clone'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="instantiation-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the object instantiation behavoir to be customized.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the method on the factory to instantiate the object instance.'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="factory-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified factory class name.'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="factory-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the method to instantiate the factory class.'</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="amendment">
- <xsd:annotation>
- <xsd:documentation>Specifies a class and static method to be called to allow for the descriptor to be amended or customized through a class API after loading.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="amendment-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation> The fully qualified name of the amendment class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="amendment-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the static amendment method on the class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="relational-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to a relational database table(s).</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="tables">
- <xsd:annotation>
- <xsd:documentation>The list of the tables the class is persisted to. Typically a class is persisted to a single table, but multiple tables can be defined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="table" type="table">
- <xsd:annotation>
- <xsd:documentation>The list of tables that the class is persisted to. This is typically a single table but can be multiple, or empty for inheritance or aggregated classes.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-keys-for-multiple-table" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>Allow the foreign key field references to be define for multiple table descriptors.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="multiple-table-join-criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>For complex multiple table join conditions an expression may be provided instead of the table foreign key information.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="version-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on a numeric version field/column that tracks changes and the version to an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy">
- <xsd:sequence>
- <xsd:element name="version-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The name and optionally the table of the column that the attribute is stored into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="store-version-in-cache" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the version value should be stored in the cache, or if it will be stored in the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="timestamp-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on timestamp version column that tracks changes and the version to an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="version-locking-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="server-time" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the timestamp should be obtained locally or from the database server.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="all-fields-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on comparing the original read values of all fields of the object with the current state of the values in the database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="changed-fields-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on comparing the original read values of only the changed fields of the object with the current state of the values in the database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="selected-fields-locking-policy">
- <xsd:annotation>
- <xsd:documentation>Defines an optimistic locking policy based on comparing the original read values of a specified set of fields of the object with the current state of the values in the database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="locking-policy">
- <xsd:sequence>
- <xsd:element name="fields">
- <xsd:annotation>
- <xsd:documentation>Specify the set of fields to compare on update and delete.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="sequencing-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how a database generated unique id should be assigned to the class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="sequence-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the name of the sequence generator. This could be the name of a sequence object, or a row value in a sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="sequence-field" type="field">
- <xsd:annotation>
- <xsd:documentation>Specify the field/column that the generated sequence id is assigned to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:simpleType name="cache-type">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid caching types.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="none" />
- <xsd:enumeration value="full" />
- <xsd:enumeration value="cache" />
- <xsd:enumeration value="weak-reference" />
- <xsd:enumeration value="soft-reference" />
- <xsd:enumeration value="soft-cache-weak-reference" />
- <xsd:enumeration value="hard-cache-weak-reference" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="caching-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class' instances should be cached and how object identity should be maintained.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="soft-cache-weak-reference" name="cache-type" type="cache-type">
- <xsd:annotation>
- <xsd:documentation>Specify the type of caching, such as LRU, weak reference or none.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="100" name="cache-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specify the initial or maximum size of the cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="always-refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to always refresh cached objects on queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="only-refresh-cache-if-newer-version" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to refresh if the cached object is an older version.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="disable-cache-hits" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Disable obtaining cache hits on primary key queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="always-conform" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to always conform queries within a transaction.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="isolated" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if objects of this type should be isolated from the shared cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="isolate-new-data-after-transaction" name="unitofwork-isolation-level" type="unitofwork-isolation-level">
- <xsd:annotation>
- <xsd:documentation>Specify how the unit of work should be isolated to the session cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="cache-invalidation-policy" type="cache-invalidation">
- <xsd:annotation>
- <xsd:documentation>Defines the cache invalidation policy. By default there will be no cache invalidation policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="change-set" name="cache-sync-type" type="cache-sync-type">
- <xsd:annotation>
- <xsd:documentation>The type of cache synchronization to be used with this descripor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="cache-invalidation" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Abstract superclass for cache invalidation policies.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="update-read-time-on-update" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="no-expiry-cache-invalidation-policy">
- <xsd:annotation>
- <xsd:documentation>Cache invalidation policy where objects in the cache do not expire.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="cache-invalidation" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="time-to-live-cache-invalidation-policy">
- <xsd:annotation>
- <xsd:documentation>Cache invalidation policy where objects live a specific number of milliseconds after they are read.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="cache-invalidation">
- <xsd:sequence>
- <xsd:element name="time-to-live" type="xsd:long" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="daily-cache-invalidation-policy">
- <xsd:annotation>
- <xsd:documentation>Cache invalidation Policy where objects expire at a specific time every day</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="cache-invalidation">
- <xsd:sequence>
- <xsd:element name="expiry-time" type="xsd:dateTime" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of objects are to be persisted to the data-store.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true" name="handle-writes" type="xsd:boolean" />
- <xsd:element minOccurs="0" default="false" name="use-database-time" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="history-tables">
- <xsd:annotation>
- <xsd:documentation>Defines the names of the mirroring historical tables.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="history-table" type="history-table" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="start-fields">
- <xsd:annotation>
- <xsd:documentation>Defines the start fields for each historical table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="start-field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="end-fields">
- <xsd:annotation>
- <xsd:documentation>Defines the end fields for each historical table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="end-field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="history-table">
- <xsd:annotation>
- <xsd:documentation>Each entry is a source (descriptor) to history table name association.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="" name="source" type="xsd:string" />
- <xsd:element minOccurs="1" name="history" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="returning-policy">
- <xsd:annotation>
- <xsd:documentation>Defines retuning policy. By default there will be no returning policy.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="1" name="returning-field-infos">
- <xsd:annotation>
- <xsd:documentation>Lists the fields to be returned together with the flags defining returning options</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="returning-field-info" type="returning-field-info" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="returning-field-info">
- <xsd:annotation>
- <xsd:documentation>Field to be returned together with type and the flags defining returning options. At least one of insert, update should be true.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the target referenced class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field to be returned.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="insert" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates whether the field should be retuned after Insert.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="insert-mode-return-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If insert==true, indicates whether the field should not be inserted (true). If insert==false - ignored.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="update" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates whether the field should be retuned after Insert.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="inheritance-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how the class is related in inheritance and how this inheritance is persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="parent-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the parent/superclass of the class being persisted. The class name must be full qualified with its package.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="read-subclasses-on-queries" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Define if subclasses of the class should be returned on queries, or only the exact class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="all-subclasses-view" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optionally specify the name of a view that joins all of the subclass' tables.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="use-class-name-as-indicator" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the fully qualified class name should be used as the class type indicator.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-extraction-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of a method on the class that takes the class' row as argument a computed that class type to be used to instantiate from the row.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-indicator-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The name of the type field/column that the class type is stored into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-indicator-mappings" type="class-indicator-mappings">
- <xsd:annotation>
- <xsd:documentation>The set of class indicator values and the subclasses they map to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-extractor" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of a class that implements a class extractor interface.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="only-instances-criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The criteria that filters out all sibling and subclass instances on queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="all-subclasses-criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The criteria that filters out sibling instances on queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="outer-join-subclasses" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>For inheritance queries specify if all subclasses should be outer joined, instead of a query per subclass.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="qname-inheritance-policy">
- <xsd:annotation>
- <xsd:documentation>Extends inheritance policy. Allows for prefixed names to be resolved at runtime to find the approriate class</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="inheritance-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="class-indicator-mappings">
- <xsd:annotation>
- <xsd:documentation>The set of class indicator values and the subclasses they map to.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="class-indicator-mapping">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the class the type maps to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="class-indicator" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>The field value used to define the class type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="event-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the persistent events for this class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="event-listeners">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="event-listener" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of an event listener class that implements the descriptor event listener interface.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-build-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after building the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-write-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before writing the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-write-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after writing the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-insert-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before inserting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-insert-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after inserting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-update-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before updating the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-update-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after updating the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="pre-delete-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before deleting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-delete-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after deleting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="about-to-insert-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before inserting the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="about-to-update-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed before updating the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-clone-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after cloning the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-merge-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after merging the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="post-refresh-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Method executed after refreshing the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="query-policy">
- <xsd:annotation>
- <xsd:documentation>The list of defined queries and query properties for the class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="queries">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="query" type="query">
- <xsd:annotation>
- <xsd:documentation>A query definition for the class' instances.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="timeout" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies a timeout to apply to all queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="check-cache" name="existence" type="existence-policy">
- <xsd:annotation>
- <xsd:documentation>Allow the behavoir used to determine if an insert or update should occur for an object to be customized.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="insert-query" type="insert-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom insert query. This overide the default insert behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="update-query" type="update-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom update query. This overide the default update behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-query" type="delete-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom delete query. This overide the default delete behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="does-exist-query" type="does-exist-query">
- <xsd:annotation>
- <xsd:documentation>Custom does exist query. This overide the default delete behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="read-object-query" type="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Custom read object query. This overide the default read behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="read-all-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Custom read all query. This overide the default read all behavoir for usage with stored procedures or custom calls.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:simpleType name="existence-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid existence policies for determining if an insert or update should occur for an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="check-cache" />
- <xsd:enumeration value="check-database" />
- <xsd:enumeration value="assume-existence" />
- <xsd:enumeration value="assume-non-existence" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for querying database information.</xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query-key alias name.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:simpleType name="cache-sync-type">
- <xsd:annotation>
- <xsd:documentation>The type of cache synchronization to use with a descriptor.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="invalidation" />
- <xsd:enumeration value="no-changes" />
- <xsd:enumeration value="change-set-with-new-objects" />
- <xsd:enumeration value="change-set" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="unitofwork-isolation-level">
- <xsd:annotation>
- <xsd:documentation>Specify how the unit of work isolated from the session cache.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="use-session-cache-after-transaction" />
- <xsd:enumeration value="isolate-new-data-after-transaction" />
- <xsd:enumeration value="isolate-cache-after-transaction" />
- <xsd:enumeration value="isolate-cache-always" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="direct-query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a database column.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="query-key">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column being aliased.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="relationship-query-key" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a join to another class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="query-key">
- <xsd:sequence>
- <xsd:element name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the target referenced class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:choice>
- <xsd:element name="foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key join condition between the source and target class' tables.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The join criteria between the source and target class' tables.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:choice>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-one-query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a 1-1 join to another class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-query-key" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-many-query-key">
- <xsd:annotation>
- <xsd:documentation>Defines an alias for a 1-m join from another class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="relationship-query-key" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping from an attirbute to a simple field datatype, i.e. String, Number, Date.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The name and optionally the table of the field/column that the attribute is stored into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="null-value" type="xsd:anySimpleType" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Optionally specify a value that null data values should be converted to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="converter" type="value-converter" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="attribute-classification" type="xsd:string" minOccurs="0"/>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="attribute-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a attribute is persisted. The attribute mapping definition is extendable to allow for different types of mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="attribute-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the attribute. This is the implementation class attribute name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="read-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the attribute is read-only.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="get-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the get method for the attribute.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="set-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the set method for the attribute.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="properties">
- <xsd:annotation>
- <xsd:documentation>Allow for user defined properties to be defined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="property" type="property">
- <xsd:annotation>
- <xsd:documentation>A user defined property.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a simple attribute is persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="abstract-direct-mapping">
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping from an attirbute to a simple field datatype, i.e. String, Number, Date.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="abstract-direct-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-cdata" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="null-policy" type="abstract-null-policy" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-direct-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping from an attirbute to a simple field datatype, i.e. String, Number, Date.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-direct-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="field-transformation" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a field transformation for a transformation mapping</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="method-based-field-transformation">
- <xsd:complexContent mixed="false">
- <xsd:extension base="field-transformation">
- <xsd:sequence>
- <xsd:element name="method" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="transformer-based-field-transformation">
- <xsd:complexContent mixed="false">
- <xsd:extension base="field-transformation">
- <xsd:sequence>
- <xsd:element name="transformer-class" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a transformation mapping that uses Java code to transform between the data and object values.</xsd:documentation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="attribute-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the attribute transformation defined in the domain class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="attribute-transformer" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The class name of the attribute transformer. Used in place of attribute-transformation.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="mutable" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy" />
- <xsd:element minOccurs="0" name="field-transformations">
- <xsd:annotation>
- <xsd:documentation>The field transformations.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field-transformation" type="field-transformation" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-transformation-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-transformation-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-transformation-mapping">
- <xsd:annotation>
- <xsd:documentation>This can be used if a single attribute maps to multiple fields, or field only mappings or attribute only mappings.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-transformation-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="aggregate-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a relationship where the target object is strictly privately owned by the source object and stores within the source objects row</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class name of the target class of the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="allow-null" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if a row of all nulls should be interpreted as null.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="field-translations">
- <xsd:annotation>
- <xsd:documentation>Allow for the mapping to use different field names than the descriptor.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field-translation">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="source-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field in the source descriptor's table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field in the aggregate descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="relationship-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines how a relationship between two classes is persisted.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class name of the target class of the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="private-owned" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the target objects are privately owned dependent objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-persist" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the create operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-merge" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the create operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the refresh operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="cascade-remove" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the remove operation should be cascaded to the referenced object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-one-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source instance to the target instance.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the source class' table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-one-to-one-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source instance to the target instance.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="one-to-one-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="one-to-many-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m relationship from the source instance to the target instances.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="target-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the target class' table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the related objects can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-one-to-many-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m relationship from the source instance to the target instances.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="source-foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="target-foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-key-grouping-element" type="field" />
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the related objects can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a collection of simple types relationship from the source instance to a set of simple data values.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="data-read-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target data values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="reference-table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the reference table that stores the source primary key and the data values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="direct-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column in the reference table that stores the data values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="reference-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the reference table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="value-converter" type="value-converter">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="insert-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to insert a row into the reference table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete a row from the reference table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the rows from the reference table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="session-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name session that defines the reference table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="history-policy" type="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of this attribute are persisted to the data-store. By default there will be no history policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-map-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a map relationship from the source instance to a set of key values pairs of simple data values.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="direct-collection-mapping">
- <xsd:sequence>
- <xsd:element name="direct-key-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column in the reference table that sores the map key data value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="key-converter" type="value-converter">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the key data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="aggregate-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m relationship from the source instance to the target instances where the target instances are strictly privately owned by the source object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="target-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key in the target class' table that defines the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the related objects can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="many-to-many-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a m-m relationship from the source instance to the target instances.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="relation-table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the relation table that stores the source/target primary keys.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="source-relation-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key from the relational table to the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-relation-foreign-key" type="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The foreign key from the relational table to the target class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="insert-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to insert a row into the relation table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete a row from the relation table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="delete-all-query" type="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>A query to delete all of the rows from the relation table can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="history-policy" type="history-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how past versions of this attribute are persisted to the data-store. By default there will be no history policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="join-fetch" type="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Specify to always join the related objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="variable-one-to-one-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source instance to the target instance that may be of several types related through an interface.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="bidirectional-target-attribute" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>For bi-directional relationships the target inverse relationship can be defined.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="batch-reading" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify to optimize reads for the class by batching the reads to this relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="indirection" type="indirection-policy">
- <xsd:annotation>
- <xsd:documentation>The indirection policy to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="selection-query" type="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Specify the query to use to select the target objects.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="type-field" type="field">
- <xsd:annotation>
- <xsd:documentation>Specify the column to store the class type of the related object into.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="foreign-key-fields">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The set of foreign key fields populated by this relationship in the source class' table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="foreign-key-to-query-key">
- <xsd:annotation>
- <xsd:documentation>The list of source/target column/query key references relating a foreign key in one table to the query keys defining a primary or unique key value in the other interface descriptor.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="query-key-reference">
- <xsd:annotation>
- <xsd:documentation>The reference of a source table foreign key and a target interface descriptor query key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="source-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The foreign key field/column name in the source table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-query-key" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query key name of the target interface descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="class-indicator-mappings" type="class-indicator-mappings">
- <xsd:annotation>
- <xsd:documentation>The set of class indicator values and the subclasses they map to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a container/collection type.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="collection-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the collection implementation class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="sorted-collection-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a sorted collection type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="comparator-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the comparitor, used to compare objects in sorting the collection.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="list-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a list collection type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="map-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a map container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="map-key-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the method to call on the target objects to get the key value for the map.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-map-container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a direct map container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="scrollable-cursor-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a scrollable cursor container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="cursored-stream-policy">
- <xsd:annotation>
- <xsd:documentation>Defines a cursored stream container type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="container-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="indirection-policy" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a deferred read indirection mechanism.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="value-holder-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of value holders to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="proxy-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of proxies to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="transparent-collection-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of transparent collections to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="collection-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the collection interface to use, i.e. List, Set, Map.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="map-key-method" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the method to call on the target objects to get the key value for the map.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="container-indirection-policy">
- <xsd:annotation>
- <xsd:documentation>Defines usage of a user defined container to implement indirection.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="indirection-policy">
- <xsd:sequence>
- <xsd:element name="container-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the container implementer to use.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-list-converter">
- <xsd:annotation>
- <xsd:documentation>List converter</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="object-class-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the list's element type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="typesafe-enumeration-converter">
- <xsd:annotation>
- <xsd:documentation>Typesafe Enumeration conversion</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="type-conversion-converter">
- <xsd:annotation>
- <xsd:documentation>Specifies the data type and an object type of the attribute to convert between.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="object-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the attribute type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="data-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the attributes storage data type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="serialized-object-converter">
- <xsd:annotation>
- <xsd:documentation>Uses object serialization to convert between the object and data type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="data-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specifies the fully qualified class name of the attributes storage data type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-type-converter">
- <xsd:annotation>
- <xsd:documentation>Specifies a mapping of values from database values used in the field and object values used in the attribute.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="value-converter">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="default-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>An optional default value can be specified. This value is used if a database type is not found in the type mapping.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="type-mappings">
- <xsd:annotation>
- <xsd:documentation>Specifies the mapping of values. Both the object and database values must be unique.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="type-mapping" type="type-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines the object and data value mapping.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="attribute-only-type-mappings">
- <xsd:annotation>
- <xsd:documentation>Specifies a mapping of additional values that map non-unique data values to a unique attribute value.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="type-mapping" type="type-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines the object and data value mapping.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="type-mapping">
- <xsd:annotation>
- <xsd:documentation>Define an object and data value mapping.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="object-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>Specifies the value to use in the object's attribute.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="data-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>Specifies the value to use in the database field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="database-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query/interaction against a database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="query">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true" name="maintain-cache" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should bypass the cache completely.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="bind-all-parameters" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should use paramater binding for arguments, or print the arguments in-line.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="cache-statement" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the queries statement should be cached, this must be used with parameter binding.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="timeout" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies a timeout to cancel the query in if the request takes too long to complete.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="prepare" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should prepare and cache its generated SQL, or regenerate the SQL on each execution.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="call" type="criteria">
- <xsd:annotation>
- <xsd:documentation>For static calls the SQL or Stored Procedure call definition can be specified.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="join-fetch-type">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid join fetch options.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="none" />
- <xsd:enumeration value="inner-join" />
- <xsd:enumeration value="outer-join" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="cascade-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid cascade policies.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="none" />
- <xsd:enumeration value="private" />
- <xsd:enumeration value="all" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="value-read-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading a single value.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="direct-read-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-read-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading a collection of values.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="data-read-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="data-read-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading raw data.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="read-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="read-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query for reading.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="cache-query-results" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specifies if the query should cache the query results to avoid future executions.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="max-rows" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies the maximum number of rows to fetch, results will be trunctate on the database to this size.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="first-result" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifies where to start the cursor in a result set returned from the database. Results prior to this number will not be built into objects</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Specifiess the number of rows to fetch from the database on each result set next operation.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="query-result-cache-policy" type="query-result-cache-policy">
- <xsd:annotation>
- <xsd:documentation>Specify how the query results should be cached.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="query-result-cache-policy">
- <xsd:annotation>
- <xsd:documentation>Defines how a query's results should be cached.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="invalidation-policy" type="cache-invalidation">
- <xsd:annotation>
- <xsd:documentation>Defines the cache invalidation policy. By default there will be no cache invalidation policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="100" name="maximum-cached-results" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>This defines the number of query result sets that will be cached. The LRU query results will be discarded when the max size is reached.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="data-modify-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for manipulating data.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-modify-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query for modifying an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="update-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for updating an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-modify-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="insert-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for inserting an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-modify-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="delete-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for deleting an object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-modify-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="does-exist-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for determining if an object exists.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="existence-check" type="existence-check">
- <xsd:annotation>
- <xsd:documentation>The existence check option.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="existence-check">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid existence check options.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="check-cache" />
- <xsd:enumeration value="check-database" />
- <xsd:enumeration value="assume-existence" />
- <xsd:enumeration value="assume-non-existence" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="delete-all-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for deleting a criteria of objects.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="database-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-level-read-query" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query for objects (as apposed to data).</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="read-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The full qualified name of the class of objects being queried.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should refresh any cached objects from the database.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="remote-refresh" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should refresh any remotely cached objects from the server.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="cascade-policy" type="cascade-policy">
- <xsd:annotation>
- <xsd:documentation>Specifies if the queries settings (such as refresh, maintain-cache) should apply to the object's relationship queries.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="primary-key" name="cache-usage" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify how the query should interact with the cache.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="lock-mode" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should lock the resulting rows on the database.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="none" name="distinct-state" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify if the query should filter distinct results.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="in-memory-querying">
- <xsd:annotation>
- <xsd:documentation>The in memory querying policy.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element default="ignore-exceptions-return-conformed" name="policy" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify how indirection or unconformable expressions should be treating with in-memory querying and conforming.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" default="true" name="use-default-fetch-group" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the default fetch group should be used for the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-group" type="fetch-group">
- <xsd:annotation>
- <xsd:documentation>Allow the query to partially fetch the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="fetch-group-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify a pre-defined named fetch group to allow the query to partially fetch the object.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="use-exclusive-connection" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if the exclusive connection (VPD) should be used for the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="joined-attribute-expressions">
- <xsd:annotation>
- <xsd:documentation>Specifies the attributes being joined.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for joining</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="read-only" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Specify if objects resulting from the query are read-only, and will not be registered in the unit of work.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="outer-join-subclasses" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>For inheritance queries specify if all subclasses should be outer joined, instead of a query per subclass.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="read-all-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for a set of objects.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-level-read-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="batch-read-attribute-expressions">
- <xsd:annotation>
- <xsd:documentation>Specifies all attributes for batch reading.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for batch reading</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="order-by-expressions">
- <xsd:annotation>
- <xsd:documentation>Sets the order expressions for the query.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for ordering</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="read-object-query">
- <xsd:annotation>
- <xsd:documentation>Defines a query for a single object.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="object-level-read-query" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="report-query">
- <xsd:annotation>
- <xsd:documentation>Query for information about a set of objects instead of the objects themselves.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="read-all-query">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="return-choice" type="return-choice">
- <xsd:annotation>
- <xsd:documentation>Simplifies the result by only returning the first result, first value, or all attribute values.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="retrieve-primary-keys" type="retrieve-primary-keys">
- <xsd:annotation>
- <xsd:documentation>Indicates wether the primary key values should also be retrieved for the reference class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="report-items">
- <xsd:annotation>
- <xsd:documentation>Items to be selected, these could be attributes or aggregate functions.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="item" type="report-item">
- <xsd:annotation>
- <xsd:documentation>Represents an item requested</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="group-by-expressions">
- <xsd:annotation>
- <xsd:documentation>Sets GROUP BY expressions for the query.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Represents an expression for grouping</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="return-choice">
- <xsd:annotation>
- <xsd:documentation>Simplifies the result by only returning the first result, first value, or all attribute values.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="return-single-result" />
- <xsd:enumeration value="return-single-value" />
- <xsd:enumeration value="return-single-attribute" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="retrieve-primary-keys">
- <xsd:annotation>
- <xsd:documentation>Indicates wether the primary key values should also be retrieved for the reference class.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="full-primary-key" />
- <xsd:enumeration value="first-primary-key" />
- <xsd:enumeration value="no-primary-key" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="report-item">
- <xsd:annotation>
- <xsd:documentation>Represents an item requested in ReportQuery.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Name given for item, can be used to retieve value from result.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="attribute-expression" type="expression">
- <xsd:annotation>
- <xsd:documentation>Expression (partial) that describes the attribute wanted.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="expression" abstract="true">
- <xsd:annotation>
- <xsd:documentation>Defines a query filter expression tree.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="relation-expression">
- <xsd:annotation>
- <xsd:documentation>Defines a relation expression that compares to expressions through operators such as equal, lessThan, etc..</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="left" type="expression" />
- <xsd:element name="right" type="expression" />
- </xsd:sequence>
- <xsd:attribute name="operator" type="operator" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="logic-expression">
- <xsd:annotation>
- <xsd:documentation>Defines a expression composed of two sub-expressions joined through an operator such as AND, OR.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="left" type="expression" />
- <xsd:element name="right" type="expression" />
- </xsd:sequence>
- <xsd:attribute name="operator" type="operator" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="function-expression">
- <xsd:annotation>
- <xsd:documentation>Defines a expression composed of a function applied to a list of sub-expressions.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of function arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="expression">
- <xsd:annotation>
- <xsd:documentation>Defines an argument expression.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="function" type="operator" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="constant-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression value. If the value is null the value tag can is absent.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="value" type="xsd:anySimpleType" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="query-key-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression query-key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="base" type="expression" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" />
- <xsd:attribute name="any-of" type="xsd:boolean" />
- <xsd:attribute name="outer-join" type="xsd:boolean" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="field-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression field.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="field" type="field" />
- <xsd:element name="base" type="expression" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="parameter-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression parameter.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression">
- <xsd:sequence>
- <xsd:element name="parameter" type="field" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="base-expression">
- <xsd:annotation>
- <xsd:documentation>Defines an expression builder/base.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="expression" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="operator">
- <xsd:annotation>
- <xsd:documentation>Defines the set of valid operators.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string" />
- </xsd:simpleType>
- <xsd:complexType name="sql-call">
- <xsd:annotation>
- <xsd:documentation>Defines an SQL query language string.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="sql" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The full SQL query string. Arguments can be specified through #arg-name tokens in the string.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="ejbql-call">
- <xsd:annotation>
- <xsd:documentation>Defines an EJB-QL query language string.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="ejbql" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The EJB-QL query string.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="stored-procedure-call">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure invocation definition.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="procedure-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the stored procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="cursor-output-procedure" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Define the call to use a cursor output parameter to define the result set.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input and output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="procedure-argument">
- <xsd:annotation>
- <xsd:documentation>Defines an argument to the procedure. The order of the arguments must match the procedure arguments if not named.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="stored-function-call">
- <xsd:annotation>
- <xsd:documentation>Defines a stored function invocation definition.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="stored-procedure-call">
- <xsd:sequence>
- <xsd:element minOccurs="1" name="stored-function-result" type="procedure-output-argument">
- <xsd:annotation>
- <xsd:documentation>The return value of the stored-function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="procedure-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure call argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="procedure-argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The stored procedure name of the argument. For indexed argument the name is not required.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query name of the argument. This is the name of the argument as define in the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="procedure-argument-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified name of the argument class type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="procedure-argument-sqltype" type="xsd:int">
- <xsd:annotation>
- <xsd:documentation>The JDBC int type of the argument, as defined in java.jdbc.Types</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="procedure-argument-sqltype-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the type if procedure-argument-sqltype is STRUCT or ARRAY</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="argument-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>The procedure argument value maybe be specified if not using a query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="procedure-output-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure call output argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="procedure-argument" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="procedure-inoutput-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure call output argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="procedure-argument">
- <xsd:sequence>
- <xsd:element name="output-argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query name of the argument. This is the name of the argument as define in the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-stored-procedure-call">
- <xsd:annotation>
- <xsd:documentation>Defines a stored procedure invocation definition whose arguments contain at least one Oracle PL/SQL type that has no JDBC representation (e.g. BOOLEAN, PLS_INTEGER, PL/SQL record).</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="procedure-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the stored procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input and output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="plsql-procedure-argument-type">
- <xsd:annotation>
- <xsd:documentation>Defines an argument to the procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-procedure-argument-type" abstract="true">
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" />
- <xsd:element minOccurs="0" name="index" type="xsd:string" />
- <xsd:element minOccurs="0" name="direction" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="jdbc-type">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:sequence>
- <xsd:choice>
- <xsd:element minOccurs="0" name="length" type="xsd:string" />
- <xsd:sequence>
- <xsd:element name="precision" type="xsd:string" />
- <xsd:element name="scale" type="xsd:string" />
- </xsd:sequence>
- </xsd:choice>
- </xsd:sequence>
- <xsd:attribute name="type-name" type="xsd:string" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-type">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:attribute name="type-name" type="xsd:string" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-record">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:sequence>
- <xsd:element name="type-name" type="xsd:string" />
- <xsd:element minOccurs="0" name="compatible-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="java-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="fields">
- <xsd:annotation>
- <xsd:documentation>The list of fields.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="plsql-procedure-argument-type">
- <xsd:annotation>
- <xsd:documentation>Defines an argument to the procedure.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="plsql-collection">
- <xsd:complexContent mixed="false">
- <xsd:extension base="plsql-procedure-argument-type">
- <xsd:sequence>
- <xsd:element name="type-name" type="xsd:string" />
- <xsd:element minOccurs="0" name="compatible-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="java-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="nested-type" type="plsql-procedure-argument-type" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to an EIS record data structure.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element name="datatype" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the record structure name the descriptor maps to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="namespace-resolver" type="namespace-resolver">
- <xsd:annotation>
- <xsd:documentation>The namespace resolver for the descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="mapped-interaction">
- <xsd:annotation>
- <xsd:documentation>Defines an EIS interaction utilizing MappedRecord.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="function-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the input result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the output result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-interaction">
- <xsd:annotation>
- <xsd:documentation>Defines an EIS interaction utilizing XML records.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="function-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-record-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name to use for the input record, if required by the adapter.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-root-element-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the output result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the input result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-result-path" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optional root key if the output result is not at the record root.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="indexed-interaction">
- <xsd:annotation>
- <xsd:documentation>Defines an EIS interaction utilizing Indexed records.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="criteria">
- <xsd:sequence>
- <xsd:element name="function-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the function.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="input-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of input arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" name="output-arguments">
- <xsd:annotation>
- <xsd:documentation>The list of output arguments.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="interaction-argument" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="interaction-argument">
- <xsd:annotation>
- <xsd:documentation>Defines an interaction argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="argument-value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>The procedure argument value maybe be specified if not using a query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The interaction name of the argument. For indexed arguments the name is not required.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="argument-name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The query name of the argumen. This is the name of the argument as define in the query, or the descriptor field name.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="object-relational-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to a Structure type in an object-relational database.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relational-class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the object structure type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="field-order">
- <xsd:annotation>
- <xsd:documentation>The ordered list of the field defined in the structure.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="nested-table-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-m/m-m relationship that makes use of the object-relational nested-table type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field/column in the source table that stores the nested-table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the object-relational type name of the nested-table type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="array-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a collection of primitive/simple type values using the object-relational array type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-direct-collection-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the object-relational type name of the structure type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-array-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a collection of object-types using the object-relational array type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping">
- <xsd:sequence>
- <xsd:element name="structure" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Specify the object-relational type name of the structure type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="structure-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a structure of object-types using the object-relational structure type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-object-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="reference-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a reference to another object-type using the object-relational reference type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="relationship-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field">
- <xsd:annotation>
- <xsd:documentation>The field in the source type that stores the reference.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-relational-field">
- <xsd:annotation>
- <xsd:documentation>Defines an ObjectRelationalDatabaseField</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="nested-type-field" type="field" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="direct-xml-type-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct mapping to an Oracle XDB XML Type.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="direct-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="read-whole-document" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-composite-direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct collection mapping for an XML list of elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="field" type="field" />
- <xsd:element minOccurs="0" name="value-converter" type="value-converter">
- <xsd:annotation>
- <xsd:documentation>Optionally specify how the data value should be converted to the object value.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="value-converter-class" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Optionally specify a user defined converter class.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-collection-reference-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-M relationship from the source XML element to the target XML element based on a key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="xml-object-reference-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="containerpolicy" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="uses-single-node" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-object-reference-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a 1-1 relationship from the source XML element to the target XML element based on one or more keys.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="aggregate-object-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="source-to-target-key-field-association" type="foreign-key" />
- <xsd:element minOccurs="0" name="source-to-target-key-fields">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="field" type="field" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-composite-direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct collection mapping for an XML list of elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-direct-collection-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-cdata" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="null-policy" type="abstract-null-policy" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-composite-direct-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a direct collection mapping for an XML list of elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-direct-collection-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-composite-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite collection mapping for an XML list of nested elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string" />
- <xsd:element name="field" type="field" />
- <xsd:element minOccurs="0" name="container" type="container-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the collection type to use for the relationship.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-composite-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite collection mapping for an XML list of nested elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping">
- <xsd:sequence>
- <xsd:element name="container-attribute" minOccurs="0"/>
- <xsd:element name="container-get-method" minOccurs="0"/>
- <xsd:element name="container-set-method" minOccurs="0"/>
- <xsd:element name="keep-as-element-policy" type="xsd:string" minOccurs="0"/>
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-composite-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite collection mapping for an XML list of nested elements.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-composite-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite object mapping for an XML nested element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reference-class" type="xsd:string" />
- <xsd:element name="field" type="field" />
- <xsd:element name="container-attribute" minOccurs="0"/>
- <xsd:element name="container-get-method" minOccurs="0"/>
- <xsd:element name="container-set-method" minOccurs="0"/>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-composite-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite object mapping for an XML nested element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-object-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="null-policy" type="abstract-null-policy" />
- <xsd:element minOccurs="0" name="keep-as-element-policy" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eis-composite-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a composite object mapping for an XML nested element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-object-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-class-mapping-descriptor">
- <xsd:annotation>
- <xsd:documentation>Defines a class mapping to an XML element.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="class-mapping-descriptor">
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="default-root-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the element the descriptor maps to.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="default-root-element-field" type="node">
- <xsd:annotation>
- <xsd:documentation>The XMLField representing the default root element of the descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="should-preserve-document" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates if nodes should be cached to preserve unmapped data</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="namespace-resolver" type="namespace-resolver">
- <xsd:annotation>
- <xsd:documentation>The namespace resolver for the descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="schema" type="schema-reference">
- <xsd:annotation>
- <xsd:documentation>The location of the XML Schema.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="false" name="result-always-xml-root" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-any-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to an xs:any declaration or xs:anyType element</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="field" type="field" />
- <xsd:element minOccurs="0" name="container" type="container-policy" />
- <xsd:element minOccurs="0" default="false" name="use-xml-root" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="keep-as-element-policy" type="xsd:string" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-any-attribute-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to an xs:any declaration or xs:anyType element</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="field" type="field" />
- <xsd:element minOccurs="0" name="container" type="container-policy" />
- <xsd:element minOccurs="0" name="include-namespace-declaration" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="include-schema-instance" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-any-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a single object to an xs:any declaration</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="field" type="field" />
- <xsd:element minOccurs="0" default="false" name="use-xml-root" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="keep-as-element-policy" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-fragment-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a single Node to a fragment of an XML document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="xml-direct-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-fragment-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection of Nodes to a fragment of an XML document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-composite-collection-mapping" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-binary-data-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a binary object to base64 binary</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="xml-direct-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-swa-ref" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="mime-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="should-inline-data" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-binary-data-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a binary object to base64 binary</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="xml-composite-direct-collection-mapping">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-swa-ref" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="mime-type" type="xsd:string" />
- <xsd:element minOccurs="0" name="should-inline-data" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-choice-collection-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to a choice structure in an xml document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element name="container-policy" type="container-policy" />
- <xsd:element maxOccurs="unbounded" name="field-to-class-association" type="xml-choice-field-to-class-association" />
- <xsd:element minOccurs="0" name="reuse-container" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-choice-object-mapping">
- <xsd:annotation>
- <xsd:documentation>Defines a mapping of a collection to a choice structure in an xml document</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="attribute-mapping">
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field-to-class-association" type="xml-choice-field-to-class-association" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-choice-field-to-class-association">
- <xsd:sequence>
- <xsd:element name="xml-field" type="node" />
- <xsd:element name="class-name" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="xml-conversion-pair">
- <xsd:sequence>
- <xsd:element name="qname" type="xsd:string" />
- <xsd:element name="class-name" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="node">
- <xsd:annotation>
- <xsd:documentation>Defines an XPath expression to an element or attribute in an XML document.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="position" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>The position of the node in the parent type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="typed-text-field" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If this is a typed text field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="single-node" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates if each item in the collection is in the same node instead of having one node per item in the collection</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="schema-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The schema type of the element.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="xml-to-java-conversion-pair" type="xml-conversion-pair" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="java-to-xml-conversion-pair" type="xml-conversion-pair" />
- <xsd:element minOccurs="0" name="leaf-element-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Indicates the elements type.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="is-required" type="xsd:boolean"/>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="union-node">
- <xsd:annotation>
- <xsd:documentation>Use to represent nodes which are mapped to unions</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="typed-text-field" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>If this is a typed text field.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="single-node" type="xsd:boolean">
- <xsd:annotation>
- <xsd:documentation>Indicates if each item in the collection is in the same node instead of having one node per item in the collection</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="schema-type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The schema type of the element.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="xml-to-java-conversion-pair" type="xml-conversion-pair" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="java-to-xml-conversion-pair" type="xml-conversion-pair" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="namespace-resolver">
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="1" name="namespaces">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="namespace" type="namespace" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element minOccurs="0" maxOccurs="1" name="default-namespace-uri" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="namespace">
- <xsd:sequence>
- <xsd:element name="prefix" type="xsd:string" />
- <xsd:element name="namespace-uri" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="schema-reference">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="resource" type="xsd:string" />
- <xsd:element name="schema-context" type="xsd:string" />
- <xsd:element name="node-type" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="schema-class-path-reference">
- <xsd:complexContent mixed="false">
- <xsd:extension base="schema-reference" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="schema-file-reference">
- <xsd:complexContent mixed="false">
- <xsd:extension base="schema-reference" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="schema-url-reference">
- <xsd:complexContent mixed="false">
- <xsd:extension base="schema-reference" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="java-character">
- <xsd:restriction base="xsd:string" />
- </xsd:simpleType>
- <xsd:simpleType name="java-timestamp">
- <xsd:restriction base="xsd:dateTime" />
- </xsd:simpleType>
- <xsd:simpleType name="java-util-date">
- <xsd:restriction base="xsd:dateTime" />
- </xsd:simpleType>
- <xsd:complexType name="cmp-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="pessimistic-locking" type="pessimistic-locking">
- <xsd:annotation>
- <xsd:documentation>Defines the cmp bean-level pessimistic locking policy.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="defer-until-commit" type="defer-until-commit">
- <xsd:annotation>
- <xsd:documentation>Defines modification deferral level for non-deferred writes.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="non-deferred-create-time" type="non-deferred-create-time">
- <xsd:annotation>
- <xsd:documentation>Defines point at which insert will be issued to Database.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="pessimistic-locking">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="wait" name="locking-mode" type="locking-mode" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:simpleType name="defer-until-commit">
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="all-modifications" />
- <xsd:enumeration value="update-modifications" />
- <xsd:enumeration value="none" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="non-deferred-create-time">
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="after-ejbcreate" />
- <xsd:enumeration value="after-ejbpostcreate" />
- <xsd:enumeration value="undefined" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:simpleType name="locking-mode">
- <xsd:annotation>
- <xsd:documentation>Holds the pessimistic locking mode.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="wait" />
- <xsd:enumeration value="no-wait" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="sequence">
- <xsd:annotation>
- <xsd:documentation>Sequence object.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="" name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Sequence name.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="50" name="preallocation-size" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>Sequence preallocation size.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="default-sequence">
- <xsd:annotation>
- <xsd:documentation>References default sequence object, overriding its name and (optionally) preallocation size.</xsd:documentation>
- <xsd:documentation>To use preallocation size of default sequence object, set preallocation size to 0</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="native-sequence">
- <xsd:annotation>
- <xsd:documentation>Database sequence mechanism used.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="table-sequence">
- <xsd:annotation>
- <xsd:documentation>Table sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="SEQUENCE" name="table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_NAME" name="name-field" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence name field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_COUNT" name="counter-field" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence counter field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="unary-table-sequence">
- <xsd:annotation>
- <xsd:documentation>Unary table sequence - sequence name is a table name, table has a single field and a single row</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="SEQUENCE" name="counter-field" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence counter field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xmlfile-sequence">
- <xsd:annotation>
- <xsd:documentation>Xmlfile sequence.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-sequence">
- <xsd:annotation>
- <xsd:documentation>Xml sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="SEQUENCE" name="root-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_NAME" name="name-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence name field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" default="SEQ_COUNT" name="counter-element" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>Define the name of the sequence counter field in the sequence table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="fetch-groups">
- <xsd:annotation>
- <xsd:documentation>Contains all pre-defined fetch groups.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="default-fetch-group" type="fetch-group" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="fetch-group" type="fetch-group" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="fetch-group">
- <xsd:annotation>
- <xsd:documentation>Contains the fetch group attributes info.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="name" type="xsd:string" />
- <xsd:element name="fetch-group-attributes">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>Contains a fetch group's attribute list.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="fetch-group-attribute" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="change-policy">
- <xsd:annotation>
- <xsd:documentation>Describes the change tracking policy for this descriptor.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="deferred-detection-change-policy">
- <xsd:annotation>
- <xsd:documentation>Uses backup clone to detect changes.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="change-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="object-level-change-policy">
- <xsd:annotation>
- <xsd:documentation>Uses "mark dirty" to detect changes.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="change-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="attribute-level-change-policy">
- <xsd:annotation>
- <xsd:documentation>Uses a ChangeTracker firing PropertyChangeEvent's to detect changes.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="change-policy" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="abstract-null-policy">
- <xsd:annotation>
- <xsd:documentation>Defines the Null Policy in use for this relationship currently a choice of [NullPolicy and IsSetNullPolicy].</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" default="false" name="xsi-nil-represents-null" type="xsd:boolean" />
- <xsd:element minOccurs="0" default="false" name="empty-node-represents-null" type="xsd:boolean" />
- <xsd:element minOccurs="0" name="null-representation-for-xml" type="marshal-null-representation" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="null-policy">
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-null-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" default="true" name="is-set-performed-for-absent-node" type="xsd:boolean" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="is-set-null-policy">
- <xsd:complexContent mixed="false">
- <xsd:extension base="abstract-null-policy">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="is-set-method-name" type="xsd:string" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="is-set-parameter-type" type="xsd:string" />
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="is-set-parameter" type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="marshal-null-representation">
- <xsd:annotation>
- <xsd:documentation>Write null, no tag(default) or an empty tag.</xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="XSI_NIL" />
- <xsd:enumeration value="ABSENT_NODE" />
- <xsd:enumeration value="EMPTY_NODE" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="field">
- <xsd:annotation>
- <xsd:documentation>Defines a generic field concept, such as a database column.</xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the field.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="column">
- <xsd:annotation>
- <xsd:documentation>Defines a column in a relational database table.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent mixed="false">
- <xsd:extension base="field">
- <xsd:attribute name="table" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the column's table. This table must be listed in the class' tables. If not specified the first table of the class will be used.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="sql-typecode" type="xsd:integer">
- <xsd:annotation>
- <xsd:documentation>(optional field) The JDBC typecode of this column</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- <xsd:attribute name="column-definition" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>(optional field) Name of the JDBC typecode for this column</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="foreign-key">
- <xsd:annotation>
- <xsd:documentation>The list of source/target field/column references relating a foreign key in one table to the primary or unique key in another table.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element maxOccurs="unbounded" name="field-reference">
- <xsd:annotation>
- <xsd:documentation>The reference of a source table foreign key and a target table primary key.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="source-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The foreign key field/column name in the source table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="target-field" type="field">
- <xsd:annotation>
- <xsd:documentation>The primary or unique key field/column name in the target table.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="query">
- <xsd:annotation>
- <xsd:documentation>Defines a query specification for querying instances of the class.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="criteria" type="criteria">
- <xsd:annotation>
- <xsd:documentation>The selection criteria of the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="arguments">
- <xsd:annotation>
- <xsd:documentation>The list of query arguments. The order of the argument must match the order of the argument value passed to the query.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element minOccurs="0" maxOccurs="unbounded" name="argument" type="query-argument">
- <xsd:annotation>
- <xsd:documentation>The query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the query. This name can be used to reference and execute the query.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="criteria">
- <xsd:annotation>
- <xsd:documentation>Defines the filtering clause of a query.</xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="query-argument">
- <xsd:annotation>
- <xsd:documentation>Defines a query argument.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element minOccurs="0" name="type" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The fully qualified class type name of the argument may be provided.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element minOccurs="0" name="value" type="xsd:anySimpleType">
- <xsd:annotation>
- <xsd:documentation>Optional constant value for the argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the query argument.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="property">
- <xsd:annotation>
- <xsd:documentation>A user defined property.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:anyType" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- <xsd:complexType name="table">
- <xsd:annotation>
- <xsd:documentation>The list of tables that the class is persisted to. This is typically a single table but can be multiple, or empty for inheritance or aggregated classes.</xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>The name of the table. The name can be fully qualified with the schema, tablespace or link.</xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- <xsd:complexType name="value-converter">
- <xsd:annotation>
- <xsd:documentation>
- Specifies how the data value should be converted to the
- object value.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
-
- <xsd:complexType name="document-preservation-policy">
- <xsd:sequence>
- <xsd:element name="node-ordering-policy"
- type="node-ordering-policy" maxOccurs="1" minOccurs="0">
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:complexType name="node-ordering-policy"></xsd:complexType>
-
-
- <xsd:complexType
- name="descriptor-level-document-preservation-policy">
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="no-document-preservation-policy">
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="xml-binder-policy">
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="append-new-elements-ordering-policy">
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="ignore-new-elements-ordering-policy">
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="relative-position-ordering-policy">
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-</xsd:schema>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.0.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.0.xsd
deleted file mode 100644
index 9831af0a26..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.0.xsd
+++ /dev/null
@@ -1,1477 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-******************************************************************************
- Copyright (c) 1998, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- which accompanies this distribution.
- The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- and the Eclipse Distribution License is available at
- http://www.eclipse.org/org/documents/edl-v10.php.
-
- Contributors:
- Oracle - initial API and implementation from Oracle TopLink
-*****************************************************************************/
--->
-<!--
-
-XML Schema definition for the Eclipse Persistence Services Project Session Configuration file. Instances
-of this file are typically located as: 'META-INF/sessions.xml'
-
- -->
-
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified" version="1.0">
- <xsd:element name="sessions">
- <xsd:annotation>
- <xsd:documentation>
- This is the root element and exists only for XML
- structure
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="session" type="session" minOccurs="0"
- maxOccurs="unbounded" />
- </xsd:sequence>
- <xsd:attribute name="version" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- <xsd:complexType name="session">
- <xsd:annotation>
- <xsd:documentation>
- This is the node element that describes a particular session
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- Generic element used to describe a string that
- represents the name of an item
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="server-platform" type="server-platform"
- minOccurs="0" />
- <xsd:choice minOccurs="0">
- <xsd:element name="remote-command">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- session element that define the Remote
- Command Module that can also be used for
- cache synchronization
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="channel"
- type="xsd:string" default="EclipseLinkCommandChannel"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element."
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="commands"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element. It determine what
- command features, the RCM
- supports
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="cache-sync"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an
- optional element of
- command element. It
- turns on cache
- synchronization to
- allow sending and
- receiving cache sync
- commands
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="transport"
- type="transport-manager" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element. It defines the
- transport mechanism of the RCM.
- The default transport mechanism
- is RMI
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:element name="event-listener-classes" minOccurs="0">
- <xsd:complexType>
- <xsd:group ref="event-listener-classes" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="profiler" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element represents if the profiler will be
- used by the session
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="dms" />
- <xsd:enumeration value="eclipselink" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="exception-handler-class"
- type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the class that the session will use to
- handle exceptions generated from within the
- session
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="logging" type="log" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element used to specify the logging options
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="session-customizer-class"
- type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies the session customizer
- class to run on a loaded session.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="server-platform">
- <xsd:annotation>
- <xsd:documentation>
- This is the node element that describes which server
- platform to use, JTA settings and runtime services
- settings
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="enable-runtime-services"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element. This
- specifies whether or not the JMX MBean for
- providing runtime services is deployed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="enable-jta" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element. This
- specifies whether or not this session will
- integrate with the JTA (i.e. whether the session
- will be populated with a transaction controller
- class. The choice of server-class will
- automatically be chosen based on the transaction
- controller
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="custom-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform">
- <xsd:sequence>
- <xsd:element name="server-class" type="xsd:string"
- default="org.eclipse.persistence.platform.server.CustomServerPlatform"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the subclass of
- org.eclipse.persistence.platform.server.PlatformBase
- to specify which server platform to use
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element
- name="external-transaction-controller-class" type="xsd:string"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-903-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-904-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1012-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1013-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1111-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform"/>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-61-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-70-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-81-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-9-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-10-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-40-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-50-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-51-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-60-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-61-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jboss-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="session-broker">
- <xsd:annotation>
- <xsd:documentation>
- Provides a single view to a session that
- transparently accesses multple databases.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="session">
- <xsd:sequence>
- <xsd:element name="session-name" type="xsd:string"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This is the element that represents the
- session name
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="project">
- <xsd:restriction base="xsd:string" />
- </xsd:simpleType>
- <xsd:simpleType name="xml">
- <xsd:restriction base="project" />
- </xsd:simpleType>
- <xsd:simpleType name="class">
- <xsd:restriction base="project" />
- </xsd:simpleType>
- <xsd:complexType name="database-session">
- <xsd:annotation>
- <xsd:documentation>
- The session is the primary interface into EclipseLink, the
- application should do all of its reading and writing of
- objects through the session. The session also manages
- transactions and units of work. The database session is
- intended for usage in two-tier client-server
- applications. Although it could be used in a server
- situation, it is limitted to only having a single
- database connection and only allows a single open
- database transaction.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="session">
- <xsd:sequence>
- <xsd:element name="primary-project" type="project"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This project (class or xml) will be
- loaded as the primary project for the
- session.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="additional-project"
- type="project" minOccurs="0" maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- Additional projects will have their
- descriptors appended to the primary
- project.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="login" type="login"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="server-session">
- <xsd:annotation>
- <xsd:documentation>
- Is an extension of a DatabaseSession
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="database-session">
- <xsd:sequence>
- <xsd:element name="connection-pools"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Connection pools are only for usage with
- internal connection pooling and should
- not be used if using external connection
- pooling
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="read-connection-pool"
- type="read-connection-pool" minOccurs="0" />
- <xsd:element
- name="write-connection-pool" type="connection-pool"
- minOccurs="0" />
- <xsd:element
- name="sequence-connection-pool" type="connection-pool"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set this tag to use the
- sequence connection pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="connection-pool"
- type="connection-pool" minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="connection-policy"
- type="connection-policy" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="connection-policy">
- <xsd:annotation>
- <xsd:documentation>
- Used to specify how default client sessions are acquired
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="exclusive-connection" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Specifies if an exclusive connection should be
- used for reads, required for VPD, or user based
- read security.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="lazy" type="xsd:boolean" default="true"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Specifies if a connection should be acquired and
- held upfront in the client session, or only
- acquired when needed and then released.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="login">
- <xsd:annotation>
- <xsd:documentation>
- Defines common fields for database-login and eis-login
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="platform-class" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the element that represents the platform
- class name
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="user-name" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="encryption-class" type="xsd:string"
- default="org.eclipse.persistence.internal.security.JCEEncryptor"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="password" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="table-qualifier" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set the default qualifier for all tables. This
- can be the creator of the table or database name
- the table exists on. This is required by some
- databases such as Oracle and DB2.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="external-connection-pooling"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if the connection should use an
- external connection pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="external-transaction-controller"
- type="xsd:boolean" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if the session will be using an
- external transaction controller
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="sequencing" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequencing information.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="default-sequence"
- type="sequence" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Default sequence. The name is
- optional. If no name provided an
- empty string will be used as a name.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="sequences" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Non default sequences. Make sure
- each sequence has unique name.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="sequence"
- type="sequence" minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="property" minOccurs="0"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of a login.
- It is used to define extra properties on the
- login
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string"
- use="required" />
- <xsd:attribute name="value" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="database-login">
- <xsd:annotation>
- <xsd:documentation>
- Holds the configuration information necessary to connect
- to a JDBC driver.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login">
- <xsd:sequence>
- <xsd:choice minOccurs="0">
- <xsd:sequence>
- <xsd:element name="driver-class"
- type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- The driver class is the Java
- class for the JDBC driver to be
- used (e.g.
- sun.jdbc.odbc.JdbcOdbcDriver.class)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="connection-url"
- type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- This is the URL that will be
- used to connect to the database.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:element name="datasource">
- <xsd:annotation>
- <xsd:documentation>
- This is the URL of a datasource that
- may be used by the session to
- connect to the database.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:simpleContent>
- <xsd:extension base="xsd:string">
- <xsd:attribute name="lookup"
- type="lookup-enum" />
- </xsd:extension>
- </xsd:simpleContent>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:element name="bind-all-parameters"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to bind all arguments to any
- SQL statement.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="cache-all-statements"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether prepared statements should
- be cached.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="byte-array-binding"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use
- parameter binding for large binary data.
- By default EclipseLink will print this data
- as hex through the JDBC binary excape
- clause. Both binding and printing have
- various limits on all databases (e.g. 5k
- - 32k).
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="string-binding"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if strings should be bound.
- Used to help bean introspection.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="streams-for-binding"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use streams
- to store large binary data. This can
- improve the max size for reading/writing
- on some JDBC drivers.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="force-field-names-to-upper-case"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This setting can be used if the
- application expects upper case but the
- database does not return consistent case
- (e.g. different databases).
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="optimize-data-conversion"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether driver level data conversion
- optimization is enabled. This can be
- disabled as some drivers perform data
- conversion themselves incorrectly.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="trim-strings" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- By default CHAR field values have
- trailing blanks trimmed, this can be
- configured.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="batch-writing" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use batch
- writing. This facility allows multiple
- write operations to be submitted to a
- database for processing at once.
- Submitting multiple updates together,
- instead of individually, can greatly
- improve performance in some situations.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="jdbc-batch-writing"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Setting this tag with true indicates to
- EclipseLink that the JDBC driver supports
- batch writing. EclipseLink's internal batch
- writing is disabled. Setting this tag
- with false indicates to EclipseLink that the
- JDBC driver does not support batch
- writing. This will revert to the default
- behaviour which is to delegate to
- EclipseLink's internal batch writing.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="max-batch-writing-size"
- type="xsd:integer" default="32000" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Allow for the max batch writing size to
- be set. This allows for the batch size
- to be limited as most database have
- strict limits. The size is in
- characters, the default is 32000 but the
- real value depends on the database
- configuration.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="native-sql" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use
- database specific sql grammar not JDBC
- specific. This is because unfortunately
- some bridges to not support the full
- JDBC standard. By default EclipseLink uses
- the JDBC sql grammar.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="struct-converters"
- minOccurs="0">
- <xsd:complexType>
- <xsd:group ref="struct-converters" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="connection-health-validated-on-error" type="xsd:boolean" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>If true will cause EclipseLink to ping database to determine if an SQLException was cause by a communication failure</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="query-retry-attempt-count" type="xsd:integer" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Configure the number of attempts EclipseLink will make if EclipseLink is attempting to retry a query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="delay-between-reconnect-attempts" type="xsd:integer" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Configure the time in miliseconds that EclipseLink will wait between attempts to reconnect if EclipseLink is attempting to retry a query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="ping-sql" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Override the platform specific SQL that EclipseLink will issue to a connection to determine if the connection is still live.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="lookup-enum">
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="composite-name" />
- <xsd:enumeration value="compound-name" />
- <xsd:enumeration value="string" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="eis-login">
- <xsd:annotation>
- <xsd:documentation>
- Defines connection information and datasource
- properties. There are three ways to connect through EIS,
- - Provide a JNDI name to the ConnectionFactory and use
- the default getConnection - Provide a JNDI name to the
- ConnectionFactory, and a driver specific ConnectionSpec
- to pass to the getConnection - Connect in a non-managed
- way directly to the driver specific ConnectionFactory An
- EISConnectionSpec must be provided to define how to
- connect to the EIS adapter. The EIS platform can be used
- to provide datasource/driver specific behavoir such as
- InteractionSpec and Record conversion.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login">
- <xsd:sequence>
- <xsd:element name="connection-spec-class"
- type="xsd:string" minOccurs="0" />
- <xsd:element name="connection-factory-url"
- type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-login">
- <xsd:annotation>
- <xsd:documentation>
- Defines login and platform type to be used
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="connection-pool">
- <xsd:annotation>
- <xsd:documentation>
- Used to specify how connections should be pooled in a
- server session.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" />
- <xsd:element name="max-connections" type="xsd:integer"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The max number of connections that will be
- created in the pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="min-connections" type="xsd:integer"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The min number of connections that will aways be
- in the pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="login" type="login" minOccurs="0" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="read-connection-pool">
- <xsd:annotation>
- <xsd:documentation>
- The read connection pool is used for read access through
- the server session. Any of the connection pools can be
- used for the read pool however this is the default. This
- pool allows for concurrent reads against the same JDBC
- connection and requires that the JDBC connection support
- concurrent read access.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="connection-pool">
- <xsd:sequence>
- <xsd:element name="exclusive" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This tag is used to specify if the
- connections from the read connection
- pool are exclusive or not
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the common logging options
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="java-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the Java log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log">
- <xsd:sequence>
- <xsd:element name="logging-options"
- type="logging-options" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eclipselink-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the EclipseLink log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log">
- <xsd:sequence>
- <xsd:element name="log-level" default="info"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies the log level for logging
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="off" />
- <xsd:enumeration value="severe" />
- <xsd:enumeration value="warning" />
- <xsd:enumeration value="info" />
- <xsd:enumeration value="config" />
- <xsd:enumeration value="fine" />
- <xsd:enumeration value="finer" />
- <xsd:enumeration value="finest" />
- <xsd:enumeration value="all" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="file-name" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Name of the file to write the logging to
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="logging-options"
- type="logging-options" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="server-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the Server log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="logging-options">
- <xsd:sequence>
- <xsd:element name="log-exception-stacktrace"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log exception stacktrace. Without
- this element, the stacktrace is logged for FINER
- or less (FINEST)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-thread" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log thread. Without this element,
- the thread is logged for FINE or less (FINER or
- FINEST)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-session" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log session. Without this
- element, the session is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-connection" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log connection. Without this
- element, the connection is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-date" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log date. Without this element,
- the date is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="transport-manager">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the transport mechanism of the RCM.
- The default transport mechanism is RMI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="on-connection-error"
- default="DiscardConnection" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element and has value of "DiscardConnection" or
- "KeepConnection". It determines whether
- connection to a RCM service should be dropped if
- there is a communication error with that RCM
- service. The default value for this element is
- "DiscardConnection".
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="KeepConnection" />
- <xsd:enumeration value="DiscardConnection" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="rmi-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element. It defines the RMI transport mechanism. The
- default naming service is JNDI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="send-mode" default="Asynchronous"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- rmi element and has value of
- "Asynchronous" or "Synchronous". It
- determines whether the RCM propagates
- command and does not wait for command to
- finish its execution in asynchronous
- mode or wait for command to finish its
- execution in synchronous mode. The
- default value of this element is
- "Asynchronous".
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="Asynchronous" />
- <xsd:enumeration value="Synchronous" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="discovery" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- rmi element. It determines whether the
- Discovery settings should be changed.
- Note that a default Discovery with its
- default settings is created when the rmi
- element is specified.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element
- name="multicast-group-address" type="xsd:string"
- default="226.10.12.64" minOccurs="0" />
- <xsd:element name="multicast-port"
- type="xsd:integer" default="3121" minOccurs="0" />
- <xsd:element name="announcement-delay"
- type="xsd:integer" default="1000" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of discovery
- elemenent. It determines
- whether the multicast group
- address should be changed.
- The default value of this
- element is "1000"
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="packet-time-to-live"
- type="xsd:integer" default="2" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of discovery
- elemenent. It determines
- whether the time-to-live of
- the packets that are sent
- from the Discovery's
- mulsticast socket should be
- changed. The default value
- of this element is "2"
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:choice minOccurs="0">
- <xsd:element name="jndi-naming-service"
- type="jndi-naming-service" />
- <xsd:element
- name="rmi-registry-naming-service">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element
- of rmi elemenent. It determines
- whether RMI registry should be used
- for naming service
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="url"
- type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="rmi-iiop-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the RMI-IIOP transport mechanism of
- the RCM. The default naming service is JNDI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="rmi-transport" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jms-topic-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the JMS topic transport mechanism
- of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="topic-host-url" type="xsd:string"
- minOccurs="0" />
- <xsd:element name="topic-connection-factory-name"
- type="xsd:string" default="jms/EclipseLinkTopicConnectionFactory"
- minOccurs="0" />
- <xsd:element name="topic-name" type="xsd:string"
- default="jms/EclipseLinkTopic" minOccurs="0" />
- <xsd:element name="jndi-naming-service"
- type="jndi-naming-service" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-jgroups-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the OC4J JGroups transport
- mechanism of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="use-single-threaded-notification"
- type="xsd:boolean" default="false" minOccurs="0" />
- <xsd:element name="topic-name" type="xsd:string"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="sun-corba-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the Sun CORBA transport mechanism
- of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="user-defined-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element. It determines whether a user implemented
- transport mechanism that should be used.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="transport-class"
- type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jndi-naming-service">
- <xsd:sequence>
- <xsd:element name="url" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether the
- URL for naming service should be changed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="user-name" type="xsd:string"
- default="admin" minOccurs="0" />
- <xsd:element name="encryption-class" type="xsd:string"
- default="org.eclipse.persistence.internal.security.JCEEncryptor"
- minOccurs="0" />
- <xsd:element name="password" type="xsd:string"
- default="password" minOccurs="0" />
- <!-- TODO: Need to have a non Oracle-AS default or route through server platform by default -->
- <xsd:element name="initial-context-factory-name"
- type="xsd:string"
- default="com.evermind.server.rmi.RMIInitialContextFactory"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether the
- initial context factory class for naming service
- should be changed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="property" minOccurs="0"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether
- naming service requires extra property that is
- not defined by EclipseLink but it is required by the
- user application
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string"
- use="required" />
- <xsd:attribute name="value" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:group name="event-listener-classes">
- <xsd:sequence>
- <xsd:element name="event-listener-class" type="xsd:string"
- minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:group>
- <xsd:group name="struct-converters">
- <xsd:sequence>
- <xsd:element name="struct-converter" type="xsd:string"
- minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:group>
- <xsd:complexType name="sequence">
- <xsd:annotation>
- <xsd:documentation>Sequence object.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequence name.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="preallocation-size" type="xsd:integer"
- default="50" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequence preallocation size.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="default-sequence">
- <xsd:annotation>
- <xsd:documentation>
- References default sequence object, overriding its name
- and (optionally) preallocation size.
- </xsd:documentation>
- <xsd:documentation>
- To use preallocation size of default sequence object,
- set preallocation size to 0
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="native-sequence">
- <xsd:annotation>
- <xsd:documentation>
- Database sequence mechanism used.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="table-sequence">
- <xsd:annotation>
- <xsd:documentation>Table sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="table" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="name-field" type="xsd:string"
- default="SEQ_NAME" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence name
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="counter-field" type="xsd:string"
- default="SEQ_COUNT" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="unary-table-sequence">
- <xsd:annotation>
- <xsd:documentation>
- Unary table sequence - sequence name is a table name,
- table has a single field and a single row
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="counter-field" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xmlfile-sequence">
- <xsd:annotation>
- <xsd:documentation>Xmlfile sequence.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-sequence">
- <xsd:annotation>
- <xsd:documentation>Xml sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="root-element" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="name-element" type="xsd:string"
- default="SEQ_NAME" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence name
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="counter-element"
- type="xsd:string" default="SEQ_COUNT" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-</xsd:schema>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.1.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.1.xsd
deleted file mode 100644
index d872a1640e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.1.xsd
+++ /dev/null
@@ -1,1585 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-*******************************************************************************
- Copyright (c) 1998, 2007 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0, which accompanies this distribution
- and is available at http://www.eclipse.org/legal/epl-v10.html.
-
- Contributors:
- Oracle - initial API and implementation from Oracle TopLink
-*****************************************************************************/
--->
-<!--
-
-XML Schema definition for the Eclipse Persistence Services Project Session Configuration file. Instances
-of this file are typically located as: 'META-INF/sessions.xml'
-
- -->
-
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified" version="1.1">
- <xsd:element name="sessions">
- <xsd:annotation>
- <xsd:documentation>
- This is the root element and exists only for XML
- structure
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="session" type="session" minOccurs="0"
- maxOccurs="unbounded" />
- </xsd:sequence>
- <xsd:attribute name="version" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- <xsd:complexType name="session">
- <xsd:annotation>
- <xsd:documentation>
- This is the node element that describes a particular session
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- Generic element used to describe a string that
- represents the name of an item
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="server-platform" type="server-platform"
- minOccurs="0" />
- <xsd:choice minOccurs="0">
- <xsd:element name="remote-command">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- session element that define the Remote
- Command Module that can also be used for
- cache synchronization
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="channel"
- type="xsd:string" default="EclipseLinkCommandChannel"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element."
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="commands"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element. It determine what
- command features, the RCM
- supports
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="cache-sync"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an
- optional element of
- command element. It
- turns on cache
- synchronization to
- allow sending and
- receiving cache sync
- commands
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="transport"
- type="transport-manager" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element. It defines the
- transport mechanism of the RCM.
- The default transport mechanism
- is RMI
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:element name="event-listener-classes" minOccurs="0">
- <xsd:complexType>
- <xsd:group ref="event-listener-classes" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="profiler" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element represents if the profiler will be
- used by the session
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="dms" />
- <xsd:enumeration value="eclipselink" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="exception-handler-class"
- type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the class that the session will use to
- handle exceptions generated from within the
- session
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="logging" type="log" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element used to specify the logging options
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="session-customizer-class"
- type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies the session customizer
- class to run on a loaded session.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="server-platform">
- <xsd:annotation>
- <xsd:documentation>
- This is the node element that describes which server
- platform to use, JTA settings and runtime services
- settings
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="enable-runtime-services"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element. This
- specifies whether or not the JMX MBean for
- providing runtime services is deployed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="enable-jta" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element. This
- specifies whether or not this session will
- integrate with the JTA (i.e. whether the session
- will be populated with a transaction controller
- class. The choice of server-class will
- automatically be chosen based on the transaction
- controller
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="custom-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform">
- <xsd:sequence>
- <xsd:element name="server-class" type="xsd:string"
- default="org.eclipse.persistence.platform.server.CustomServerPlatform"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the subclass of
- org.eclipse.persistence.platform.server.PlatformBase
- to specify which server platform to use
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element
- name="external-transaction-controller-class" type="xsd:string"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-903-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-904-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1012-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1013-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1111-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform"/>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-61-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-70-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-81-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-9-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-10-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-40-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-50-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-51-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-60-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-61-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jboss-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="session-broker">
- <xsd:annotation>
- <xsd:documentation>
- Provides a single view to a session that
- transparently accesses multple databases.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="session">
- <xsd:sequence>
- <xsd:element name="session-name" type="xsd:string"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This is the element that represents the
- session name
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="project">
- <xsd:restriction base="xsd:string" />
- </xsd:simpleType>
- <xsd:simpleType name="xml">
- <xsd:restriction base="project" />
- </xsd:simpleType>
- <xsd:simpleType name="class">
- <xsd:restriction base="project" />
- </xsd:simpleType>
- <xsd:complexType name="database-session">
- <xsd:annotation>
- <xsd:documentation>
- The session is the primary interface into EclipseLink, the
- application should do all of its reading and writing of
- objects through the session. The session also manages
- transactions and units of work. The database session is
- intended for usage in two-tier client-server
- applications. Although it could be used in a server
- situation, it is limitted to only having a single
- database connection and only allows a single open
- database transaction.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="session">
- <xsd:sequence>
- <xsd:element name="primary-project" type="project"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This project (class or xml) will be
- loaded as the primary project for the
- session.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="additional-project"
- type="project" minOccurs="0" maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- Additional projects will have their
- descriptors appended to the primary
- project.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="login" type="login"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="server-session">
- <xsd:annotation>
- <xsd:documentation>
- Is an extension of a DatabaseSession
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="database-session">
- <xsd:sequence>
- <xsd:element name="connection-pools"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Connection pools are only for usage with
- internal connection pooling and should
- not be used if using external connection
- pooling
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="read-connection-pool"
- type="read-connection-pool" minOccurs="0" />
- <xsd:element
- name="write-connection-pool" type="connection-pool"
- minOccurs="0" />
- <xsd:element
- name="sequence-connection-pool" type="connection-pool"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set this tag to use the
- sequence connection pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="connection-pool"
- type="connection-pool" minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="connection-policy"
- type="connection-policy" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="connection-policy">
- <xsd:annotation>
- <xsd:documentation>
- Used to specify how default client sessions are acquired
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="exclusive-connection" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Specifies if an exclusive connection should be
- used for reads, required for VPD, or user based
- read security.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="lazy" type="xsd:boolean" default="true"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Specifies if a connection should be acquired and
- held upfront in the client session, or only
- acquired when needed and then released.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="login">
- <xsd:annotation>
- <xsd:documentation>
- Defines common fields for database-login and eis-login
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="platform-class" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the element that represents the platform
- class name
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="user-name" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="encryption-class" type="xsd:string"
- default="org.eclipse.persistence.internal.security.JCEEncryptor"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="password" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="table-qualifier" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set the default qualifier for all tables. This
- can be the creator of the table or database name
- the table exists on. This is required by some
- databases such as Oracle and DB2.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="external-connection-pooling"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if the connection should use an
- external connection pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="external-transaction-controller"
- type="xsd:boolean" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if the session will be using an
- external transaction controller
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="sequencing" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequencing information.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="default-sequence"
- type="sequence" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Default sequence. The name is
- optional. If no name provided an
- empty string will be used as a name.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="sequences" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Non default sequences. Make sure
- each sequence has unique name.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="sequence"
- type="sequence" minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="property" minOccurs="0"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of a login.
- It is used to define extra properties on the
- login
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string"
- use="required" />
- <xsd:attribute name="value" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="database-login">
- <xsd:annotation>
- <xsd:documentation>
- Holds the configuration information necessary to connect
- to a JDBC driver.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login">
- <xsd:sequence>
- <xsd:choice minOccurs="0">
- <xsd:sequence>
- <xsd:element name="driver-class"
- type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- The driver class is the Java
- class for the JDBC driver to be
- used (e.g.
- sun.jdbc.odbc.JdbcOdbcDriver.class)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="connection-url"
- type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- This is the URL that will be
- used to connect to the database.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:element name="datasource">
- <xsd:annotation>
- <xsd:documentation>
- This is the URL of a datasource that
- may be used by the session to
- connect to the database.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:simpleContent>
- <xsd:extension base="xsd:string">
- <xsd:attribute name="lookup"
- type="lookup-enum" />
- </xsd:extension>
- </xsd:simpleContent>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:element name="bind-all-parameters"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to bind all arguments to any
- SQL statement.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="cache-all-statements"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether prepared statements should
- be cached.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="byte-array-binding"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use
- parameter binding for large binary data.
- By default EclipseLink will print this data
- as hex through the JDBC binary excape
- clause. Both binding and printing have
- various limits on all databases (e.g. 5k
- - 32k).
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="string-binding"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if strings should be bound.
- Used to help bean introspection.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="streams-for-binding"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use streams
- to store large binary data. This can
- improve the max size for reading/writing
- on some JDBC drivers.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="force-field-names-to-upper-case"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This setting can be used if the
- application expects upper case but the
- database does not return consistent case
- (e.g. different databases).
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="optimize-data-conversion"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether driver level data conversion
- optimization is enabled. This can be
- disabled as some drivers perform data
- conversion themselves incorrectly.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="trim-strings" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- By default CHAR field values have
- trailing blanks trimmed, this can be
- configured.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="batch-writing" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use batch
- writing. This facility allows multiple
- write operations to be submitted to a
- database for processing at once.
- Submitting multiple updates together,
- instead of individually, can greatly
- improve performance in some situations.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="jdbc-batch-writing"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Setting this tag with true indicates to
- EclipseLink that the JDBC driver supports
- batch writing. EclipseLink's internal batch
- writing is disabled. Setting this tag
- with false indicates to EclipseLink that the
- JDBC driver does not support batch
- writing. This will revert to the default
- behaviour which is to delegate to
- EclipseLink's internal batch writing.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="max-batch-writing-size"
- type="xsd:integer" default="32000" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Allow for the max batch writing size to
- be set. This allows for the batch size
- to be limited as most database have
- strict limits. The size is in
- characters, the default is 32000 but the
- real value depends on the database
- configuration.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="native-sql" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use
- database specific sql grammar not JDBC
- specific. This is because unfortunately
- some bridges to not support the full
- JDBC standard. By default EclipseLink uses
- the JDBC sql grammar.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="struct-converters"
- minOccurs="0">
- <xsd:complexType>
- <xsd:group ref="struct-converters" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="connection-health-validated-on-error" type="xsd:boolean" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>If true will cause EclipseLink to ping database to determine if an SQLException was cause by a communication failure</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="query-retry-attempt-count" type="xsd:integer" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Configure the number of attempts EclipseLink will make if EclipseLink is attempting to retry a query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="delay-between-reconnect-attempts" type="xsd:integer" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Configure the time in miliseconds that EclipseLink will wait between attempts to reconnect if EclipseLink is attempting to retry a query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="ping-sql" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Override the platform specific SQL that EclipseLink will issue to a connection to determine if the connection is still live.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="lookup-enum">
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="composite-name" />
- <xsd:enumeration value="compound-name" />
- <xsd:enumeration value="string" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="eis-login">
- <xsd:annotation>
- <xsd:documentation>
- Defines connection information and datasource
- properties. There are three ways to connect through EIS,
- - Provide a JNDI name to the ConnectionFactory and use
- the default getConnection - Provide a JNDI name to the
- ConnectionFactory, and a driver specific ConnectionSpec
- to pass to the getConnection - Connect in a non-managed
- way directly to the driver specific ConnectionFactory An
- EISConnectionSpec must be provided to define how to
- connect to the EIS adapter. The EIS platform can be used
- to provide datasource/driver specific behavoir such as
- InteractionSpec and Record conversion.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login">
- <xsd:sequence>
- <xsd:element name="connection-spec-class"
- type="xsd:string" minOccurs="0" />
- <xsd:element name="connection-factory-url"
- type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-login">
- <xsd:annotation>
- <xsd:documentation>
- Defines login and platform type to be used
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login">
- <xsd:sequence>
- <xsd:element name="equal-namespace-resolvers"
- type="xsd:boolean" maxOccurs="1" minOccurs="0">
- </xsd:element>
- <xsd:element name="document-preservation-policy"
- maxOccurs="1" minOccurs="0"
- type="document-preservation-policy">
-
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="connection-pool">
- <xsd:annotation>
- <xsd:documentation>
- Used to specify how connections should be pooled in a
- server session.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" />
- <xsd:element name="max-connections" type="xsd:integer"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The max number of connections that will be
- created in the pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="min-connections" type="xsd:integer"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The min number of connections that will aways be
- in the pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="login" type="login" minOccurs="0" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="read-connection-pool">
- <xsd:annotation>
- <xsd:documentation>
- The read connection pool is used for read access through
- the server session. Any of the connection pools can be
- used for the read pool however this is the default. This
- pool allows for concurrent reads against the same JDBC
- connection and requires that the JDBC connection support
- concurrent read access.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="connection-pool">
- <xsd:sequence>
- <xsd:element name="exclusive" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This tag is used to specify if the
- connections from the read connection
- pool are exclusive or not
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the common logging options
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="java-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the Java log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log">
- <xsd:sequence>
- <xsd:element name="logging-options"
- type="logging-options" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eclipselink-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the EclipseLink log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log">
- <xsd:sequence>
- <xsd:element name="log-level" default="info"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies the log level for logging
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="off" />
- <xsd:enumeration value="severe" />
- <xsd:enumeration value="warning" />
- <xsd:enumeration value="info" />
- <xsd:enumeration value="config" />
- <xsd:enumeration value="fine" />
- <xsd:enumeration value="finer" />
- <xsd:enumeration value="finest" />
- <xsd:enumeration value="all" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="file-name" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Name of the file to write the logging to
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="logging-options"
- type="logging-options" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="server-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the Server log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="logging-options">
- <xsd:sequence>
- <xsd:element name="log-exception-stacktrace"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log exception stacktrace. Without
- this element, the stacktrace is logged for FINER
- or less (FINEST)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-thread" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log thread. Without this element,
- the thread is logged for FINE or less (FINER or
- FINEST)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-session" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log session. Without this
- element, the session is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-connection" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log connection. Without this
- element, the connection is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-date" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log date. Without this element,
- the date is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="transport-manager">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the transport mechanism of the RCM.
- The default transport mechanism is RMI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="on-connection-error"
- default="DiscardConnection" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element and has value of "DiscardConnection" or
- "KeepConnection". It determines whether
- connection to a RCM service should be dropped if
- there is a communication error with that RCM
- service. The default value for this element is
- "DiscardConnection".
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="KeepConnection" />
- <xsd:enumeration value="DiscardConnection" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="rmi-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element. It defines the RMI transport mechanism. The
- default naming service is JNDI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="send-mode" default="Asynchronous"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- rmi element and has value of
- "Asynchronous" or "Synchronous". It
- determines whether the RCM propagates
- command and does not wait for command to
- finish its execution in asynchronous
- mode or wait for command to finish its
- execution in synchronous mode. The
- default value of this element is
- "Asynchronous".
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="Asynchronous" />
- <xsd:enumeration value="Synchronous" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="discovery" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- rmi element. It determines whether the
- Discovery settings should be changed.
- Note that a default Discovery with its
- default settings is created when the rmi
- element is specified.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element
- name="multicast-group-address" type="xsd:string"
- default="226.10.12.64" minOccurs="0" />
- <xsd:element name="multicast-port"
- type="xsd:integer" default="3121" minOccurs="0" />
- <xsd:element name="announcement-delay"
- type="xsd:integer" default="1000" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of discovery
- elemenent. It determines
- whether the multicast group
- address should be changed.
- The default value of this
- element is "1000"
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="packet-time-to-live"
- type="xsd:integer" default="2" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of discovery
- elemenent. It determines
- whether the time-to-live of
- the packets that are sent
- from the Discovery's
- mulsticast socket should be
- changed. The default value
- of this element is "2"
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:choice minOccurs="0">
- <xsd:element name="jndi-naming-service"
- type="jndi-naming-service" />
- <xsd:element
- name="rmi-registry-naming-service">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element
- of rmi elemenent. It determines
- whether RMI registry should be used
- for naming service
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="url"
- type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="rmi-iiop-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the RMI-IIOP transport mechanism of
- the RCM. The default naming service is JNDI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="rmi-transport" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jms-topic-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the JMS topic transport mechanism
- of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="topic-host-url" type="xsd:string"
- minOccurs="0" />
- <xsd:element name="topic-connection-factory-name"
- type="xsd:string" default="jms/EclipseLinkTopicConnectionFactory"
- minOccurs="0" />
- <xsd:element name="topic-name" type="xsd:string"
- default="jms/EclipseLinkTopic" minOccurs="0" />
- <xsd:element name="jndi-naming-service"
- type="jndi-naming-service" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-jgroups-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the OC4J JGroups transport
- mechanism of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="use-single-threaded-notification"
- type="xsd:boolean" default="false" minOccurs="0" />
- <xsd:element name="topic-name" type="xsd:string"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="sun-corba-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the Sun CORBA transport mechanism
- of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="user-defined-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element. It determines whether a user implemented
- transport mechanism that should be used.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="transport-class"
- type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jndi-naming-service">
- <xsd:sequence>
- <xsd:element name="url" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether the
- URL for naming service should be changed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="user-name" type="xsd:string"
- default="admin" minOccurs="0" />
- <xsd:element name="encryption-class" type="xsd:string"
- default="org.eclipse.persistence.internal.security.JCEEncryptor"
- minOccurs="0" />
- <xsd:element name="password" type="xsd:string"
- default="password" minOccurs="0" />
- <!-- TODO: Need to have a non WebLogic (previously OC4J) default or route through server platform by default -->
- <xsd:element name="initial-context-factory-name"
- type="xsd:string"
- default="weblogic.jndi.WLInitialContextFactory"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether the
- initial context factory class for naming service
- should be changed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="property" minOccurs="0"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether
- naming service requires extra property that is
- not defined by EclipseLink but it is required by the
- user application
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string"
- use="required" />
- <xsd:attribute name="value" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:group name="event-listener-classes">
- <xsd:sequence>
- <xsd:element name="event-listener-class" type="xsd:string"
- minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:group>
- <xsd:group name="struct-converters">
- <xsd:sequence>
- <xsd:element name="struct-converter" type="xsd:string"
- minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:group>
- <xsd:complexType name="sequence">
- <xsd:annotation>
- <xsd:documentation>Sequence object.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequence name.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="preallocation-size" type="xsd:integer"
- default="50" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequence preallocation size.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="default-sequence">
- <xsd:annotation>
- <xsd:documentation>
- References default sequence object, overriding its name
- and (optionally) preallocation size.
- </xsd:documentation>
- <xsd:documentation>
- To use preallocation size of default sequence object,
- set preallocation size to 0
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="native-sequence">
- <xsd:annotation>
- <xsd:documentation>
- Database sequence mechanism used.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="table-sequence">
- <xsd:annotation>
- <xsd:documentation>Table sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="table" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="name-field" type="xsd:string"
- default="SEQ_NAME" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence name
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="counter-field" type="xsd:string"
- default="SEQ_COUNT" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="unary-table-sequence">
- <xsd:annotation>
- <xsd:documentation>
- Unary table sequence - sequence name is a table name,
- table has a single field and a single row
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="counter-field" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xmlfile-sequence">
- <xsd:annotation>
- <xsd:documentation>Xmlfile sequence.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-sequence">
- <xsd:annotation>
- <xsd:documentation>Xml sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="root-element" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="name-element" type="xsd:string"
- default="SEQ_NAME" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence name
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="counter-element"
- type="xsd:string" default="SEQ_COUNT" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
-
-
- <xsd:complexType name="document-preservation-policy">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies which document preservation
- strategy will be used.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="node-ordering-policy"
- type="node-ordering-policy" maxOccurs="1" minOccurs="0">
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:complexType name="node-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies which node ordering strategy will
- be used.
- </xsd:documentation>
- </xsd:annotation></xsd:complexType>
-
- <xsd:complexType
- name="descriptor-level-document-preservation-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of DocumentPreservation Policy that
- accesses the session cache to store Objects and their
- associated nodes.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="no-document-preservation-policy">
- <xsd:annotation>
- <xsd:documentation>
- A DocumentPreservationPolicy to indicate that no
- document preservation work should be done.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="xml-binder-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of DocumentPreservationPolicy that
- maintains bidirectional relationships between Java
- Objects and the XMLNodes they originated from.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="append-new-elements-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of NodeOrderingPolicy that simply
- appends the new child element to the parent.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="ignore-new-elements-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of NodeOrderingPolicy that ignores any
- new elements when updating a cached document.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="relative-position-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of NodeOrderingPolicy that adds new
- elements to an XML Document based on the last updated
- sibling in their context.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-</xsd:schema>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.2.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.2.xsd
deleted file mode 100644
index b58242768c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_1.2.xsd
+++ /dev/null
@@ -1,1586 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-*******************************************************************************
- Copyright (c) 1998, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0, which accompanies this distribution
- and is available at http://www.eclipse.org/legal/epl-v10.html.
-
- Contributors:
- Oracle - initial API and implementation from Oracle TopLink
- tware - update version number to 1.2
-*****************************************************************************/
--->
-<!--
-
-XML Schema definition for the Eclipse Persistence Services Project Session Configuration file. Instances
-of this file are typically located as: 'META-INF/sessions.xml'
-
- -->
-
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified" version="1.2">
- <xsd:element name="sessions">
- <xsd:annotation>
- <xsd:documentation>
- This is the root element and exists only for XML
- structure
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="session" type="session" minOccurs="0"
- maxOccurs="unbounded" />
- </xsd:sequence>
- <xsd:attribute name="version" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- <xsd:complexType name="session">
- <xsd:annotation>
- <xsd:documentation>
- This is the node element that describes a particular session
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- Generic element used to describe a string that
- represents the name of an item
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="server-platform" type="server-platform"
- minOccurs="0" />
- <xsd:choice minOccurs="0">
- <xsd:element name="remote-command">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- session element that define the Remote
- Command Module that can also be used for
- cache synchronization
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="channel"
- type="xsd:string" default="EclipseLinkCommandChannel"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element."
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="commands"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element. It determine what
- command features, the RCM
- supports
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="cache-sync"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an
- optional element of
- command element. It
- turns on cache
- synchronization to
- allow sending and
- receiving cache sync
- commands
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="transport"
- type="transport-manager" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element. It defines the
- transport mechanism of the RCM.
- The default transport mechanism
- is RMI
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:element name="event-listener-classes" minOccurs="0">
- <xsd:complexType>
- <xsd:group ref="event-listener-classes" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="profiler" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element represents if the profiler will be
- used by the session
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="dms" />
- <xsd:enumeration value="eclipselink" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="exception-handler-class"
- type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the class that the session will use to
- handle exceptions generated from within the
- session
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="logging" type="log" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element used to specify the logging options
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="session-customizer-class"
- type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies the session customizer
- class to run on a loaded session.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="server-platform">
- <xsd:annotation>
- <xsd:documentation>
- This is the node element that describes which server
- platform to use, JTA settings and runtime services
- settings
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="enable-runtime-services"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element. This
- specifies whether or not the JMX MBean for
- providing runtime services is deployed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="enable-jta" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element. This
- specifies whether or not this session will
- integrate with the JTA (i.e. whether the session
- will be populated with a transaction controller
- class. The choice of server-class will
- automatically be chosen based on the transaction
- controller
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="custom-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform">
- <xsd:sequence>
- <xsd:element name="server-class" type="xsd:string"
- default="org.eclipse.persistence.platform.server.CustomServerPlatform"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the subclass of
- org.eclipse.persistence.platform.server.PlatformBase
- to specify which server platform to use
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element
- name="external-transaction-controller-class" type="xsd:string"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-903-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-904-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1012-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1013-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1111-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform"/>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-61-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-70-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-81-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-9-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-10-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-40-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-50-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-51-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-60-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-61-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jboss-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="session-broker">
- <xsd:annotation>
- <xsd:documentation>
- Provides a single view to a session that
- transparently accesses multple databases.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="session">
- <xsd:sequence>
- <xsd:element name="session-name" type="xsd:string"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This is the element that represents the
- session name
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="project">
- <xsd:restriction base="xsd:string" />
- </xsd:simpleType>
- <xsd:simpleType name="xml">
- <xsd:restriction base="project" />
- </xsd:simpleType>
- <xsd:simpleType name="class">
- <xsd:restriction base="project" />
- </xsd:simpleType>
- <xsd:complexType name="database-session">
- <xsd:annotation>
- <xsd:documentation>
- The session is the primary interface into EclipseLink, the
- application should do all of its reading and writing of
- objects through the session. The session also manages
- transactions and units of work. The database session is
- intended for usage in two-tier client-server
- applications. Although it could be used in a server
- situation, it is limitted to only having a single
- database connection and only allows a single open
- database transaction.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="session">
- <xsd:sequence>
- <xsd:element name="primary-project" type="project"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This project (class or xml) will be
- loaded as the primary project for the
- session.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="additional-project"
- type="project" minOccurs="0" maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- Additional projects will have their
- descriptors appended to the primary
- project.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="login" type="login"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="server-session">
- <xsd:annotation>
- <xsd:documentation>
- Is an extension of a DatabaseSession
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="database-session">
- <xsd:sequence>
- <xsd:element name="connection-pools"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Connection pools are only for usage with
- internal connection pooling and should
- not be used if using external connection
- pooling
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="read-connection-pool"
- type="read-connection-pool" minOccurs="0" />
- <xsd:element
- name="write-connection-pool" type="connection-pool"
- minOccurs="0" />
- <xsd:element
- name="sequence-connection-pool" type="connection-pool"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set this tag to use the
- sequence connection pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="connection-pool"
- type="connection-pool" minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="connection-policy"
- type="connection-policy" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="connection-policy">
- <xsd:annotation>
- <xsd:documentation>
- Used to specify how default client sessions are acquired
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="exclusive-connection" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Specifies if an exclusive connection should be
- used for reads, required for VPD, or user based
- read security.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="lazy" type="xsd:boolean" default="true"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Specifies if a connection should be acquired and
- held upfront in the client session, or only
- acquired when needed and then released.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="login">
- <xsd:annotation>
- <xsd:documentation>
- Defines common fields for database-login and eis-login
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="platform-class" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the element that represents the platform
- class name
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="user-name" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="encryption-class" type="xsd:string"
- default="org.eclipse.persistence.internal.security.JCEEncryptor"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="password" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="table-qualifier" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set the default qualifier for all tables. This
- can be the creator of the table or database name
- the table exists on. This is required by some
- databases such as Oracle and DB2.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="external-connection-pooling"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if the connection should use an
- external connection pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="external-transaction-controller"
- type="xsd:boolean" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if the session will be using an
- external transaction controller
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="sequencing" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequencing information.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="default-sequence"
- type="sequence" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Default sequence. The name is
- optional. If no name provided an
- empty string will be used as a name.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="sequences" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Non default sequences. Make sure
- each sequence has unique name.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="sequence"
- type="sequence" minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="property" minOccurs="0"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of a login.
- It is used to define extra properties on the
- login
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string"
- use="required" />
- <xsd:attribute name="value" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="database-login">
- <xsd:annotation>
- <xsd:documentation>
- Holds the configuration information necessary to connect
- to a JDBC driver.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login">
- <xsd:sequence>
- <xsd:choice minOccurs="0">
- <xsd:sequence>
- <xsd:element name="driver-class"
- type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- The driver class is the Java
- class for the JDBC driver to be
- used (e.g.
- sun.jdbc.odbc.JdbcOdbcDriver.class)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="connection-url"
- type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- This is the URL that will be
- used to connect to the database.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:element name="datasource">
- <xsd:annotation>
- <xsd:documentation>
- This is the URL of a datasource that
- may be used by the session to
- connect to the database.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:simpleContent>
- <xsd:extension base="xsd:string">
- <xsd:attribute name="lookup"
- type="lookup-enum" />
- </xsd:extension>
- </xsd:simpleContent>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:element name="bind-all-parameters"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to bind all arguments to any
- SQL statement.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="cache-all-statements"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether prepared statements should
- be cached.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="byte-array-binding"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use
- parameter binding for large binary data.
- By default EclipseLink will print this data
- as hex through the JDBC binary excape
- clause. Both binding and printing have
- various limits on all databases (e.g. 5k
- - 32k).
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="string-binding"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if strings should be bound.
- Used to help bean introspection.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="streams-for-binding"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use streams
- to store large binary data. This can
- improve the max size for reading/writing
- on some JDBC drivers.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="force-field-names-to-upper-case"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This setting can be used if the
- application expects upper case but the
- database does not return consistent case
- (e.g. different databases).
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="optimize-data-conversion"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether driver level data conversion
- optimization is enabled. This can be
- disabled as some drivers perform data
- conversion themselves incorrectly.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="trim-strings" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- By default CHAR field values have
- trailing blanks trimmed, this can be
- configured.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="batch-writing" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use batch
- writing. This facility allows multiple
- write operations to be submitted to a
- database for processing at once.
- Submitting multiple updates together,
- instead of individually, can greatly
- improve performance in some situations.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="jdbc-batch-writing"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Setting this tag with true indicates to
- EclipseLink that the JDBC driver supports
- batch writing. EclipseLink's internal batch
- writing is disabled. Setting this tag
- with false indicates to EclipseLink that the
- JDBC driver does not support batch
- writing. This will revert to the default
- behaviour which is to delegate to
- EclipseLink's internal batch writing.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="max-batch-writing-size"
- type="xsd:integer" default="32000" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Allow for the max batch writing size to
- be set. This allows for the batch size
- to be limited as most database have
- strict limits. The size is in
- characters, the default is 32000 but the
- real value depends on the database
- configuration.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="native-sql" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use
- database specific sql grammar not JDBC
- specific. This is because unfortunately
- some bridges to not support the full
- JDBC standard. By default EclipseLink uses
- the JDBC sql grammar.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="struct-converters"
- minOccurs="0">
- <xsd:complexType>
- <xsd:group ref="struct-converters" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="connection-health-validated-on-error" type="xsd:boolean" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>If true will cause EclipseLink to ping database to determine if an SQLException was cause by a communication failure</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="query-retry-attempt-count" type="xsd:integer" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Configure the number of attempts EclipseLink will make if EclipseLink is attempting to retry a query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="delay-between-reconnect-attempts" type="xsd:integer" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Configure the time in miliseconds that EclipseLink will wait between attempts to reconnect if EclipseLink is attempting to retry a query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="ping-sql" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Override the platform specific SQL that EclipseLink will issue to a connection to determine if the connection is still live.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="lookup-enum">
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="composite-name" />
- <xsd:enumeration value="compound-name" />
- <xsd:enumeration value="string" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="eis-login">
- <xsd:annotation>
- <xsd:documentation>
- Defines connection information and datasource
- properties. There are three ways to connect through EIS,
- - Provide a JNDI name to the ConnectionFactory and use
- the default getConnection - Provide a JNDI name to the
- ConnectionFactory, and a driver specific ConnectionSpec
- to pass to the getConnection - Connect in a non-managed
- way directly to the driver specific ConnectionFactory An
- EISConnectionSpec must be provided to define how to
- connect to the EIS adapter. The EIS platform can be used
- to provide datasource/driver specific behavoir such as
- InteractionSpec and Record conversion.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login">
- <xsd:sequence>
- <xsd:element name="connection-spec-class"
- type="xsd:string" minOccurs="0" />
- <xsd:element name="connection-factory-url"
- type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-login">
- <xsd:annotation>
- <xsd:documentation>
- Defines login and platform type to be used
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login">
- <xsd:sequence>
- <xsd:element name="equal-namespace-resolvers"
- type="xsd:boolean" maxOccurs="1" minOccurs="0">
- </xsd:element>
- <xsd:element name="document-preservation-policy"
- maxOccurs="1" minOccurs="0"
- type="document-preservation-policy">
-
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="connection-pool">
- <xsd:annotation>
- <xsd:documentation>
- Used to specify how connections should be pooled in a
- server session.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" />
- <xsd:element name="max-connections" type="xsd:integer"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The max number of connections that will be
- created in the pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="min-connections" type="xsd:integer"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The min number of connections that will aways be
- in the pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="login" type="login" minOccurs="0" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="read-connection-pool">
- <xsd:annotation>
- <xsd:documentation>
- The read connection pool is used for read access through
- the server session. Any of the connection pools can be
- used for the read pool however this is the default. This
- pool allows for concurrent reads against the same JDBC
- connection and requires that the JDBC connection support
- concurrent read access.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="connection-pool">
- <xsd:sequence>
- <xsd:element name="exclusive" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This tag is used to specify if the
- connections from the read connection
- pool are exclusive or not
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the common logging options
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="java-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the Java log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log">
- <xsd:sequence>
- <xsd:element name="logging-options"
- type="logging-options" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eclipselink-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the EclipseLink log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log">
- <xsd:sequence>
- <xsd:element name="log-level" default="info"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies the log level for logging
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="off" />
- <xsd:enumeration value="severe" />
- <xsd:enumeration value="warning" />
- <xsd:enumeration value="info" />
- <xsd:enumeration value="config" />
- <xsd:enumeration value="fine" />
- <xsd:enumeration value="finer" />
- <xsd:enumeration value="finest" />
- <xsd:enumeration value="all" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="file-name" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Name of the file to write the logging to
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="logging-options"
- type="logging-options" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="server-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the Server log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="logging-options">
- <xsd:sequence>
- <xsd:element name="log-exception-stacktrace"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log exception stacktrace. Without
- this element, the stacktrace is logged for FINER
- or less (FINEST)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-thread" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log thread. Without this element,
- the thread is logged for FINE or less (FINER or
- FINEST)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-session" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log session. Without this
- element, the session is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-connection" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log connection. Without this
- element, the connection is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-date" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log date. Without this element,
- the date is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="transport-manager">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the transport mechanism of the RCM.
- The default transport mechanism is RMI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="on-connection-error"
- default="DiscardConnection" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element and has value of "DiscardConnection" or
- "KeepConnection". It determines whether
- connection to a RCM service should be dropped if
- there is a communication error with that RCM
- service. The default value for this element is
- "DiscardConnection".
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="KeepConnection" />
- <xsd:enumeration value="DiscardConnection" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="rmi-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element. It defines the RMI transport mechanism. The
- default naming service is JNDI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="send-mode" default="Asynchronous"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- rmi element and has value of
- "Asynchronous" or "Synchronous". It
- determines whether the RCM propagates
- command and does not wait for command to
- finish its execution in asynchronous
- mode or wait for command to finish its
- execution in synchronous mode. The
- default value of this element is
- "Asynchronous".
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="Asynchronous" />
- <xsd:enumeration value="Synchronous" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="discovery" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- rmi element. It determines whether the
- Discovery settings should be changed.
- Note that a default Discovery with its
- default settings is created when the rmi
- element is specified.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element
- name="multicast-group-address" type="xsd:string"
- default="226.10.12.64" minOccurs="0" />
- <xsd:element name="multicast-port"
- type="xsd:integer" default="3121" minOccurs="0" />
- <xsd:element name="announcement-delay"
- type="xsd:integer" default="1000" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of discovery
- elemenent. It determines
- whether the multicast group
- address should be changed.
- The default value of this
- element is "1000"
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="packet-time-to-live"
- type="xsd:integer" default="2" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of discovery
- elemenent. It determines
- whether the time-to-live of
- the packets that are sent
- from the Discovery's
- mulsticast socket should be
- changed. The default value
- of this element is "2"
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:choice minOccurs="0">
- <xsd:element name="jndi-naming-service"
- type="jndi-naming-service" />
- <xsd:element
- name="rmi-registry-naming-service">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element
- of rmi elemenent. It determines
- whether RMI registry should be used
- for naming service
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="url"
- type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="rmi-iiop-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the RMI-IIOP transport mechanism of
- the RCM. The default naming service is JNDI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="rmi-transport" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jms-topic-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the JMS topic transport mechanism
- of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="topic-host-url" type="xsd:string"
- minOccurs="0" />
- <xsd:element name="topic-connection-factory-name"
- type="xsd:string" default="jms/EclipseLinkTopicConnectionFactory"
- minOccurs="0" />
- <xsd:element name="topic-name" type="xsd:string"
- default="jms/EclipseLinkTopic" minOccurs="0" />
- <xsd:element name="jndi-naming-service"
- type="jndi-naming-service" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-jgroups-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the OC4J JGroups transport
- mechanism of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="use-single-threaded-notification"
- type="xsd:boolean" default="false" minOccurs="0" />
- <xsd:element name="topic-name" type="xsd:string"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="sun-corba-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the Sun CORBA transport mechanism
- of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="user-defined-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element. It determines whether a user implemented
- transport mechanism that should be used.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="transport-class"
- type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jndi-naming-service">
- <xsd:sequence>
- <xsd:element name="url" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether the
- URL for naming service should be changed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="user-name" type="xsd:string"
- default="admin" minOccurs="0" />
- <xsd:element name="encryption-class" type="xsd:string"
- default="org.eclipse.persistence.internal.security.JCEEncryptor"
- minOccurs="0" />
- <xsd:element name="password" type="xsd:string"
- default="password" minOccurs="0" />
- <!-- TODO: Need to have a non WebLogic (previously OC4J) default or route through server platform by default -->
- <xsd:element name="initial-context-factory-name"
- type="xsd:string"
- default="weblogic.jndi.WLInitialContextFactory"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether the
- initial context factory class for naming service
- should be changed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="property" minOccurs="0"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether
- naming service requires extra property that is
- not defined by EclipseLink but it is required by the
- user application
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string"
- use="required" />
- <xsd:attribute name="value" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:group name="event-listener-classes">
- <xsd:sequence>
- <xsd:element name="event-listener-class" type="xsd:string"
- minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:group>
- <xsd:group name="struct-converters">
- <xsd:sequence>
- <xsd:element name="struct-converter" type="xsd:string"
- minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:group>
- <xsd:complexType name="sequence">
- <xsd:annotation>
- <xsd:documentation>Sequence object.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequence name.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="preallocation-size" type="xsd:integer"
- default="50" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequence preallocation size.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="default-sequence">
- <xsd:annotation>
- <xsd:documentation>
- References default sequence object, overriding its name
- and (optionally) preallocation size.
- </xsd:documentation>
- <xsd:documentation>
- To use preallocation size of default sequence object,
- set preallocation size to 0
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="native-sequence">
- <xsd:annotation>
- <xsd:documentation>
- Database sequence mechanism used.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="table-sequence">
- <xsd:annotation>
- <xsd:documentation>Table sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="table" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="name-field" type="xsd:string"
- default="SEQ_NAME" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence name
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="counter-field" type="xsd:string"
- default="SEQ_COUNT" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="unary-table-sequence">
- <xsd:annotation>
- <xsd:documentation>
- Unary table sequence - sequence name is a table name,
- table has a single field and a single row
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="counter-field" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xmlfile-sequence">
- <xsd:annotation>
- <xsd:documentation>Xmlfile sequence.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-sequence">
- <xsd:annotation>
- <xsd:documentation>Xml sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="root-element" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="name-element" type="xsd:string"
- default="SEQ_NAME" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence name
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="counter-element"
- type="xsd:string" default="SEQ_COUNT" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
-
-
- <xsd:complexType name="document-preservation-policy">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies which document preservation
- strategy will be used.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="node-ordering-policy"
- type="node-ordering-policy" maxOccurs="1" minOccurs="0">
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:complexType name="node-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies which node ordering strategy will
- be used.
- </xsd:documentation>
- </xsd:annotation></xsd:complexType>
-
- <xsd:complexType
- name="descriptor-level-document-preservation-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of DocumentPreservation Policy that
- accesses the session cache to store Objects and their
- associated nodes.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="no-document-preservation-policy">
- <xsd:annotation>
- <xsd:documentation>
- A DocumentPreservationPolicy to indicate that no
- document preservation work should be done.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="xml-binder-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of DocumentPreservationPolicy that
- maintains bidirectional relationships between Java
- Objects and the XMLNodes they originated from.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="append-new-elements-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of NodeOrderingPolicy that simply
- appends the new child element to the parent.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="ignore-new-elements-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of NodeOrderingPolicy that ignores any
- new elements when updating a cached document.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="relative-position-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of NodeOrderingPolicy that adds new
- elements to an XML Document based on the last updated
- sibling in their context.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-</xsd:schema>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_2.0.xsd b/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_2.0.xsd
deleted file mode 100644
index c84821e948..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/schemas/eclipselink_sessions_2.0.xsd
+++ /dev/null
@@ -1,1591 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-*******************************************************************************
- Copyright (c) 1998, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0, which accompanies this distribution
- and is available at http://www.eclipse.org/legal/epl-v10.html.
-
- Contributors:
- Oracle - initial API and implementation from Oracle TopLink
- tware - update version number to 2.0
-*****************************************************************************/
--->
-<!--
-
-XML Schema definition for the Eclipse Persistence Services Project Session Configuration file. Instances
-of this file are typically located as: 'META-INF/sessions.xml'
-
- -->
-
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- elementFormDefault="qualified" version="2.0">
- <xsd:element name="sessions">
- <xsd:annotation>
- <xsd:documentation>
- This is the root element and exists only for XML
- structure
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="session" type="session" minOccurs="0"
- maxOccurs="unbounded" />
- </xsd:sequence>
- <xsd:attribute name="version" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- <xsd:complexType name="session">
- <xsd:annotation>
- <xsd:documentation>
- This is the node element that describes a particular session
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- Generic element used to describe a string that
- represents the name of an item
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="server-platform" type="server-platform"
- minOccurs="0" />
- <xsd:choice minOccurs="0">
- <xsd:element name="remote-command">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- session element that define the Remote
- Command Module that can also be used for
- cache synchronization
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="channel"
- type="xsd:string" default="EclipseLinkCommandChannel"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element."
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="commands"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element. It determine what
- command features, the RCM
- supports
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="cache-sync"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an
- optional element of
- command element. It
- turns on cache
- synchronization to
- allow sending and
- receiving cache sync
- commands
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="transport"
- type="transport-manager" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of remote-command
- element. It defines the
- transport mechanism of the RCM.
- The default transport mechanism
- is RMI
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:element name="event-listener-classes" minOccurs="0">
- <xsd:complexType>
- <xsd:group ref="event-listener-classes" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="profiler" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element represents if the profiler will be
- used by the session
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="dms" />
- <xsd:enumeration value="eclipselink" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="exception-handler-class"
- type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the class that the session will use to
- handle exceptions generated from within the
- session
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="logging" type="log" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element used to specify the logging options
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="session-customizer-class"
- type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies the session customizer
- class to run on a loaded session.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="server-platform">
- <xsd:annotation>
- <xsd:documentation>
- This is the node element that describes which server
- platform to use, JTA settings and runtime services
- settings
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="enable-runtime-services"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element. This
- specifies whether or not the JMX MBean for
- providing runtime services is deployed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="enable-jta" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element. This
- specifies whether or not this session will
- integrate with the JTA (i.e. whether the session
- will be populated with a transaction controller
- class. The choice of server-class will
- automatically be chosen based on the transaction
- controller
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="custom-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform">
- <xsd:sequence>
- <xsd:element name="server-class" type="xsd:string"
- default="org.eclipse.persistence.platform.server.CustomServerPlatform"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the subclass of
- org.eclipse.persistence.platform.server.PlatformBase
- to specify which server platform to use
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element
- name="external-transaction-controller-class" type="xsd:string"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-903-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-904-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1012-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1013-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-1111-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform"/>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-61-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-70-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-81-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-9-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="weblogic-10-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-40-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-50-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-51-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-60-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-61-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="websphere-7-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jboss-platform">
- <xsd:complexContent>
- <xsd:extension base="server-platform" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="session-broker">
- <xsd:annotation>
- <xsd:documentation>
- Provides a single view to a session that
- transparently accesses multple databases.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="session">
- <xsd:sequence>
- <xsd:element name="session-name" type="xsd:string"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This is the element that represents the
- session name
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="project">
- <xsd:restriction base="xsd:string" />
- </xsd:simpleType>
- <xsd:simpleType name="xml">
- <xsd:restriction base="project" />
- </xsd:simpleType>
- <xsd:simpleType name="class">
- <xsd:restriction base="project" />
- </xsd:simpleType>
- <xsd:complexType name="database-session">
- <xsd:annotation>
- <xsd:documentation>
- The session is the primary interface into EclipseLink, the
- application should do all of its reading and writing of
- objects through the session. The session also manages
- transactions and units of work. The database session is
- intended for usage in two-tier client-server
- applications. Although it could be used in a server
- situation, it is limitted to only having a single
- database connection and only allows a single open
- database transaction.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="session">
- <xsd:sequence>
- <xsd:element name="primary-project" type="project"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This project (class or xml) will be
- loaded as the primary project for the
- session.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="additional-project"
- type="project" minOccurs="0" maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- Additional projects will have their
- descriptors appended to the primary
- project.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="login" type="login"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="server-session">
- <xsd:annotation>
- <xsd:documentation>
- Is an extension of a DatabaseSession
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="database-session">
- <xsd:sequence>
- <xsd:element name="connection-pools"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Connection pools are only for usage with
- internal connection pooling and should
- not be used if using external connection
- pooling
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="read-connection-pool"
- type="read-connection-pool" minOccurs="0" />
- <xsd:element
- name="write-connection-pool" type="connection-pool"
- minOccurs="0" />
- <xsd:element
- name="sequence-connection-pool" type="connection-pool"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set this tag to use the
- sequence connection pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="connection-pool"
- type="connection-pool" minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="connection-policy"
- type="connection-policy" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="connection-policy">
- <xsd:annotation>
- <xsd:documentation>
- Used to specify how default client sessions are acquired
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="exclusive-connection" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Specifies if an exclusive connection should be
- used for reads, required for VPD, or user based
- read security.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="lazy" type="xsd:boolean" default="true"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Specifies if a connection should be acquired and
- held upfront in the client session, or only
- acquired when needed and then released.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="login">
- <xsd:annotation>
- <xsd:documentation>
- Defines common fields for database-login and eis-login
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="platform-class" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This is the element that represents the platform
- class name
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="user-name" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="encryption-class" type="xsd:string"
- default="org.eclipse.persistence.internal.security.JCEEncryptor"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="password" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is used in the login as well as the
- Cache Synchronization feature
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="table-qualifier" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set the default qualifier for all tables. This
- can be the creator of the table or database name
- the table exists on. This is required by some
- databases such as Oracle and DB2.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="external-connection-pooling"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if the connection should use an
- external connection pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="external-transaction-controller"
- type="xsd:boolean" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if the session will be using an
- external transaction controller
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="sequencing" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequencing information.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="default-sequence"
- type="sequence" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Default sequence. The name is
- optional. If no name provided an
- empty string will be used as a name.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="sequences" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Non default sequences. Make sure
- each sequence has unique name.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="sequence"
- type="sequence" minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="property" minOccurs="0"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of a login.
- It is used to define extra properties on the
- login
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string"
- use="required" />
- <xsd:attribute name="value" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="database-login">
- <xsd:annotation>
- <xsd:documentation>
- Holds the configuration information necessary to connect
- to a JDBC driver.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login">
- <xsd:sequence>
- <xsd:choice minOccurs="0">
- <xsd:sequence>
- <xsd:element name="driver-class"
- type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- The driver class is the Java
- class for the JDBC driver to be
- used (e.g.
- sun.jdbc.odbc.JdbcOdbcDriver.class)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="connection-url"
- type="xsd:string">
- <xsd:annotation>
- <xsd:documentation>
- This is the URL that will be
- used to connect to the database.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- <xsd:element name="datasource">
- <xsd:annotation>
- <xsd:documentation>
- This is the URL of a datasource that
- may be used by the session to
- connect to the database.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:simpleContent>
- <xsd:extension base="xsd:string">
- <xsd:attribute name="lookup"
- type="lookup-enum" />
- </xsd:extension>
- </xsd:simpleContent>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- <xsd:element name="bind-all-parameters"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to bind all arguments to any
- SQL statement.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="cache-all-statements"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether prepared statements should
- be cached.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="byte-array-binding"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use
- parameter binding for large binary data.
- By default EclipseLink will print this data
- as hex through the JDBC binary excape
- clause. Both binding and printing have
- various limits on all databases (e.g. 5k
- - 32k).
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="string-binding"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set to true if strings should be bound.
- Used to help bean introspection.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="streams-for-binding"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use streams
- to store large binary data. This can
- improve the max size for reading/writing
- on some JDBC drivers.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="force-field-names-to-upper-case"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This setting can be used if the
- application expects upper case but the
- database does not return consistent case
- (e.g. different databases).
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="optimize-data-conversion"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether driver level data conversion
- optimization is enabled. This can be
- disabled as some drivers perform data
- conversion themselves incorrectly.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="trim-strings" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- By default CHAR field values have
- trailing blanks trimmed, this can be
- configured.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="batch-writing" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use batch
- writing. This facility allows multiple
- write operations to be submitted to a
- database for processing at once.
- Submitting multiple updates together,
- instead of individually, can greatly
- improve performance in some situations.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="jdbc-batch-writing"
- type="xsd:boolean" default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Setting this tag with true indicates to
- EclipseLink that the JDBC driver supports
- batch writing. EclipseLink's internal batch
- writing is disabled. Setting this tag
- with false indicates to EclipseLink that the
- JDBC driver does not support batch
- writing. This will revert to the default
- behaviour which is to delegate to
- EclipseLink's internal batch writing.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="max-batch-writing-size"
- type="xsd:integer" default="32000" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Allow for the max batch writing size to
- be set. This allows for the batch size
- to be limited as most database have
- strict limits. The size is in
- characters, the default is 32000 but the
- real value depends on the database
- configuration.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="native-sql" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- EclipseLink can be configured to use
- database specific sql grammar not JDBC
- specific. This is because unfortunately
- some bridges to not support the full
- JDBC standard. By default EclipseLink uses
- the JDBC sql grammar.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="struct-converters"
- minOccurs="0">
- <xsd:complexType>
- <xsd:group ref="struct-converters" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="connection-health-validated-on-error" type="xsd:boolean" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>If true will cause EclipseLink to ping database to determine if an SQLException was cause by a communication failure</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="query-retry-attempt-count" type="xsd:integer" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Configure the number of attempts EclipseLink will make if EclipseLink is attempting to retry a query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="delay-between-reconnect-attempts" type="xsd:integer" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Configure the time in miliseconds that EclipseLink will wait between attempts to reconnect if EclipseLink is attempting to retry a query.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="ping-sql" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>Override the platform specific SQL that EclipseLink will issue to a connection to determine if the connection is still live.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:simpleType name="lookup-enum">
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="composite-name" />
- <xsd:enumeration value="compound-name" />
- <xsd:enumeration value="string" />
- </xsd:restriction>
- </xsd:simpleType>
- <xsd:complexType name="eis-login">
- <xsd:annotation>
- <xsd:documentation>
- Defines connection information and datasource
- properties. There are three ways to connect through EIS,
- - Provide a JNDI name to the ConnectionFactory and use
- the default getConnection - Provide a JNDI name to the
- ConnectionFactory, and a driver specific ConnectionSpec
- to pass to the getConnection - Connect in a non-managed
- way directly to the driver specific ConnectionFactory An
- EISConnectionSpec must be provided to define how to
- connect to the EIS adapter. The EIS platform can be used
- to provide datasource/driver specific behavoir such as
- InteractionSpec and Record conversion.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login">
- <xsd:sequence>
- <xsd:element name="connection-spec-class"
- type="xsd:string" minOccurs="0" />
- <xsd:element name="connection-factory-url"
- type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-login">
- <xsd:annotation>
- <xsd:documentation>
- Defines login and platform type to be used
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="login">
- <xsd:sequence>
- <xsd:element name="equal-namespace-resolvers"
- type="xsd:boolean" maxOccurs="1" minOccurs="0">
- </xsd:element>
- <xsd:element name="document-preservation-policy"
- maxOccurs="1" minOccurs="0"
- type="document-preservation-policy">
-
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="connection-pool">
- <xsd:annotation>
- <xsd:documentation>
- Used to specify how connections should be pooled in a
- server session.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" />
- <xsd:element name="max-connections" type="xsd:integer"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The max number of connections that will be
- created in the pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="min-connections" type="xsd:integer"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The min number of connections that will aways be
- in the pool
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="login" type="login" minOccurs="0" />
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="read-connection-pool">
- <xsd:annotation>
- <xsd:documentation>
- The read connection pool is used for read access through
- the server session. Any of the connection pools can be
- used for the read pool however this is the default. This
- pool allows for concurrent reads against the same JDBC
- connection and requires that the JDBC connection support
- concurrent read access.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="connection-pool">
- <xsd:sequence>
- <xsd:element name="exclusive" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This tag is used to specify if the
- connections from the read connection
- pool are exclusive or not
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the common logging options
- </xsd:documentation>
- </xsd:annotation>
- </xsd:complexType>
- <xsd:complexType name="java-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the Java log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log">
- <xsd:sequence>
- <xsd:element name="logging-options"
- type="logging-options" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="eclipselink-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the EclipseLink log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log">
- <xsd:sequence>
- <xsd:element name="log-level" default="info"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies the log level for logging
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="off" />
- <xsd:enumeration value="severe" />
- <xsd:enumeration value="warning" />
- <xsd:enumeration value="info" />
- <xsd:enumeration value="config" />
- <xsd:enumeration value="fine" />
- <xsd:enumeration value="finer" />
- <xsd:enumeration value="finest" />
- <xsd:enumeration value="all" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="file-name" type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Name of the file to write the logging to
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="logging-options"
- type="logging-options" minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="server-log">
- <xsd:annotation>
- <xsd:documentation>
- Defines the options of the Server log
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="log" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="logging-options">
- <xsd:sequence>
- <xsd:element name="log-exception-stacktrace"
- type="xsd:boolean" default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log exception stacktrace. Without
- this element, the stacktrace is logged for FINER
- or less (FINEST)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-thread" type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log thread. Without this element,
- the thread is logged for FINE or less (FINER or
- FINEST)
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-session" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log session. Without this
- element, the session is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-connection" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log connection. Without this
- element, the connection is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="print-date" type="xsd:boolean"
- default="true" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Set whether to log date. Without this element,
- the date is always printed
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="transport-manager">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the transport mechanism of the RCM.
- The default transport mechanism is RMI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="on-connection-error"
- default="DiscardConnection" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element and has value of "DiscardConnection" or
- "KeepConnection". It determines whether
- connection to a RCM service should be dropped if
- there is a communication error with that RCM
- service. The default value for this element is
- "DiscardConnection".
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="KeepConnection" />
- <xsd:enumeration value="DiscardConnection" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="rmi-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element. It defines the RMI transport mechanism. The
- default naming service is JNDI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="send-mode" default="Asynchronous"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- rmi element and has value of
- "Asynchronous" or "Synchronous". It
- determines whether the RCM propagates
- command and does not wait for command to
- finish its execution in asynchronous
- mode or wait for command to finish its
- execution in synchronous mode. The
- default value of this element is
- "Asynchronous".
- </xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType>
- <xsd:restriction base="xsd:string">
- <xsd:enumeration value="Asynchronous" />
- <xsd:enumeration value="Synchronous" />
- </xsd:restriction>
- </xsd:simpleType>
- </xsd:element>
- <xsd:element name="discovery" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- rmi element. It determines whether the
- Discovery settings should be changed.
- Note that a default Discovery with its
- default settings is created when the rmi
- element is specified.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element
- name="multicast-group-address" type="xsd:string"
- default="226.10.12.64" minOccurs="0" />
- <xsd:element name="multicast-port"
- type="xsd:integer" default="3121" minOccurs="0" />
- <xsd:element name="announcement-delay"
- type="xsd:integer" default="1000" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of discovery
- elemenent. It determines
- whether the multicast group
- address should be changed.
- The default value of this
- element is "1000"
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="packet-time-to-live"
- type="xsd:integer" default="2" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional
- element of discovery
- elemenent. It determines
- whether the time-to-live of
- the packets that are sent
- from the Discovery's
- mulsticast socket should be
- changed. The default value
- of this element is "2"
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- <xsd:choice minOccurs="0">
- <xsd:element name="jndi-naming-service"
- type="jndi-naming-service" />
- <xsd:element
- name="rmi-registry-naming-service">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element
- of rmi elemenent. It determines
- whether RMI registry should be used
- for naming service
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="url"
- type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="rmi-iiop-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the RMI-IIOP transport mechanism of
- the RCM. The default naming service is JNDI
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="rmi-transport" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jms-topic-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the JMS topic transport mechanism
- of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="topic-host-url" type="xsd:string"
- minOccurs="0" />
- <xsd:element name="topic-connection-factory-name"
- type="xsd:string" default="jms/EclipseLinkTopicConnectionFactory"
- minOccurs="0" />
- <xsd:element name="topic-name" type="xsd:string"
- default="jms/EclipseLinkTopic" minOccurs="0" />
- <xsd:element name="jndi-naming-service"
- type="jndi-naming-service" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="oc4j-jgroups-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the OC4J JGroups transport
- mechanism of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="use-single-threaded-notification"
- type="xsd:boolean" default="false" minOccurs="0" />
- <xsd:element name="topic-name" type="xsd:string"
- minOccurs="0" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="sun-corba-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element defines the Sun CORBA transport mechanism
- of the RCM
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="user-defined-transport">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of transport
- element. It determines whether a user implemented
- transport mechanism that should be used.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="transport-manager">
- <xsd:sequence>
- <xsd:element name="transport-class"
- type="xsd:string" />
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="jndi-naming-service">
- <xsd:sequence>
- <xsd:element name="url" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether the
- URL for naming service should be changed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="user-name" type="xsd:string"
- default="admin" minOccurs="0" />
- <xsd:element name="encryption-class" type="xsd:string"
- default="org.eclipse.persistence.internal.security.JCEEncryptor"
- minOccurs="0" />
- <xsd:element name="password" type="xsd:string"
- default="password" minOccurs="0" />
- <!-- TODO: Need to have a non WebLogic (previously OC4J) default or route through server platform by default -->
- <xsd:element name="initial-context-factory-name"
- type="xsd:string"
- default="weblogic.jndi.WLInitialContextFactory"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether the
- initial context factory class for naming service
- should be changed.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="property" minOccurs="0"
- maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- This element is an optional element of
- jndi-naming-service. It determines whether
- naming service requires extra property that is
- not defined by EclipseLink but it is required by the
- user application
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:attribute name="name" type="xsd:string"
- use="required" />
- <xsd:attribute name="value" type="xsd:string"
- use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:group name="event-listener-classes">
- <xsd:sequence>
- <xsd:element name="event-listener-class" type="xsd:string"
- minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:group>
- <xsd:group name="struct-converters">
- <xsd:sequence>
- <xsd:element name="struct-converter" type="xsd:string"
- minOccurs="0" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:group>
- <xsd:complexType name="sequence">
- <xsd:annotation>
- <xsd:documentation>Sequence object.</xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="name" type="xsd:string" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequence name.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="preallocation-size" type="xsd:integer"
- default="50" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Sequence preallocation size.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- <xsd:complexType name="default-sequence">
- <xsd:annotation>
- <xsd:documentation>
- References default sequence object, overriding its name
- and (optionally) preallocation size.
- </xsd:documentation>
- <xsd:documentation>
- To use preallocation size of default sequence object,
- set preallocation size to 0
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="native-sequence">
- <xsd:annotation>
- <xsd:documentation>
- Database sequence mechanism used.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="table-sequence">
- <xsd:annotation>
- <xsd:documentation>Table sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="table" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="name-field" type="xsd:string"
- default="SEQ_NAME" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence name
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="counter-field" type="xsd:string"
- default="SEQ_COUNT" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="unary-table-sequence">
- <xsd:annotation>
- <xsd:documentation>
- Unary table sequence - sequence name is a table name,
- table has a single field and a single row
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="counter-field" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xmlfile-sequence">
- <xsd:annotation>
- <xsd:documentation>Xmlfile sequence.</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence" />
- </xsd:complexContent>
- </xsd:complexType>
- <xsd:complexType name="xml-sequence">
- <xsd:annotation>
- <xsd:documentation>Xml sequence</xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="sequence">
- <xsd:sequence>
- <xsd:element name="root-element" type="xsd:string"
- default="SEQUENCE" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="name-element" type="xsd:string"
- default="SEQ_NAME" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence name
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <xsd:element name="counter-element"
- type="xsd:string" default="SEQ_COUNT" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Define the name of the sequence counter
- field in the sequence table.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
-
-
- <xsd:complexType name="document-preservation-policy">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies which document preservation
- strategy will be used.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element name="node-ordering-policy"
- type="node-ordering-policy" maxOccurs="1" minOccurs="0">
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:complexType name="node-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- This element specifies which node ordering strategy will
- be used.
- </xsd:documentation>
- </xsd:annotation></xsd:complexType>
-
- <xsd:complexType
- name="descriptor-level-document-preservation-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of DocumentPreservation Policy that
- accesses the session cache to store Objects and their
- associated nodes.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="no-document-preservation-policy">
- <xsd:annotation>
- <xsd:documentation>
- A DocumentPreservationPolicy to indicate that no
- document preservation work should be done.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="xml-binder-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of DocumentPreservationPolicy that
- maintains bidirectional relationships between Java
- Objects and the XMLNodes they originated from.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="document-preservation-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="append-new-elements-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of NodeOrderingPolicy that simply
- appends the new child element to the parent.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="ignore-new-elements-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of NodeOrderingPolicy that ignores any
- new elements when updating a cached document.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-
- <xsd:complexType name="relative-position-ordering-policy">
- <xsd:annotation>
- <xsd:documentation>
- An implementation of NodeOrderingPolicy that adds new
- elements to an XML Document based on the last updated
- sibling in their context.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="node-ordering-policy"></xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
-</xsd:schema>
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/JptCommonEclipseLinkCorePlugin.java b/common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/JptCommonEclipseLinkCorePlugin.java
deleted file mode 100644
index 60cb45646a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/JptCommonEclipseLinkCorePlugin.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.eclipselink.core;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.BundleContext;
-
-
-public class JptCommonEclipseLinkCorePlugin
- extends Plugin {
-
- // ********** public constants **********
-
- /**
- * The plug-in identifier of the jpt common core support
- * (value <code>"org.eclipse.jpt.common.core"</code>).
- */
- public static final String PLUGIN_ID = "org.eclipse.jpt.common.eclipselink.core"; //$NON-NLS-1$
- public static final String PLUGIN_ID_ = PLUGIN_ID + '.';
-
-
- // ********** singleton **********
-
- private static JptCommonEclipseLinkCorePlugin INSTANCE;
-
- /**
- * Return the singleton jpt common eclipselink core plug-in.
- */
- public static JptCommonEclipseLinkCorePlugin instance() {
- return INSTANCE;
- }
-
-
- // ********** public static methods **********
-
- /**
- * Log the specified status.
- */
- public static void log(IStatus status) {
- INSTANCE.getLog().log(status);
- }
-
- /**
- * Log the specified message.
- */
- public static void log(String msg) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, null));
- }
-
- /**
- * Log the specified exception or error.
- */
- public static void log(Throwable throwable) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, throwable.getLocalizedMessage(), throwable));
- }
-
-
- // ********** plug-in implementation **********
-
- public JptCommonEclipseLinkCorePlugin() {
- super();
- if (INSTANCE != null) {
- throw new IllegalStateException();
- }
- // this convention is *wack*... ~bjv
- INSTANCE = this;
- }
-
-
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- // nothing yet...
- }
-
- @Override
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- // nothing yet...
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/internal/JptCommonEclipseLinkCoreMessages.java b/common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/internal/JptCommonEclipseLinkCoreMessages.java
deleted file mode 100644
index 64af708d3b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/internal/JptCommonEclipseLinkCoreMessages.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.eclipselink.core.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-public class JptCommonEclipseLinkCoreMessages {
-
- public static String EclipseLinkLibraryValidator_noEclipseLinkVersion;
- public static String EclipseLinkLibraryValidator_multipleEclipseLinkVersions;
- public static String EclipseLinkLibraryValidator_improperEclipseLinkVersion;
-
- // TODO - move to jpt.jaxb.eclipselink.core when there are messages there
- public static String ELJaxbUserLibraryValidator_noXjcClasses;
-
-
- private static final String BUNDLE_NAME = "jpt_common_eclipselink_core"; //$NON-NLS-1$
-
- private static final Class<?> BUNDLE_CLASS = JptCommonEclipseLinkCoreMessages.class;
-
- static {
- NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
- }
-
- private JptCommonEclipseLinkCoreMessages() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/internal/libval/EclipseLinkLibValUtil.java b/common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/internal/libval/EclipseLinkLibValUtil.java
deleted file mode 100644
index 1ad52aba44..0000000000
--- a/common/plugins/org.eclipse.jpt.common.eclipselink.core/src/org/eclipse/jpt/common/eclipselink/core/internal/libval/EclipseLinkLibValUtil.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.eclipselink.core.internal.libval;
-
-import java.util.Set;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ToolFactory;
-import org.eclipse.jdt.core.util.IClassFileReader;
-import org.eclipse.jdt.core.util.IFieldInfo;
-import org.eclipse.jpt.common.eclipselink.core.JptCommonEclipseLinkCorePlugin;
-import org.eclipse.jpt.common.eclipselink.core.internal.JptCommonEclipseLinkCoreMessages;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.osgi.service.resolver.VersionRange;
-import org.osgi.framework.Version;
-
-
-public class EclipseLinkLibValUtil {
-
- private final static String VERSION_CLASS_PATH = "org/eclipse/persistence/Version.class"; //$NON-NLS-1$
-
- private final static String VERSION_FIELD_NAME = "version"; //$NON-NLS-1$
-
-
- public static IStatus validate(Iterable<IClasspathEntry> libraryEntries, Set<VersionRange> versionRanges) {
- Version version = null;
- for (IClasspathEntry entry : libraryEntries) {
- String versionString = null;
- if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- IClassFileReader classReader =
- ToolFactory.createDefaultClassFileReader(
- entry.getPath().toFile().getAbsolutePath(), VERSION_CLASS_PATH, IClassFileReader.FIELD_INFOS);
- if (classReader != null) {
- for (IFieldInfo field : classReader.getFieldInfos()) {
- if (StringTools.stringsAreEqual(field.getName(), VERSION_FIELD_NAME.toCharArray())) {
- try {
- versionString = field.getConstantValueAttribute().getConstantValue().getStringValue();
- }
- catch (Exception e) {
- // potentially a bit could go wrong with that last line, but if any
- // assumptions aren't met, there's no value
- }
- break;
- }
- }
- }
- if (versionString != null) {
- if (version != null) {
- return new Status(
- IStatus.ERROR, JptCommonEclipseLinkCorePlugin.PLUGIN_ID,
- JptCommonEclipseLinkCoreMessages.EclipseLinkLibraryValidator_multipleEclipseLinkVersions);
- }
- else {
- version = new Version(versionString);
- }
- }
- }
- }
-
- if (version == null) {
- return new Status(
- IStatus.ERROR, JptCommonEclipseLinkCorePlugin.PLUGIN_ID,
- JptCommonEclipseLinkCoreMessages.EclipseLinkLibraryValidator_noEclipseLinkVersion);
- }
-
- for (VersionRange versionRange : versionRanges) {
- if (! versionRange.isIncluded(version)) {
- return new Status(
- IStatus.ERROR, JptCommonEclipseLinkCorePlugin.PLUGIN_ID,
- JptCommonEclipseLinkCoreMessages.EclipseLinkLibraryValidator_improperEclipseLinkVersion);
- }
- }
-
- return Status.OK_STATUS;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/.classpath b/common/plugins/org.eclipse.jpt.common.ui/.classpath
deleted file mode 100644
index 934fb38085..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/.classpath
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="property_files"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/jst/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/wst/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/common/plugins/org.eclipse.jpt.common.ui/.cvsignore b/common/plugins/org.eclipse.jpt.common.ui/.cvsignore
deleted file mode 100644
index ba077a4031..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/common/plugins/org.eclipse.jpt.common.ui/.project b/common/plugins/org.eclipse.jpt.common.ui/.project
deleted file mode 100644
index 7fde966914..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.ui</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/common/plugins/org.eclipse.jpt.common.ui/.settings/org.eclipse.jdt.core.prefs b/common/plugins/org.eclipse.jpt.common.ui/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 4ab78dabaf..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Mon Mar 21 17:39:13 EDT 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
diff --git a/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
deleted file mode 100644
index ebe08ea779..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,73 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.common.ui;singleton:=true
-Bundle-Version: 1.2.0.qualifier
-Bundle-Activator: org.eclipse.jpt.common.ui.JptCommonUiPlugin
-Bundle-ActivationPolicy: lazy
-Bundle-ClassPath: .
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.draw2d;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jdt.ui;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jface;bundle-version="[3.7.0,4.0.0)",
- org.eclipse.jface.text;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jpt.common.core;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.jpt.common.utility;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jst.common.project.facet.core;bundle-version="[1.3.100,2.0.0)",
- org.eclipse.jst.common.project.facet.ui;bundle-version="[1.3.100,2.0.0)",
- org.eclipse.ui.ide;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.ui.navigator;bundle-version="[3.3.100,4.0.0)",
- org.eclipse.ui.views.properties.tabbed;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.wst.common.project.facet.ui;bundle-version="[1.3.0,2.0.0)"
-Dali-Comment: *NO* EclipseLink friends!
-Export-Package: org.eclipse.jpt.common.ui,
- org.eclipse.jpt.common.ui.internal;
- x-friends:="org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.ui.internal.dialogs;
- x-friends:="org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.ui.internal.jface;
- x-friends:="org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.ui.internal.listeners;
- x-friends:="org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.ui.internal.properties;
- x-friends:="org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.ui.internal.swt;
- x-friends:="org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.ui.internal.util;
- x-friends:="org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.ui.internal.utility;
- x-friends:="org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.ui.internal.utility.swt;
- x-friends:="org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.ui.internal.widgets;
- x-friends:="org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.ui.internal.wizards;
- x-friends:="org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.ui.jface
-Import-Package: com.ibm.icu.text;version="4.0.1"
diff --git a/common/plugins/org.eclipse.jpt.common.ui/about.html b/common/plugins/org.eclipse.jpt.common.ui/about.html
deleted file mode 100644
index be534ba44f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>May 02, 2008</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/common/plugins/org.eclipse.jpt.common.ui/build.properties b/common/plugins/org.eclipse.jpt.common.ui/build.properties
deleted file mode 100644
index 7fc780eaa0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-################################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-source.. = src/,\
- property_files/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- about.html,\
- plugin.properties
-jars.compile.order = .
diff --git a/common/plugins/org.eclipse.jpt.common.ui/plugin.properties b/common/plugins/org.eclipse.jpt.common.ui/plugin.properties
deleted file mode 100644
index 4caf90e773..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/plugin.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-###############################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-###############################################################################
-
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-pluginName= Dali Java Persistence Tools - Common UI
-providerName=Eclipse Web Tools Platform
diff --git a/common/plugins/org.eclipse.jpt.common.ui/property_files/jpt_common_ui.properties b/common/plugins/org.eclipse.jpt.common.ui/property_files/jpt_common_ui.properties
deleted file mode 100644
index 443a195cf2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/property_files/jpt_common_ui.properties
+++ /dev/null
@@ -1,30 +0,0 @@
-################################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-
-Boolean_True=True
-Boolean_False=False
-
-NoneSelected=<None>
-DefaultEmpty=Default
-DefaultWithOneParam=Default ({0})
-
-AddRemovePane_AddButtonText=Add...
-AddRemovePane_RemoveButtonText=Remove
-ChooserPane_browseButton=Browse...
-ClassChooserPane_dialogMessage=&Enter type name prefix or pattern (*, ?, or camel case):
-ClassChooserPane_dialogTitle=Class Selection
-PackageChooserPane_dialogTitle=Package Selection
-PackageChooserPane_dialogMessage=&Enter package name prefix or pattern (* = any string, ? = any character):
-EnumComboViewer_default=Default ()
-EnumComboViewer_defaultWithDefault=Default ({0})
-NewNameStateObject_nameMustBeSpecified=A name must be specified.
-NewNameStateObject_nameAlreadyExists=An object with this name already exists.
-
-OptionalMessageDialog_doNotShowWarning=Do not show this &message again
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/JptCommonUiPlugin.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/JptCommonUiPlugin.java
deleted file mode 100644
index b72827853f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/JptCommonUiPlugin.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui;
-
-import org.eclipse.jpt.common.ui.internal.JptUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * Dali UI plug-in.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class JptCommonUiPlugin
- extends JptUIPlugin
-{
- // ********** constants **********
-
- /**
- * The plug-in identifier of JPT Common UI support (value {@value}).
- */
- public static final String PLUGIN_ID = "org.eclipse.jpt.common.ui"; //$NON-NLS-1$
- public static final String PLUGIN_ID_ = PLUGIN_ID + '.';
-
- // ********** singleton **********
-
- private static JptCommonUiPlugin INSTANCE;
-
- /**
- * Returns the singleton JPT UI plug-in.
- */
- public static JptCommonUiPlugin instance() {
- return INSTANCE;
- }
-
-
- // ********** logging **********
-
- public static void log(String msg) {
- INSTANCE.logError(msg);
- }
-
- public static void log(Throwable throwable) {
- INSTANCE.logError(throwable);
- }
-
-
- // ********** construction **********
-
- public JptCommonUiPlugin() {
- super();
- if (INSTANCE != null) {
- throw new IllegalStateException();
- }
- // this convention is *wack*... ~bjv
- INSTANCE = this;
- }
-
- @Override
- public synchronized void start(BundleContext context) throws Exception {
- super.start(context);
- // nothing yet...
- }
-
- @Override
- public synchronized void stop(BundleContext context) throws Exception {
- try {
- // nothing yet...
- } finally {
- super.stop(context);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/WidgetFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/WidgetFactory.java
deleted file mode 100644
index 4a7154aeee..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/WidgetFactory.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui;
-
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.DateTime;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Spinner;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.widgets.FormText;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * A widget factory is responsible for creating an SWT widget based on the right
- * style. Some style shows the widgets differently, for instance, the flat style
- * shows the widgets with less borders.
- * <p>
- * Provisional API: This interface is part of an interim API that is still under
- * development and expected to change significantly before reaching stability.
- * It is available at this early stage to solicit feedback from pioneering
- * adopters on the understanding that any code that uses this API will almost
- * certainly be broken (repeatedly) as the API evolves.
- *
- * @version 2.0
- * @since 2.0
- */
-public interface WidgetFactory {
-
- /**
- * Creates a new regular button.
- *
- * @param parent The parent container
- * @param text The button's text
- * @return A new <code>Button</code>
- */
- Button createButton(Composite parent, String text);
-
- /**
- * Creates a new non-editable custom <code>Combo</code>.
- *
- * @deprecated
- * @param parent The parent container
- * @return A new <code>CCombo</code>
- */
- @Deprecated
- CCombo createCCombo(Composite parent);
-
- /**
- * Creates a new check box button.
- *
- * @param parent The parent container
- * @param text The button's text
- * @return A new <code>Button</code>
- */
- Button createCheckBox(Composite parent, String text);
-
- /**
- * Creates a new non-editable <code>Combo</code>.
- *
- * @param parent The parent container
- * @return A new <code>Combo</code>
- */
- Combo createCombo(Composite parent);
-
- /**
- * Creates a new container.
- *
- * @param parent The parent container
- * @return A new <code>Composite</code>
- */
- Composite createComposite(Composite parent);
-
- /**
- * Creates a new DateTime.
- *
- * @param container The parent container
- * @param style The style is to tell the type of widget
- * (<code>SWT.DATE</code> or <code>SWT.TIME</code> or <code>SWT.CALENDAR</code>)
- * @return A new <code>DateTime</code>
- */
- DateTime createDateTime(Composite parent, int style);
-
- /**
- * Creates a new editable custom <code>CCombo</code>.
- *
- * @deprecated
- * @param parent The parent container
- * @return A new <code>CCombo</code>
- */
- @Deprecated
- CCombo createEditableCCombo(Composite parent);
-
- /**
- * Creates a new editable <code>Combo</code>.
- *
- * @param parent The parent container
- * @return A new <code>Combo</code>
- */
- Combo createEditableCombo(Composite parent);
-
- /**
- * Creates a new titled pane (group box).
- *
- * @param parent The parent container
- * @param title The group pane's title
- * @return A new <code>Group</code>
- */
- Group createGroup(Composite parent, String title);
-
- /**
- * Creates a new label that is shown as a hyperlink.
- *
- * @param parent The parent container
- * @param text The label's text
- * @return A new <code>Hyperlink</code>
- */
- Hyperlink createHyperlink(Composite parent, String text);
-
- /**
- * Creates a new label.
- *
- * @param container The parent container
- * @param labelText The label's text
- * @return A new <code>Label</code>
- */
- Label createLabel(Composite container, String labelText);
-
- /**
- * Creates a new list.
- *
- * @param container The parent container
- * @param style The style is usually to tell what type of selection
- * (<code>SWT.MULTI</code> or <code>SWT.SINGLE</code>)
- * @return A new <code>Label</code>
- */
- List createList(Composite container, int style);
-
- /**
- * Creates a new label that can be wrapped on multiple lines.
- *
- * @param container The parent container
- * @param labelText The label's text
- * @return A new <code>FormText</code>
- */
- FormText createMultiLineLabel(Composite container, String labelText);
-
- /**
- * Creates a new editable text area.
- *
- * @param parent The parent container
- * @param parent The number of lines the text area should display
- * @return A new <code>Text</code>
- */
- Text createMultiLineText(Composite parent);
-
- /**
- * Creates a new editable text field that handles password.
- *
- * @param container The parent container
- * @return A new <code>Text</code>
- */
- Text createPasswordText(Composite container);
-
- /**
- * Creates a new push button (toggle between selected and unselected).
- *
- * @param parent The parent container
- * @param text The button's text
- * @return A new <code>Button</code>
- */
- Button createPushButton(Composite parent, String text);
-
- /**
- * Creates a new radio button.
- *
- * @param parent The parent container
- * @param text The button's text
- * @return A new <code>Button</code>
- */
- Button createRadioButton(Composite parent, String text);
-
- /**
- * Creates a new section, which is a collapsable pane with a title bar.
- *
- * @param parent The parent container
- * @param style The style of the title bar, which can be
- * <code>ExpandableComposite.TWISTIE</code> and
- * <code>ExpandableComposite.TITLE_BAR</code>
- * @return A new <code>Section</code>
- */
- Section createSection(Composite parent, int style);
-
- /**
- * Creates a new spinner.
- *
- * @param parent The parent container
- * @return A new <code>Spinner</code>
- */
- Spinner createSpinner(Composite parent);
-
- /**
- * Creates a new table.
- *
- * @param container The parent container
- * @param style The style to apply to the table
- * @return A new <code>Table</code>
- */
- Table createTable(Composite parent, int style);
-
- /**
- * Creates a new editable text field.
- *
- * @param container The parent container
- * @return A new <code>Text</code>
- */
- Text createText(Composite parent);
-
- /**
- * Creates a new tri-state check box.
- *
- * @param parent The parent container
- * @param text The button's text
- * @return A new <code>Button</code> that has 3 selection states
- */
- Button createTriStateCheckBox(Composite parent, String text);
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptCommonUiMessages.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptCommonUiMessages.java
deleted file mode 100644
index 75e14336c4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptCommonUiMessages.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Localized messages used by Dali UI.
- *
- * @version 3.0
- * @since 1.0
- */
-public class JptCommonUiMessages {
-
-
- public static String Boolean_True;
- public static String Boolean_False;
-
- public static String DefaultEmpty;
- public static String DefaultWithOneParam;
- public static String NoneSelected;
-
- public static String AddRemovePane_AddButtonText;
- public static String AddRemovePane_RemoveButtonText;
-
- public static String ChooserPane_browseButton;
- public static String ClassChooserPane_dialogMessage;
- public static String ClassChooserPane_dialogTitle;
- public static String PackageChooserPane_dialogMessage;
- public static String PackageChooserPane_dialogTitle;
- public static String EnumComboViewer_default;
- public static String EnumComboViewer_defaultWithDefault;
- public static String NewNameStateObject_nameAlreadyExists;
- public static String NewNameStateObject_nameMustBeSpecified;
-
- public static String OptionalMessageDialog_doNotShowWarning;
-
- private static final String BUNDLE_NAME = "jpt_common_ui"; //$NON-NLS-1$
- private static final Class<?> BUNDLE_CLASS = JptCommonUiMessages.class;
- static {
- NLS.initializeMessages(BUNDLE_NAME, BUNDLE_CLASS);
- }
-
- private JptCommonUiMessages() {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptUIPlugin.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptUIPlugin.java
deleted file mode 100644
index 6cbe2d57c1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/JptUIPlugin.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.osgi.service.debug.DebugOptions;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * Common Dali UI plug-in behavior.
- * See JptPlugin
- */
-public class JptUIPlugin
- extends AbstractUIPlugin
-{
- protected BundleContext bundleContext;
- protected ServiceTracker<DebugOptions, DebugOptions> debugOptionsServiceTracker;
-
-
- protected JptUIPlugin() {
- super();
- }
-
-
- // ********** logging **********
-
- /**
- * Log the specified message with a severity of
- * {@link IStatus#ERROR ERROR}.
- * @see #log(int, String)
- * @see IStatus
- */
- public void logError(String message) {
- this.log(IStatus.ERROR, message);
- }
-
- /**
- * Log the specified message with the specified severity.
- * @see IStatus#getSeverity()
- */
- public void log(int severity, String message) {
- this.log(severity, message, null);
- }
-
- /**
- * Log the specified exception or error with a severity of
- * {@link IStatus#ERROR ERROR}.
- * @see #log(int, Throwable)
- * @see IStatus
- */
- public void logError(Throwable throwable) {
- this.log(IStatus.ERROR, throwable);
- }
-
- /**
- * Log the specified exception or error with the specified severity.
- * @see IStatus#getSeverity()
- */
- public void log(int severity, Throwable throwable) {
- this.log(severity, throwable.getLocalizedMessage(), throwable);
- }
-
- /**
- * Log the specified message and exception or error with a severity of
- * {@link IStatus#ERROR ERROR}.
- * @see #log(int, String, Throwable)
- * @see IStatus
- */
- public void logError(String msg, Throwable throwable) {
- this.log(IStatus.ERROR, msg, throwable);
- }
-
- /**
- * Log the specified message and exception or error
- * with the specified severity.
- * @see IStatus#getSeverity()
- * @see IStatus#getCode()
- */
- public void log(int severity, String msg, Throwable throwable) {
- this.log(severity, IStatus.OK, msg, throwable);
- }
-
- /**
- * Log the specified message and exception or error
- * with the specified severity and code.
- * @see IStatus#getSeverity()
- * @see IStatus#getCode()
- */
- public void log(int severity, int code, String msg, Throwable throwable) {
- this.getLog().log(new Status(severity, this.getPluginID(), code, msg, throwable));
- }
-
-
- // ********** debug options **********
-
- /**
- * Return the specified debug option as a <code>boolean</code> value.
- * Return <code>false</code> if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public boolean getBooleanDebugOption(String option) {
- return this.getBooleanDebugOption(option, false);
- }
-
- /**
- * Return the specified debug option as a <code>boolean</code> value.
- * Return the specified default value if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public boolean getBooleanDebugOption(String option, boolean defaultValue) {
- String value = this.getDebugOption(option);
- return (value == null) ? defaultValue : Boolean.parseBoolean(value.trim());
- }
-
- /**
- * Return the specified debug option as an <code>int</code> value.
- * Return <code>-1</code> if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public int getIntegerDebugOption(String option) {
- return this.getIntegerDebugOption(option, -1);
- }
-
- /**
- * Return the specified debug option as an <code>int</code> value.
- * Return the specified default value if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public int getIntegerDebugOption(String option, int defaultValue) {
- String value = this.getDebugOption(option);
- return (value == null) ? defaultValue : Integer.parseInt(value.trim());
- }
-
- /**
- * Return the specified debug option.
- * Return <code>null</code> if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public String getDebugOption(String option) {
- return this.getDebugOption(option, null);
- }
-
- /**
- * Return the specified debug option.
- * Return the specified default value if no such option is found.
- * <p>
- * The debug option is within the scope of the plug-in's debug options
- * (e.g. for the plug-in <code>"org.eclipse.jpt.common.core"</code>,
- * the specified option <code>"foo"</code> will be mapped to
- * the {@link Platform} option
- * <code>"org.eclipse.jpt.common.core/debug/foo"</code>).
- */
- public String getDebugOption(String option, String defaultValue) {
- return this.isDebugging() ? this.getDebugOption_(option, defaultValue) : defaultValue;
- }
-
- protected String getDebugOption_(String option, String defaultValue) {
- if (StringTools.stringIsEmpty(option)) {
- throw new IllegalArgumentException("debug option cannot be blank"); //$NON-NLS-1$
- }
- String value = this.getDebugOption_(option);
- return (value != null) ? value : defaultValue;
- }
-
- protected String getDebugOption_(String option) {
- DebugOptions debugOptions = this.getDebugOptions();
- return (debugOptions == null) ? null : debugOptions.getOption(this.getPluginDebugOption() + option);
- }
-
- protected DebugOptions getDebugOptions() {
- ServiceTracker<DebugOptions, DebugOptions> tracker = this.getDebugOptionsServiceTracker();
- return (tracker == null) ? null : tracker.getService();
- }
-
- private synchronized ServiceTracker<DebugOptions, DebugOptions> getDebugOptionsServiceTracker() {
- if (this.isActive() && (this.debugOptionsServiceTracker == null)) {
- this.debugOptionsServiceTracker = this.buildDebugOptionsServiceTracker();
- this.debugOptionsServiceTracker.open();
- }
- return this.debugOptionsServiceTracker;
- }
-
- private ServiceTracker<DebugOptions, DebugOptions> buildDebugOptionsServiceTracker() {
- return new ServiceTracker<DebugOptions, DebugOptions>(this.bundleContext, DebugOptions.class, null);
- }
-
- /**
- * Return the plug-in's debug option path.
- */
- protected String getPluginDebugOption() {
- return this.getPluginID() + DEBUG_OPTION_SCOPE;
- }
- protected static final String DEBUG_OPTION_SCOPE = "/debug/"; //$NON-NLS-1$
-
-
- // ********** plug-in lifecycle **********
-
- @Override
- public synchronized void start(BundleContext context) throws Exception {
- super.start(context);
- this.bundleContext = context;
- }
-
- @Override
- public synchronized void stop(BundleContext context) throws Exception {
- try {
- this.stop_();
- } finally {
- this.bundleContext = null;
- super.stop(context);
- }
- }
-
- protected void stop_() throws Exception {
- if (this.debugOptionsServiceTracker != null) {
- this.debugOptionsServiceTracker.close();
- this.debugOptionsServiceTracker = null;
- }
- }
-
-
- // ********** misc **********
-
- public String getPluginID() {
- return this.getBundle().getSymbolicName();
- }
-
- /**
- * Return whether the plug-in is active; i.e. it has been
- * {@link #start(BundleContext) started}.
- */
- public synchronized boolean isActive() {
- return this.bundleContext != null;
- }
-
- /**
- * Return whether the plug-in is inactive; i.e. it has been
- * {@link #stop(BundleContext) stopped} or not yet
- * {@link #start(BundleContext) started}.
- */
- public boolean isInactive() {
- return ! this.isActive();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/Tracing.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/Tracing.java
deleted file mode 100644
index 7826015d18..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/Tracing.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jpt.common.ui.JptCommonUiPlugin;
-
-/**
- * This tracing class manages to convert the string value into boolean values or
- * integer values that are associated with the tracing debug flags. Those flags
- * are specified in the .options file. The supported keys are defined here as
- * constants for quick reference.
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public final class Tracing
-{
- /**
- * A constant used to retrieve the value associated with "/debug".
- */
- public static final String DEBUG = "/debug";
-
- /**
- * A constant used to retrieve the value associated with "/debug/ui/db".
- */
- public static final String UI_DB = "/debug/ui/db";
-
- /**
- * A constant used to retrieve the value associated with "/debug/ui/detailsView".
- */
- public static final String UI_DETAILS_VIEW = "/debug/ui/detailsView";
-
- /**
- * A constant used to retrieve the value associated with "/debug/ui/layout".
- */
- public static final String UI_LAYOUT = "/debug/ui/layout";
-
- /**
- * A constant used to retrieve the value associated with "/unit-tests".
- */
- public static final String UNIT_TESTS = "/unit-tests";
-
- /**
- * Can't instantiate this <code>Tracing</code> class.
- */
- private Tracing()
- {
- super();
- throw new UnsupportedOperationException("Tracing cannot be instantiated");
- }
-
- /**
- * Retrieves the debug value associated with the given flag. The default
- * value is <code>false</code>.
- *
- * @param flag The flag to retrieve the debug value, which should be
- * contained in the .options file, the flag should start with "/"
- * @return <code>true</code> if the given flag is active; <code>false</code>
- * otherwise
- */
- public static boolean booleanDebugOption(String flag)
- {
- return booleanDebugOption(flag, false);
- }
-
- /**
- * Retrieves the debug value associated with the given flag.
- *
- * @param flag The flag to retrieve the debug value, which should be
- * contained in the .options file, the flag should start with "/"
- * @param defaultValue The default value if the value associated with the
- * given flag could not be found
- * @return <code>true</code> if the given flag is active; <code>false</code>
- * otherwise
- */
- public static boolean booleanDebugOption(String flag, boolean defaultValue)
- {
- String string = Platform.getDebugOption(JptCommonUiPlugin.PLUGIN_ID + flag);
- return (string == null) ? defaultValue : Boolean.parseBoolean(string.trim());
- }
-
- /**
- * Retrieves the debug value associated with the given flag. The default value
- * is 0.
- *
- * @param flag The flag to retrieve the debug value, which should be
- * contained in the .options file, the flag should start with "/"
- * @return The value associated with the given flag, or the given default
- * value
- */
- public static int intDebugOption(String flag)
- {
- return intDebugOption(flag, 0);
- }
-
- /**
- * Retrieves the debug value associated with the given flag.
- *
- * @param flag The flag to retrieve the debug value, which should be
- * contained in the .options file, the flag should start with "/"
- * @param defaultValue The default value if the value associated with the
- * given flag could not be found
- * @return The value associated with the given flag, or the given default
- * value
- */
- public static int intDebugOption(String flag, int defaultValue)
- {
- String string = Platform.getDebugOption(JptCommonUiPlugin.PLUGIN_ID + flag);
- return (string == null) ? defaultValue : Integer.parseInt(string);
- }
-
- /**
- * Logs the given messages, appends it with this plug-in id.
- *
- * @param message The message to be logged
- */
- public static void log(String message)
- {
- System.out.print("[" + JptCommonUiPlugin.PLUGIN_ID + "] ");
- System.out.println(message);
- }
-
- /**
- * Retrieves the debug value associated with the given flag. The default value
- * is an empty string.
- *
- * @param flag The flag to retrieve the debug value, which should be
- * contained in the .options file, the flag should start with "/"
- * @return The value associated with the given flag, or the given default
- * value
- */
- public static String stringDebugOption(String flag)
- {
- return stringDebugOption(flag, "");
- }
-
- /**
- * Retrieves the debug value associated with the given flag.
- *
- * @param flag The flag to retrieve the debug value, which should be
- * contained in the .options file, the flag should start with "/"
- * @param defaultValue The default value if the value associated with the
- * given flag could not be found
- * @return The value associated with the given flag, or the given default
- * value
- */
- public static String stringDebugOption(String flag, String defaultValue)
- {
- String string = Platform.getDebugOption(JptCommonUiPlugin.PLUGIN_ID + flag);
- return (string != null) ? string : defaultValue;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/dialogs/OptionalMessageDialog.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/dialogs/OptionalMessageDialog.java
deleted file mode 100644
index bf281fc4de..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/dialogs/OptionalMessageDialog.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package org.eclipse.jpt.common.ui.internal.dialogs;
-
-import org.eclipse.jdt.internal.ui.JavaPlugin;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-
-/**
- * A <code>OptionalMessageDialog</code> is a dialog that has a check box allowing the
- * option to no longer show the dialog in the future.
- */
-public abstract class OptionalMessageDialog extends MessageDialog {
-
- private static final String CHECKBOX_TEXT = JptCommonUiMessages.OptionalMessageDialog_doNotShowWarning;
-
- // Dialog store id constants
- private static final String STORE_ID = "OptionalMessageDialog.hide."; //$NON-NLS-1$
-
- public static final int NOT_SHOWN = IDialogConstants.CLIENT_ID + 1;
-
- private final String id;
-
- private final String checkBoxText;
-
- /**
- * Creates a dialog with the given parent.
- *
- * @param parentShell
- * object that returns the current parent shell
- */
- public OptionalMessageDialog(String id, Shell parentShell, String dialogTitle, String dialogMessage, int dialogType, String[] buttonLabels, int defaultButtonIndex) {
- this(id, parentShell, dialogTitle, dialogMessage, dialogType, buttonLabels, defaultButtonIndex, CHECKBOX_TEXT);
- }
-
- /**
- * Creates a dialog with the given parent and a checkbox with the labeled with the text in <code>checkBoxText</code>
- *
- * @param parentShell
- * object that returns the current parent shell
- */
- public OptionalMessageDialog(String id, Shell parentShell, String dialogTitle, String dialogMessage, int dialogType, String[] buttonLabels, int defaultButtonIndex, String checkBoxText) {
- super(parentShell, dialogTitle, null, dialogMessage, dialogType, buttonLabels, defaultButtonIndex);
- this.id = id;
- this.checkBoxText = checkBoxText;
- }
-
- @Override
- protected Control createCustomArea(Composite parent) {
- final Button checkbox = new Button(parent, SWT.CHECK);
- checkbox.setText(this.checkBoxText);
- checkbox.setSelection(false);
- checkbox.setLayoutData(new GridData(GridData.FILL_BOTH));
- checkbox.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- setDialogEnabled(id, !((Button)e.widget).getSelection());
- }
- });
- return checkbox;
- }
-
- /**
- * Returns this dialog settings
- *
- * @return the settings to be used
- */
- private static IDialogSettings getDialogSettings() {
- IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
- settings= settings.getSection(STORE_ID);
- if (settings == null)
- settings= JavaPlugin.getDefault().getDialogSettings().addNewSection(STORE_ID);
- return settings;
- }
-
- /**
- * Answers whether the optional dialog is enabled and should be shown.
- */
- public static boolean isDialogEnabled(String key) {
- IDialogSettings settings= getDialogSettings();
- return !settings.getBoolean(key);
- }
-
- /**
- * Sets whether the optional dialog is enabled and should be shown.
- */
- public static void setDialogEnabled(String key, boolean isEnabled) {
- IDialogSettings settings= getDialogSettings();
- settings.put(key, !isEnabled);
- }
-
- /**
- * Clears all remembered information about hidden dialogs
- */
- public static void clearAllRememberedStates() {
- IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings();
- settings.addNewSection(STORE_ID);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemExtendedLabelProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemExtendedLabelProvider.java
deleted file mode 100644
index affc4ca4ac..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemExtendedLabelProvider.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProvider;
-import org.eclipse.jpt.common.ui.jface.ItemLabelProvider;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Abstract {@link ItemLabelProvider} that provides support for listening to an
- * {@link #item} and notifying the
- * {@link org.eclipse.jpt.common.ui.jface.ItemLabelProvider.Manager manager}
- * whenever the item changes in a significant way.
- * <p>
- * Subclasses can implement the following methods if the corresponding aspects
- * of the {@link #item} change:<ul>
- * <li>{@link #buildImageModel()}<br>
- * Return a {@link PropertyValueModel} that represents the item's image
- * <li>{@link #buildTextModel()}<br>
- * Return a {@link PropertyValueModel} that represents the item's text
- * <li>{@link #buildDescriptionModel()}<br>
- * Return a {@link PropertyValueModel} that represents the item's description
- * </ul>
- * Alternatively, subclasses can implement the following methods if the
- * corresponding aspects of the {@link #item} do <em>not</em> change:<ul>
- * <li>{@link #getImage()}<br>
- * Return the item's image
- * <li>{@link #getText()}<br>
- * Return the item's text
- * <li>{@link #getDescription()}<br>
- * Return the item's description
- * </ul>
- * For each aspect (image, text, and description) one and only one of the two
- * methods must be overridden.
- *
- * @see StaticItemExtendedLabelProvider
- */
-public abstract class AbstractItemExtendedLabelProvider<I>
- implements ItemExtendedLabelProvider
-{
- protected final ItemLabelProvider.Manager manager;
-
- protected final I item;
-
- protected volatile PropertyChangeListener listener;
-
- protected volatile PropertyValueModel<Image> imageModel;
-
- protected volatile PropertyValueModel<String> textModel;
-
- protected volatile PropertyValueModel<String> descriptionModel;
-
-
- protected AbstractItemExtendedLabelProvider(I item, ItemLabelProvider.Manager manager) {
- this.item = item;
- this.manager = manager;
- }
-
-
- // ********** image **********
-
- public Image getImage() {
- return this.getImageModel().getValue();
- }
-
- /**
- * Return the image model (lazy-initialized).
- */
- protected synchronized PropertyValueModel<Image> getImageModel() {
- if (this.imageModel == null) {
- this.imageModel = this.buildImageModel();
- this.engageImageModel();
- }
- return this.imageModel;
- }
-
- /**
- * Construct an image model.
- */
- protected PropertyValueModel<Image> buildImageModel() {
- throw new UnsupportedOperationException();
- }
-
- protected void engageImageModel() {
- this.imageModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.getListener());
- }
-
- protected void disengageImageModel() {
- this.imageModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- }
-
- protected void disposeImageModel() {
- if (this.imageModel != null) {
- this.disengageImageModel();
- this.imageModel = null;
- }
- }
-
-
- // ********** text **********
-
- public String getText() {
- return this.getTextModel().getValue();
- }
-
- /**
- * Return the text model (lazy-initialized).
- */
- protected synchronized PropertyValueModel<String> getTextModel() {
- if (this.textModel == null) {
- this.textModel = this.buildTextModel();
- this.engageTextModel();
- }
- return this.textModel;
- }
-
- /**
- * Construct a text model.
- */
- protected PropertyValueModel<String> buildTextModel() {
- throw new UnsupportedOperationException();
- }
-
- protected void engageTextModel() {
- this.textModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.getListener());
- }
-
- protected void disengageTextModel() {
- this.textModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- }
-
- protected void disposeTextModel() {
- if (this.textModel != null) {
- this.disengageTextModel();
- this.textModel = null;
- }
- }
-
-
- // ********** description **********
-
- public String getDescription() {
- return this.getDescriptionModel().getValue();
- }
-
- /**
- * Return the description model (lazy-initialized).
- */
- protected synchronized PropertyValueModel<String> getDescriptionModel() {
- if (this.descriptionModel == null) {
- this.descriptionModel = this.buildDescriptionModel();
- this.engageDescriptionModel();
- }
- return this.descriptionModel;
- }
-
- /**
- * Construct a description model.
- */
- protected PropertyValueModel<String> buildDescriptionModel() {
- throw new UnsupportedOperationException();
- }
-
- protected void engageDescriptionModel() {
- this.descriptionModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.getListener());
- }
-
- protected void disengageDescriptionModel() {
- this.descriptionModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- }
-
- protected void disposeDescriptionModel() {
- if (this.descriptionModel != null) {
- this.disengageDescriptionModel();
- this.descriptionModel = null;
- }
- }
-
-
- // ********** listener **********
-
- protected synchronized PropertyChangeListener getListener() {
- if (this.listener == null) {
- this.listener = this.buildListener();
- }
- return this.listener;
- }
-
- /**
- * Build a listener that will listen to the {@link #imageModel},
- * {@link #textModel}, and {@link #descriptionModel}.
- */
- protected PropertyChangeListener buildListener() {
- return new Listener();
- }
-
- /* CU private */ class Listener
- extends PropertyChangeAdapter
- {
- @Override
- public void propertyChanged(PropertyChangeEvent event) {
- AbstractItemExtendedLabelProvider.this.itemChanged();
- }
- }
-
- /* CU private */ void itemChanged() {
- this.manager.updateLabel(this.item);
- }
-
-
- // ********** dispose **********
-
- public synchronized void dispose() {
- this.disposeImageModel();
- this.disposeTextModel();
- this.disposeDescriptionModel();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.item);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemStructuredStateProviderManager.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemStructuredStateProviderManager.java
deleted file mode 100644
index 0bf4676761..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemStructuredStateProviderManager.java
+++ /dev/null
@@ -1,280 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import java.util.HashMap;
-import org.eclipse.jface.viewers.BaseLabelProvider;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProvider;
-import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProviderFactory;
-import org.eclipse.jpt.common.ui.jface.ItemLabelProvider;
-import org.eclipse.jpt.common.ui.jface.ItemStructuredContentProvider;
-import org.eclipse.jpt.common.ui.jface.StructuredStateProvider;
-import org.eclipse.jpt.common.utility.internal.RunnableAdapter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * This provider maintains caches of item content and label providers, each
- * keyed by item. This allows the providers to listen to the items and update
- * the viewer as necessary.
- * <p>
- * <strong>NB:</strong> This class, if used as a label provider should typically
- * be used also as a content provider for the same viewer. Otherwise, the item
- * label providers will not be disposed until the viewer is disposed; because
- * the item label providers are disposed (here) as their associated items are
- * disposed by their item content providers, which are listening to the items.
- * This is only a problem if the items in the tree can be removed, thus leaking
- * stale item label providers in the manager's cache. The default behavior is
- * to disallow using the manager as only a label provider (see
- * {@link #checkViewer()}).
- *
- * @see ItemStructuredContentProvider
- * @see ItemExtendedLabelProvider
- */
-public abstract class AbstractItemStructuredStateProviderManager<V extends StructuredViewer, CP extends ItemStructuredContentProvider>
- extends BaseLabelProvider
- implements StructuredStateProvider, ItemStructuredContentProvider.Manager, ItemExtendedLabelProvider.Manager
-{
- /**
- * May be <code>null</code>.
- */
- protected final ItemExtendedLabelProviderFactory itemLabelProviderFactory;
-
- protected final HashMap<Object, CP> itemContentProviders = new HashMap<Object, CP>();
-
- protected final HashMap<Object, ItemExtendedLabelProvider> itemLabelProviders = new HashMap<Object, ItemExtendedLabelProvider>();
-
- protected volatile V viewer;
-
-
- protected AbstractItemStructuredStateProviderManager(ItemExtendedLabelProviderFactory itemLabelProviderFactory) {
- super();
- this.itemLabelProviderFactory = itemLabelProviderFactory;
- }
-
-
- // ********** content provider **********
-
- @SuppressWarnings("unchecked")
- public synchronized void inputChanged(Viewer v, Object oldInput, Object newInput) {
- if (oldInput != newInput) {
- this.disposeProviders();
- }
- this.viewer = (V) v;
- }
-
- public Object[] getElements(Object inputElement) {
- CP provider = this.getItemContentProvider(inputElement);
- return (provider == null) ? EMPTY_ARRAY : provider.getElements();
- }
-
-
- // ********** label provider **********
-
- public Image getImage(Object element) {
- ItemLabelProvider provider = this.getItemLabelProvider(element);
- return (provider == null) ? null :provider.getImage();
- }
-
- public String getText(Object element) {
- ItemLabelProvider provider = this.getItemLabelProvider(element);
- return (provider == null) ? null : provider.getText();
- }
-
- public String getDescription(Object element) {
- ItemExtendedLabelProvider provider = this.getItemLabelProvider(element);
- return (provider == null) ? null : provider.getDescription();
- }
-
-
- // ********** item provider caches **********
-
- protected synchronized CP getItemContentProvider(Object item) {
- CP provider = this.itemContentProviders.get(item);
- if (provider == null) {
- if ( ! this.itemContentProviders.containsKey(item)) { // null is an allowed value
- provider = this.buildItemContentProvider(item);
- this.itemContentProviders.put(item, provider);
- }
- }
- return provider;
- }
-
- protected abstract CP buildItemContentProvider(Object item);
-
- protected synchronized ItemExtendedLabelProvider getItemLabelProvider(Object item) {
- ItemExtendedLabelProvider provider = this.itemLabelProviders.get(item);
- if (provider == null) {
- if ( ! this.itemLabelProviders.containsKey(item)) { // null is an allowed value
- provider = this.buildItemLabelProvider(item);
- this.itemLabelProviders.put(item, provider);
- }
- }
- return provider;
- }
-
- protected ItemExtendedLabelProvider buildItemLabelProvider(Object item) {
- this.checkViewer();
- return (this.itemLabelProviderFactory == null) ? null : this.itemLabelProviderFactory.buildProvider(item, this);
- }
-
- /**
- * The viewer passes itself to its content provider; so it will be
- * initialized by the time we get here if this provider is the
- * viewer's content provider.
- */
- protected void checkViewer() {
- if (this.viewer == null) {
- throw new IllegalStateException("This provider must be used as a content provider *as well as* a label provider."); //$NON-NLS-1$
- }
- }
-
-
- // ********** update elements **********
-
- /**
- * Dispatch to the UI thread.
- */
- public void updateElements(Object inputElement) {
- this.execute(new UpdateElementsRunnable(inputElement));
- }
-
- /* CU private */ class UpdateElementsRunnable
- extends RunnableAdapter
- {
- private final Object inputElement;
- UpdateElementsRunnable(Object inputElement) {
- super();
- this.inputElement = inputElement;
- }
- @Override
- public void run() {
- AbstractItemStructuredStateProviderManager.this.updateElements_(this.inputElement);
- }
- }
-
- /**
- * Update the specified item's elements.
- */
- /* CU private */ void updateElements_(Object inputElement) {
- if (this.viewerIsAlive()) {
- this.viewer.refresh(inputElement);
- }
- }
-
-
- // ********** update label **********
-
- /**
- * Dispatch to the UI thread.
- */
- public void updateLabel(Object item) {
- this.execute(new UpdateLabelRunnable(item));
- }
-
- /* CU private */ class UpdateLabelRunnable
- extends RunnableAdapter
- {
- private final Object item;
- UpdateLabelRunnable(Object item) {
- super();
- this.item = item;
- }
- @Override
- public void run() {
- AbstractItemStructuredStateProviderManager.this.updateLabel_(this.item);
- }
- }
-
- /**
- * Update the specified item's label.
- */
- /* CU private */ void updateLabel_(Object item) {
- if (this.viewerIsAlive()) {
- this.fireLabelProviderChanged(new LabelProviderChangedEvent(this, item));
- }
- }
-
-
- // ********** update description **********
-
- public void updateDescription(Object item) {
- // NOP - currently there is no way affect the status bar;
- // it is updated when the viewer's selection changes
- }
-
-
- // ********** misc **********
-
- protected void execute(Runnable runnable) {
- SWTUtil.execute(this.viewer, runnable);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
- protected boolean viewerIsAlive() {
- Control control = (this.viewer == null) ? null : this.viewer.getControl();
- return (control != null) && ! control.isDisposed();
- }
-
-
- // ********** dispose **********
-
- /**
- * Disposes all items
- */
- @Override
- public synchronized void dispose() {
- this.disposeProviders();
- super.dispose();
- }
-
- protected synchronized void disposeProviders() {
- // coded this way because the item providers will call back to this
- // manager to dispose their children when they are disposed
- while ( ! this.itemContentProviders.isEmpty()) {
- this.dispose_(this.itemContentProviders.keySet().iterator().next());
- }
- // dispose the label providers for any items that did not have a content provider;
- // although that is most likely a bug, it is allowed and handled
- while (! this.itemLabelProviders.isEmpty()) {
- this.dispose_(this.itemLabelProviders.keySet().iterator().next());
- }
- }
-
- /**
- * Dispose the specified item's content and label providers.
- */
- public synchronized void dispose(Object item) {
- this.dispose_(item);
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void dispose_(Object item) {
- ItemStructuredContentProvider icp = this.itemContentProviders.remove(item);
- if (icp != null) {
- icp.dispose();
- }
- ItemLabelProvider ilp = this.itemLabelProviders.remove(item);
- if (ilp != null) {
- ilp.dispose();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemTreeContentProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemTreeContentProvider.java
deleted file mode 100644
index c79b5a61f6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractItemTreeContentProvider.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import java.util.ConcurrentModificationException;
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-
-/**
- * Abstract {@link ItemTreeContentProvider} that provides support for listening to an
- * {@link #item} and notifying the
- * {@link org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider.Manager manager}
- * whenever the item's children change in a significant way.
- * <p>
- * Subclasses must implement the following method:<ul>
- * <li>{@link #buildChildrenModel()}<br>
- * Return a {@link CollectionValueModel} that represents the item's children
- * </ul>
- *
- * @see StaticItemTreeContentProvider
- */
-public abstract class AbstractItemTreeContentProvider<I, C>
- implements ItemTreeContentProvider
-{
- protected final Manager manager;
-
- protected final I item;
-
- protected volatile CollectionValueModel<C> childrenModel;
-
- protected volatile CollectionChangeListener childrenListener;
-
-
- protected AbstractItemTreeContentProvider(I item, Manager manager) {
- this.item = item;
- this.manager = manager;
- }
-
-
- // ********** children **********
-
- /**
- * Typical implementation for a tree.
- */
- public Object[] getElements() {
- return this.getChildren();
- }
-
- // TODO bjv
- public Object[] getChildren() {
- while (true) {
- try {
- return ArrayTools.array(this.getChildrenModel());
- } catch (ConcurrentModificationException ex) {
- // try again - hack: need to make value model stuff thread-safe...
- }
- }
- }
-
- /**
- * Return the children model (lazy-initialized).
- */
- protected synchronized CollectionValueModel<C> getChildrenModel() {
- if (this.childrenModel == null) {
- this.childrenModel = this.buildChildrenModel();
- this.childrenListener = this.buildChildrenListener();
- this.engageChildrenModel();
- }
- return this.childrenModel;
- }
-
- /**
- * Construct a children model.
- */
- protected abstract CollectionValueModel<C> buildChildrenModel();
-
- /**
- * Override with potentially more efficient logic.
- */
- public boolean hasChildren() {
- return this.getChildrenModel().iterator().hasNext();
- }
-
- protected void engageChildrenModel() {
- this.childrenModel.addCollectionChangeListener(CollectionValueModel.VALUES, this.childrenListener);
- }
-
- protected void disengageChildrenModel() {
- this.childrenModel.removeCollectionChangeListener(CollectionValueModel.VALUES, this.childrenListener);
- }
-
-
- // ********** listener **********
-
- protected CollectionChangeListener buildChildrenListener() {
- return new ChildrenListener();
- }
-
- protected class ChildrenListener
- extends CollectionChangeAdapter
- {
- @Override
- @SuppressWarnings("unchecked")
- public void itemsAdded(CollectionAddEvent event) {
- AbstractItemTreeContentProvider.this.childrenAdded((Iterable<C>) event.getItems());
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void itemsRemoved(CollectionRemoveEvent event) {
- AbstractItemTreeContentProvider.this.childrenRemoved((Iterable<C>) event.getItems());
- }
-
- /**
- * <strong>NB:</strong> Any removed children will malinger until the
- * manager itself is disposed.
- */
- @Override
- public void collectionChanged(CollectionChangeEvent event) {
- AbstractItemTreeContentProvider.this.childrenChanged();
- }
-
- /**
- * <strong>NB:</strong> Any removed children will malinger until the
- * manager itself is disposed.
- */
- @Override
- public void collectionCleared(CollectionClearEvent event) {
- AbstractItemTreeContentProvider.this.childrenChanged();
- }
- }
-
- protected void childrenAdded(@SuppressWarnings("unused") Iterable<C> children) {
- this.manager.updateChildren(this.item);
- }
-
- protected void childrenRemoved(Iterable<C> children) {
- this.manager.updateChildren(this.item);
- for (Object child : children) {
- this.manager.dispose(child);
- }
- }
-
- protected void childrenChanged() {
- this.manager.updateChildren(this.item);
- }
-
-
- // ********** dispose **********
-
- public synchronized void dispose() {
- if (this.childrenModel != null) {
- this.dispose_();
- }
- }
-
- /**
- * Pre-condition: {@link #childrenModel} is not <code>null</code>.
- */
- protected void dispose_() {
- for (Object child : this.childrenModel) {
- this.manager.dispose(child);
- }
- this.disengageChildrenModel();
- this.childrenModel = null;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.item);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractSelectionProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractSelectionProvider.java
deleted file mode 100644
index cd7e6ed8d1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/AbstractSelectionProvider.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.core.commands.common.EventManager;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Provide support for {@link ISelectionChangedListener selection change
- * listeners} and {@link #fireSelectionChanged(ISelection) the safe firing of
- * events}.
- */
-public abstract class AbstractSelectionProvider
- extends EventManager
- implements ISelectionProvider
-{
- protected AbstractSelectionProvider() {
- super();
- }
-
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- this.addListenerObject(listener);
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- this.removeListenerObject(listener);
- }
-
- protected void fireSelectionChanged(ISelection selection) {
- SelectionChangedEvent event = new SelectionChangedEvent(this, selection);
- for (Object listener : this.getListeners()) {
- SafeRunner.run(new ListenerNotifier(listener, event));
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-
- // ********** listener notifier **********
-
- /**
- * A runnable that forwards an event to a listener and handles any
- * exceptions thrown by the listener by notifying the user via a dialog.
- */
- /* CU private */ class ListenerNotifier
- extends SafeRunnable
- {
- private final ISelectionChangedListener listener;
- private final SelectionChangedEvent event;
-
- ListenerNotifier(Object listener, SelectionChangedEvent event) {
- super();
- this.listener = (ISelectionChangedListener) listener;
- this.event = event;
- }
-
- public void run() {
- this.listener.selectionChanged(this.event);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listener);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ArchiveFileViewerFilter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ArchiveFileViewerFilter.java
deleted file mode 100644
index bbff5516fc..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ArchiveFileViewerFilter.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jpt.common.ui.JptCommonUiPlugin;
-
-/**
- * This filter will deny showing any file that are not JAR files or folders
- * that don't contain any JAR files in its sub-hierarchy.
- */
-public class ArchiveFileViewerFilter
- extends ViewerFilter
-{
- private static final String[] archiveExtensions= { "jar", "zip" }; //$NON-NLS-1$ //$NON-NLS-2$
-
-
- public ArchiveFileViewerFilter() {
- super();
- }
-
-
- @Override
- public boolean select(
- Viewer viewer, Object parentElement, Object element) {
- if (element instanceof IFile) {
- return isArchivePath(((IFile)element).getFullPath());
- }
- else if (element instanceof IFolder) {
- IFolder folder = (IFolder) element;
- try {
- for (IResource each : folder.members()) {
- if (select(viewer, folder, each)) {
- return true;
- }
- }
- }
- catch (CoreException ce) {
- // just skip this one, then
- JptCommonUiPlugin.log(ce);
- }
- }
- return false;
- }
-
- public static boolean isArchivePath(IPath path) {
- String ext= path.getFileExtension();
- if (ext != null && ext.length() != 0) {
- for (int i= 0; i < archiveExtensions.length; i++) {
- if (ext.equalsIgnoreCase(archiveExtensions[i])) {
- return true;
- }
- }
- }
- return false;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ContentProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ContentProvider.java
deleted file mode 100644
index 176f774443..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ContentProvider.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Convenience implementation of {@link IContentProvider}.
- */
-public class ContentProvider
- implements IContentProvider
-{
- private static final IContentProvider NULL_PROVIDER = new ContentProvider();
-
- public static IContentProvider nullProvider() {
- return NULL_PROVIDER;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // do nothing
- }
-
- public void dispose() {
- // do nothing
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/EmptySelection.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/EmptySelection.java
deleted file mode 100644
index 089d0f78b1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/EmptySelection.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Empty implementation of {@link ISelection}.
- * Implemented as a singleton.
- */
-public class EmptySelection
- implements ISelection
-{
- public static final ISelection INSTANCE = new EmptySelection();
-
- public static ISelection instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure a single instance.
- */
- private EmptySelection() {
- super();
- }
-
- public boolean isEmpty() {
- return true;
- }
-
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ImageImageDescriptor.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ImageImageDescriptor.java
deleted file mode 100644
index e2079e0227..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ImageImageDescriptor.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-
-/**
- * Image descriptor for an image.
- */
-public class ImageImageDescriptor extends ImageDescriptor
-{
-
- private Image fImage;
-
- /**
- * Constructor for ImagImageDescriptor.
- */
- public ImageImageDescriptor(Image image) {
- super();
- this.fImage = image;
- }
-
- @Override
- public boolean equals(Object obj) {
- return (obj != null) && getClass().equals(obj.getClass()) && this.fImage.equals(((ImageImageDescriptor) obj).fImage);
- }
-
- @Override
- public ImageData getImageData() {
- return this.fImage.getImageData();
- }
-
- @Override
- public int hashCode() {
- return this.fImage.hashCode();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ItemStructuredStateProviderManager.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ItemStructuredStateProviderManager.java
deleted file mode 100644
index 677c1d526f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ItemStructuredStateProviderManager.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProviderFactory;
-import org.eclipse.jpt.common.ui.jface.ItemStructuredContentProvider;
-import org.eclipse.jpt.common.ui.jface.ItemStructuredContentProviderFactory;
-
-/**
- * @see AbstractItemStructuredStateProviderManager
- */
-public class ItemStructuredStateProviderManager
- extends AbstractItemStructuredStateProviderManager<StructuredViewer, ItemStructuredContentProvider>
-{
- /**
- * Never <code>null</code>.
- */
- protected final ItemStructuredContentProviderFactory itemContentProviderFactory;
-
-
- public ItemStructuredStateProviderManager(ItemStructuredContentProviderFactory itemContentProviderFactory) {
- this(itemContentProviderFactory, null);
- }
-
- public ItemStructuredStateProviderManager(ItemStructuredContentProviderFactory itemContentProviderFactory, ItemExtendedLabelProviderFactory itemLabelProviderFactory) {
- super(itemLabelProviderFactory);
- if (itemContentProviderFactory == null) {
- throw new NullPointerException();
- }
- this.itemContentProviderFactory = itemContentProviderFactory;
- }
-
- @Override
- protected ItemStructuredContentProvider buildItemContentProvider(Object item) {
- return this.itemContentProviderFactory.buildProvider(item, this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ItemTreeStateProviderManager.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ItemTreeStateProviderManager.java
deleted file mode 100644
index b5d40efa54..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/ItemTreeStateProviderManager.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProviderFactory;
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider;
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProviderFactory;
-import org.eclipse.jpt.common.ui.jface.TreeStateProvider;
-import org.eclipse.jpt.common.utility.internal.RunnableAdapter;
-
-/**
- * @see AbstractItemStructuredStateProviderManager
- * @see ItemTreeContentProvider
- */
-public class ItemTreeStateProviderManager
- extends AbstractItemStructuredStateProviderManager<TreeViewer, ItemTreeContentProvider>
- implements TreeStateProvider, ItemTreeContentProvider.Manager
-{
- /**
- * Never <code>null</code>.
- */
- protected final ItemTreeContentProviderFactory itemContentProviderFactory;
-
-
- public ItemTreeStateProviderManager(ItemTreeContentProviderFactory itemContentProviderFactory) {
- this(itemContentProviderFactory, null);
- }
-
- public ItemTreeStateProviderManager(ItemTreeContentProviderFactory itemContentProviderFactory, ItemExtendedLabelProviderFactory itemLabelProviderFactory) {
- super(itemLabelProviderFactory);
- if (itemContentProviderFactory == null) {
- throw new NullPointerException();
- }
- this.itemContentProviderFactory = itemContentProviderFactory;
- }
-
-
- // ********** tree content provider **********
-
- public boolean hasChildren(Object element) {
- ItemTreeContentProvider provider = this.getItemContentProvider(element);
- return (provider != null) && provider.hasChildren();
- }
-
- public Object[] getChildren(Object parentElement) {
- ItemTreeContentProvider provider = this.getItemContentProvider(parentElement);
- return (provider == null) ? EMPTY_ARRAY : provider.getChildren();
- }
-
- public Object getParent(Object element) {
- ItemTreeContentProvider provider = this.getItemContentProvider(element);
- return (provider == null) ? null : provider.getParent();
- }
-
- @Override
- protected ItemTreeContentProvider buildItemContentProvider(Object item) {
- return this.itemContentProviderFactory.buildProvider(item, this);
- }
-
-
- // ********** update children **********
-
- /**
- * Dispatch to the UI thread.
- */
- public void updateChildren(Object inputElement) {
- SWTUtil.execute(this.viewer, new UpdateChildrenRunnable(inputElement));
- }
-
- /* CU private */ class UpdateChildrenRunnable
- extends RunnableAdapter
- {
- private final Object element;
- UpdateChildrenRunnable(Object element) {
- super();
- this.element = element;
- }
- @Override
- public void run() {
- ItemTreeStateProviderManager.this.updateChildren_(this.element);
- }
- }
-
- /**
- * Update the specified item's children.
- */
- /* CU private */ void updateChildren_(Object element) {
- if (this.viewerIsAlive()) {
- this.viewer.refresh(element, false);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/LabelProviderAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/LabelProviderAdapter.java
deleted file mode 100644
index e5e7ac18f2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/LabelProviderAdapter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Convenience implementation of {@link ILabelProviderListener}.
- */
-public class LabelProviderAdapter
- implements ILabelProviderListener
-{
- public void labelProviderChanged(LabelProviderChangedEvent event) {
- // do nothing
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorContentProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorContentProvider.java
deleted file mode 100644
index 17ba135212..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorContentProvider.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProviderFactory;
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProviderFactory;
-import org.eclipse.jpt.common.ui.jface.TreeStateProvider;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.navigator.ICommonContentExtensionSite;
-import org.eclipse.ui.navigator.ICommonContentProvider;
-
-/**
- * This content provider delegates to a {@link TreeStateProvider} that is
- * shared with a partner {@link NavigatorLabelProvider label provider}.
- * <p>
- * Concrete subclasses of this provider can be used as the content provider
- * in extensions of <code>org.eclipse.ui.navigator.navigatorContent</code>.
- */
-public abstract class NavigatorContentProvider
- implements ICommonContentProvider
-{
- protected TreeStateProvider delegate;
-
-
- /**
- * Must use zero-argument constructor because the provider is instantiated
- * by the Navigator Content extension point
- * (<code>org.eclipse.ui.navigator.navigatorContent</code>).
- */
- protected NavigatorContentProvider() {
- super();
- }
-
- /**
- * The content provider is initialized first; so we build the delegate
- * here.
- */
- public void init(ICommonContentExtensionSite config) {
- this.delegate = this.buildDelegate();
- }
-
- protected TreeStateProvider buildDelegate() {
- return new ItemTreeStateProviderManager(
- this.buildItemContentProviderFactory(),
- this.buildItemLabelProviderFactory()
- );
- }
-
- /**
- * Return a factory that will build item content providers for the
- * appropriate items in the navigator.
- */
- protected abstract ItemTreeContentProviderFactory buildItemContentProviderFactory();
-
- /**
- * Return a factory that will build item label providers for the
- * appropriate items in the navigator.
- */
- protected abstract ItemExtendedLabelProviderFactory buildItemLabelProviderFactory();
-
- public void inputChanged(Viewer commonViewer, Object oldInput, Object newInput) {
- this.delegate.inputChanged(commonViewer, oldInput, newInput);
- }
-
- public Object[] getElements(Object inputElement) {
- // never called?
- return this.delegate.getElements(inputElement);
- }
-
- public Object getParent(Object element) {
- return this.delegate.getParent(element);
- }
-
- public boolean hasChildren(Object element) {
- return this.hasChildren_(element) || this.delegate.hasChildren(element);
- }
-
- /**
- * Return whether the specified element has children. This method handles
- * any element that is <em>not</em> handled by the {@link #delegate} but is
- * the parent of element(s) that <em>are</em> handled by the
- * {@link #delegate} (i.e. any third-party element that is to hold the
- * provider's elements; e.g. a project). Return <code>false</code> if the
- * element is to be handled by the {@link #delegate}.
- */
- protected abstract boolean hasChildren_(Object element);
-
- public Object[] getChildren(Object element) {
- Object[] children = this.getChildren_(element);
- return (children != null) ? children : this.delegate.getChildren(element);
- }
-
- /**
- * Return the specified element's children. This method handles
- * any element that is <em>not</em> handled by the {@link #delegate} but is
- * the parent of element(s) that <em>are</em> handled by the
- * {@link #delegate} (i.e. any third-party element that is to hold the
- * provider's elements; e.g. a project). Return <code>null</code> if the
- * element is to be handled by the {@link #delegate}.
- */
- protected abstract Object[] getChildren_(Object element);
-
- public void saveState(IMemento memento) {
- // TODO
- }
-
- public void restoreState(IMemento memento) {
- // TODO
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
- public void dispose() {
- this.delegate.dispose();
- }
-
- /**
- * @see NavigatorLabelProvider#getDelegate()
- */
- TreeStateProvider getDelegate() {
- return this.delegate;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorLabelProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorLabelProvider.java
deleted file mode 100644
index d85ae97b22..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/NavigatorLabelProvider.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.BaseLabelProvider;
-import org.eclipse.jface.viewers.LabelProviderChangedEvent;
-import org.eclipse.jpt.common.ui.internal.jface.LabelProviderAdapter;
-import org.eclipse.jpt.common.ui.jface.TreeStateProvider;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.navigator.ICommonContentExtensionSite;
-import org.eclipse.ui.navigator.ICommonLabelProvider;
-
-/**
- * @see NavigatorContentProvider
- * <p>
- * This provider can be used as the label provider
- * in extensions of <code>org.eclipse.ui.navigator.navigatorContent</code>.
- */
-public class NavigatorLabelProvider
- extends BaseLabelProvider
- implements ICommonLabelProvider
-{
- /**
- * "Partner" content provider that holds the tree
- * state provider.
- */
- private NavigatorContentProvider contentProvider;
-
- /**
- * Listen to the delegate provider and forward any events.
- */
- private DelegateListener delegateListener;
-
-
- public NavigatorLabelProvider() {
- super();
- }
-
- /**
- * @see #dispose()
- */
- public void init(ICommonContentExtensionSite config) {
- this.contentProvider = (NavigatorContentProvider) config.getExtension().getContentProvider();
- this.delegateListener = new DelegateListener();
- this.getDelegate().addListener(this.delegateListener);
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- return this.getDelegate().isLabelProperty(element, property);
- }
-
- public Image getImage(Object element) {
- return this.getDelegate().getImage(element);
- }
-
- public String getText(Object element) {
- return this.getDelegate().getText(element);
- }
-
- public String getDescription(Object element) {
- return this.getDelegate().getDescription(element);
- }
-
- public void saveState(IMemento memento) {
- // TODO
- }
-
- public void restoreState(IMemento memento) {
- // TODO
- }
-
- private TreeStateProvider getDelegate() {
- return this.contentProvider.getDelegate();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
- /**
- * NB: The delegate will remove our listener when it is disposed
- * in {@link NavigatorContentProvider#dispose()}. :-(
- * @see BaseLabelProvider#dispose()
- */
- @Override
- public void dispose() {
- super.dispose();
- }
-
-
- // ********** delegate listener **********
-
- /* CU private */ class DelegateListener
- extends LabelProviderAdapter
- {
- @Override
- public void labelProviderChanged(LabelProviderChangedEvent event) {
- NavigatorLabelProvider.this.labelProviderChanged(event);
- }
- }
-
- /* CU private */ void labelProviderChanged(LabelProviderChangedEvent event) {
- // forward the event with *this* provider as the source
- this.fireLabelProviderChanged(new LabelProviderChangedEvent(this, event.getElements()));
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/RunnableWithProgressAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/RunnableWithProgressAdapter.java
deleted file mode 100644
index c32a0fa584..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/RunnableWithProgressAdapter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import java.lang.reflect.InvocationTargetException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Convenience implementation of {@link IRunnableWithProgress}.
- */
-public class RunnableWithProgressAdapter
- implements IRunnableWithProgress
-{
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- // NOP
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SelectionChangedAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SelectionChangedAdapter.java
deleted file mode 100644
index 165ac1c850..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SelectionChangedAdapter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Convenience implementation of {@link ISelectionChangedListener}.
- */
-public class SelectionChangedAdapter
- implements ISelectionChangedListener
-{
- public void selectionChanged(SelectionChangedEvent event) {
- // do nothing
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SimpleItemTreeStateProviderFactoryProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SimpleItemTreeStateProviderFactoryProvider.java
deleted file mode 100644
index 454e7040f4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SimpleItemTreeStateProviderFactoryProvider.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProviderFactory;
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProviderFactory;
-import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Straightforward implementation of {@link ItemTreeStateProviderFactoryProvider}.
- */
-public class SimpleItemTreeStateProviderFactoryProvider
- implements ItemTreeStateProviderFactoryProvider
-{
- private final ItemTreeContentProviderFactory contentProviderFactory;
- private final ItemExtendedLabelProviderFactory labelProviderFactory;
-
-
- public SimpleItemTreeStateProviderFactoryProvider(
- ItemTreeContentProviderFactory contentProviderFactory,
- ItemExtendedLabelProviderFactory labelProviderFactory
- ) {
- super();
- this.contentProviderFactory = contentProviderFactory;
- this.labelProviderFactory = labelProviderFactory;
- }
-
- public ItemTreeContentProviderFactory getItemContentProviderFactory() {
- return this.contentProviderFactory;
- }
-
- public ItemExtendedLabelProviderFactory getItemLabelProviderFactory() {
- return this.labelProviderFactory;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SimpleMessageTreeContent.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SimpleMessageTreeContent.java
deleted file mode 100644
index ca019ef46e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/SimpleMessageTreeContent.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Tree content with a root with a single child, the message that will be
- * displayed in the tree widget.
- * <p>
- * To display a message in a {@link org.eclipse.jface.viewers.TreeViewer}:
- * <pre>
- * TreeViewer treeViewer = ...;
- * treeViewer.setInput(null);
- * treeViewer.setContentProvider(SimpleMessageTreeContent.contentProvider());
- * treeViewer.setLabelProvider(SimpleMessageTreeContent.labelProvider());
- * treeViewer.setInput(new SimpleMessageTreeContent("message"));
- * </pre>
- */
-public class SimpleMessageTreeContent {
- private final String message;
-
- public SimpleMessageTreeContent(String message) {
- super();
- this.message = message;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.message);
- }
-
- public String getMessage() {
- return this.message;
- }
-
-
- // ********** tree content provider **********
-
- public static ITreeContentProvider contentProvider() {
- return CONTENT_PROVIDER;
- }
-
- private static final ITreeContentProvider CONTENT_PROVIDER = new ContentProvider();
-
- /**
- * Content provider for message tree content.
- */
- /* CU private */ static class ContentProvider
- extends TreeContentProvider
- {
- @Override
- public boolean hasChildren(Object element) {
- return (element instanceof SimpleMessageTreeContent);
- }
-
- @Override
- public Object[] getChildren(Object element) {
- if (element instanceof SimpleMessageTreeContent) {
- String msg = ((SimpleMessageTreeContent) element).getMessage();
- return new Object[] { msg };
- }
- return EMPTY_ARRAY;
- }
- }
-
-
- // ********** label provider **********
-
- public static ILabelProvider labelProvider() {
- return LABEL_PROVIDER;
- }
-
- private static final ILabelProvider LABEL_PROVIDER = new LabelProvider();
-
- /**
- * Label provider for message tree content.
- */
- /* CU private */ static class LabelProvider
- extends org.eclipse.jface.viewers.LabelProvider
- {
- @Override
- public String getText(Object element) {
- return (element instanceof String) ? (String) element : null;
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemExtendedLabelProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemExtendedLabelProvider.java
deleted file mode 100644
index 5033a00292..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemExtendedLabelProvider.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Item label provider that contains unchanging image, text, and description.
- */
-public class StaticItemExtendedLabelProvider
- extends StaticItemLabelProvider
- implements ItemExtendedLabelProvider
-{
- protected final String description;
-
- /**
- * Construct an item label provider that returns the specified text
- * but no image. The provider will also return the specified text as the
- * description.
- */
- public StaticItemExtendedLabelProvider(String text) {
- this(null, text);
- }
-
- /**
- * Construct an item label provider that returns the specified image
- * and text. The provider will also return the specified text as the
- * description.
- */
- public StaticItemExtendedLabelProvider(Image image, String text) {
- this(image, text, text);
- }
-
- /**
- * Construct an item label provider that returns the specified image, text,
- * and description.
- */
- public StaticItemExtendedLabelProvider(Image image, String text, String description) {
- super(image, text);
- this.description = description;
- }
-
- public String getDescription() {
- return this.description;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemLabelProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemLabelProvider.java
deleted file mode 100644
index 29415f13b3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemLabelProvider.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jpt.common.ui.jface.ItemLabelProvider;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Item label provider that contains unchanging image and text.
- */
-public class StaticItemLabelProvider
- implements ItemLabelProvider
-{
- protected final Image image;
- protected final String text;
-
- /**
- * Construct an item label provider that returns the specified text but
- * no image.
- */
- public StaticItemLabelProvider(String text) {
- this(null, text);
- }
-
- /**
- * Construct an item label provider that returns the specified image
- * and text.
- */
- public StaticItemLabelProvider(Image image, String text) {
- super();
- this.image = image;
- this.text = text;
- }
-
- public Image getImage() {
- return this.image;
- }
-
- public String getText() {
- return this.text;
- }
-
- public void dispose() {
- // NOP
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.text);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemTreeContentProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemTreeContentProvider.java
deleted file mode 100644
index 4eddce1fa0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StaticItemTreeContentProvider.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Item tree content provider that contains unchanging parent and children.
- *
- * @see org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider.Null
- */
-public class StaticItemTreeContentProvider
- implements ItemTreeContentProvider
-{
- protected final Object parent;
- protected final Object[] children;
-
- /**
- * Construct an item tree content provider for an item with neither
- * a parent nor children.
- */
- public StaticItemTreeContentProvider() {
- this(null);
- }
-
- /**
- * Construct an item tree content provider for an item with the specified
- * parent but no children.
- */
- public StaticItemTreeContentProvider(Object parent) {
- this(parent, EMPTY_ARRAY);
- }
-
- /**
- * Construct an item tree content provider for an item with the specified
- * parent and children.
- */
- public StaticItemTreeContentProvider(Object parent, Object[] children) {
- super();
- if (children == null) {
- throw new NullPointerException();
- }
- this.parent = parent;
- this.children = children;
- }
-
- public Object[] getElements() {
- return this.children;
- }
-
- public Object getParent() {
- return this.parent;
- }
-
- public Object[] getChildren() {
- return this.children;
- }
-
- public boolean hasChildren() {
- return this.children.length > 0;
- }
-
- public void dispose() {
- // NOP
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StructuredContentProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StructuredContentProvider.java
deleted file mode 100644
index 891c15309b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StructuredContentProvider.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-
-/**
- * Convenience implementation of {@link IStructuredContentProvider}.
- */
-public class StructuredContentProvider
- extends ContentProvider
- implements IStructuredContentProvider
-{
- private static final IStructuredContentProvider NULL_PROVIDER = new StructuredContentProvider();
-
- public static IStructuredContentProvider nullProvider() {
- return NULL_PROVIDER;
- }
-
- public Object[] getElements(Object inputElement) {
- return EMPTY_ARRAY;
- }
-
- protected static final Object[] EMPTY_ARRAY = new Object[0];
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StructuredContentProviderAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StructuredContentProviderAdapter.java
deleted file mode 100644
index ca953012ae..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/StructuredContentProviderAdapter.java
+++ /dev/null
@@ -1,265 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.AbstractListViewer;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTListChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionListValueModelAdapter;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * This adapter can be used to keep an AbstractListViewer
- * (e.g. a ListViewer or ComboViewer) in synch with a ListValueModel
- * (or a CollectionValueModel).
- */
-public class StructuredContentProviderAdapter
- implements IStructuredContentProvider
-{
- /** The underlying model list. */
- protected ListValueModel listHolder;
-
- /** The list viewer we keep in synch with the model list. */
- protected final AbstractListViewer listViewer;
-
- /** A listener that allows us to forward changes made to the underlying model list. */
- protected final ListChangeListener listChangeListener;
-
-
- // ********** static **********
-
- /**
- * Adapt the specified list viewer to the specified list holder so they
- * stay in synch.
- */
- public static StructuredContentProviderAdapter adapt(AbstractListViewer listViewer, ListValueModel listHolder) {
- // we need only construct the adapter and it will hook up to the list viewer etc.
- return new StructuredContentProviderAdapter(listViewer, listHolder);
- }
-
- /**
- * Adapt the specified list viewer to the specified list holder so they
- * stay in synch.
- */
- public static StructuredContentProviderAdapter adapt(AbstractListViewer listViewer, CollectionValueModel collectionHolder) {
- // we need only construct the adapter and it will hook up to the list viewer etc.
- return new StructuredContentProviderAdapter(listViewer, collectionHolder);
- }
-
-
- // ********** constructors **********
-
- /**
- * Constructor.
- */
- protected StructuredContentProviderAdapter(AbstractListViewer listViewer, ListValueModel listHolder) {
- super();
- this.listChangeListener = this.buildListChangeListener();
- this.listViewer = listViewer;
- this.listViewer.setContentProvider(this);
- // the list viewer will call back to #inputChanged(Viewer, Object, Object)
- this.listViewer.setInput(listHolder);
- }
-
- /**
- * Constructor.
- */
- protected StructuredContentProviderAdapter(AbstractListViewer listViewer, CollectionValueModel collectionHolder) {
- this(listViewer, new CollectionListValueModelAdapter(collectionHolder));
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildListChangeListener() {
- return new SWTListChangeListenerWrapper(this.buildListChangeListener_());
- }
-
- protected ListChangeListener buildListChangeListener_() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent e) {
- StructuredContentProviderAdapter.this.itemsAdded(e);
- }
- public void itemsRemoved(ListRemoveEvent e) {
- StructuredContentProviderAdapter.this.itemsRemoved(e);
- }
- public void itemsReplaced(ListReplaceEvent e) {
- StructuredContentProviderAdapter.this.itemsReplaced(e);
- }
- public void itemsMoved(ListMoveEvent e) {
- StructuredContentProviderAdapter.this.itemsMoved(e);
- }
- public void listCleared(ListClearEvent e) {
- StructuredContentProviderAdapter.this.listCleared();
- }
- public void listChanged(ListChangeEvent e) {
- StructuredContentProviderAdapter.this.listChanged();
- }
- @Override
- public String toString() {
- return "list listener";
- }
- };
- }
-
-
- // ********** IStructuredContentProvider implementation **********
-
- public Object[] getElements(Object inputElement) {
- if (inputElement != this.listHolder) {
- throw new IllegalArgumentException("invalid input element: " + inputElement);
- }
- return this.listHolder.toArray();
- }
-
- /**
- * This is called by the list viewer, so don't update the list viewer here.
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (viewer != this.listViewer) {
- throw new IllegalArgumentException("invalid viewer: " + viewer);
- }
- if (oldInput != this.listHolder) {
- throw new IllegalArgumentException("invalid old input: " + oldInput);
- }
- this.modelChanged((ListValueModel) oldInput, (ListValueModel) newInput);
- }
-
- public void dispose() {
- // do nothing - listeners should've already been removed in #inputChanged(Viewer, Object, Object)
- }
-
-
- // ********** internal methods **********
-
- protected void modelChanged(ListValueModel oldModel, ListValueModel newModel) {
- if (oldModel != null) {
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
- this.listHolder = newModel;
- if (newModel != null) {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
- }
-
-
- // ********** public API **********
-
- /**
- * Return the underlying list model.
- */
- public ListValueModel model() {
- return this.listHolder;
- }
-
- /**
- * Set the underlying list model.
- */
- public void setModel(ListValueModel listHolder) {
- // the list viewer will call back to #inputChanged(Viewer, Object, Object)
- this.listViewer.setInput(listHolder);
- }
-
- /**
- * Set the underlying collection model.
- */
- public void setModel(CollectionValueModel collectionHolder) {
- this.setModel(new CollectionListValueModelAdapter(collectionHolder));
- }
-
-
- // ********** list change support **********
-
- /**
- * Items were added to the underlying model list.
- * Synchronize the list viewer.
- */
- protected void itemsAdded(ListAddEvent e) {
- int i = e.getIndex();
- for (Object item : e.getItems()) {
- this.listViewer.insert(item, i++);
- }
- }
-
- /**
- * Items were removed from the underlying model list.
- * Synchronize the list viewer.
- */
- protected void itemsRemoved(ListRemoveEvent e) {
- this.listViewer.remove(ArrayTools.array(e.getItems(), e.getItemsSize()));
- }
-
- /**
- * Items were replaced in the underlying model list.
- * Synchronize the list viewer.
- */
- protected void itemsReplaced(ListReplaceEvent e) {
- this.listViewer.remove(ArrayTools.array(e.getOldItems(), e.getItemsSize()));
- int i = e.getIndex();
- for (Object item : e.getNewItems()) {
- this.listViewer.insert(item, i++);
- }
- }
-
- /**
- * Items were moved in the underlying model list.
- * Synchronize the list viewer.
- */
- protected void itemsMoved(ListMoveEvent e) {
- int len = e.getLength();
- Object[] items = new Object[len];
- int offset = e.getSourceIndex();
- for (int i = 0; i < len; i++) {
- items[i] = this.listHolder.get(offset + i);
- }
- this.listViewer.remove(items);
-
- offset = e.getTargetIndex();
- for (int i = 0; i < len; i++) {
- this.listViewer.insert(items[i], offset + i);
- }
- }
-
- /**
- * The underlying model list was cleared.
- * Synchronize the list viewer.
- */
- protected void listCleared() {
- this.listViewer.refresh();
- }
-
- /**
- * The underlying model list has changed "dramatically".
- * Synchronize the list viewer.
- */
- protected void listChanged() {
- this.listViewer.refresh();
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listHolder);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/TreeContentProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/TreeContentProvider.java
deleted file mode 100644
index 86fcbcd311..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/jface/TreeContentProvider.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.jface;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-
-/**
- * Convenience implementation of {@link ITreeContentProvider}.
- */
-public class TreeContentProvider
- extends StructuredContentProvider
- implements ITreeContentProvider
-{
- private static final ITreeContentProvider NULL_PROVIDER = new TreeContentProvider();
-
- public static ITreeContentProvider nullProvider() {
- return NULL_PROVIDER;
- }
-
- @Override
- public Object[] getElements(Object input) {
- // typical tree implementation
- return this.getChildren(input);
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return false;
- }
-
- public Object[] getChildren(Object element) {
- return EMPTY_ARRAY;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTCollectionChangeListenerWrapper.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTCollectionChangeListenerWrapper.java
deleted file mode 100644
index 8c94238d76..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTCollectionChangeListenerWrapper.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.listeners;
-
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.internal.RunnableAdapter;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-
-/**
- * Wrap another collection change listener and forward events to it on the SWT
- * UI thread, asynchronously if necessary.
- *
- * @see SWTPropertyChangeListenerWrapper
- */
-public class SWTCollectionChangeListenerWrapper
- implements CollectionChangeListener
-{
- private final CollectionChangeListener listener;
-
- public SWTCollectionChangeListenerWrapper(CollectionChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void itemsAdded(CollectionAddEvent event) {
- this.execute(new ItemsAddedRunnable(event));
- }
-
- /* CU private */ class ItemsAddedRunnable
- extends RunnableAdapter
- {
- private final CollectionAddEvent event;
- ItemsAddedRunnable(CollectionAddEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTCollectionChangeListenerWrapper.this.itemsAdded_(this.event);
- }
- }
-
- void itemsAdded_(CollectionAddEvent event) {
- this.listener.itemsAdded(event);
- }
-
- public void itemsRemoved(CollectionRemoveEvent event) {
- this.execute(new ItemsRemovedRunnable(event));
- }
-
- /* CU private */ class ItemsRemovedRunnable
- extends RunnableAdapter
- {
- private final CollectionRemoveEvent event;
- ItemsRemovedRunnable(CollectionRemoveEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTCollectionChangeListenerWrapper.this.itemsRemoved_(this.event);
- }
- }
-
- void itemsRemoved_(CollectionRemoveEvent event) {
- this.listener.itemsRemoved(event);
- }
-
- public void collectionCleared(CollectionClearEvent event) {
- this.execute(new CollectionClearedRunnable(event));
- }
-
- /* CU private */ class CollectionClearedRunnable
- extends RunnableAdapter
- {
- private final CollectionClearEvent event;
- CollectionClearedRunnable(CollectionClearEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTCollectionChangeListenerWrapper.this.collectionCleared_(this.event);
- }
- }
-
- void collectionCleared_(CollectionClearEvent event) {
- this.listener.collectionCleared(event);
- }
-
- public void collectionChanged(CollectionChangeEvent event) {
- this.execute(new CollectionChangedRunnable(event));
- }
-
- /* CU private */ class CollectionChangedRunnable
- extends RunnableAdapter
- {
- private final CollectionChangeEvent event;
- CollectionChangedRunnable(CollectionChangeEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTCollectionChangeListenerWrapper.this.collectionChanged_(this.event);
- }
- }
-
- void collectionChanged_(CollectionChangeEvent event) {
- this.listener.collectionChanged(event);
- }
-
- /**
- * {@link SWTUtil#execute(Runnable)} seems to work OK;
- * but using {@link SWTUtil#syncExec(Runnable)} can somtimes make things
- * more predictable when debugging, at the risk of deadlocks.
- */
- private void execute(Runnable r) {
- SWTUtil.execute(r);
-// SWTUtil.syncExec(r);
- }
-
- @Override
- public String toString() {
- return "SWT(" + this.listener + ')'; //$NON-NLS-1$
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTListChangeListenerWrapper.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTListChangeListenerWrapper.java
deleted file mode 100644
index 3037b60e79..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTListChangeListenerWrapper.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.listeners;
-
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.internal.RunnableAdapter;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-
-/**
- * Wrap another list change listener and forward events to it on the SWT
- * UI thread, asynchronously if necessary.
- *
- * @see SWTPropertyChangeListenerWrapper
- */
-public class SWTListChangeListenerWrapper
- implements ListChangeListener
-{
- private final ListChangeListener listener;
-
- public SWTListChangeListenerWrapper(ListChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void itemsAdded(ListAddEvent event) {
- this.execute(new ItemsAddedRunnable(event));
- }
-
- /* CU private */ class ItemsAddedRunnable
- extends RunnableAdapter
- {
- private final ListAddEvent event;
- ItemsAddedRunnable(ListAddEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTListChangeListenerWrapper.this.itemsAdded_(this.event);
- }
- }
-
- void itemsAdded_(ListAddEvent event) {
- this.listener.itemsAdded(event);
- }
-
- public void itemsRemoved(ListRemoveEvent event) {
- this.execute(new ItemsRemovedRunnable(event));
- }
-
- /* CU private */ class ItemsRemovedRunnable
- extends RunnableAdapter
- {
- private final ListRemoveEvent event;
- ItemsRemovedRunnable(ListRemoveEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTListChangeListenerWrapper.this.itemsRemoved_(this.event);
- }
- }
-
- void itemsRemoved_(ListRemoveEvent event) {
- this.listener.itemsRemoved(event);
- }
-
- public void itemsMoved(ListMoveEvent event) {
- this.execute(new ItemsMovedRunnable(event));
- }
-
- /* CU private */ class ItemsMovedRunnable
- extends RunnableAdapter
- {
- private final ListMoveEvent event;
- ItemsMovedRunnable(ListMoveEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTListChangeListenerWrapper.this.itemsMoved_(this.event);
- }
- }
-
- void itemsMoved_(ListMoveEvent event) {
- this.listener.itemsMoved(event);
- }
-
- public void itemsReplaced(ListReplaceEvent event) {
- this.execute(new ItemsReplacedRunnable(event));
- }
-
- /* CU private */ class ItemsReplacedRunnable
- extends RunnableAdapter
- {
- private final ListReplaceEvent event;
- ItemsReplacedRunnable(ListReplaceEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTListChangeListenerWrapper.this.itemsReplaced_(this.event);
- }
- }
-
- public void listCleared(ListClearEvent event) {
- this.execute(new ListClearedRunnable(event));
- }
-
- void itemsReplaced_(ListReplaceEvent event) {
- this.listener.itemsReplaced(event);
- }
-
- /* CU private */ class ListClearedRunnable
- extends RunnableAdapter
- {
- private final ListClearEvent event;
- ListClearedRunnable(ListClearEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTListChangeListenerWrapper.this.listCleared_(this.event);
- }
- }
-
- void listCleared_(ListClearEvent event) {
- this.listener.listCleared(event);
- }
-
- public void listChanged(ListChangeEvent event) {
- this.execute(new ListChangedRunnable(event));
- }
-
- /* CU private */ class ListChangedRunnable
- extends RunnableAdapter
- {
- private final ListChangeEvent event;
- ListChangedRunnable(ListChangeEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTListChangeListenerWrapper.this.listChanged_(this.event);
- }
- }
-
- void listChanged_(ListChangeEvent event) {
- this.listener.listChanged(event);
- }
-
- /**
- * {@link SWTUtil#execute(Runnable)} seems to work OK;
- * but using {@link SWTUtil#syncExec(Runnable)} can somtimes make things
- * more predictable when debugging, at the risk of deadlocks.
- */
- private void execute(Runnable r) {
- SWTUtil.execute(r);
-// SWTUtil.syncExec(r);
- }
-
- @Override
- public String toString() {
- return "SWT(" + this.listener + ')'; //$NON-NLS-1$
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTPropertyChangeListenerWrapper.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTPropertyChangeListenerWrapper.java
deleted file mode 100644
index a12e215685..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTPropertyChangeListenerWrapper.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.listeners;
-
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.internal.RunnableAdapter;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-
-/**
- * Wrap another property change listener and forward events to it on the SWT
- * UI thread, asynchronously if necessary. If the event arrived on the UI
- * thread that is probably because it was initiated by a UI widget; as a
- * result, we want to loop back synchronously so the events can be
- * short-circuited. (Typically, the adapter(s) between a <em>property</em> and
- * its corresponding UI widget are read-write; as opposed to the adapter(s)
- * between a <em>collection</em> (or <em>list</em>) and its UI widget, which
- * is read-only.)
- */
-public class SWTPropertyChangeListenerWrapper
- implements PropertyChangeListener
-{
- private final PropertyChangeListener listener;
-
- public SWTPropertyChangeListenerWrapper(PropertyChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void propertyChanged(PropertyChangeEvent event) {
- this.execute(new PropertyChangedRunnable(event));
- }
-
- /* CU private */ class PropertyChangedRunnable
- extends RunnableAdapter
- {
- private final PropertyChangeEvent event;
- PropertyChangedRunnable(PropertyChangeEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTPropertyChangeListenerWrapper.this.propertyChanged_(this.event);
- }
- }
-
- void propertyChanged_(PropertyChangeEvent event) {
- this.listener.propertyChanged(event);
- }
-
- /**
- * {@link SWTUtil#execute(Runnable)} seems to work OK;
- * but using {@link SWTUtil#syncExec(Runnable)} can somtimes make things
- * more predictable when debugging, at the risk of deadlocks.
- */
- private void execute(Runnable r) {
- SWTUtil.execute(r);
-// SWTUtil.syncExec(r);
- }
-
- @Override
- public String toString() {
- return "SWT(" + this.listener + ')'; //$NON-NLS-1$
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTStateChangeListenerWrapper.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTStateChangeListenerWrapper.java
deleted file mode 100644
index 7437bf48b2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/listeners/SWTStateChangeListenerWrapper.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.listeners;
-
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.internal.RunnableAdapter;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-
-/**
- * Wrap another state change listener and forward events to it on the SWT
- * UI thread, asynchronously if necessary.
- *
- * @see SWTPropertyChangeListenerWrapper
- */
-public class SWTStateChangeListenerWrapper
- implements StateChangeListener
-{
- private final StateChangeListener listener;
-
- public SWTStateChangeListenerWrapper(StateChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void stateChanged(StateChangeEvent event) {
- this.execute(new StateChangedRunnable(event));
- }
-
- /* CU private */ class StateChangedRunnable
- extends RunnableAdapter
- {
- private final StateChangeEvent event;
- StateChangedRunnable(StateChangeEvent event) {
- super();
- this.event = event;
- }
- @Override
- public void run() {
- SWTStateChangeListenerWrapper.this.stateChanged_(this.event);
- }
- }
-
- void stateChanged_(StateChangeEvent event) {
- this.listener.stateChanged(event);
- }
-
- /**
- * {@link SWTUtil#execute(Runnable)} seems to work OK;
- * but using {@link SWTUtil#syncExec(Runnable)} can somtimes make things
- * more predictable when debugging, at the risk of deadlocks.
- */
- private void execute(Runnable r) {
- SWTUtil.execute(r);
-// SWTUtil.syncExec(r);
- }
-
- @Override
- public String toString() {
- return "SWT(" + this.listener + ')'; //$NON-NLS-1$
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/properties/JptProjectPropertiesPage.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/properties/JptProjectPropertiesPage.java
deleted file mode 100644
index f739b28dc4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/properties/JptProjectPropertiesPage.java
+++ /dev/null
@@ -1,449 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.properties;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.value.BufferedWritablePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.AbstractChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jst.common.project.facet.core.libprov.IPropertyChangeListener;
-import org.eclipse.jst.common.project.facet.core.libprov.LibraryInstallDelegate;
-import org.eclipse.jst.common.project.facet.ui.libprov.LibraryFacetPropertyPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.common.project.facet.ui.internal.FacetsPropertyPage;
-
-
-public abstract class JptProjectPropertiesPage
- extends LibraryFacetPropertyPage {
-
- protected final ModifiablePropertyValueModel<IProject> projectModel;
- protected final BufferedWritablePropertyValueModel.Trigger trigger;
-
- protected final ChangeListener validationListener;
-
-
- public JptProjectPropertiesPage() {
- super();
-
- this.projectModel = new SimplePropertyValueModel<IProject>();
- this.trigger = new BufferedWritablePropertyValueModel.Trigger();
-
- this.buildModels();
-
- this.validationListener = this.buildValidationListener();
- }
-
-
- /**
- * Build any additional models needed by this page. The project model has been created at this
- * point.
- */
- protected abstract void buildModels();
-
-
- // ********** convenience methods **********
-
- public static boolean flagIsSet(PropertyValueModel<Boolean> flagModel) {
- Boolean flag = flagModel.getValue();
- return (flag != null) && flag.booleanValue();
- }
-
-
- // ********** LibraryFacetPropertyPage implementation **********
-
- protected IPropertyChangeListener buildLibraryProviderListener() {
- return new LibraryProviderListener();
- }
-
- protected class LibraryProviderListener
- implements IPropertyChangeListener
- {
- public void propertyChanged(String property, Object oldValue, Object newValue ) {
- if (LibraryInstallDelegate.PROP_AVAILABLE_PROVIDERS.equals(property)) {
- JptProjectPropertiesPage.this.adjustLibraryProviders();
- }
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
-
- protected abstract void adjustLibraryProviders();
-
-
- // ********** page **********
-
- @Override
- protected Control createPageContents(Composite parent) {
- if (this.projectModel.getValue() != null) {
- this.disengageListeners();
- }
-
- this.projectModel.setValue(this.getProject());
-
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- composite.setLayout(layout);
-
- this.createWidgets(composite);
-
- Dialog.applyDialogFont(composite);
-
- this.adjustLibraryProviders();
-
- this.engageListeners();
- this.updateValidation();
-
- return composite;
- }
-
- /**
- * Build specific widgets. Layout and validation will be taken care of.
- */
- protected abstract void createWidgets(Composite parent);
-
- protected void engageListeners() {
- this.engageValidationListener();
- }
-
- protected void disengageListeners() {
- this.disengageValidationListener();
- }
-
- protected Link buildFacetsPageLink(Composite parent, String text) {
- Link facetsPageLink = this.buildLink(parent, text);
- facetsPageLink.addSelectionListener(new FacetsPageLinkListener()); // the link will be GCed
- return facetsPageLink;
- }
-
- /* CU private */ class FacetsPageLinkListener
- extends SelectionAdapter
- {
- @Override
- public void widgetSelected(SelectionEvent e) {
- JptProjectPropertiesPage.this.openProjectFacetsPage();
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
-
- protected void openProjectFacetsPage() {
- ((IWorkbenchPreferenceContainer)this.getContainer()).openPage(FacetsPropertyPage.ID, null);
- }
-
- /**
- * Don't allow {@link org.eclipse.jface.preference.PreferencePage#computeSize()}
- * to cache the page's size, since the size of the "Library" panel can
- * change depending on the user's selection from the drop-down list.
- */
- @Override
- public Point computeSize() {
- return this.doComputeSize();
- }
-
-
- // ********** widgets **********
-
- protected Button buildCheckBox(Composite parent, int horizontalSpan, String text) {
- return this.buildButton(parent, horizontalSpan, text, SWT.CHECK);
- }
-
- protected Button buildRadioButton(Composite parent, int horizontalSpan, String text) {
- return this.buildButton(parent, horizontalSpan, text, SWT.RADIO);
- }
-
- protected Button buildButton(Composite parent, int horizontalSpan, String text, int style) {
- Button button = new Button(parent, SWT.NONE | style);
- button.setText(text);
- GridData gd = new GridData();
- gd.horizontalSpan = horizontalSpan;
- button.setLayoutData(gd);
- return button;
- }
-
- protected Combo buildDropDown(Composite parent) {
- return this.buildDropDown(parent, 1);
- }
-
- protected Combo buildDropDown(Composite parent, int horizontalSpan) {
- Combo combo = new Combo(parent, SWT.READ_ONLY);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = horizontalSpan;
- combo.setLayoutData(gd);
- return combo;
- }
-
- protected Label buildLabel(Composite parent, String text) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(text);
- GridData gd = new GridData();
- gd.horizontalSpan = 1;
- label.setLayoutData(gd);
- return label;
- }
-
- protected Link buildLink(Composite parent, String text) {
- Link link = new Link(parent, SWT.NONE);
- GridData data = new GridData(GridData.END, GridData.CENTER, false, false);
- data.horizontalSpan = 2;
- link.setLayoutData(data);
- link.setText(text);
- return link;
- }
-
-
- // ********** OK/Revert/Apply behavior **********
-
- @Override
- public boolean performOk() {
- super.performOk();
-
- try {
- // true=fork; false=uncancellable
- this.buildOkProgressMonitorDialog().run(true, false, this.buildOkRunnableWithProgress());
- }
- catch (InterruptedException ex) {
- // should *not* happen...
- Thread.currentThread().interrupt();
- return false;
- }
- catch (InvocationTargetException ex) {
- throw new RuntimeException(ex.getTargetException());
- }
-
- return true;
- }
-
- protected IRunnableContext buildOkProgressMonitorDialog() {
- return new ProgressMonitorDialog(this.getShell());
- }
-
- protected IRunnableWithProgress buildOkRunnableWithProgress() {
- return new OkRunnableWithProgress();
- }
-
- protected class OkRunnableWithProgress
- implements IRunnableWithProgress
- {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- IWorkspace ws = ResourcesPlugin.getWorkspace();
- try {
- // the build we execute in #performOk_() locks the workspace root,
- // so we need to use the workspace root as our scheduling rule here
- ws.run(
- new OkWorkspaceRunnable(),
- ws.getRoot(),
- IWorkspace.AVOID_UPDATE,
- monitor
- );
- } catch (CoreException ex) {
- throw new InvocationTargetException(ex);
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
- /* class private */ class OkWorkspaceRunnable
- implements IWorkspaceRunnable
- {
- public void run(IProgressMonitor monitor) throws CoreException {
- JptProjectPropertiesPage.this.performOk_(monitor);
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
- }
-
-
- // ********** OK/Revert/Apply behavior **********
-
- /* CU private */ void performOk_(IProgressMonitor monitor) throws CoreException {
- if (this.isBuffering()) {
- boolean rebuild = this.projectRebuildRequired();
- this.trigger.accept();
- if (rebuild) {
- this.rebuildProject();
- }
- this.getProject().build(IncrementalProjectBuilder.FULL_BUILD, monitor);
- }
- }
-
- protected abstract boolean projectRebuildRequired();
-
- protected abstract void rebuildProject() throws CoreException;
-
- /**
- * Return whether any of the models are buffering a change.
- */
- private boolean isBuffering() {
- for (BufferedWritablePropertyValueModel<?> model : this.buildBufferedModels()) {
- if (model.isBuffering()) {
- return true;
- }
- }
- return false;
- }
-
- protected abstract BufferedWritablePropertyValueModel<?>[] buildBufferedModels();
-
- @Override
- protected void performDefaults() {
- super.performDefaults();
- this.trigger.reset();
- }
-
-
- // ********** dispose **********
-
- @Override
- public void dispose() {
- this.disengageListeners();
- super.dispose();
- }
-
-
- // ********** validation **********
-
- private ChangeListener buildValidationListener() {
- return new ValidationListener();
- }
-
- /* CU private */ class ValidationListener
- extends AbstractChangeListener
- {
- @Override
- protected void modelChanged() {
- JptProjectPropertiesPage.this.validate();
- }
- }
-
- protected void validate() {
- if ( ! this.getControl().isDisposed()) {
- this.updateValidation();
- }
- }
-
- private void engageValidationListener() {
- for (Model model : this.buildValidationModels()) {
- model.addChangeListener(this.validationListener);
- }
- }
-
- protected abstract Model[] buildValidationModels();
-
- private void disengageValidationListener() {
- for (Model model : this.buildReverseValidationModels()) {
- model.removeChangeListener(this.validationListener);
- }
- }
-
- protected Model[] buildReverseValidationModels() {
- return ArrayTools.reverse(this.buildValidationModels());
- }
-
- protected static final Integer ERROR_STATUS = Integer.valueOf(IStatus.ERROR);
- protected static final Integer WARNING_STATUS = Integer.valueOf(IStatus.WARNING);
- protected static final Integer INFO_STATUS = Integer.valueOf(IStatus.INFO);
- protected static final Integer OK_STATUS = Integer.valueOf(IStatus.OK);
-
- protected IStatus buildInfoStatus(String message) {
- return this.buildStatus(IStatus.INFO, message);
- }
-
- protected IStatus buildWarningStatus(String message) {
- return this.buildStatus(IStatus.WARNING, message);
- }
-
- protected IStatus buildErrorStatus(String message) {
- return this.buildStatus(IStatus.ERROR, message);
- }
-
- protected IStatus buildStatus(int severity, String message) {
- return new Status(severity, JptCommonCorePlugin.PLUGIN_ID, message);
- }
-
- @Override
- protected IStatus performValidation() {
- HashMap<Integer, ArrayList<IStatus>> statuses = new HashMap<Integer, ArrayList<IStatus>>();
- statuses.put(ERROR_STATUS, new ArrayList<IStatus>());
- statuses.put(WARNING_STATUS, new ArrayList<IStatus>());
- statuses.put(INFO_STATUS, new ArrayList<IStatus>());
- statuses.put(OK_STATUS, new ArrayList<IStatus>());
-
- /* library provider */
- this.addStatus(super.performValidation(), statuses);
- this.performValidation(statuses);
-
- ArrayList<IStatus> list = statuses.get(ERROR_STATUS);
- if ( ! list.isEmpty()) {
- return list.get(0);
- }
- list = statuses.get(WARNING_STATUS);
- if ( ! list.isEmpty()) {
- return list.get(0);
- }
- list = statuses.get(INFO_STATUS);
- if ( ! list.isEmpty()) {
- return list.get(0);
- }
- return Status.OK_STATUS;
- }
-
- protected abstract void performValidation(Map<Integer, ArrayList<IStatus>> statuses);
-
- protected void addStatus(IStatus status, Map<Integer, ArrayList<IStatus>> statuses) {
- statuses.get(Integer.valueOf(status.getSeverity())).add(status);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/AbstractComboModelAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/AbstractComboModelAdapter.java
deleted file mode 100644
index 5dcd988961..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/AbstractComboModelAdapter.java
+++ /dev/null
@@ -1,704 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.swt;
-
-import java.util.EventListener;
-import java.util.EventObject;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTListChangeListenerWrapper;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-import org.eclipse.jpt.common.utility.internal.StringConverter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-
-/**
- * This adapter provides a more object-oriented interface to the items and
- * selected item in a combo.
- * <p>
- * <b>listHolder</b> contains the items in the combo.<br>
- * <b>selectedItemHolder</b> contains the items in 'listHolder' that are
- * selected in the combo.
- *
- * @param <E> The type of the items in <b>listHolder</b>
- * @see ComboModelAdapter
- * @see CComboModelAdapter
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public abstract class AbstractComboModelAdapter<E> {
-
- // ********** model **********
- /**
- * A value model on the underlying model list.
- */
- protected final ListValueModel<E> listHolder;
-
- /**
- * A listener that allows us to synchronize the combo's contents with
- * the model list.
- */
- protected final ListChangeListener listChangeListener;
-
- /**
- * A value model on the underlying model selection.
- */
- protected final ModifiablePropertyValueModel<E> selectedItemHolder;
-
- /**
- * A listener that allows us to synchronize the combo's selection with the
- * model selection.
- */
- protected final PropertyChangeListener selectedItemChangeListener;
-
- /**
- * A converter that converts items in the model list
- * to strings that can be put in the combo.
- */
- protected StringConverter<E> stringConverter;
-
- // ********** UI **********
- /**
- * The combo we keep synchronized with the model list.
- */
- protected final ComboHolder comboHolder;
-
- /**
- * A listener that allows us to synchronize our selection list holder
- * with the combo's text.
- */
- protected ModifyListener comboModifyListener;
-
- /**
- * A listener that allows us to synchronize our selection list holder
- * with the combo's selection.
- */
- protected SelectionListener comboSelectionListener;
-
- /**
- * Clients that are interested in selection change events.
- */
- @SuppressWarnings("unchecked")
- protected final ListenerList<SelectionChangeListener> selectionChangeListenerList;
-
- /**
- * Clients that are interested in double click events.
- */
- @SuppressWarnings("unchecked")
- protected final ListenerList<DoubleClickListener> doubleClickListenerList;
-
- /**
- * A listener that allows us to stop listening to stuff when the combo
- * is disposed.
- */
- protected final DisposeListener comboDisposeListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the list holder, selections holder, combo, and
- * string converter are required.
- */
- protected AbstractComboModelAdapter(
- ListValueModel<E> listHolder,
- ModifiablePropertyValueModel<E> selectedItemHolder,
- ComboHolder comboHolder,
- StringConverter<E> stringConverter)
- {
- super();
-
- Assert.isNotNull(listHolder, "The holder of the items");
- Assert.isNotNull(selectedItemHolder, "The holder of the selected item cannot be null");
- Assert.isNotNull(comboHolder, "The holder of the combo widget cannot be null");
- Assert.isNotNull(stringConverter, "The string converter cannot be null");
-
- this.listHolder = listHolder;
- this.selectedItemHolder = selectedItemHolder;
- this.comboHolder = comboHolder;
- this.stringConverter = stringConverter;
-
- this.listChangeListener = this.buildListChangeListener();
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
-
- this.selectedItemChangeListener = this.buildSelectedItemChangeListener();
- this.selectedItemHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.selectedItemChangeListener);
-
- if (this.comboHolder.isEditable()) {
- this.comboModifyListener = this.buildComboModifyListener();
- this.comboHolder.addModifyListener(this.comboModifyListener);
- }
- else {
- this.comboSelectionListener = this.buildComboSelectionListener();
- this.comboHolder.addSelectionListener(this.comboSelectionListener);
- }
-
- this.selectionChangeListenerList = this.buildSelectionChangeListenerList();
- this.doubleClickListenerList = this.buildDoubleClickListenerList();
-
- this.comboDisposeListener = this.buildComboDisposeListener();
- this.comboHolder.addDisposeListener(this.comboDisposeListener);
-
- this.synchronizeCombo();
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildListChangeListener() {
- return new SWTListChangeListenerWrapper(this.buildListChangeListener_());
- }
-
- protected ListChangeListener buildListChangeListener_() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent event) {
- AbstractComboModelAdapter.this.listItemsAdded(event);
- }
- public void itemsRemoved(ListRemoveEvent event) {
- AbstractComboModelAdapter.this.listItemsRemoved(event);
- }
- public void itemsMoved(ListMoveEvent event) {
- AbstractComboModelAdapter.this.listItemsMoved(event);
- }
- public void itemsReplaced(ListReplaceEvent event) {
- AbstractComboModelAdapter.this.listItemsReplaced(event);
- }
- public void listCleared(ListClearEvent event) {
- AbstractComboModelAdapter.this.listCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- AbstractComboModelAdapter.this.listChanged(event);
- }
- @Override
- public String toString() {
- return "list listener";
- }
- };
- }
-
- protected PropertyChangeListener buildSelectedItemChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildSelectedItemChangeListener_());
- }
-
- protected PropertyChangeListener buildSelectedItemChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- AbstractComboModelAdapter.this.selectedItemChanged(e);
- }
- };
- }
-
- protected ModifyListener buildComboModifyListener() {
- return new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- AbstractComboModelAdapter.this.comboSelectionChanged(event);
- }
-
- @Override
- public String toString() {
- return "combo modify listener";
- }
- };
- }
-
- protected SelectionListener buildComboSelectionListener() {
- return new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- AbstractComboModelAdapter.this.comboSelectionChanged(event);
- }
-
- @Override
- public String toString() {
- return "combo modify listener";
- }
- };
- }
-
- @SuppressWarnings("unchecked")
- protected ListenerList<DoubleClickListener> buildDoubleClickListenerList() {
- return new ListenerList<DoubleClickListener>(DoubleClickListener.class);
- }
-
- @SuppressWarnings("unchecked")
- protected ListenerList<SelectionChangeListener> buildSelectionChangeListenerList() {
- return new ListenerList<SelectionChangeListener>(SelectionChangeListener.class);
- }
-
- protected DisposeListener buildComboDisposeListener() {
- return new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- AbstractComboModelAdapter.this.comboDisposed(event);
- }
-
- @Override
- public String toString() {
- return "combo dispose listener";
- }
- };
- }
-
- protected void synchronizeCombo() {
- this.synchronizeComboItems();
- this.synchronizeComboSelection();
- }
-
-
- // ********** string converter **********
-
- public void setStringConverter(StringConverter<E> stringConverter) {
- Assert.isNotNull(stringConverter, "The StringConverter cannot be null");
- this.stringConverter = stringConverter;
- this.synchronizeCombo();
- }
-
-
- // ********** list **********
-
- /**
- * Use the string converter to convert the specified item to a
- * string that can be added to the combo.
- */
- protected String convert(E item) {
- return this.stringConverter.convertToString(item);
- }
-
- /**
- * Brute force synchronization of combo with the model list.
- */
- protected void synchronizeComboItems() {
- if (this.comboHolder.isDisposed()) {
- return;
- }
- int len = this.listHolder.size();
- String[] items = new String[len];
- for (int index = 0; index < len; index++) {
- items[index] = this.convert(this.listHolder.get(index));
- }
- try {
- this.comboHolder.setPopulating(true);
- this.comboHolder.setItems(items);
- }
- finally {
- this.comboHolder.setPopulating(false);
- }
- }
-
- /**
- * The model has changed - synchronize the combo.
- */
- protected void listItemsAdded(ListAddEvent event) {
- if (this.comboHolder.isDisposed()) {
- return;
- }
-
- int count = this.comboHolder.getItemCount();
- int index = event.getIndex();
-
- for (E item : this.getItems(event)) {
- this.comboHolder.add(this.convert(item), index++);
- }
-
- // When the combo is populated, it's possible the selection was already
- // set but no items was found, resync the selected item
- synchronizeComboSelection();
- }
-
- /**
- * The model has changed - synchronize the combo.
- */
- protected void listItemsRemoved(ListRemoveEvent event) {
- if (this.comboHolder.isDisposed()) {
- return;
- }
- this.comboHolder.setPopulating(true);
- try {
- this.comboHolder.remove(event.getIndex(), event.getIndex() + event.getItemsSize() - 1);
- }
- finally {
- this.comboHolder.setPopulating(false);
- }
- }
-
- /**
- * The model has changed - synchronize the combo.
- */
- protected void listItemsMoved(ListMoveEvent event) {
- if (this.comboHolder.isDisposed()) {
- return;
- }
- int target = event.getTargetIndex();
- int source = event.getSourceIndex();
- int len = event.getLength();
- int loStart = Math.min(target, source);
- int hiStart = Math.max(target, source);
- // make a copy of the affected items...
- String[] subArray = ArrayTools.subArray(this.comboHolder.getItems(), loStart, hiStart + len - loStart);
- // ...move them around...
- subArray = ArrayTools.move(subArray, target - loStart, source - loStart, len);
- // ...and then put them back
- for (int index = 0; index < subArray.length; index++) {
- this.comboHolder.setItem(loStart + index, subArray[index]);
- }
- }
-
- /**
- * The model has changed - synchronize the combo.
- */
- protected void listItemsReplaced(ListReplaceEvent event) {
- if (this.comboHolder.isDisposed()) {
- return;
- }
- int index = event.getIndex();
- int selectionIndex = this.comboHolder.getSelectionIndex();
- //fixing bug 269100 by setting the populating flag to true
- this.comboHolder.setPopulating(true);
- try {
- for (E item : this.getNewItems(event)) {
- this.comboHolder.setItem(index++, this.convert(item));
- }
- if (selectionIndex == 0) {
- this.comboHolder.setText(this.comboHolder.getItems()[0]);
- }
- }
- finally {
- this.comboHolder.setPopulating(false);
- }
- }
-
- /**
- * The model has changed - synchronize the combo.
- */
- protected void listCleared(ListClearEvent event) {
- if (this.comboHolder.isDisposed()) {
- return;
- }
- this.comboHolder.setPopulating(true);
- try {
- this.comboHolder.removeAll();
- }
- finally {
- this.comboHolder.setPopulating(false);
- }
- }
-
- /**
- * The model has changed - synchronize the combo.
- */
- protected void listChanged(ListChangeEvent event) {
- this.synchronizeCombo();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(ListAddEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getNewItems(ListReplaceEvent event) {
- return (Iterable<E>) event.getNewItems();
- }
-
-
- // ********** selected items **********
-
- protected int indexOf(E item) {
- int length = this.listHolder.size();
- for (int index = 0; index < length; index++) {
- if (valuesAreEqual(this.listHolder.get(index), item)) {
- return index;
- }
- }
- return -1;
- }
-
- protected void synchronizeComboSelection() {
- if (this.comboHolder.isDisposed() || this.comboHolder.isPopulating()) {
- return;
- }
-
- E selectedValue = this.selectedItemHolder.getValue();
- if (this.comboHolder.getText().equals(selectedValue)) {
- //if the selection is still the same, don't reset it
- return;
- }
- this.comboHolder.setPopulating(true);
- try {
- this.comboHolder.deselectAll();
- String selectedItem = this.convert(selectedValue);
- if (selectedItem == null) {
- selectedItem = "";
- }
- this.comboHolder.setText(selectedItem);
- this.notifyListeners(selectedValue);
- }
- finally {
- this.comboHolder.setPopulating(false);
- }
- }
-
- protected void selectedItemChanged(PropertyChangeEvent event) {
- this.synchronizeComboSelection();
- }
-
- /**
- * Return whether the values are equal, with the appropriate null checks.
- * Convenience method for checking whether an attribute value has changed.
- */
- protected final boolean valuesAreEqual(Object value1, Object value2) {
- if ((value1 == null) && (value2 == null)) {
- return true; // both are null
- }
- if ((value1 == null) || (value2 == null)) {
- return false; // one is null but the other is not
- }
- return value1.equals(value2);
- }
-
- // ********** combo events **********
-
- protected void comboSelectionChanged(SelectionEvent event) {
- this.selectionChanged();
- }
-
- protected void comboSelectionChanged(ModifyEvent event) {
- this.selectionChanged();
- }
-
- protected void selectionChanged() {
- if (!this.comboHolder.isPopulating()) {
- E selectedItem = this.selectedItem();
- this.comboHolder.setPopulating(true);
- try {
- this.selectedItemHolder.setValue(selectedItem);
- this.notifyListeners(selectedItem);
- }
- finally {
- this.comboHolder.setPopulating(false);
- }
- }
- }
-
- private void notifyListeners(E selectedItem) {
- if (this.selectionChangeListenerList.size() > 0) {
- SelectionChangeEvent<E> scEvent = new SelectionChangeEvent<E>(this, selectedItem);
- for (SelectionChangeListener<E> selectionChangeListener : this.selectionChangeListenerList.getListeners()) {
- selectionChangeListener.selectionChanged(scEvent);
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- protected E selectedItem() {
- if (this.comboHolder.isDisposed()) {
- return null;
- }
-
- if (this.comboHolder.isEditable()) {
- String text = this.comboHolder.getText();
-
- if (text.length() == 0) {
- return null;
- }
-
- for (int index = this.listHolder.size(); --index >= 0; ) {
- E item = this.listHolder.get(index);
- String value = this.convert(item);
- if (valuesAreEqual(text, value)) {
- return item;
- }
- }
-
- // TODO: Find a way to prevent this type cast (it'll work if E is
- // String but it won't work if E is something else), maybe use a
- // BidiStringConverter instead of StringConverter
- try {
- return (E) text;
- }
- catch (ClassCastException e) {
- return null;
- }
- }
-
- int index = this.comboHolder.getSelectionIndex();
-
- if (index == -1) {
- return null;
- }
-
- return this.listHolder.get(index);
- }
-
- protected void comboDoubleClicked(SelectionEvent event) {
- if (this.comboHolder.isDisposed()) {
- return;
- }
- if (this.doubleClickListenerList.size() > 0) {
- // there should be only a single item selected during a double-click(?)
- E selection = this.listHolder.get(this.comboHolder.getSelectionIndex());
- DoubleClickEvent<E> dcEvent = new DoubleClickEvent<E>(this, selection);
- for (DoubleClickListener<E> doubleClickListener : this.doubleClickListenerList.getListeners()) {
- doubleClickListener.doubleClick(dcEvent);
- }
- }
- }
-
-
- // ********** dispose **********
-
- protected void comboDisposed(DisposeEvent event) {
- // the combo is not yet "disposed" when we receive this event
- // so we can still remove our listeners
- this.comboHolder.removeDisposeListener(this.comboDisposeListener);
- if (this.comboHolder.isEditable()) {
- this.comboHolder.removeModifyListener(this.comboModifyListener);
- }
- else {
- this.comboHolder.removeSelectionListener(this.comboSelectionListener);
- }
- this.selectedItemHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.selectedItemChangeListener);
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listHolder);
- }
-
-
- // ********** double click support **********
-
- public void addDoubleClickListener(DoubleClickListener<E> listener) {
- this.doubleClickListenerList.add(listener);
- }
-
- public void removeDoubleClickListener(DoubleClickListener<E> listener) {
- this.doubleClickListenerList.remove(listener);
- }
-
- public interface DoubleClickListener<E> extends EventListener {
- void doubleClick(DoubleClickEvent<E> event);
- }
-
- public static class DoubleClickEvent<E> extends EventObject {
- private final E selection;
- private static final long serialVersionUID = 1L;
-
- protected DoubleClickEvent(AbstractComboModelAdapter<E> source, E selection) {
- super(source);
- if (selection == null) {
- throw new NullPointerException();
- }
- this.selection = selection;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public AbstractComboModelAdapter<E> getSource() {
- return (AbstractComboModelAdapter<E>) super.getSource();
- }
-
- public E selection() {
- return this.selection;
- }
- }
-
-
- // ********** selection support **********
-
- public void addSelectionChangeListener(SelectionChangeListener<E> listener) {
- this.selectionChangeListenerList.add(listener);
- }
-
- public void removeSelectionChangeListener(SelectionChangeListener<E> listener) {
- this.selectionChangeListenerList.remove(listener);
- }
-
- public interface SelectionChangeListener<E> extends EventListener {
- void selectionChanged(SelectionChangeEvent<E> event);
- }
-
- public static class SelectionChangeEvent<E> extends EventObject {
- private final E selectedItem;
- private static final long serialVersionUID = 1L;
-
- protected SelectionChangeEvent(AbstractComboModelAdapter<E> source, E selectedItem) {
- super(source);
- this.selectedItem = selectedItem;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public AbstractComboModelAdapter<E> getSource() {
- return (AbstractComboModelAdapter<E>) super.getSource();
- }
-
- public E selectedItem() {
- return this.selectedItem;
- }
- }
-
- // ********** Internal member **********
-
- /**
- * This holder is required for supporting <code>Combo</code> and
- * <code>CCombo</code> transparently.
- */
- protected static interface ComboHolder {
- void add(String item, int index);
- void addDisposeListener(DisposeListener disposeListener);
- void addModifyListener(ModifyListener modifyListener);
- void addSelectionListener(SelectionListener selectionListener);
- void deselectAll();
- int getItemCount();
- String[] getItems();
- int getSelectionIndex();
- String getText();
- boolean isDisposed();
- boolean isEditable();
- boolean isPopulating();
- void removeDisposeListener(DisposeListener disposeListener);
- void removeModifyListener(ModifyListener modifyListener);
- void removeSelectionListener(SelectionListener selectionListener);
- void setItem(int index, String item);
- void setItems(String[] items);
- void setPopulating(boolean populating);
- void setText(String item);
- void remove(int start, int end);
- void removeAll();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/ColumnAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/ColumnAdapter.java
deleted file mode 100644
index c8f86f84ec..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/ColumnAdapter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.swt;
-
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This adapter is used by the table model adapter to convert a model object
- * into the models used for each of the cells for the object's corresponding row
- * in the table.
- *
- * @version 2.0
- * @since 2.0
- */
-public interface ColumnAdapter<V> {
-
- /**
- * Return the cell models for the specified subject
- * that corresponds to a single row in the table.
- */
- ModifiablePropertyValueModel<?>[] cellModels(V subject);
-
- /**
- * Returns the number of columns in the table. Typically this is static.
- *
- * @return The number of columns
- */
- int columnCount();
-
- /**
- * Returns the name of the column at the specified index.
- *
- * @param columnIndex The index of the column to retrieve its display text
- * @return The display text of the column
- */
- String columnName(int columnIndex);
-
- /**
- * Returns whether the specified column is editable. Typically this is the
- * same for every row.
- *
- * @param columnIndex The index of the column for which we determine if
- * the content can be modified
- * @return <code>true</code> to allow editing of the cell at the given
- * column index; <code>false</code> to keep it not editable
- */
-// boolean columnIsEditable(int columnIndex);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/ComboModelAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/ComboModelAdapter.java
deleted file mode 100644
index 66204dc079..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/ComboModelAdapter.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.swt;
-
-import org.eclipse.jpt.common.utility.internal.StringConverter;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Combo;
-
-/**
- * This adapter provides a more object-oriented interface to the items and
- * selected item in a <code>Combo</code>.
- * <p>
- * <b>listHolder</b> contains the items in the <code>Combo</code>.<br>
- * <b>selectedItemHolder</b> contains the items in 'listHolder' that are
- * selected in the <code>Combo</code>.
- *
- * @param <E> The type of the items in <b>listHolder</b>
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public class ComboModelAdapter<E> extends AbstractComboModelAdapter<E> {
-
- // ********** static methods **********
-
- /**
- * Adapt the specified model list and selection to the specified combo.
- * Use the default string converter to convert the model items to strings
- * to be displayed in the combo, which calls #toString() on the
- * items in the model list.
- */
- public static <T> ComboModelAdapter<T> adapt(
- ListValueModel<T> listHolder,
- ModifiablePropertyValueModel<T> selectedItemHolder,
- Combo combo)
- {
- return adapt(
- listHolder,
- selectedItemHolder,
- combo,
- StringConverter.Default.<T>instance()
- );
- }
-
- /**
- * Adapt the specified model list and selection to the specified combo.
- * Use the specified string converter to convert the model items to strings
- * to be displayed in the combo.
- */
- public static <T> ComboModelAdapter<T> adapt(
- ListValueModel<T> listHolder,
- ModifiablePropertyValueModel<T> selectedItemHolder,
- Combo combo,
- StringConverter<T> stringConverter)
- {
- return new ComboModelAdapter<T>(
- listHolder,
- selectedItemHolder,
- combo,
- stringConverter
- );
- }
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the list holder, selections holder, combo, and
- * string converter are required.
- */
- protected ComboModelAdapter(
- ListValueModel<E> listHolder,
- ModifiablePropertyValueModel<E> selectedItemHolder,
- Combo combo,
- StringConverter<E> stringConverter)
- {
- super(listHolder,
- selectedItemHolder,
- new SWTComboHolder(combo),
- stringConverter);
- }
-
-
- // ********** Internal member **********
-
- private static class SWTComboHolder implements ComboHolder {
- private final Combo combo;
- private final boolean editable;
- private String selectedItem;
-
- SWTComboHolder(Combo combo) {
- super();
- this.combo = combo;
- this.editable = (combo.getStyle() & SWT.READ_ONLY) == 0;
- }
-
- public void add(String item, int index) {
- this.combo.add(item, index);
-
- // It is possible the selected item was set before the combo is being
- // populated, update the selected item if it's matches the item being
- // added
- if ((this.selectedItem != null) && this.selectedItem.equals(item)) {
- this.setText(this.selectedItem);
- this.selectedItem = null;
- }
- }
-
- public void addDisposeListener(DisposeListener disposeListener) {
- this.combo.addDisposeListener(disposeListener);
- }
-
- public void addModifyListener(ModifyListener modifyListener) {
- this.combo.addModifyListener(modifyListener);
- }
-
- public void addSelectionListener(SelectionListener selectionListener) {
- this.combo.addSelectionListener(selectionListener);
- }
-
- public void deselectAll() {
- this.combo.deselectAll();
- }
-
- public int getItemCount() {
- return this.combo.getItemCount();
- }
-
- public String[] getItems() {
- return this.combo.getItems();
- }
-
- public int getSelectionIndex() {
- return this.combo.getSelectionIndex();
- }
-
- public String getText() {
- return this.combo.getText();
- }
-
- public boolean isDisposed() {
- return this.combo.isDisposed();
- }
-
- public boolean isEditable() {
- return this.editable;
- }
-
- public boolean isPopulating() {
- return this.combo.getData("populating") == Boolean.TRUE;
- }
-
- public void remove(int start, int end) {
- this.combo.remove(start, end);
- }
-
- public void removeAll() {
- this.combo.removeAll();
- }
-
- public void removeDisposeListener(DisposeListener disposeListener) {
- this.combo.removeDisposeListener(disposeListener);
- }
-
- public void removeModifyListener(ModifyListener modifyListener) {
- this.combo.removeModifyListener(modifyListener);
- }
-
- public void removeSelectionListener(SelectionListener selectionListener) {
- this.combo.removeSelectionListener(selectionListener);
- }
-
- public void setItem(int index, String item) {
- this.combo.setItem(index, item);
- }
-
- public void setItems(String[] items) {
- this.combo.setItems(items);
- }
-
- public void setPopulating(boolean populating) {
- this.combo.setData("populating", Boolean.valueOf(populating));
- }
-
- public void setText(String item) {
-
- // Keep track of the selected item since it's possible the selected
- // item is before the combo is populated
- if (this.combo.getItemCount() == 0) {
- this.selectedItem = item;
- }
- else {
- this.selectedItem = null;
- }
- this.combo.setText(item);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/DateTimeModelAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/DateTimeModelAdapter.java
deleted file mode 100644
index 3c617b5a28..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/DateTimeModelAdapter.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.swt;
-
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.DateTime;
-
-/**
- * This adapter can be used to keep a DateTime widget in synch with
- * model integers hours, minutes, and seconds. Has default hours,
- * minutes and seconds of 0 which corresponds to 12:00:00 AM. This model
- * adapter can only be used for a DateTime widget with the style SWT.TIME
- */
-@SuppressWarnings("nls")
-public class DateTimeModelAdapter {
-
- /**
- * A value model on the underlying model hours integer.
- */
- protected final ModifiablePropertyValueModel<Integer> hoursHolder;
-
- /**
- * A value model on the underlying model minutes integer.
- */
- protected final ModifiablePropertyValueModel<Integer> minutesHolder;
-
- /**
- * A value model on the underlying model seconds integer.
- */
- protected final ModifiablePropertyValueModel<Integer> secondsHolder;
-
- /**
- * A listener that allows us to synchronize the dateTime's selection state with
- * the model hours integer.
- */
- protected final PropertyChangeListener hoursPropertyChangeListener;
-
- /**
- * A listener that allows us to synchronize the dateTime's selection state with
- * the model minutes integer.
- */
- protected final PropertyChangeListener minutesPropertyChangeListener;
-
- /**
- * A listener that allows us to synchronize the dateTime's selection state with
- * the model seconds integer.
- */
- protected final PropertyChangeListener secondsPropertyChangeListener;
-
- /**
- * The dateTime we keep synchronized with the model integers.
- */
- protected final DateTime dateTime;
-
- /**
- * A listener that allows us to synchronize our selection number holder
- * with the spinner's value.
- */
- protected final SelectionListener dateTimeSelectionListener;
-
- /**
- * A listener that allows us to stop listening to stuff when the dateTime
- * is disposed.
- */
- protected final DisposeListener dateTimeDisposeListener;
-
- /**
- * This lock is used to prevent the listeners to be notified when the value
- * changes from the spinner or from the holder.
- */
- private boolean locked;
-
- // ********** static methods **********
-
- /**
- * Adapt the specified model integer holders to the specified dateTime.
- */
- public static DateTimeModelAdapter adapt(
- ModifiablePropertyValueModel<Integer> hoursHolder,
- ModifiablePropertyValueModel<Integer> minutesHolder,
- ModifiablePropertyValueModel<Integer> secondsHolder,
- DateTime dateTime)
- {
- return new DateTimeModelAdapter(hoursHolder, minutesHolder, secondsHolder, dateTime);
- }
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the hoursHolder, minutesHolder, secondsHolder, and dateTime are required
- */
- protected DateTimeModelAdapter(ModifiablePropertyValueModel<Integer> hoursHolder,
- ModifiablePropertyValueModel<Integer> minutesHolder,
- ModifiablePropertyValueModel<Integer> secondsHolder,
- DateTime dateTime) {
- super();
- if ((hoursHolder == null)
- || (minutesHolder == null)
- || (secondsHolder == null)
- || (dateTime == null)) {
- throw new NullPointerException();
- }
- this.hoursHolder = hoursHolder;
- this.minutesHolder = minutesHolder;
- this.secondsHolder = secondsHolder;
- this.dateTime = dateTime;
-
- this.hoursPropertyChangeListener = this.buildHoursPropertyChangeListener();
- this.hoursHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.hoursPropertyChangeListener);
-
- this.minutesPropertyChangeListener = this.buildMinutesPropertyChangeListener();
- this.minutesHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.minutesPropertyChangeListener);
-
- this.secondsPropertyChangeListener = this.buildSecondsPropertyChangeListener();
- this.secondsHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.secondsPropertyChangeListener);
-
- this.dateTimeSelectionListener = this.buildDateTimeSelectionListener();
- this.dateTime.addSelectionListener(this.dateTimeSelectionListener);
-
- this.dateTimeDisposeListener = this.buildDateTimeDisposeListener();
- this.dateTime.addDisposeListener(this.dateTimeDisposeListener);
-
- this.updateDateTimeHours(hoursHolder.getValue());
- this.updateDateTimeMinutes(minutesHolder.getValue());
- this.updateDateTimeSeconds(secondsHolder.getValue());
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildHoursPropertyChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildHoursPropertyChangeListener_());
- }
-
- protected PropertyChangeListener buildHoursPropertyChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- DateTimeModelAdapter.this.hoursChanged(event);
- }
- @Override
- public String toString() {
- return "dateTime hours listener";
- }
- };
- }
-
- protected PropertyChangeListener buildMinutesPropertyChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildMinutesPropertyChangeListener_());
- }
-
- protected PropertyChangeListener buildMinutesPropertyChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- DateTimeModelAdapter.this.minutesChanged(event);
- }
- @Override
- public String toString() {
- return "dateTime minutes listener";
- }
- };
- }
-
- protected PropertyChangeListener buildSecondsPropertyChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildSecondsPropertyChangeListener_());
- }
-
- protected PropertyChangeListener buildSecondsPropertyChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- DateTimeModelAdapter.this.secondsChanged(event);
- }
- @Override
- public String toString() {
- return "dateTime seconds listener";
- }
- };
- }
-
- protected SelectionListener buildDateTimeSelectionListener() {
- return new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- DateTimeModelAdapter.this.dateTimeSelected(e);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- @Override
- public String toString() {
- return "dateTime selection listener";
- }
- };
- }
-
- protected DisposeListener buildDateTimeDisposeListener() {
- return new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- DateTimeModelAdapter.this.dateTimeDisposed(event);
- }
- @Override
- public String toString() {
- return "dateTime dispose listener";
- }
- };
- }
-
-
- // ********** model events **********
-
- protected void hoursChanged(PropertyChangeEvent event) {
- if (!this.locked) {
- this.updateDateTimeHours((Integer) event.getNewValue());
- }
- }
-
- protected void minutesChanged(PropertyChangeEvent event) {
- if (!this.locked) {
- this.updateDateTimeMinutes((Integer) event.getNewValue());
- }
- }
-
- protected void secondsChanged(PropertyChangeEvent event) {
- if (!this.locked) {
- this.updateDateTimeSeconds((Integer) event.getNewValue());
- }
- }
-
- // ********** dateTime events **********
-
- protected void dateTimeSelected(SelectionEvent event) {
- if (!this.locked) {
- this.locked = true;
- try {
- //too bad they didn't split the event up
- hoursSelected();
- minutesSelected();
- secondsSelected();
- }
- finally {
- this.locked = false;
- }
- }
- }
-
- protected void hoursSelected() {
- Integer hours = null;
- if (this.dateTime.getHours() != 0) {
- hours = Integer.valueOf(this.dateTime.getHours());
- }
- this.hoursHolder.setValue(hours);
- }
-
- protected void minutesSelected() {
- Integer minutes = null;
- if (this.dateTime.getMinutes() != 0) {
- minutes = Integer.valueOf(this.dateTime.getMinutes());
- }
- this.minutesHolder.setValue(minutes);
- }
-
- protected void secondsSelected() {
- Integer seconds = null;
- if (this.dateTime.getSeconds() != 0) {
- seconds = Integer.valueOf(this.dateTime.getSeconds());
- }
- this.secondsHolder.setValue(seconds);
- }
-
- protected void dateTimeDisposed(DisposeEvent event) {
- // the dateTime is not yet "disposed" when we receive this event
- // so we can still remove our listeners
- this.dateTime.removeDisposeListener(this.dateTimeDisposeListener);
- this.dateTime.removeSelectionListener(this.dateTimeSelectionListener);
- this.hoursHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.hoursPropertyChangeListener);
- this.minutesHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.minutesPropertyChangeListener);
- this.secondsHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.secondsPropertyChangeListener);
- }
-
- // ********** update **********
-
- protected void updateDateTimeHours(Integer hours) {
- if (this.dateTime.isDisposed()) {
- return;
- }
- if (hours == null) {
- hours = Integer.valueOf(0);//TODO defaultHours
- }
- this.locked = true;
- try {
- this.dateTime.setHours(hours.intValue());
- }
- finally {
- this.locked = false;
- }
- }
-
- protected void updateDateTimeMinutes(Integer minutes) {
- if (this.dateTime.isDisposed()) {
- return;
- }
- if (minutes == null) {
- minutes = Integer.valueOf(0);//TODO defaultMinutes
- }
- this.locked = true;
- try {
- this.dateTime.setMinutes(minutes.intValue());
- }
- finally {
- this.locked = false;
- }
- }
-
- protected void updateDateTimeSeconds(Integer seconds) {
- if (this.dateTime.isDisposed()) {
- return;
- }
- if (seconds == null) {
- seconds = Integer.valueOf(0);//TODO defaultSeconds
- }
- this.locked = true;
- try {
- this.dateTime.setSeconds(seconds.intValue());
- }
- finally {
- this.locked = false;
- }
- }
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.hoursHolder);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/DisposeAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/DisposeAdapter.java
deleted file mode 100644
index a765a55feb..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/DisposeAdapter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.swt;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-
-/**
- * Convenience SWT dispose listener.
- */
-public class DisposeAdapter
- implements DisposeListener
-{
- public void widgetDisposed(DisposeEvent e) {
- // NOP
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/SpinnerModelAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/SpinnerModelAdapter.java
deleted file mode 100644
index 99ebc70f0b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/SpinnerModelAdapter.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.swt;
-
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Spinner;
-
-/**
- *
- */
-@SuppressWarnings("nls")
-public class SpinnerModelAdapter {
-
- /**
- * A value model on the underlying model list.
- */
- protected final ModifiablePropertyValueModel<Integer> numberHolder;
-
- /**
- * A listener that allows us to synchronize the spinner's contents with
- * the model list.
- */
- protected final PropertyChangeListener propertyChangeListener;
-
- /**
- * The spinner we keep synchronized with the model string.
- */
- protected final Spinner spinner;
-
- /**
- * A listener that allows us to synchronize our selection number holder
- * with the spinner's value.
- */
- protected final ModifyListener spinnerModifyListener;
-
- /**
- * A listener that allows us to stop listening to stuff when the spinner
- * is disposed.
- */
- protected final DisposeListener spinnerDisposeListener;
-
- /**
- * The value shown when the number holder's value is <code>null</code>.
- */
- protected final int defaultValue;
-
- /**
- * This lock is used to prevent the listeners to be notified when the value
- * changes from the spinner or from the holder.
- */
- private boolean locked;
-
- // ********** static methods **********
-
- /**
- * Adapt the specified model list and selections to the specified spinner.
- * Use the specified string converter to convert the model items to strings
- * to be displayed in the spinner.
- */
- public static SpinnerModelAdapter adapt(
- ModifiablePropertyValueModel<Integer> numberHolder,
- Spinner spinner,
- int defaultValue)
- {
- return new SpinnerModelAdapter(numberHolder, spinner, defaultValue);
- }
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the list holder, selections holder, list box, and
- * string converter are required.
- */
- protected SpinnerModelAdapter(ModifiablePropertyValueModel<Integer> numberHolder,
- Spinner spinner,
- int defaultValue) {
- super();
- if ((numberHolder == null) || (spinner == null)) {
- throw new NullPointerException();
- }
- this.numberHolder = numberHolder;
- this.spinner = spinner;
- this.defaultValue = defaultValue;
-
- this.propertyChangeListener = this.buildPropertyChangeListener();
- this.numberHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.propertyChangeListener);
-
- this.spinnerModifyListener = this.buildSpinnerModifyListener();
- this.spinner.addModifyListener(this.spinnerModifyListener);
-
- this.spinnerDisposeListener = this.buildSpinnerDisposeListener();
- this.spinner.addDisposeListener(this.spinnerDisposeListener);
-
- this.updateSpinner(numberHolder.getValue());
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildPropertyChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildPropertyChangeListener_());
- }
-
- protected PropertyChangeListener buildPropertyChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- SpinnerModelAdapter.this.valueChanged(event);
- }
- @Override
- public String toString() {
- return "spinner listener";
- }
- };
- }
-
- protected ModifyListener buildSpinnerModifyListener() {
- return new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- SpinnerModelAdapter.this.spinnerModified(e);
- }
- @Override
- public String toString() {
- return "spinner selection listener";
- }
- };
- }
-
- protected DisposeListener buildSpinnerDisposeListener() {
- return new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- SpinnerModelAdapter.this.spinnerDisposed(event);
- }
- @Override
- public String toString() {
- return "spinner dispose listener";
- }
- };
- }
-
-
- // ********** model events **********
-
- protected void valueChanged(PropertyChangeEvent event) {
- if (!this.locked) {
- this.updateSpinner((Integer) event.getNewValue());
- }
- }
-
-
- // ********** spinner events **********
-
- protected void spinnerModified(ModifyEvent event) {
- if (!this.locked) {
- this.locked = true;
- try {
- this.numberHolder.setValue(this.spinner.getSelection());
- }
- finally {
- this.locked = false;
- }
- }
- }
-
- protected void spinnerDisposed(DisposeEvent event) {
- // the spinner is not yet "disposed" when we receive this event
- // so we can still remove our listeners
- this.spinner.removeDisposeListener(this.spinnerDisposeListener);
- this.spinner.removeModifyListener(this.spinnerModifyListener);
- this.numberHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.propertyChangeListener);
- }
-
- // ********** update **********
-
- protected void updateSpinner(Integer value) {
- if (this.spinner.isDisposed()) {
- return;
- }
- // the model can be null, but the spinner cannot
- if (value == null) {
- value = defaultValue;
- }
- this.locked = true;
- try {
- this.spinner.setSelection(value);
- }
- finally {
- this.locked = false;
- }
- }
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.numberHolder);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TableItemModelAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TableItemModelAdapter.java
deleted file mode 100644
index 88e92486f6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TableItemModelAdapter.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.swt;
-
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-/**
- * This adapter can be used to keep a table item in synch with the properties of
- * a model.
- */
-@SuppressWarnings("nls")
-public class TableItemModelAdapter {
-
- /** The table item we synchronize with the model. */
- protected final TableItem tableItem;
-
- /**
- * A listener that allows us to stop listening to stuff when the button
- * is disposed.
- */
- protected final DisposeListener tableItemDisposeListener;
-
- /**
- * Client-supplied adapter that provides with the various column settings and
- * converts the objects in the LVM into an array of cell models.
- */
- private ColumnAdapter<Object> columnAdapter;
-
- /**
- * The value models used to listen to each property that are display by the
- * table item.
- */
- private ModifiablePropertyValueModel<?>[] valueHolders;
-
- /**
- * The list of <code>PropertyChangeListener</code>s used to be notified when
- * the properties of the model being display into a row change.
- */
- private PropertyChangeListener[] propertyChangeListeners;
-
- /**
- * The label used to format the objects into a string representation.
- */
- private ITableLabelProvider labelProvider;
-
- // ********** static methods **********
-
- /**
- * Adapt the specified boolean to the specified button.
- * If the boolean is null, the button's value will be "unselected".
- */
- public static TableItemModelAdapter adapt(TableItem tableItem, ColumnAdapter<?> columnAdapter, ITableLabelProvider labelProvider) {
- return new TableItemModelAdapter(tableItem, columnAdapter, labelProvider);
- }
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the boolean holder and button are required.
- */
- @SuppressWarnings("unchecked")
- protected TableItemModelAdapter(TableItem tableItem, ColumnAdapter<?> columnAdapter, ITableLabelProvider labelProvider) {
- super();
- if (tableItem == null || columnAdapter == null || labelProvider == null) {
- throw new NullPointerException();
- }
- this.tableItem = tableItem;
- this.labelProvider = labelProvider;
- this.columnAdapter = (ColumnAdapter<Object>) columnAdapter;
-
- this.tableItemDisposeListener = this.buildTableItemDisposeListener();
- this.tableItem.addDisposeListener(this.tableItemDisposeListener);
-
- this.valueHolders = this.columnAdapter.cellModels(tableItem.getData());
- this.propertyChangeListeners = this.buildPropertyChangeListeners();
-
- for (int index = this.columnAdapter.columnCount(); --index >= 0; ) {
- tableItemChanged(index, tableItem.getData(), false);
- valueHolders[index].addPropertyChangeListener(PropertyValueModel.VALUE, propertyChangeListeners[index]);
- }
- }
-
-
- // ********** initialization **********
-
- private PropertyChangeListener[] buildPropertyChangeListeners() {
- PropertyChangeListener[] listeners = new PropertyChangeListener[columnAdapter.columnCount()];
- for (int index = listeners.length; --index >= 0; ) {
- listeners[index] = buildPropertyChangeListener(index);
- }
- return listeners;
- }
-
-
- protected PropertyChangeListener buildPropertyChangeListener(int index) {
- return new SWTPropertyChangeListenerWrapper(
- this.buildPropertyChangeListener_(index)
- );
- }
-
- protected PropertyChangeListener buildPropertyChangeListener_(int index) {
- return new TableItemPropertyChangeListener(index);
- }
-
- protected DisposeListener buildTableItemDisposeListener() {
- return new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- TableItemModelAdapter.this.tableItemDisposed(event);
- }
- @Override
- public String toString() {
- return "TableItem dispose listener";
- }
- };
- }
-
-
- // ********** behavior **********
-
- protected void tableItemChanged(int index, Object subject, boolean revalidate) {
-
- if (!this.tableItem.isDisposed()) {
- this.updateTableItemText(index, subject);
- this.updateTableItemImage(index, subject);
-
- if (revalidate) {
- this.layoutTable();
- }
- }
- }
-
- private void updateTableItemText(int index, Object subject) {
- String text = this.labelProvider.getColumnText(subject, index);
- if (text == null) {
- text = "";
- }
- this.tableItem.setText(index, text);
- }
-
- private void updateTableItemImage(int index, Object subject) {
- Image image = this.labelProvider.getColumnImage(subject, index);
- this.tableItem.setImage(index, image);
- }
-
- private void layoutTable() {
- // Refresh the table in order to show the scrollbar if required
- Composite container = this.tableItem.getParent().getParent();
- container.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- container.layout();
- }
-
- // ********** dispose **********
-
- protected void tableItemDisposed(DisposeEvent event) {
- // the button is not yet "disposed" when we receive this event
- // so we can still remove our listeners
- this.tableItem.removeDisposeListener(this.tableItemDisposeListener);
-
- for (int index = valueHolders.length; --index >= 0; ) {
- valueHolders[index].removePropertyChangeListener(PropertyValueModel.VALUE, propertyChangeListeners[index]);
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
- private class TableItemPropertyChangeListener implements PropertyChangeListener {
-
- private final int index;
-
- TableItemPropertyChangeListener(int index) {
- super();
- this.index = index;
- }
-
- public void propertyChanged(PropertyChangeEvent event) {
- if (!tableItem.isDisposed()) {
- Table table = tableItem.getParent();
- tableItemChanged(index, tableItem.getData(), table.getColumnCount() == 0);
- }
- }
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TableModelAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TableModelAdapter.java
deleted file mode 100644
index 5c0172faa3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TableModelAdapter.java
+++ /dev/null
@@ -1,746 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.swt;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EventListener;
-import java.util.EventObject;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTCollectionChangeListenerWrapper;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTListChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyCollectionValueModelAdapter;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-
-/**
- * This adapter provides a more object-oriented interface to the items and
- * selected items in a table.
- * {@link #listHolder} contains the data of a single column in the table.
- * {@link #selectedItemsHolder} contains the data of a single column in
- * {@link #listHolder} that are selected in the table.
- */
-// TODO bjv
-@SuppressWarnings("nls")
-public class TableModelAdapter<E> {
-
- // ********** model **********
- /**
- * A value model on the underlying model list.
- */
- protected final ListValueModel<E> listHolder;
-
- /**
- * A listener that allows us to synchronize the table's contents with
- * the model list.
- */
- protected final ListChangeListener listChangeListener;
-
- /**
- * A value model on the underlying model selections.
- */
- protected final CollectionValueModel<E> selectedItemsHolder;
-
- /**
- * A listener that allows us to synchronize the table's selection with
- * the model selections.
- */
- protected final CollectionChangeListener selectedItemsChangeListener;
-
- /**
- * The table we keep synchronized with the model list.
- */
- protected final Table table;
-
- /**
- * A listener that allows us to synchronize our selection list holder
- * with the table's selection.
- */
- protected final SelectionListener tableSelectionListener;
-
- /**
- * Clients that are interested in selection change events.
- */
- protected final ListenerList<SelectionChangeListener<E>> selectionChangeListenerList;
-
- /**
- * Clients that are interested in double click events.
- */
- protected final ListenerList<DoubleClickListener<E>> doubleClickListenerList;
-
- /**
- * A listener that allows us to stop listening to stuff when the table
- * is disposed.
- */
- protected final DisposeListener tableDisposeListener;
-
- /**
- * This label provider is responsible to convert a property at a column index
- * to a string value.
- */
- protected final ITableLabelProvider labelProvider;
-
- /**
- * The column adapter is responsible to return the count of columns and to
- * create the value holders for all the properties.
- */
- private ColumnAdapter<E> columnAdapter;
-
- /**
- * Keeps track of the <code>TableItemModelAdapter</code>s that were created
- * for each item of the list holder.
- */
- private List<TableItemModelAdapter> tableItemModelAdapters;
-
-
- // ********** static methods **********
-
- /**
- * Adapt the specified list model and selection to the specified table.
- * Use the specified string converter to convert the model items to strings
- * to be displayed in the table.
- */
- public static <T> TableModelAdapter<T> adapt(
- ListValueModel<T> listHolder,
- PropertyValueModel<T> selectedItemHolder,
- Table table,
- ColumnAdapter<T> columnAdapter,
- ITableLabelProvider labelProvider) {
-
- return new TableModelAdapter<T>(
- listHolder,
- new PropertyCollectionValueModelAdapter<T>(selectedItemHolder),
- table,
- columnAdapter,
- labelProvider);
- }
-
- /**
- * Adapt the specified list model and selection to the specified table.
- * The specified selection model will be kept in sync with the table.
- * Use the specified string converter to convert the model items to strings
- * to be displayed in the table.
- */
- public static <T> TableModelAdapter<T> adapt(
- ListValueModel<T> listHolder,
- ModifiableCollectionValueModel<T> selectionModel,
- Table table,
- ColumnAdapter<T> columnAdapter,
- ITableLabelProvider labelProvider) {
-
- TableModelAdapter adapter =
- new TableModelAdapter<T>(
- listHolder,
- selectionModel,
- table,
- columnAdapter,
- labelProvider);
- adapter.addSelectionChangeListener(buildSyncListener(selectionModel));
- return adapter;
- }
-
- private static <T> SelectionChangeListener buildSyncListener(
- final ModifiableCollectionValueModel<T> selectionModel) {
-
- return new SelectionChangeListener() {
- public void selectionChanged(SelectionChangeEvent event) {
- selectionModel.setValues(CollectionTools.iterable(event.selection()));
- }
- };
- }
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the list holder, selections holder, table, and
- * string converter are required.
- */
- protected TableModelAdapter(
- ListValueModel<E> listHolder,
- CollectionValueModel<E> selectedItemsHolder,
- Table table,
- ColumnAdapter<E> columnAdapter,
- ITableLabelProvider labelProvider)
- {
- super();
- if ((listHolder == null) || (selectedItemsHolder == null) || (table == null) || (labelProvider == null)) {
- throw new NullPointerException();
- }
- this.listHolder = listHolder;
- this.selectedItemsHolder = selectedItemsHolder;
- this.table = table;
- this.columnAdapter = columnAdapter;
- this.labelProvider = labelProvider;
- this.tableItemModelAdapters = new ArrayList<TableItemModelAdapter>(columnAdapter.columnCount());
-
- this.listChangeListener = this.buildListChangeListener();
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
-
- this.selectedItemsChangeListener = this.buildSelectedItemsChangeListener();
- this.selectedItemsHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.selectedItemsChangeListener);
-
- this.tableSelectionListener = this.buildTableSelectionListener();
- this.table.addSelectionListener(this.tableSelectionListener);
-
- this.selectionChangeListenerList = this.buildSelectionChangeListenerList();
- this.doubleClickListenerList = this.buildDoubleClickListenerList();
-
- this.tableDisposeListener = this.buildTableDisposeListener();
- this.table.addDisposeListener(this.tableDisposeListener);
-
- this.synchronizeTable();
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildListChangeListener() {
- return new SWTListChangeListenerWrapper(this.buildListChangeListener_());
- }
-
- protected ListChangeListener buildListChangeListener_() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent event) {
- TableModelAdapter.this.listItemsAdded(event);
- }
- public void itemsRemoved(ListRemoveEvent event) {
- TableModelAdapter.this.listItemsRemoved(event);
- }
- public void itemsMoved(ListMoveEvent event) {
- TableModelAdapter.this.listItemsMoved(event);
- }
- public void itemsReplaced(ListReplaceEvent event) {
- TableModelAdapter.this.listItemsReplaced(event);
- }
- public void listCleared(ListClearEvent event) {
- TableModelAdapter.this.listCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- TableModelAdapter.this.listChanged(event);
- }
- @Override
- public String toString() {
- return "TableModelAdapter list listener";
- }
- };
- }
-
- protected CollectionChangeListener buildSelectedItemsChangeListener() {
- return new SWTCollectionChangeListenerWrapper(this.buildSelectedItemsChangeListener_());
- }
-
- protected CollectionChangeListener buildSelectedItemsChangeListener_() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent event) {
- TableModelAdapter.this.selectedItemsAdded(event);
- }
- public void itemsRemoved(CollectionRemoveEvent event) {
- TableModelAdapter.this.selectedItemsRemoved(event);
- }
- public void collectionCleared(CollectionClearEvent event) {
- TableModelAdapter.this.selectedItemsCleared(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- TableModelAdapter.this.selectedItemsChanged(event);
- }
- @Override
- public String toString() {
- return "TableModelAdapter selected items listener";
- }
- };
- }
-
- protected SelectionListener buildTableSelectionListener() {
- return new SelectionListener() {
- public void widgetSelected(SelectionEvent event) {
- TableModelAdapter.this.tableSelectionChanged(event);
- }
- public void widgetDefaultSelected(SelectionEvent event) {
- TableModelAdapter.this.tableDoubleClicked(event);
- }
- @Override
- public String toString() {
- return "TableModelAdapter table selection listener";
- }
- };
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- protected ListenerList<DoubleClickListener<E>> buildDoubleClickListenerList() {
- return new ListenerList(DoubleClickListener.class);
- }
-
- @SuppressWarnings({"rawtypes", "unchecked"})
- protected ListenerList<SelectionChangeListener<E>> buildSelectionChangeListenerList() {
- return new ListenerList(SelectionChangeListener.class);
- }
-
- protected DisposeListener buildTableDisposeListener() {
- return new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- TableModelAdapter.this.tableDisposed(event);
- }
- @Override
- public String toString() {
- return "TableModelAdapter table dispose listener";
- }
- };
- }
-
- protected void synchronizeTable() {
- this.synchronizeTableColumns();
- this.synchronizeTableItems();
- this.synchronizeTableSelection();
- }
-
-
- // ********** list **********
-
- /**
- * Creates the table colums.
- */
- protected void synchronizeTableColumns() {
- if (this.table.isDisposed()) {
- return;
- }
-
- int columnCount = this.columnAdapter.columnCount();
-
- for (int index = 0; index < columnCount; index++) {
- TableColumn tableColumn = new TableColumn(this.table, SWT.NULL, index);
- tableColumn.setMoveable(false);
- tableColumn.setResizable(true);
- tableColumn.setWidth(100);
-
- String columnName = this.columnAdapter.columnName(index);
-
- if (columnName == null) {
- columnName = "";
- }
-
- tableColumn.setText(columnName);
- }
- }
-
- /**
- * Brute force synchronization of table with the model list.
- */
- protected void synchronizeTableItems() {
- if (this.table.isDisposed()) {
- return;
- }
-
- for (int index = this.table.getItemCount(); --index >= 0; ) {
- this.table.remove(index);
- this.tableItemModelAdapters.remove(index);
- }
-
- int itemCount = this.listHolder.size();
-
- for (int index = 0; index < itemCount; index++) {
-
- TableItem tableItem = new TableItem(this.table, SWT.NULL, index);
- tableItem.setData(this.listHolder.get(index));
-
- TableItemModelAdapter adapter = this.buildItemModel(tableItem);
- this.tableItemModelAdapters.add(adapter);
- }
- }
-
- /**
- * The model has changed - synchronize the table.
- */
- protected void listItemsAdded(ListAddEvent event) {
-
- if (this.table.isDisposed()) {
- return;
- }
-
- int index = event.getIndex();
-
- for (E item : this.getItems(event)) {
-
- TableItem tableItem = new TableItem(this.table, SWT.NULL, index);
- tableItem.setData(item);
-
- TableItemModelAdapter adapter = this.buildItemModel(tableItem);
- this.tableItemModelAdapters.add(index++, adapter);
- }
- }
-
- /**
- * The model has changed - synchronize the table.
- */
- protected void listItemsRemoved(ListRemoveEvent event) {
-
- if (this.table.isDisposed()) {
- return;
- }
-
- this.table.remove(event.getIndex(), event.getIndex() + event.getItemsSize() - 1);
-
- for (int index = event.getIndex() + event.getItemsSize(); --index >= event.getIndex(); ) {
- this.tableItemModelAdapters.remove(index);
- }
- }
-
- /**
- * The model has changed - synchronize the table.
- */
- protected void listItemsMoved(ListMoveEvent event) {
-
- if (this.table.isDisposed()) {
- return;
- }
-
- int length = event.getLength();
- int sourceIndex = event.getSourceIndex();
- int targetIndex = event.getTargetIndex();
- int lowStartIndex = Math.min(targetIndex, sourceIndex);
- int hiStartIndex = Math.max(targetIndex, sourceIndex);
-
- Object[] items = new Object[hiStartIndex - lowStartIndex + length];
- int itemsIndex = items.length;
-
- // Remove the TableItems wrapping the moved items
- for (int index = hiStartIndex + length; --index >= lowStartIndex; ) {
-
- TableItemModelAdapter tableItemModel = this.tableItemModelAdapters.get(index);
- items[--itemsIndex] = tableItemModel.tableItem.getData();
-
- // Remove the TableItem, which will also dispose TableItemModelAdapter
- this.table.remove(index);
- }
-
- // Move the items so they can retrieved in the right order when
- // re-creating the TableItems
- ArrayTools.move(
- items,
- targetIndex - lowStartIndex,
- sourceIndex - lowStartIndex,
- length
- );
-
- itemsIndex = 0;
-
- // Add TableItems for the moved items
- for (int index = lowStartIndex; index <= hiStartIndex + length - 1; index++) {
-
- // Create the new TableItem
- TableItem tableItem = new TableItem(this.table, SWT.NULL, index);
- tableItem.setData(items[itemsIndex++]);
-
- // Adapt it with a model adapter
- TableItemModelAdapter adapter = this.buildItemModel(tableItem);
- this.tableItemModelAdapters.set(index, adapter);
- }
- }
-
-
- private TableItemModelAdapter buildItemModel(TableItem tableItem) {
- return TableItemModelAdapter.adapt(
- tableItem,
- this.columnAdapter,
- this.labelProvider
- );
- }
-
- /**
- * The model has changed - synchronize the table.
- */
- protected void listItemsReplaced(ListReplaceEvent event) {
- if (this.table.isDisposed()) {
- return;
- }
-
- int rowIndex = event.getIndex();
-
- for (E item : this.getNewItems(event)) {
- TableItem tableItem = this.table.getItem(rowIndex);
- tableItem.setData(item);
-
- TableItemModelAdapter adapter = this.tableItemModelAdapters.get(rowIndex);
-
- int columnCount = this.columnAdapter.columnCount();
- boolean revalidate = (columnCount == 1);
-
- for (int columnIndex = columnCount; --columnIndex >= 0; ) {
- adapter.tableItemChanged(columnIndex, tableItem.getData(), revalidate);
- }
-
- rowIndex++;
- }
- }
-
- /**
- * The model has changed - synchronize the table.
- */
- protected void listCleared(@SuppressWarnings("unused") ListClearEvent event) {
- if (this.table.isDisposed()) {
- return;
- }
- this.table.removeAll();
- }
-
- /**
- * The model has changed - synchronize the table.
- */
- protected void listChanged(@SuppressWarnings("unused") ListChangeEvent event) {
- this.synchronizeTableItems();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(ListAddEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getNewItems(ListReplaceEvent event) {
- return (Iterable<E>) event.getNewItems();
- }
-
-
- // ********** selected items **********
-
- protected int indexOf(E item) {
- int len = this.listHolder.size();
- for (int i = 0; i < len; i++) {
- if (this.listHolder.get(i) == item) {
- return i;
- }
- }
- return -1;
- }
-
- protected void synchronizeTableSelection() {
- if (this.table.isDisposed()) {
- return;
- }
- int[] indices = new int[this.selectedItemsHolder.size()];
- int i = 0;
- for (E selectedItemHolder : this.selectedItemsHolder) {
- indices[i++] = this.indexOf(selectedItemHolder);
- }
- this.table.deselectAll();
- this.table.select(indices);
- }
-
- protected void selectedItemsAdded(CollectionAddEvent event) {
- if (this.table.isDisposed()) {
- return;
- }
- this.table.select(this.getIndices(event.getItemsSize(), this.getItems(event)));
- }
-
- protected void selectedItemsRemoved(CollectionRemoveEvent event) {
- if (this.table.isDisposed()) {
- return;
- }
- this.table.deselect(this.getIndices(event.getItemsSize(), this.getItems(event)));
- }
-
- protected int[] getIndices(int itemsSize, Iterable<E> items) {
- int[] indices = new int[itemsSize];
- int i = 0;
- for (E item : items) {
- indices[i++] = this.indexOf(item);
- }
- return indices;
- }
-
- protected void selectedItemsCleared(@SuppressWarnings("unused") CollectionClearEvent event) {
- if (this.table.isDisposed()) {
- return;
- }
- this.table.deselectAll();
- }
-
- protected void selectedItemsChanged(@SuppressWarnings("unused") CollectionChangeEvent event) {
- this.synchronizeTableSelection();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(CollectionAddEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(CollectionRemoveEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
-
- // ********** list box events **********
-
- protected void tableSelectionChanged(@SuppressWarnings("unused") SelectionEvent event) {
- if (this.selectionChangeListenerList.size() > 0) {
- SelectionChangeEvent<E> scEvent = new SelectionChangeEvent<E>(this, this.selectedItems());
- for (SelectionChangeListener<E> selectionChangeListener : this.selectionChangeListenerList.getListeners()) {
- selectionChangeListener.selectionChanged(scEvent);
- }
- }
- }
-
- protected Collection<E> selectedItems() {
- if (this.table.isDisposed()) {
- return Collections.emptySet();
- }
- ArrayList<E> selectedItems = new ArrayList<E>(this.table.getSelectionCount());
- for (int selectionIndex : this.table.getSelectionIndices()) {
- selectedItems.add(this.listHolder.get(selectionIndex));
- }
- return selectedItems;
- }
-
- protected void tableDoubleClicked(@SuppressWarnings("unused") SelectionEvent event) {
- if (this.table.isDisposed()) {
- return;
- }
- if (this.doubleClickListenerList.size() > 0) {
- // there should be only a single item selected during a double-click(?)
- E selection = this.listHolder.get(this.table.getSelectionIndex());
- DoubleClickEvent<E> dcEvent = new DoubleClickEvent<E>(this, selection);
- for (DoubleClickListener<E> doubleClickListener : this.doubleClickListenerList.getListeners()) {
- doubleClickListener.doubleClick(dcEvent);
- }
- }
- }
-
-
- // ********** dispose **********
-
- protected void tableDisposed(@SuppressWarnings("unused") DisposeEvent event) {
- // the table is not yet "disposed" when we receive this event
- // so we can still remove our listeners
- this.table.removeDisposeListener(this.tableDisposeListener);
- this.table.removeSelectionListener(this.tableSelectionListener);
- this.selectedItemsHolder.removeCollectionChangeListener(CollectionValueModel.VALUES, this.selectedItemsChangeListener);
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listHolder);
- }
-
-
- // ********** double click support **********
-
- public void addDoubleClickListener(DoubleClickListener<E> listener) {
- this.doubleClickListenerList.add(listener);
- }
-
- public void removeDoubleClickListener(DoubleClickListener<E> listener) {
- this.doubleClickListenerList.remove(listener);
- }
-
- public interface DoubleClickListener<E> extends EventListener {
- void doubleClick(DoubleClickEvent<E> event);
- }
-
- public static class DoubleClickEvent<E> extends EventObject {
- private final E selection;
- private static final long serialVersionUID = 1L;
-
- protected DoubleClickEvent(TableModelAdapter<E> source, E selection) {
- super(source);
- if (selection == null) {
- throw new NullPointerException();
- }
- this.selection = selection;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public TableModelAdapter<E> getSource() {
- return (TableModelAdapter<E>) super.getSource();
- }
-
- public E selection() {
- return this.selection;
- }
-
- }
-
-
- // ********** selection support **********
-
- public void addSelectionChangeListener(SelectionChangeListener<E> listener) {
- this.selectionChangeListenerList.add(listener);
- }
-
- public void removeSelectionChangeListener(SelectionChangeListener<E> listener) {
- this.selectionChangeListenerList.remove(listener);
- }
-
- public interface SelectionChangeListener<E> extends EventListener {
- void selectionChanged(SelectionChangeEvent<E> event);
- }
-
- public static class SelectionChangeEvent<E> extends EventObject {
- private final Collection<E> selection;
- private static final long serialVersionUID = 1L;
-
- protected SelectionChangeEvent(TableModelAdapter<E> source, Collection<E> selection) {
- super(source);
- if (selection == null) {
- throw new NullPointerException();
- }
- this.selection = selection;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public TableModelAdapter<E> getSource() {
- return (TableModelAdapter<E>) super.getSource();
- }
-
- public Iterator<E> selection() {
- return this.selection.iterator();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TriStateCheckBoxModelAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TriStateCheckBoxModelAdapter.java
deleted file mode 100644
index be0ee1f839..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/swt/TriStateCheckBoxModelAdapter.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.swt;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.ui.internal.widgets.TriStateCheckBox;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-
-/**
- * This adapter can be used to keep a tri-state check box in synch with
- * a model Boolean where the value can be <code>null</code>.
- */
-@SuppressWarnings("nls")
-public class TriStateCheckBoxModelAdapter {
-
- /** A value model on the underlying model boolean. */
- protected final ModifiablePropertyValueModel<Boolean> booleanHolder;
-
- /**
- * A listener that allows us to synchronize the button's selection state with
- * the model boolean.
- */
- protected final PropertyChangeListener booleanChangeListener;
-
- /** The check box/toggle button we synchronize with the model boolean. */
- protected final TriStateCheckBox button;
-
- /**
- * A listener that allows us to synchronize the model boolean with
- * the button's selection state.
- */
- protected final SelectionListener buttonSelectionListener;
-
- /**
- * A listener that allows us to stop listening to stuff when the button
- * is disposed.
- */
- protected final DisposeListener buttonDisposeListener;
-
-
- // ********** static methods **********
-
- /**
- * Adapt the specified boolean to the specified button.
- * If the boolean is null, the button's value will be "partially checked"
- * (i.e. the button will be checked but grayed out).
- */
- public static TriStateCheckBoxModelAdapter adapt(ModifiablePropertyValueModel<Boolean> booleanHolder, TriStateCheckBox button) {
- return new TriStateCheckBoxModelAdapter(booleanHolder, button);
- }
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the boolean holder and button are required.
- */
- protected TriStateCheckBoxModelAdapter(ModifiablePropertyValueModel<Boolean> booleanHolder, TriStateCheckBox button) {
- super();
-
- Assert.isNotNull(booleanHolder, "The boolean holder cannot be null");
- Assert.isNotNull(button, "The check box cannot be null");
-
- this.booleanHolder = booleanHolder;
- this.button = button;
-
- this.booleanChangeListener = this.buildBooleanChangeListener();
- this.booleanHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.booleanChangeListener);
-
- this.buttonDisposeListener = this.buildButtonDisposeListener();
- this.button.addDisposeListener(this.buttonDisposeListener);
-
- this.buttonSelectionListener = this.buildButtonSelectionListener();
- this.button.addSelectionListener(this.buttonSelectionListener);
-
- this.setButtonSelection(this.booleanHolder.getValue());
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildBooleanChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildBooleanChangeListener_());
- }
-
- protected PropertyChangeListener buildBooleanChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- TriStateCheckBoxModelAdapter.this.booleanChanged(event);
- }
- @Override
- public String toString() {
- return "tri-state boolean listener";
- }
- };
- }
-
- protected SelectionListener buildButtonSelectionListener() {
- return new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- TriStateCheckBoxModelAdapter.this.buttonSelected(event);
- }
- @Override
- public String toString() {
- return "tri-state button selection listener";
- }
- };
- }
-
- protected DisposeListener buildButtonDisposeListener() {
- return new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- TriStateCheckBoxModelAdapter.this.buttonDisposed(event);
- }
- @Override
- public String toString() {
- return "tri-state button dispose listener";
- }
- };
- }
-
-
- // ********** behavior **********
-
- /**
- * The model has changed - synchronize the button.
- * If the new model value is null, use the adapter's default value
- * (which is typically false).
- */
- protected void booleanChanged(PropertyChangeEvent event) {
- this.setButtonSelection((Boolean) event.getNewValue());
- }
-
- protected void setButtonSelection(Boolean selection) {
- if (this.button.isDisposed()) {
- return;
- }
- this.button.setSelection(selection);
- }
-
- /**
- * The button has been "selected" - synchronize the model.
- */
- protected void buttonSelected(SelectionEvent event) {
- if (this.button.isDisposed()) {
- return;
- }
- this.booleanHolder.setValue(button.getSelection());
- }
-
-
- // ********** dispose **********
-
- protected void buttonDisposed(DisposeEvent event) {
- // the button is not yet "disposed" when we receive this event
- // so we can still remove our listeners
- this.button.removeSelectionListener(this.buttonSelectionListener);
- this.button.removeDisposeListener(this.buttonDisposeListener);
- this.booleanHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.booleanChangeListener);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.booleanHolder);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlAligner.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlAligner.java
deleted file mode 100644
index ebbd1eed4c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlAligner.java
+++ /dev/null
@@ -1,913 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-
-/**
- * This class is responsible to set a preferred width on the registered widgets
- * (either <code>Control</code> or <code>ControlAligner</code>) based on the
- * widest widget.
- * <p>
- * Important: The layout data has to be a <code>GridData</code>. If none is set,
- * then a new <code>GridData</code> is automatically created.
- * <p>
- * Here an example of the result if this aligner is used to align controls
- * within either one or two group boxes, the controls added are the labels in
- * this case. It is also possible to align controls on the right side of the
- * main component, a spacer can be used for extra space.
- * <p>
- * Here's an example:
- * <pre>
- * - Group Box 1 --------------------------------------------------------------
- * | -------------------------------------- ------------- |
- * | Name: | I | | Browse... | |
- * | -------------------------------------- ------------- |
- * | --------- |
- * | Preallocation Size: | |I| |
- * | --------- |
- * | -------------------------------------- |
- * | Descriptor: | |v| |
- * | -------------------------------------- |
- * ----------------------------------------------------------------------------
- *
- * - Group Box 2 --------------------------------------------------------------
- * | -------------------------------------- |
- * | Mapping Type: | |V| |
- * | -------------------------------------- |
- * | -------------------------------------- |
- * | Check in Script: | I | |
- * | -------------------------------------- |
- * ----------------------------------------------------------------------------</pre>
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public final class ControlAligner
-{
- /**
- * Flag used to prevent a validation so it can be done after an operation
- * completed.
- */
- private boolean autoValidate;
-
- /**
- * The utility class used to support bound properties.
- */
- private Collection<Listener> changeSupport;
-
- /**
- * The listener added to each of the controls that listens only to a text
- * change.
- */
- private Listener listener;
-
- /**
- * Prevents infinite recursion when recalculating the preferred width.
- * This happens in an hierarchy of <code>ControlAligner</code>s. The lock
- * has to be placed here and not in the {@link ControlAlignerWrapper}.
- */
- private boolean locked;
-
- /**
- * The length of the widest control. If the length was not calculated, then
- * this value is 0.
- */
- private int maximumWidth;
-
- /**
- * The collection of {@link Wrapper}s encapsulating either <code>Control</code>s
- * or {@link ControlAligner}s.
- */
- private Collection<Wrapper> wrappers;
-
- /**
- * A null-<code>Point</code> object used to clear the preferred size.
- */
- private static final Point DEFAULT_SIZE = new Point(SWT.DEFAULT, SWT.DEFAULT);
-
- /**
- * The types of events to listen in order to properly adjust the size of all
- * the widgets.
- */
- private static final int[] EVENT_TYPES = {
- SWT.Dispose,
- SWT.Hide,
- SWT.Resize,
- SWT.Show
- };
-
- /**
- * Creates a new <code>ControlAligner</code>.
- */
- public ControlAligner() {
- super();
- initialize();
- }
-
- /**
- * Creates a new <code>ControlAligner</code>.
- *
- * @param controls The collection of <code>Control</code>s
- */
- public ControlAligner(Collection<? extends Control> controls) {
- this();
- addAllControls(controls);
- }
-
- /**
- * Adds the given control. Its width will be used along with the width of all
- * the other registered controls in order to get the greater witdh and use
- * it as the width for all the controls.
- *
- * @param control The <code>Control</code> to be added
- */
- public void add(Control control) {
-
- Assert.isNotNull(control, "Can't add null to this ControlAligner");
-
- Wrapper wrapper = buildWrapper(control);
- wrapper.addListener(listener);
- wrappers.add(wrapper);
-
- revalidate(false);
- }
-
- /**
- * Adds the given control. Its width will be used along with the width of all
- * the other registered controls in order to get the greater witdh and use
- * it as the width for all the controls.
- *
- * @param controlAligner The <code>ControlAligner</code> to be added
- * @exception IllegalArgumentException Can't add the <code>ControlAligner</code>
- * to itself
- */
- public void add(ControlAligner controlAligner) {
-
- Assert.isNotNull(controlAligner, "Can't add null to this ControlAligner");
- Assert.isLegal(controlAligner != this, "Can't add the ControlAligner to itself");
-
- Wrapper wrapper = buildWrapper(controlAligner);
- wrapper.addListener(listener);
- wrappers.add(wrapper);
-
- if (!controlAligner.wrappers.isEmpty()) {
- revalidate(false);
- }
- }
-
- /**
- * Adds the items contained in the given collection into this
- * <code>ControlAligner</code>. The preferred width of each item will be
- * used along with the width of all the other items in order to get the
- * widest control and use its width as the width for all the controls.
- *
- * @param aligners The collection of <code>ControlAligner</code>s
- */
- public void addAllControlAligners(Collection<ControlAligner> aligners) {
-
- // Deactivate the auto validation while adding all the Controls and/or
- // ControlAligners in order to improve performance
- boolean oldAutoValidate = autoValidate;
- autoValidate = false;
-
- for (ControlAligner aligner : aligners) {
- add(aligner);
- }
-
- autoValidate = oldAutoValidate;
- revalidate(false);
- }
-
- /**
- * Adds the items contained in the given collection into this
- * <code>ControlAligner</code>. The preferred width of each item will be
- * used along with the width of all the other items in order to get the
- * widest control and use its width as the width for all the controls.
- *
- * @param controls The collection of <code>Control</code>s
- */
- public void addAllControls(Collection<? extends Control> controls) {
-
- // Deactivate the auto validation while adding all the Controls and/or
- // ControlAligners in order to improve performance
- boolean oldAutoValidate = autoValidate;
- autoValidate = false;
-
- for (Control control : controls) {
- add(control);
- }
-
- autoValidate = oldAutoValidate;
- revalidate(false);
- }
-
- /**
- * Adds the given <code>ControListener</code>.
- *
- * @param listener The <code>Listener</code> to be added
- */
- private void addListener(Listener listener) {
-
- if (changeSupport == null) {
- changeSupport = new ArrayList<Listener>();
- }
-
- changeSupport.add(listener);
- }
-
- /**
- * Creates a new <code>Wrapper</code> that encapsulates the given source.
- *
- * @param control The control to be wrapped
- * @return A new {@link Wrapper}
- */
- private Wrapper buildWrapper(Control control) {
- return new ControlWrapper(control);
- }
-
- /**
- * Creates a new <code>Wrapper</code> that encapsulates the given source.
- *
- * @param ControlAligner The <code>ControlAligner</code> to be wrapped
- * @return A new {@link ControlAlignerWrapper}
- */
- private Wrapper buildWrapper(ControlAligner ControlAligner) {
- return new ControlAlignerWrapper(ControlAligner);
- }
-
- /**
- * Calculates the width taken by the widgets and returns the maximum width.
- *
- * @param recalculateSize <code>true</code> to recalculate the preferred size
- * of all the wrappers contained within them rather than using the cached
- * size; <code>false</code> to use the cached size
- */
- private int calculateWidth(boolean recalculateSize) {
-
- int width = 0;
-
- for (Wrapper wrapper : wrappers) {
- Point size = wrapper.cachedSize();
-
- // The size has not been calculated yet
- if (recalculateSize || (size.x == 0)) {
- size = wrapper.calculateSize();
- }
-
- // Only keep the greatest width
- width = Math.max(size.x, width);
- }
-
- return width;
- }
-
- /**
- * Reports a bound property change.
- *
- * @param oldValue the old value of the property (as an int)
- * @param newValue the new value of the property (as an int)
- */
- private void controlResized(int oldValue, int newValue) {
-
- if ((changeSupport != null) && (oldValue != newValue)) {
- Event event = new Event();
- event.widget = SWTUtil.getShell();
- event.data = this;
-
- for (Listener listener : changeSupport) {
- listener.handleEvent(event);
- }
- }
- }
-
- /**
- * Disposes this <code>ControlAligner</code>, this can improve the speed of
- * disposing a pane. When a pane is disposed, this aligner doesn't need to
- * revalidate its size upon dispose of its widgets.
- */
- public void dispose() {
-
- for (Iterator<Wrapper> iter = wrappers.iterator(); iter.hasNext(); ) {
- Wrapper wrapper = iter.next();
- wrapper.removeListener(listener);
- iter.remove();
- }
-
- this.wrappers.clear();
- }
-
- /**
- * Returns the length of the widest control. If the length was not
- * calculated, then this value is 0.
- *
- * @return The width of the widest control or 0 if the length has not been
- * calculated yet
- */
- public int getMaximumWidth() {
- return maximumWidth;
- }
-
- /**
- * Initializes this <code>ControlAligner</code>.
- */
- private void initialize() {
-
- this.autoValidate = true;
- this.maximumWidth = 0;
- this.listener = new ListenerHandler();
- this.wrappers = new ArrayList<Wrapper>();
- }
-
- /**
- * Invalidates the size of the given object.
- *
- * @param source The source object to be invalidated
- */
- private void invalidate(Object source) {
-
- Wrapper wrapper = retrieveWrapper(source);
-
- if (!wrapper.locked()) {
- Point size = wrapper.cachedSize();
- size.x = size.y = 0;
- wrapper.setSize(DEFAULT_SIZE);
- }
- }
-
- /**
- * Updates the maximum length based on the widest control. This methods
- * does not update the width of the controls.
- *
- * @param recalculateSize <code>true</code> to recalculate the preferred size
- * of all the wrappers contained within them rather than using the cached
- * size; <code>false</code> to use the cached size
- */
- private void recalculateWidth(boolean recalculateSize) {
-
- int width = calculateWidth(recalculateSize);
-
- try {
- locked = true;
- setMaximumWidth(width);
- }
- finally {
- locked = false;
- }
- }
-
- /**
- * Removes the given control. Its preferred width will not be used when
- * calculating the preferred width.
- *
- * @param control The control to be removed
- * @exception AssertionFailedException If the given <code>Control</code> is
- * <code>null</code>
- */
- public void remove(Control control) {
-
- Assert.isNotNull(control, "The Control to remove cannot be null");
-
- Wrapper wrapper = retrieveWrapper(control);
- wrapper.removeListener(listener);
- wrappers.remove(wrapper);
-
- revalidate(true);
- }
-
- /**
- * Removes the given <code>ControlAligner</code>. Its preferred width
- * will not be used when calculating the preferred witdh.
- *
- * @param controlAligner The <code>ControlAligner</code> to be removed
- * @exception AssertionFailedException If the given <code>ControlAligner</code>
- * is <code>null</code>
- */
- public void remove(ControlAligner controlAligner) {
-
- Assert.isNotNull(controlAligner, "The ControlAligner to remove cannot be null");
-
- Wrapper wrapper = retrieveWrapper(controlAligner);
- wrapper.removeListener(listener);
- wrappers.remove(wrapper);
-
- revalidate(true);
- }
-
- /**
- * Removes the given <code>Listener</code>.
- *
- * @param listener The <code>Listener</code> to be removed
- */
- private void removeListener(Listener listener) {
-
- changeSupport.remove(listener);
-
- if (changeSupport.isEmpty()) {
- changeSupport = null;
- }
- }
-
- /**
- * Retrieves the <code>Wrapper</code> that is encapsulating the given object.
- *
- * @param source Either a <code>Control</code> or a <code>ControlAligner</code>
- * @return Its <code>Wrapper</code>
- */
- private Wrapper retrieveWrapper(Object source) {
-
- for (Wrapper wrapper : wrappers) {
- if (wrapper.source() == source) {
- return wrapper;
- }
- }
-
- throw new IllegalArgumentException("Can't retrieve the Wrapper for " + source);
- }
-
- /**
- * If the count of control is greater than one and {@link #isAutoValidate()}
- * returns <code>true</code>, then the size of all the registered
- * <code>Control</code>s will be udpated.
- *
- * @param recalculateSize <code>true</code> to recalculate the preferred size
- * of all the wrappers contained within them rather than using the cached
- * size; <code>false</code> to use the cached size
- */
- private void revalidate(boolean recalculateSize) {
-
- if (autoValidate) {
- recalculateWidth(recalculateSize);
- updateWrapperSize(recalculateSize);
- }
- }
-
- /**
- * Bases on the information contained in the given <code>Event</code>,
- * resize the controls.
- *
- * @param event The <code>Event</code> sent by the UI thread when the state
- * of a widget changed
- */
- private void revalidate(Event event) {
-
- // We don't need to revalidate during a revalidation process
- if (locked) {
- return;
- }
-
- Object source;
-
- if (event.widget != SWTUtil.getShell()) {
- source = event.widget;
- Control control = (Control) source;
-
- // When a dialog is opened, we need to actually force a layout of
- // the controls, this is required because the control is actually
- // not visible when the preferred width is caculated
- if (control == control.getShell()) {
- if (event.type == SWT.Dispose) {
- return;
- }
-
- source = null;
- }
- }
- else {
- source = event.data;
- }
-
- // Either remove the ControlWrapper if the widget was disposed or
- // invalidate the widget in order to recalculate the preferred size
- if (source != null) {
- if (event.type == SWT.Dispose) {
- Wrapper wrapper = retrieveWrapper(source);
- wrappers.remove(wrapper);
- }
- else {
- invalidate(source);
- }
- }
-
- // Now revalidate all the Controls and ControlAligners
- revalidate(true);
- }
-
- /**
- * Sets the length of the widest control. If the length was not calulcated,
- * then this value is 0.
- *
- * @param maximumWidth The width of the widest control
- */
- private void setMaximumWidth(int maximumWidth) {
-
- int oldMaximumWidth = this.maximumWidth;
- this.maximumWidth = maximumWidth;
- controlResized(oldMaximumWidth, maximumWidth);
- }
-
- /**
- * Returns a string representation of this <code>ControlAligner</code>.
- *
- * @return Information about this object
- */
- @Override
- public String toString() {
-
- StringBuffer sb = new StringBuffer();
- sb.append("maximumWidth=");
- sb.append(maximumWidth);
- sb.append(", wrappers=");
- sb.append(wrappers);
- return StringTools.buildToStringFor(this, sb);
- }
-
- /**
- * Updates the size of every <code>Wrapper</code> based on the maximum width.
- *
- * @param forceRevalidate <code>true</code> to revalidate the wrapper's size
- * even though its current size might be the same as the maximum width;
- * <code>false</code> to only revalidate the wrappers with a different width
- */
- private void updateWrapperSize(boolean forceRevalidate) {
-
- for (Wrapper wrapper : wrappers) {
- Point cachedSize = wrapper.cachedSize();
-
- // No need to change the size of the wrapper since it's always using
- // the maximum width
- if (forceRevalidate || (cachedSize.x != maximumWidth)) {
- Point size = new Point(maximumWidth, cachedSize.y);
- wrapper.setSize(size);
- }
- }
- }
-
- /**
- * This <code>Wrapper</code> encapsulates a {@link ControlAligner}.
- */
- private class ControlAlignerWrapper implements Wrapper {
- /**
- * The cached size, which is {@link ControlAligner#maximumWidth}.
- */
- private final Point cachedSize;
-
- /**
- * The <code>ControlAligner</code> encapsulated by this
- * <code>Wrapper</code>.
- */
- private final ControlAligner controlAligner;
-
- /**
- * Creates a new <code>ControlAlignerWrapper</code> that encapsulates
- * the given <code>ControlAligner</code>.
- *
- * @param controlAligner The <code>ControlAligner</code> to be
- * encapsulated by this <code>Wrapper</code>
- */
- private ControlAlignerWrapper(ControlAligner controlAligner) {
- super();
- this.controlAligner = controlAligner;
- this.cachedSize = new Point(controlAligner.maximumWidth, 0);
- }
-
- /*
- * (non-Javadoc)
- */
- public void addListener(Listener listener) {
- controlAligner.addListener(listener);
- }
-
- /*
- * (non-Javadoc)
- */
- public Point cachedSize() {
- cachedSize.x = controlAligner.maximumWidth;
- return cachedSize;
- }
-
- /*
- * (non-Javadoc)
- */
- public Point calculateSize() {
-
- Point size = new Point(controlAligner.calculateWidth(false), 0);
-
- if (size.x != SWT.DEFAULT) {
- cachedSize.x = size.x;
- }
- else {
- cachedSize.x = 0;
- }
-
- if (size.y != SWT.DEFAULT) {
- cachedSize.y = size.y;
- }
- else {
- cachedSize.y = 0;
- }
-
- return size;
- }
-
- /*
- * (non-Javadoc)
- */
- public boolean locked() {
- return controlAligner.locked;
- }
-
- /*
- * (non-Javadoc)
- */
- public void removeListener(Listener listener) {
- controlAligner.removeListener(listener);
- }
-
- /*
- * (non-Javadoc)
- */
- public void setSize(Point size) {
-
- if (size == DEFAULT_SIZE) {
- controlAligner.maximumWidth = 0;
- }
- else if (controlAligner.maximumWidth != size.x) {
- controlAligner.maximumWidth = size.x;
- controlAligner.updateWrapperSize(true);
- }
- }
-
- /*
- * (non-Javadoc)
- */
- public Object source() {
- return controlAligner;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public String toString() {
-
- StringBuffer sb = new StringBuffer();
- sb.append("Cached size=");
- sb.append(cachedSize);
- sb.append(", ControlAligner=");
- sb.append(controlAligner);
- return StringTools.buildToStringFor(this, sb);
- }
- }
-
- /**
- * This <code>Wrapper</code> encapsulates a {@link Control}.
- */
- private class ControlWrapper implements Wrapper {
- /**
- * The cached size, which is control's size.
- */
- private Point cachedSize;
-
- /**
- * The control to be encapsulated by this <code>Wrapper</code>.
- */
- private final Control control;
-
- /**
- * Creates a new <code>controlWrapper</code> that encapsulates the given
- * control.
- *
- * @param control The control to be encapsulated by this <code>Wrapper</code>
- */
- private ControlWrapper(Control control) {
- super();
-
- this.control = control;
- this.cachedSize = new Point(0, 0);
- }
-
- /*
- * (non-Javadoc)
- */
- public void addListener(Listener listener) {
-
- for (int eventType : EVENT_TYPES) {
- control.addListener(eventType, listener);
- }
- }
-
- /*
- * (non-Javadoc)
- */
- public Point cachedSize() {
- return cachedSize;
- }
-
- /*
- * (non-Javadoc)
- */
- public Point calculateSize() {
-
- cachedSize = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
-
- // Update right away the control's GridData
- GridData gridData = (GridData) control.getLayoutData();
-
- if (gridData == null) {
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- control.setLayoutData(gridData);
- }
-
- gridData.widthHint = cachedSize.x;
- gridData.heightHint = cachedSize.y;
-
- // Make sure the size is not -1
- if (cachedSize.x == SWT.DEFAULT) {
- cachedSize.x = 0;
- }
-
- if (cachedSize.y == SWT.DEFAULT) {
- cachedSize.y = 0;
- }
-
- return cachedSize;
- }
-
- /*
- * (non-Javadoc)
- */
- public boolean locked() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- */
- public void removeListener(Listener listener) {
-
- for (int eventType : EVENT_TYPES) {
- control.removeListener(eventType, listener);
- }
- }
-
- /*
- * (non-Javadoc)
- */
- public void setSize(Point size) {
-
- if (control.isDisposed()) {
- return;
- }
-
- // Update the GridData with the new size
- GridData gridData = (GridData) control.getLayoutData();
-
- if (gridData == null) {
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- control.setLayoutData(gridData);
- }
-
- gridData.widthHint = size.x;
- gridData.heightHint = size.y;
-
- // Force the control to be resized, and tell its parent to layout
- // its widgets
- if (size.x > 0) {
-// locked = true;
-// try {
-//// control.getParent().layout(new Control[] { control });
-// control.getParent().layout(true);
-// }
-// finally {
-// locked = false;
-// }
- Rectangle bounds = control.getBounds();
-
- // Only update the control's width if it's
- // different from the current size
- if (bounds.width != size.x) {
- locked = true;
-
- try {
-// control.setBounds(bounds.x, bounds.y, size.x, size.y);
- control.getParent().layout(true);
- }
- finally
- {
- locked = false;
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- */
- public Control source() {
- return control;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public String toString() {
-
- StringBuffer sb = new StringBuffer();
- sb.append("Cached size=");
- sb.append(cachedSize);
- sb.append(", Control=");
- sb.append(control);
- return StringTools.buildToStringFor(this, sb);
- }
- }
-
- /**
- * The listener added to each of the control that is notified in order to
- * revalidate the preferred size.
- */
- private class ListenerHandler implements Listener {
- public void handleEvent(Event event) {
- ControlAligner.this.revalidate(event);
- }
- }
-
- /**
- * This <code>Wrapper</code> helps to encapsulate heterogeneous objects and
- * apply the same behavior on them.
- */
- private interface Wrapper {
- /**
- * Adds the given <code>Listener</code> to wrapped object in order to
- * receive notification when its property changed.
- *
- * @param listener The <code>Listener</code> to be added
- */
- void addListener(Listener listener);
-
- /**
- * Returns the cached size of the encapsulated source.
- *
- * @return A non-<code>null</code> <code>Point</code> where the x is the
- * width and the y is the height of the widget
- */
- Point cachedSize();
-
- /**
- * Calculates the preferred size the wrapped object would take by itself.
- *
- * @return The calculated size
- */
- Point calculateSize();
-
- /**
- * Prevents infinite recursion when recalculating the preferred width.
- * This happens in an hierarchy of <code>ControlAligner</code>s.
- *
- * @return <code>true</code> to prevent this <code>Wrapper</code> from
- * being invalidated; otherwise <code>false</code>
- */
- boolean locked();
-
- /**
- * Removes the given <code>Listener</code>.
- *
- * @param listener The <code>Listener</code> to be removed
- */
- void removeListener(Listener listener);
-
- /**
- * Sets the size on the encapsulated source.
- *
- * @param size The new size
- */
- void setSize(Point size);
-
- /**
- * Returns the encapsulated object.
- *
- * @return The object that is been wrapped
- */
- Object source();
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlSwitcher.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlSwitcher.java
deleted file mode 100644
index 45d6471162..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/ControlSwitcher.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.util;
-
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.part.PageBook;
-
-/**
- * This controller is responsible to switch the active page based on a value. A
- * <code>Transformer</code> is used to transformed that value into a
- * <code>Control</code>.
- *
- * @version 2.3
- * @since 2.0
- */
-public final class ControlSwitcher
-{
- /**
- * The widget that is used to show the active <code>Control</code>.
- */
- private PageBook pageBook;
-
- /**
- * The <code>Transformer</code> used to transform the value into a
- * <code>Control</code>.
- */
- private Transformer<?, Control> controlTransformer;
-
- private Label emptyLabel;
-
- /**
- * Creates a new <code>ControlSwitcher</code>.
- *
- * @param switchHolder The holder of the value that will be used to retrieve
- * the right <code>Control</code> when passed to the given transformer
- * @param controlTransformer The <code>Transformer</code> used to transform the value into a
- * <code>Control</code>
- * @param pageBook The <code>PageBook</code> used for switching the <code>Control</code>
- */
- public <T> ControlSwitcher(PropertyValueModel<? extends T> switchHolder,
- Transformer<T, Control> controlTransformer,
- PageBook pageBook)
- {
- super();
- initialize(switchHolder, controlTransformer, pageBook);
- }
-
- public <T> ControlSwitcher(PropertyValueModel<? extends T> switchHolder,
- Control control,
- PageBook pageBook)
- {
- this(switchHolder, buildNullControlTransformer(control), pageBook);
- }
-
- private static <T> Transformer<T, Control> buildNullControlTransformer(final Control control) {
- return new Transformer<T, Control>() {
- public Control transform(T model) {
- if (model == null) {
- return null;
- }
- return control;
- }
- };
- }
-
- private void initialize(PropertyValueModel<?> switchHolder,
- Transformer<?, Control> controlTransformer,
- PageBook pageBook)
- {
- this.pageBook = pageBook;
- this.controlTransformer = controlTransformer;
-
- this.emptyLabel = this.buildEmptyLabel();
-
- switchHolder.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- buildPropertyChangeListener()
- );
-
- switchPages(switchHolder.getValue());
- }
-
- //Build an empty label to display in the page book when the controlTransformer returns null.
- //SWT.SHADOW_NONE makes the line separator not visible
- //This is the best we can come up with for an empty page
- private Label buildEmptyLabel() {
- return new Label(this.pageBook, SWT.SEPARATOR | SWT.SHADOW_NONE | SWT.HORIZONTAL);
- }
-
- private PropertyChangeListener buildPropertyChangeListener() {
- return new SWTPropertyChangeListenerWrapper(
- buildPropertyChangeListener_()
- );
- }
-
- private PropertyChangeListener buildPropertyChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- switchPages(e.getNewValue());
- }
- };
- }
-
- /**
- * Switches the active page by transforming the given value into its
- * corresponding control.
- *
- * @param value The state passed to the transformer in order to retrieve the
- * new control
- */
- private void switchPages(Object value) {
- if (this.pageBook.isDisposed()) {
- return;
- }
-
- // Retrieve the Control for the new value
- Control page = transform(value);
-
- if (page == null) {
- //Note: We can't pass in null due to a bug in PageBook
- page = this.emptyLabel;
- }
- this.pageBook.showPage(page);
-
- // Revalidate the parents in order to update the layout
- SWTUtil.reflow(this.pageBook);
- }
-
- @SuppressWarnings("unchecked")
- private Control transform(Object value) {
- return ((Transformer<Object, Control>) this.controlTransformer).transform(value);
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledButton.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledButton.java
deleted file mode 100644
index a1d6d2979a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledButton.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Oracle. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.util;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Button;
-
-/**
- * A default implementation of <code>LabeledControl</code> that updates a
- * <code>Button</code> when required.
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public final class LabeledButton implements LabeledControl
-{
- /**
- * The button to be updated with a different icon and text.
- */
- private final Button button;
-
- /**
- * Creates a new <code>LabeledButton</code>.
- *
- * @param button The button that will have its text and icon updated when
- * required
- * @exception AssertionFailedException If the given <code>Button</code> is
- * <code>null</code>
- */
- public LabeledButton(Button button) {
- super();
-
- Assert.isNotNull(button, "The button cannot be null");
- this.button = button;
- }
-
- /*
- * (non-Javadoc)
- */
- public void setImage(Image image) {
- if (!this.button.isDisposed()) {
- this.button.setImage(image);
- this.button.getParent().layout(true);
- }
- }
-
- /*
- * (non-Javadoc)
- */
- public void setText(String text) {
- if (!this.button.isDisposed()) {
- this.button.setText(text);
- this.button.getParent().layout(true);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledControl.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledControl.java
deleted file mode 100644
index 2cef0dc8b2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledControl.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Oracle. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.util;
-
-import org.eclipse.swt.graphics.Image;
-
-/**
- * This <code>LabeledControl</code> is used to encapsulate a widget and update
- * its properties (icon and text).
- *
- * @see LabeledButton
- * @see LabeledLabel
- *
- * @version 2.0
- * @since 2.0
- */
-public interface LabeledControl {
- /**
- * Passes the image so the wrapped component can receive it.
- *
- * @param image The new <code>Image</code>
- */
- void setImage(Image image);
-
- /**
- * Passes the text so the wrapped component can receive it.
- *
- * @param text The new text
- */
- void setText(String text);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledControlUpdater.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledControlUpdater.java
deleted file mode 100644
index 8be981398a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledControlUpdater.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.util;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * This updater is responsible to update the <code>LabeledControl</code> when
- * the text and the icon need to change.
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public final class LabeledControlUpdater {
-
- /**
- * The wrapper around a control that has text and icon.
- */
- private LabeledControl labeledControl;
-
- /**
- * Creates a new <code>LabeledControlUpdater</code>.
- *
- * @param labeledControl The wrapper around the control that needs to
- * have its text updated
- * @param textHolder The holder this class will listen for changes
- */
- public LabeledControlUpdater(LabeledControl labeledControl,
- PropertyValueModel<String> textHolder)
- {
- this(labeledControl, textHolder, null);
- }
-
- /**
- * Creates a new <code>LabeledControlUpdater</code>.
- *
- * @param labeledControl The wrapper around the control that needs to
- * have its image and text updated
- * @param imageHolder The holder this class will listen for changes or
- * <code>null</code> if the text never changes
- * @param textHolder The holder this class will listen for changes or
- * <code>null</code> if the image never changes
- */
- public LabeledControlUpdater(LabeledControl labeledControl,
- PropertyValueModel<String> textHolder,
- PropertyValueModel<Image> imageHolder)
- {
- super();
- initialize(labeledControl, textHolder, imageHolder);
- }
-
- private PropertyChangeListener buildIconListener() {
- return new SWTPropertyChangeListenerWrapper(buildIconListener_());
- }
-
- private PropertyChangeListener buildIconListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- LabeledControlUpdater.this.setImage((Image) e.getNewValue());
- }
-
- @Override
- public String toString() {
- return "LabeledControlUpdater.imageListener";
- }
- };
- }
-
- private PropertyChangeListener buildTextListener() {
- return new SWTPropertyChangeListenerWrapper(buildTextListener_());
- }
-
- private PropertyChangeListener buildTextListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- LabeledControlUpdater.this.setText((String) e.getNewValue());
- }
-
- @Override
- public String toString() {
- return "LabeledControlUpdater.textListener";
- }
- };
- }
-
- private void initialize(LabeledControl labeledControl,
- PropertyValueModel<String> textHolder,
- PropertyValueModel<Image> imageHolder)
- {
- Assert.isNotNull(labeledControl, "The LabeledControl cannot be null");
-
- this.labeledControl = labeledControl;
-
- if (textHolder != null) {
- textHolder.addPropertyChangeListener(PropertyValueModel.VALUE, buildTextListener());
- setText(textHolder.getValue());
- }
-
- if (imageHolder != null) {
- imageHolder.addPropertyChangeListener(PropertyValueModel.VALUE, buildIconListener());
- setImage(imageHolder.getValue());
- }
- }
-
- private void setImage(Image icon) {
- labeledControl.setImage(icon);
- }
-
- private void setText(String text) {
-
- if (text == null) {
- text = "";
- }
-
- labeledControl.setText(text);
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledLabel.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledLabel.java
deleted file mode 100644
index c74ef06559..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/LabeledLabel.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Oracle. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.util;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Label;
-
-/**
- * A default implementation of <code>LabeledControl</code> that updates an
- * <code>Label</code> when required.
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public final class LabeledLabel implements LabeledControl
-{
- /**
- * The label to be updated with a different icon and text.
- */
- private final Label label;
-
- /**
- * Creates a new <code>LabeledButton</code>.
- *
- * @param label The label that will have its text and icon updated when
- * required
- * @exception AssertionFailedException If the given <code>Label</code> is
- * <code>null</code>
- */
- public LabeledLabel(Label label) {
- super();
-
- Assert.isNotNull(label, "The label cannot be null");
- this.label = label;
- }
-
- /*
- * (non-Javadoc)
- */
- public void setImage(Image image) {
- if (!this.label.isDisposed()) {
- this.label.setImage(image);
- this.label.getParent().layout(true);
- }
- }
-
- /*
- * (non-Javadoc)
- */
- public void setText(String text) {
- if (!this.label.isDisposed()) {
- this.label.setText(text);
- this.label.getParent().layout(true);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/PaneEnabler.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/PaneEnabler.java
deleted file mode 100644
index 6615c72127..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/PaneEnabler.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.util;
-
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.jpt.common.ui.internal.widgets.Pane;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This <code>PaneEnabler</code> keeps the "enabled" state of a collection of
- * controls in synch with the provided boolean holder.
- *
- * @version 2.0
- * @since 2.0
- */
-public class PaneEnabler extends StateController
-{
- /**
- * Creates a new <code>PaneEnabler</code> with a default value of
- * <code>false</code> (i.e. disabled).
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param pane The pane whose "enabled" state is kept in sync with the
- * boolean holder's value
- */
- public PaneEnabler(PropertyValueModel<Boolean> booleanHolder,
- Pane<?> pane) {
-
- this(booleanHolder, pane, false);
- }
-
- /**
- * Creates a new <code>PaneEnabler</code> with a default value of
- * <code>false</code> (i.e. disabled).
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes The collection of panes whose "enabled" state is kept in sync
- * with the boolean holder's value
- */
- public PaneEnabler(PropertyValueModel<Boolean> booleanHolder,
- Pane<?>... panes) {
-
- this(booleanHolder, CollectionTools.collection(panes), false);
- }
-
- /**
- * Creates a new <code>PaneEnabler</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param pane The pane whose "enabled" state is kept in sync with the
- * boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- public PaneEnabler(PropertyValueModel<Boolean> booleanHolder,
- Pane<?> pane,
- boolean defaultValue) {
-
- this(booleanHolder, CollectionTools.singletonIterator(pane), false);
- }
-
- /**
- * Creates a new <code>PaneEnabler</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes The collection of panes whose "enabled" state is kept in sync
- * with the boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- public PaneEnabler(PropertyValueModel<Boolean> booleanHolder,
- Pane<?>[] panes,
- boolean defaultValue) {
-
- this(booleanHolder, CollectionTools.iterator(panes), defaultValue);
- }
-
- /**
- * Creates a new <code>BaseJpaControllerEnabler</code> with a default value
- * of* <code>false</code> (i.e. disabled).
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes The collection of panes whose "enabled" state is kept in sync
- * with the boolean holder's value
- */
- public PaneEnabler(PropertyValueModel<Boolean> booleanHolder,
- Collection<? extends Pane<?>> panes) {
-
- this(booleanHolder, panes, false);
- }
-
- /**
- * Creates a new <code>BaseJpaControllerEnabler</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes The collection of panes whose "enabled" state is kept in sync
- * with the boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- public PaneEnabler(PropertyValueModel<Boolean> booleanHolder,
- Collection<? extends Pane<?>> panes,
- boolean defaultValue) {
-
- this(booleanHolder, panes.iterator(), defaultValue);
- }
-
- /**
- * Creates a new <code>BaseJpaControllerEnabler</code> with a default value of
- * <code>false</code> (i.e. disabled).
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes An iterator on the collection of panes whose "enabled" state
- * is kept in sync with the boolean holder's value
- */
- public PaneEnabler(PropertyValueModel<Boolean> booleanHolder,
- Iterator<? extends Pane<?>> panes) {
-
- this(booleanHolder, panes, false);
- }
-
- /**
- * Creates a new <code>BaseJpaControllerEnabler</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes An iterator on the collection of panes whose "enabled" state
- * is kept in sync with the boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- public PaneEnabler(PropertyValueModel<Boolean> booleanHolder,
- Iterator<? extends Pane<?>> panes,
- boolean defaultValue) {
-
- super(booleanHolder, wrap(panes), defaultValue);
- }
-
- private static Collection<ControlHolder> wrap(Iterator<? extends Pane<?>> panes) {
- return CollectionTools.collection(new TransformationIterator<Pane<?>, ControlHolder>(panes) {
- @Override
- protected ControlHolder transform(Pane<?> pane) {
- return new PaneHolder(pane);
- }
- });
- }
-
- /**
- * This holder holds onto an <code>Pane</code> and update its enabled
- * state.
- */
- private static class PaneHolder implements ControlHolder {
- private final Pane<?> pane;
-
- PaneHolder(Pane<?> pane) {
- super();
- this.pane = pane;
- }
-
- public void updateState(boolean state) {
- if (!this.pane.getControl().isDisposed()) {
- this.pane.enableWidgets(state);
- }
- }
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/PaneVisibilityEnabler.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/PaneVisibilityEnabler.java
deleted file mode 100644
index c081839b5f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/PaneVisibilityEnabler.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.util;
-
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.jpt.common.ui.internal.widgets.Pane;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This <code>PaneVisibilityEnabler</code> keeps the "visible" state of a
- * collection of controls in synch with the provided boolean holder.
- *
- * @version 2.0
- * @since 2.0
- */
-public class PaneVisibilityEnabler extends StateController
-{
- /**
- * Creates a new <code>PaneVisibilityEnabler</code> with a default value of
- * <code>false</code> (i.e. not visible).
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param pane The pane whose "visible" state is kept in sync with the
- * boolean holder's value
- */
- public PaneVisibilityEnabler(PropertyValueModel<Boolean> booleanHolder,
- Pane<?> pane) {
-
- this(booleanHolder, pane, false);
- }
-
- /**
- * Creates a new <code>PaneVisibilityEnabler</code> with a default value of
- * <code>false</code> (i.e. not visible).
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes The collection of panes whose "visible" state is kept in sync
- * with the boolean holder's value
- */
- public PaneVisibilityEnabler(PropertyValueModel<Boolean> booleanHolder,
- Pane<?>... panes) {
-
- this(booleanHolder, CollectionTools.collection(panes), false);
- }
-
- /**
- * Creates a new <code>PaneVisibilityEnabler</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param pane The pane whose "visible" state is kept in sync with the
- * boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- public PaneVisibilityEnabler(PropertyValueModel<Boolean> booleanHolder,
- Pane<?> pane,
- boolean defaultValue) {
-
- this(booleanHolder, CollectionTools.singletonIterator(pane), false);
- }
-
- /**
- * Creates a new <code>PaneVisibilityEnabler</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes The collection of panes whose "visible" state is kept in sync
- * with the boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- public PaneVisibilityEnabler(PropertyValueModel<Boolean> booleanHolder,
- Pane<?>[] panes,
- boolean defaultValue) {
-
- this(booleanHolder, CollectionTools.iterator(panes), defaultValue);
- }
-
- /**
- * Creates a new <code>PaneVisibilityEnabler</code> with a default value of
- * <code>false</code> (i.e. not visible).
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes The collection of panes whose "visible" state is kept in sync
- * with the boolean holder's value
- */
- public PaneVisibilityEnabler(PropertyValueModel<Boolean> booleanHolder,
- Collection<? extends Pane<?>> panes) {
-
- this(booleanHolder, panes, false);
- }
-
- /**
- * Creates a new <code>PaneVisibilityEnabler</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes The collection of panes whose "visible" state is kept in sync
- * with the boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- public PaneVisibilityEnabler(PropertyValueModel<Boolean> booleanHolder,
- Collection<? extends Pane<?>> panes,
- boolean defaultValue) {
-
- this(booleanHolder, panes.iterator(), defaultValue);
- }
-
- /**
- * Creates a new <code>PaneVisibilityEnabler</code> with a default value of
- * <code>false</code> (i.e. not visible).
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes An iterator on the collection of panes whose "visible" state
- * is kept in sync with the boolean holder's value
- */
- public PaneVisibilityEnabler(PropertyValueModel<Boolean> booleanHolder,
- Iterator<? extends Pane<?>> panes) {
-
- this(booleanHolder, panes, false);
- }
-
- /**
- * Creates a new <code>PaneVisibilityEnabler</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param panes An iterator on the collection of panes whose "visible" state
- * is kept in sync with the boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- public PaneVisibilityEnabler(PropertyValueModel<Boolean> booleanHolder,
- Iterator<? extends Pane<?>> panes,
- boolean defaultValue) {
-
- super(booleanHolder, wrap(panes), defaultValue);
- }
-
- private static Collection<ControlHolder> wrap(Iterator<? extends Pane<?>> panes) {
- return CollectionTools.collection(new TransformationIterator<Pane<?>, ControlHolder>(panes) {
- @Override
- protected ControlHolder transform(Pane<?> pane) {
- return new PaneHolder(pane);
- }
- });
- }
-
- /**
- * This holder holds onto an <code>Pane</code> and update its visible
- * state.
- */
- private static class PaneHolder implements ControlHolder {
- private final Pane<?> pane;
-
- PaneHolder(Pane<?> pane) {
- super();
- this.pane = pane;
- }
-
- public void updateState(boolean state) {
- this.pane.setVisible(state);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java
deleted file mode 100644
index eaa395c23d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/SWTUtil.java
+++ /dev/null
@@ -1,449 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.util;
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.OpenStrategy;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-
-/**
- * A suite of utility methods related to the user interface.
- *
- * @version 2.0
- * @since 1.0
- */
-public class SWTUtil {
-
- /**
- * @see Display#asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #timerExec(int, Runnable)
- * @see #execute(Runnable)
- */
- public static void asyncExec(Runnable runnable) {
- getDisplay().asyncExec(runnable);
- }
-
- /**
- * @see Display#syncExec(Runnable)
- * @see #asyncExec(Runnable)
- * @see #timerExec(int, Runnable)
- * @see #execute(Runnable)
- */
- public static void syncExec(Runnable runnable) {
- getDisplay().syncExec(runnable);
- }
-
- /**
- * Use the standard delay.
- * @see OpenStrategy#getPostSelectionDelay()
- * @see #timerExec(int, Runnable)
- */
- public static void delayedExec(Runnable runnable) {
- timerExec(OpenStrategy.getPostSelectionDelay(), runnable);
- }
-
- /**
- * @see Display#timerExec(int, Runnable)
- * @see #asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #execute(Runnable)
- */
- public static void timerExec(int milliseconds, Runnable runnable) {
- getDisplay().timerExec(milliseconds, runnable);
- }
-
- /**
- * Execute the specified runnable if the current thread is the UI thread;
- * otherwise asynchrounously dispatch the runnable to the UI thread,
- * returning immediately. This is useful for event handlers when it is not
- * obviously whether the events are fired on the UI thread.
- *
- * @see Display#asyncExec(Runnable)
- * @see #asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #timerExec(int, Runnable)
- */
- public static void execute(Runnable runnable) {
- Display display = Display.getCurrent();
- if (display != null) {
- // the current thread is the UI thread
- runnable.run();
- } else {
- Display.getDefault().asyncExec(runnable);
- }
- }
-
- /**
- * Execute the specified runnable if the current thread is the specified
- * viewer's thread;
- * otherwise asynchrounously dispatch the runnable to the viewer's thread,
- * returning immediately. This is useful for event handlers when it is not
- * obviously whether the events are fired on the viewer's thread.
- *
- * @see #execute(Runnable)
- * @see Display#asyncExec(Runnable)
- * @see #asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #timerExec(int, Runnable)
- */
- public static void execute(Viewer viewer, Runnable runnable) {
- execute(viewer.getControl(), runnable);
- }
-
- /**
- * Execute the specified runnable if the current thread is the specified
- * control's thread;
- * otherwise asynchrounously dispatch the runnable to the control's thread,
- * returning immediately. This is useful for event handlers when it is not
- * obviously whether the events are fired on the control's thread.
- *
- * @see #execute(Runnable)
- * @see Display#asyncExec(Runnable)
- * @see #asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #timerExec(int, Runnable)
- */
- public static void execute(Control control, Runnable runnable) {
- execute(control.getDisplay(), runnable);
- }
-
- /**
- * Execute the specified runnable if the current thread is the specified
- * display's thread;
- * otherwise asynchrounously dispatch the runnable to the display's thread,
- * returning immediately. This is useful for event handlers when it is not
- * obviously whether the events are fired on the display's thread.
- *
- * @see #execute(Runnable)
- * @see Display#asyncExec(Runnable)
- * @see #asyncExec(Runnable)
- * @see #syncExec(Runnable)
- * @see #timerExec(int, Runnable)
- */
- public static void execute(Display display, Runnable runnable) {
- if (display.getThread() == Thread.currentThread()) {
- // the current thread is the display's thread
- runnable.run();
- } else {
- display.asyncExec(runnable);
- }
- }
-
- /**
- * Convenience method for getting the current shell. If the current thread is
- * not the UI thread, then an invalid thread access exception will be thrown.
- *
- * @return The shell, never <code>null</code>
- */
- public static Shell getShell() {
- // Retrieve the active shell, which can be the shell from any window
- Shell shell = getDisplay().getActiveShell();
- if (shell != null) {
- return shell;
- }
-
- // No shell could be found, revert back to the active workbench window
- shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- return (shell != null) ? shell : new Shell();
- }
-
- /**
- * Return the most appropriate {@link Display display}; i.e. return the
- * {@link Display#getCurrent() display associated with the current thread}
- * if it is present; otherwise return the
- * {@link Display#getDefault() default display}.
- */
- public static Display getDisplay() {
- Display display = Display.getCurrent();
- return (display != null) ? display : Display.getDefault();
- }
-
- /**
- * Center the specified shell within its display.
- * <p>
- * <strong>NB:</strong> This will not look too good on a dual monitor system.
- */
- public static void center(Shell shell) {
- shell.setBounds(calculateCenteredBounds(shell.getBounds(), shell.getDisplay().getBounds()));
- }
-
- /**
- * Center the specified shell within the specified parent shell.
- */
- public static void center(Shell shell, Shell parentShell) {
- shell.setBounds(calculateCenteredBounds(shell.getBounds(), parentShell.getBounds()));
- }
-
- /**
- * Calculate the bounds (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Rectangle calculateCenteredBounds(Rectangle rectangle1, Rectangle rectangle2) {
- return calculateCenteredBounds(rectangle1.width, rectangle1.height, rectangle2.x, rectangle2.y, rectangle2.width, rectangle2.height);
- }
-
- /**
- * Calculate the bounds (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Rectangle calculateCenteredBounds(Point size1, Point size2) {
- return calculateCenteredBounds(size1.x, size1.y, size2.x, size2.y);
- }
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Rectangle calculateCenteredBounds(int width1, int height1, int width2, int height2) {
- return calculateCenteredBounds(width1, height1, 0, 0, width2, height2);
- }
-
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Rectangle calculateCenteredBounds(int width1, int height1, int x2, int y2, int width2, int height2) {
- return new Rectangle(x2 + ((width2 - width1) / 2), y2 + ((height2 - height1) / 2), width1, height1);
- }
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Point calculateCenteredPosition(Rectangle rectangle1, Rectangle rectangle2) {
- return calculateCenteredPosition(rectangle1.width, rectangle1.height, rectangle2.x, rectangle2.y, rectangle2.width, rectangle2.height);
- }
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Point calculateCenteredPosition(Point size1, Point size2) {
- return calculateCenteredPosition(size1.x, size1.y, size2.x, size2.y);
- }
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Point calculateCenteredPosition(int width1, int height1, int width2, int height2) {
- return calculateCenteredPosition(width1, height1, 0, 0, width2, height2);
- }
-
- /**
- * Calculate the point (within the second specified rectangle's coordinate
- * system) that would center the first specified rectangle
- * with respect to the second specified rectangle.
- */
- public static Point calculateCenteredPosition(int width1, int height1, int x2, int y2, int width2, int height2) {
- return new Point(x2 + ((width2 - width1) / 2), y2 + ((height2 - height1) / 2));
- }
-
- /**
- * Tweaks the given <code>Combo</code> to remove the default value when the
- * widget receives the focus and to show the default when the widget loses
- * the focus.
- *
- * @param combo The widget having a default value that is always at the
- * beginning of the list
- */
- public static void attachDefaultValueHandler(Combo combo) {
- ComboHandler handler = new ComboHandler();
- combo.addFocusListener(handler);
- combo.addModifyListener(handler);
- }
-
-
- public static int getTableHeightHint(Table table, int rows) {
- if (table.getFont().equals(JFaceResources.getDefaultFont()))
- table.setFont(JFaceResources.getDialogFont());
- int result= table.getItemHeight() * rows + table.getHeaderHeight();
- if (table.getLinesVisible())
- result+= table.getGridLineWidth() * (rows - 1);
- return result;
- }
-
- /**
- * Relays out the parents of the <code>Control</code>. This was taken from
- * the widget <code>Section</code>.
- *
- * @param pane The pane to revalidate as well as its parents
- */
- public static void reflow(Composite pane) {
-
- for (Composite composite = pane; composite != null; ) {
- composite.setRedraw(false);
- composite = composite.getParent();
-
- if (composite instanceof ScrolledForm || composite instanceof Shell) {
- break;
- }
- }
-
- for (Composite composite = pane; composite != null; ) {
- composite.layout(true);
- composite = composite.getParent();
-
- if (composite instanceof ScrolledForm) {
- ((ScrolledForm) composite).reflow(true);
- break;
- }
- }
-
- for (Composite composite = pane; composite != null; ) {
- composite.setRedraw(true);
- composite = composite.getParent();
-
- if (composite instanceof ScrolledForm || composite instanceof Shell) {
- break;
- }
- }
- }
-
-
- /**
- * Determines if the current thread is the UI event thread.
- *
- * @return <code>true</code> if it's the UI event thread, <code>false</code>
- * otherwise
- */
- public static boolean uiThread() {
- return Display.getCurrent() != null;
- }
-
- /**
- * Determines if the current thread is the UI event thread by using the
- * thread from which the given viewer's display was instantiated.
- *
- * @param viewer The viewer used to determine if the current thread
- * is the UI event thread
- * @return <code>true</code> if the current thread is the UI event thread;
- * <code>false</code> otherwise
- */
- public static boolean uiThread(Viewer viewer) {
- return uiThread(viewer.getControl());
- }
-
- /**
- * Determines if the current thread is the UI event thread by using the
- * thread from which the given widget's display was instantiated.
- *
- * @param widget The widget used to determine if the current thread
- * is the UI event thread
- * @return <code>true</code> if the current thread is the UI event thread;
- * <code>false</code> otherwise
- */
- public static boolean uiThread(Widget widget) {
- return widget.getDisplay().getThread() == Thread.currentThread();
- }
-
-
- /**
- * This handler is responsible for removing the default value when the combo
- * has the focus or when the selected item is the default value and to select
- * it when the combo loses the focus.
- */
- private static class ComboHandler implements ModifyListener,
- FocusListener {
-
- public void focusGained(FocusEvent e) {
- Combo combo = (Combo) e.widget;
-
- if (combo.getSelectionIndex() == 0) {
- // The text selection has to be changed outside of the context of this
- // listener otherwise the combo won't update because it's currently
- // notifying its listeners
- asyncExec(new SelectText(combo));
- }
- }
-
- public void focusLost(FocusEvent e) {
- //do nothing
- }
-
- public void modifyText(ModifyEvent e) {
-
- Combo combo = (Combo) e.widget;
-
- if (combo.isFocusControl() &&
- combo.getSelectionIndex() == 0) {
-
- // The text has to be changed outside of the context of this
- // listener otherwise the combo won't update because it's currently
- // notifying its listeners
- asyncExec(new ModifyText(combo));
- }
- }
-
- private class ModifyText implements Runnable {
- private final Combo combo;
-
- public ModifyText(Combo combo) {
- super();
- this.combo = combo;
- }
-
- public void run() {
- if (this.combo.isDisposed()) {
- return;
- }
- String text = this.combo.getText();
-
- if (text.length() == 0) {
- text = this.combo.getItem(0);
- this.combo.setText(text);
- }
-
- this.combo.setSelection(new Point(0, text.length()));
- }
- }
-
- private class SelectText implements Runnable {
- private final Combo combo;
-
- public SelectText(Combo combo) {
- super();
- this.combo = combo;
- }
-
- public void run() {
- if (this.combo.isDisposed()) {
- return;
- }
- String text = this.combo.getText();
- this.combo.setSelection(new Point(0, text.length()));
- }
- }
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/StateController.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/StateController.java
deleted file mode 100644
index 5c313e6603..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/StateController.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.util;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * A <code>StateController</code> keeps the state of a collection of widgets in
- * synch with the provided boolean holder.
- *
- * @see ControlEnabler
- * @see ControlVisibilityEnabler
- * @see PaneEnabler
- * @see PaneVisibilityEnabler
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-abstract class StateController
-{
- /**
- * A listener that allows us to synchronize the controlHolders with changes
- * made to the underlying boolean model.
- */
- private PropertyChangeListener booleanChangeListener;
-
- /**
- * A value model on the underlying boolean model
- */
- private PropertyValueModel<Boolean> booleanHolder;
-
- /**
- * The collection of <code>ControlHolder</code>s whose state is kept in sync
- * with the boolean holder's value.
- */
- private Collection<ControlHolder> controlHolders;
-
- /**
- * The default setting for the state; for when the underlying model is
- * <code>null</code>. The default [default value] is <code>false<code>.
- */
- private boolean defaultValue;
-
- /**
- * Creates a new <code>StateController</code>.
- */
- StateController() {
- super();
- initialize();
- }
-
- /**
- * Creates a new <code>StateController</code> with a default value of
- * <code>false</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param controlHolders The collection of <code>ControlHolder</code>s whose
- * state is kept in sync with the boolean holder's value
- */
- StateController(PropertyValueModel<Boolean> booleanHolder,
- Collection<ControlHolder> controlHolders) {
-
- this(booleanHolder, controlHolders, false);
- }
-
- /**
- * Creates a new <code>StateController</code> with a default value of
- * <code>false</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param controlHolders The collection of <code>ControlHolder</code>s whose
- * state is kept in sync with the boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- StateController(PropertyValueModel<Boolean> booleanHolder,
- Collection<ControlHolder> controlHolders,
- boolean defaultValue) {
-
- this();
- initialize(booleanHolder, controlHolders, defaultValue);
- }
-
- /**
- * Creates a new <code>StateController</code> with a default value of
- * <code>false</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param controlHolder The <code>ControlHolder</code> whose state is kept
- * in sync with the boolean holder's value
- */
- StateController(PropertyValueModel<Boolean> booleanHolder,
- ControlHolder controlHolder) {
-
- this(booleanHolder, controlHolder, false);
- }
-
- /**
- * Creates a new <code>StateController</code> with a default value of
- * <code>false</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param controlHolders The collection of <code>ControlHolder</code>s whose
- * state is kept in sync with the boolean holder's value
- */
- StateController(PropertyValueModel<Boolean> booleanHolder,
- ControlHolder... controlHolders) {
-
- this(booleanHolder, CollectionTools.collection(controlHolders), false);
- }
-
- /**
- * Creates a new <code>StateController</code> with a default value of
- * <code>false</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param controlHolder The <code>ControlHolder</code> whose state is kept
- * in sync with the boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- StateController(PropertyValueModel<Boolean> booleanHolder,
- ControlHolder controlHolder,
- boolean defaultValue) {
-
- this(booleanHolder, new ControlHolder[] { controlHolder }, false);
- }
-
- /**
- * Creates a new <code>StateController</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param controlHolders The collection of <code>ControlHolder</code>s whose
- * state is kept in sync with the boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- StateController(PropertyValueModel<Boolean> booleanHolder,
- ControlHolder[] controlHolders,
- boolean defaultValue) {
-
- this();
- this.initialize(booleanHolder, CollectionTools.collection(controlHolders), defaultValue);
- }
-
- /**
- * Creates a new <code>StateController</code> with a default value of
- * <code>false</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param controlHolders An iterator on the collection of
- * <code>ControlHolder</code>s whose state is kept in sync with the boolean
- * holder's value
- */
- StateController(PropertyValueModel<Boolean> booleanHolder,
- Iterator<ControlHolder> controlHolders) {
-
- this(booleanHolder, CollectionTools.collection(controlHolders), false);
- }
-
- /**
- * Creates a new <code>StateController</code>.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param controlHolders An iterator on the collection of
- * <code>ControlHolder</code>s whose state is kept in sync with the boolean
- * holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- StateController(PropertyValueModel<Boolean> booleanHolder,
- Iterator<ControlHolder> controlHolders,
- boolean defaultValue) {
-
- this();
- initialize(booleanHolder, CollectionTools.collection(controlHolders), defaultValue);
- }
-
- /**
- * Returns the boolean primitive of the given <code>Boolean</code> value but
- * also checks for <code>null</code>, if that is the case, then
- * {@link #defaultValue} is returned.
- *
- * @param value The <code>Boolean</code> value to be returned as a primitive
- * @return The primitive of the given value or {@link #defaultValue}when the
- * value is <code>null</code>
- */
- protected boolean booleanValue(Boolean value) {
- return (value == null) ? this.defaultValue : value.booleanValue();
- }
-
- /**
- * Creates a listener for the boolean holder.
- *
- * @return A new <code>PropertyChangeListener</code>
- */
- private PropertyChangeListener buildBooleanChangeListener() {
- return new SWTPropertyChangeListenerWrapper(
- buildBooleanChangeListener_()
- )
- {
- @Override
- public String toString() {
- return "StateController.SWTPropertyChangeListenerWrapper";
- }
- };
- }
-
- /**
- * Creates a listener for the boolean holder.
- *
- * @return A new <code>PropertyChangeListener</code>
- */
- private PropertyChangeListener buildBooleanChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- updateState();
- }
-
- @Override
- public String toString() {
- return "StateController.PropertyChangeListener";
- }
- };
- }
-
- /**
- * Returns an <code>Iterator</code> over the collection of
- * <code>ControlHolder</code>s.
- *
- * @return The iteration of <code>ControlHolder</code>s
- */
- protected final Iterator<ControlHolder> controlHolders() {
- return new CloneIterator<ControlHolder>(this.controlHolders);
- }
-
- /**
- * Initializes this <code>StateController</code> by building the appropriate
- * listeners.
- */
- protected void initialize() {
- this.booleanChangeListener = this.buildBooleanChangeListener();
- }
-
- /**
- * Initializes this <code>StateController</code> with the given state.
- *
- * @param booleanHolder A value model on the underlying boolean model
- * @param controlHolders A <code>ControlHolder</code>s whose enablement state
- * is kept in sync with the boolean holder's value
- * @param defaultValue The value to use when the underlying model is
- * <code>null</code>
- */
- protected void initialize(PropertyValueModel<Boolean> booleanHolder,
- Collection<ControlHolder> controlHolders,
- boolean defaultValue) {
-
- Assert.isNotNull(booleanHolder, "The holder of the boolean value cannot be null");
- Assert.isNotNull(controlHolders, "The collection of ControlHolders cannot be null");
-
- this.controlHolders = new ArrayList<ControlHolder>(controlHolders);
- this.defaultValue = defaultValue;
- this.booleanHolder = booleanHolder;
-
- this.booleanHolder.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- this.booleanChangeListener
- );
-
- this.updateState();
- }
-
- /**
- * Updates the state of the control holders.
- */
- protected void updateState() {
- this.updateState(booleanValue(this.booleanHolder.getValue()));
- }
-
- /**
- * Updates the state of the <code>Control</code>s.
- *
- * @param state The new state the widgets need to have
- */
- protected void updateState(boolean state) {
- for (ControlHolder controlHolder : this.controlHolders) {
- controlHolder.updateState(state);
- }
- }
-
- /**
- * The holder of the actual widget.
- */
- static interface ControlHolder {
-
- /**
- * Updates the state of the wrapped control.
- *
- * @param state The new state the control should have
- */
- void updateState(boolean state);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/TableLayoutComposite.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/TableLayoutComposite.java
deleted file mode 100644
index 9a8790c941..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/util/TableLayoutComposite.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-// copied from org.eclipse.jdt.internal.ui.util.TableLayoutComposite
-package org.eclipse.jpt.common.ui.internal.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-
-import org.eclipse.core.runtime.Assert;
-
-import org.eclipse.jface.viewers.ColumnLayoutData;
-import org.eclipse.jface.viewers.ColumnPixelData;
-import org.eclipse.jface.viewers.ColumnWeightData;
-
-/**
- * A special composite to layout columns inside a table. The composite is needed since we have
- * to layout the columns "before" the actual table gets layouted. Hence we can't use a normal
- * layout manager.
- * <p>
- * XXX: Should switch to use {@link org.eclipse.jface.layout.TableColumnLayout}.
- * </p>
- */
-public class TableLayoutComposite extends Composite {
-
- /**
- * The number of extra pixels taken as horizontal trim by the table column.
- * To ensure there are N pixels available for the content of the column,
- * assign N+COLUMN_TRIM for the column width.
- * <p>
- * XXX: Should either switch to use {@link org.eclipse.jface.layout.TableColumnLayout} or get API from JFace or SWT, see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=218483
- * </p>
- *
- * @since 3.1
- */
- private static int COLUMN_TRIM;
- static {
- String platform= SWT.getPlatform();
- if ("win32".equals(platform)) //$NON-NLS-1$
- COLUMN_TRIM= 4;
- else if ("carbon".equals(platform)) //$NON-NLS-1$
- COLUMN_TRIM= 24;
- else
- COLUMN_TRIM= 3;
- }
-
- private List columns= new ArrayList();
-
- /**
- * Creates a new <code>TableLayoutComposite</code>.
- *
- * @param parent the parent composite
- * @param style the SWT style
- */
- public TableLayoutComposite(Composite parent, int style) {
- super(parent, style);
- addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- Rectangle area= getClientArea();
- Table table= (Table)getChildren()[0];
- Point preferredSize= computeTableSize(table);
- int width= area.width - 2 * table.getBorderWidth();
- if (preferredSize.y > area.height) {
- // Subtract the scrollbar width from the total column width
- // if a vertical scrollbar will be required
- Point vBarSize = table.getVerticalBar().getSize();
- width -= vBarSize.x;
- }
- layoutTable(table, width, area, table.getSize().x < area.width);
- }
- });
- }
-
- /**
- * Adds a new column of data to this table layout.
- *
- * @param data the column layout data
- */
- public void addColumnData(ColumnLayoutData data) {
- columns.add(data);
- }
-
- //---- Helpers -------------------------------------------------------------------------------------
-
- private Point computeTableSize(Table table) {
- Point result= table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- int width= 0;
- int size= columns.size();
- for (int i= 0; i < size; ++i) {
- ColumnLayoutData layoutData= (ColumnLayoutData) columns.get(i);
- if (layoutData instanceof ColumnPixelData) {
- ColumnPixelData col= (ColumnPixelData) layoutData;
- width += col.width;
- if (col.addTrim) {
- width += COLUMN_TRIM;
- }
- } else if (layoutData instanceof ColumnWeightData) {
- ColumnWeightData col= (ColumnWeightData) layoutData;
- width += col.minimumWidth;
- } else {
- Assert.isTrue(false, "Unknown column layout data"); //$NON-NLS-1$
- }
- }
- if (width > result.x)
- result.x= width;
- return result;
- }
-
- private void layoutTable(Table table, int width, Rectangle area, boolean increase) {
- // XXX: Layout is being called with an invalid value the first time
- // it is being called on Linux. This method resets the
- // Layout to null so we make sure we run it only when
- // the value is OK.
- if (width <= 1)
- return;
-
- TableColumn[] tableColumns= table.getColumns();
- int size= Math.min(columns.size(), tableColumns.length);
- int[] widths= new int[size];
- int fixedWidth= 0;
- int numberOfWeightColumns= 0;
- int totalWeight= 0;
-
- // First calc space occupied by fixed columns
- for (int i= 0; i < size; i++) {
- ColumnLayoutData col= (ColumnLayoutData) columns.get(i);
- if (col instanceof ColumnPixelData) {
- ColumnPixelData cpd= (ColumnPixelData) col;
- int pixels= cpd.width;
- if (cpd.addTrim) {
- pixels += COLUMN_TRIM;
- }
- widths[i]= pixels;
- fixedWidth += pixels;
- } else if (col instanceof ColumnWeightData) {
- ColumnWeightData cw= (ColumnWeightData) col;
- numberOfWeightColumns++;
- // first time, use the weight specified by the column data, otherwise use the actual width as the weight
- // int weight = firstTime ? cw.weight : tableColumns[i].getWidth();
- int weight= cw.weight;
- totalWeight += weight;
- } else {
- Assert.isTrue(false, "Unknown column layout data"); //$NON-NLS-1$
- }
- }
-
- // Do we have columns that have a weight
- if (numberOfWeightColumns > 0) {
- // Now distribute the rest to the columns with weight.
- int rest= width - fixedWidth;
- int totalDistributed= 0;
- for (int i= 0; i < size; ++i) {
- ColumnLayoutData col= (ColumnLayoutData) columns.get(i);
- if (col instanceof ColumnWeightData) {
- ColumnWeightData cw= (ColumnWeightData) col;
- // calculate weight as above
- // int weight = firstTime ? cw.weight : tableColumns[i].getWidth();
- int weight= cw.weight;
- int pixels= totalWeight == 0 ? 0 : weight * rest / totalWeight;
- if (pixels < cw.minimumWidth)
- pixels= cw.minimumWidth;
- totalDistributed += pixels;
- widths[i]= pixels;
- }
- }
-
- // Distribute any remaining pixels to columns with weight.
- int diff= rest - totalDistributed;
- for (int i= 0; diff > 0; ++i) {
- if (i == size)
- i= 0;
- ColumnLayoutData col= (ColumnLayoutData) columns.get(i);
- if (col instanceof ColumnWeightData) {
- ++widths[i];
- --diff;
- }
- }
- }
-
- if (increase) {
- table.setSize(area.width, area.height);
- }
- for (int i= 0; i < size; i++) {
- tableColumns[i].setWidth(widths[i]);
- }
- if (!increase) {
- table.setSize(area.width, area.height);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AbstractUiCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AbstractUiCommandExecutor.java
deleted file mode 100644
index ec8ffd6dcb..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AbstractUiCommandExecutor.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility;
-
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.command.CommandRunnable;
-import org.eclipse.jpt.common.utility.internal.command.SynchronizingCommand;
-
-/**
- * Gather the tiny bit of common behavior.
- */
-abstract class AbstractUiCommandExecutor
- implements ExtendedCommandExecutor
-{
- AbstractUiCommandExecutor() {
- super();
- }
-
- Runnable buildRunnable(Command command) {
- return new CommandRunnable(command);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- /**
- * A common way to put a time constraint on a command dispatched
- * to the UI thread.
- */
- public boolean waitToExecute(Command command, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitToExecute(command);
- return true;
- }
-
- // configure the sync command to execute the client command
- SynchronizingCommand syncCommand = new SynchronizingCommand(command);
-
- // dispatch the sync command to the UI thread...
- SWTUtil.asyncExec(this.buildRunnable(syncCommand));
-
- // ...and wait for it to execute
- try {
- return syncCommand.waitForExecution(timeout);
- } finally {
- syncCommand.release();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AsynchronousUiCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AsynchronousUiCommandExecutor.java
deleted file mode 100644
index d905f53b5d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/AsynchronousUiCommandExecutor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility;
-
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-
-/**
- * This command executor asynchronously executes a {@link Command command}
- * on the UI thread.
- * <p>
- * This command executor allows a non-UI process to modify any objects
- * associated with documents that are currently displayed in the UI.
- */
-public final class AsynchronousUiCommandExecutor
- extends AbstractUiCommandExecutor
-{
- public static final ExtendedCommandExecutor INSTANCE = new AsynchronousUiCommandExecutor();
-
- public static ExtendedCommandExecutor instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private AsynchronousUiCommandExecutor() {
- super();
- }
-
- public void execute(Command command) {
- SWTUtil.asyncExec(this.buildRunnable(command));
- }
-
- public void waitToExecute(Command command) {
- SWTUtil.syncExec(this.buildRunnable(command));
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PageAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PageAdapter.java
deleted file mode 100644
index ff7494bf92..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PageAdapter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.ui.IPageListener;
-import org.eclipse.ui.IWorkbenchPage;
-
-/**
- * Convenience implementation of {@link IPageListener}.
- */
-public class PageAdapter
- implements IPageListener
-{
- public void pageOpened(IWorkbenchPage page) {
- // do nothing
- }
- public void pageActivated(IWorkbenchPage page) {
- // do nothing
- }
- public void pageClosed(IWorkbenchPage page) {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PartAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PartAdapter.java
deleted file mode 100644
index 527bea9abe..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PartAdapter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * Convenience implementation of {@link IPartListener}.
- */
-public class PartAdapter
- implements IPartListener
-{
- public void partOpened(IWorkbenchPart part) {
- // do nothing
- }
- public void partBroughtToTop(IWorkbenchPart part) {
- // do nothing
- }
- public void partActivated(IWorkbenchPart part) {
- // do nothing
- }
- public void partDeactivated(IWorkbenchPart part) {
- // do nothing
- }
- public void partClosed(IWorkbenchPart part) {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PartAdapter2.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PartAdapter2.java
deleted file mode 100644
index 25176a909d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PartAdapter2.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IWorkbenchPartReference;
-
-/**
- * Convenience implementation of {@link IPartListener2}.
- */
-public class PartAdapter2
- implements IPartListener2
-{
- public void partOpened(IWorkbenchPartReference partRef) {
- // do nothing
- }
- public void partActivated(IWorkbenchPartReference partRef) {
- // do nothing
- }
- public void partBroughtToTop(IWorkbenchPartReference partRef) {
- // do nothing
- }
- public void partVisible(IWorkbenchPartReference partRef) {
- // do nothing
- }
- public void partInputChanged(IWorkbenchPartReference partRef) {
- // do nothing
- }
- public void partHidden(IWorkbenchPartReference partRef) {
- // do nothing
- }
- public void partDeactivated(IWorkbenchPartReference partRef) {
- // do nothing
- }
- public void partClosed(IWorkbenchPartReference partRef) {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PropertyAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PropertyAdapter.java
deleted file mode 100644
index 039808a373..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/PropertyAdapter.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.ui.IPropertyListener;
-
-/**
- * Convenience implementation of {@link IPropertyListener}.
- */
-public class PropertyAdapter
- implements IPropertyListener
-{
- public void propertyChanged(Object source, int propId) {
- // do nothing
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/SynchronousUiCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/SynchronousUiCommandExecutor.java
deleted file mode 100644
index d3be8f3190..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/SynchronousUiCommandExecutor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility;
-
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-
-/**
- * This command executor synchronously executes a {@link Command command}
- * on the UI thread.
- * <p>
- * This command executor allows a non-UI process to modify any objects
- * associated with documents that are currently displayed in the UI.
- */
-public final class SynchronousUiCommandExecutor
- extends AbstractUiCommandExecutor
-{
- public static final ExtendedCommandExecutor INSTANCE = new SynchronousUiCommandExecutor();
-
- public static ExtendedCommandExecutor instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private SynchronousUiCommandExecutor() {
- super();
- }
-
- public void execute(Command command) {
- SWTUtil.syncExec(this.buildRunnable(command));
- }
-
- public void waitToExecute(Command command) {
- this.execute(command);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/WindowAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/WindowAdapter.java
deleted file mode 100644
index 8a8e08a36c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/WindowAdapter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.ui.IWindowListener;
-import org.eclipse.ui.IWorkbenchWindow;
-
-/**
- * Convenience implementation of {@link IWindowListener}.
- */
-public class WindowAdapter
- implements IWindowListener
-{
- public void windowOpened(IWorkbenchWindow window) {
- // do nothing
- }
- public void windowActivated(IWorkbenchWindow window) {
- // do nothing
- }
- public void windowDeactivated(IWorkbenchWindow window) {
- // do nothing
- }
- public void windowClosed(IWorkbenchWindow window) {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/AbstractListWidgetAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/AbstractListWidgetAdapter.java
deleted file mode 100644
index 50df45253c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/AbstractListWidgetAdapter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * All the "list widgets" are subclasses of {@link Widget}; so we can provide
- * a smidgen of common behavior here.
- */
-abstract class AbstractListWidgetAdapter<W extends Widget>
- implements ListWidgetModelBinding.ListWidget
-{
- final W widget;
-
- AbstractListWidgetAdapter(W widget) {
- super();
- this.widget = widget;
- }
-
- public boolean isDisposed() {
- return this.widget.isDisposed();
- }
-
- public void addDisposeListener(DisposeListener listener) {
- this.widget.addDisposeListener(listener);
- }
-
- public void removeDisposeListener(DisposeListener listener) {
- this.widget.removeDisposeListener(listener);
- }
-
-}
-
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/BooleanButtonModelBinding.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/BooleanButtonModelBinding.java
deleted file mode 100644
index 64c19c6853..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/BooleanButtonModelBinding.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-
-/**
- * This binding can be used to keep a check-box, toggle button, or radio button
- * "selection" synchronized with a model boolean.
- *
- * @see ModifiablePropertyValueModel
- * @see Button
- */
-@SuppressWarnings("nls")
-final class BooleanButtonModelBinding {
-
- // ***** model
- /** A value model on the underlying model boolean. */
- private final ModifiablePropertyValueModel<Boolean> booleanModel;
-
- /**
- * A listener that allows us to synchronize the button's selection state with
- * the model boolean.
- */
- private final PropertyChangeListener booleanChangeListener;
-
- /**
- * The default setting for the check-box/toggle button/radio button;
- * for when the underlying model is <code>null</code>.
- * The default [default value] is <code>false</code> (i.e. the check-box
- * is unchecked/toggle button popped out/radio button unchecked).
- */
- private final boolean defaultValue;
-
- // ***** UI
- /** The check-box/toggle button/radio button we synchronize with the model boolean. */
- private final Button button;
-
- /**
- * A listener that allows us to synchronize the model boolean with
- * the button's selection state.
- */
- private final SelectionListener buttonSelectionListener;
-
- /**
- * A listener that allows us to stop listening to stuff when the button
- * is disposed. (Critical for preventing memory leaks.)
- */
- private final DisposeListener buttonDisposeListener;
-
-
- // ********** constructor **********
-
- /**
- * Constructor - the boolean model and button are required.
- */
- BooleanButtonModelBinding(ModifiablePropertyValueModel<Boolean> booleanModel, Button button, boolean defaultValue) {
- super();
- if ((booleanModel == null) || (button == null)) {
- throw new NullPointerException();
- }
- this.booleanModel = booleanModel;
- this.button = button;
- this.defaultValue = defaultValue;
-
- this.booleanChangeListener = this.buildBooleanChangeListener();
- this.booleanModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.booleanChangeListener);
-
- this.buttonSelectionListener = this.buildButtonSelectionListener();
- this.button.addSelectionListener(this.buttonSelectionListener);
-
- this.buttonDisposeListener = this.buildButtonDisposeListener();
- this.button.addDisposeListener(this.buttonDisposeListener);
-
- this.setButtonSelection(this.booleanModel.getValue());
- }
-
-
- // ********** initialization **********
-
- private PropertyChangeListener buildBooleanChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildBooleanChangeListener_());
- }
-
- private PropertyChangeListener buildBooleanChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- BooleanButtonModelBinding.this.booleanChanged(event);
- }
- @Override
- public String toString() {
- return "boolean listener";
- }
- };
- }
-
- private SelectionListener buildButtonSelectionListener() {
- return new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- BooleanButtonModelBinding.this.buttonSelected();
- }
- @Override
- public String toString() {
- return "button selection listener";
- }
- };
- }
-
- private DisposeListener buildButtonDisposeListener() {
- return new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- BooleanButtonModelBinding.this.buttonDisposed();
- }
- @Override
- public String toString() {
- return "button dispose listener";
- }
- };
- }
-
-
- // ********** boolean model events **********
-
- /**
- * The model has changed - synchronize the button.
- * If the new model value is null, use the binding's default value
- * (which is typically false).
- */
- /* CU private */ void booleanChanged(PropertyChangeEvent event) {
- this.setButtonSelection((Boolean) event.getNewValue());
- }
-
- private void setButtonSelection(Boolean b) {
- if ( ! this.button.isDisposed()) {
- this.button.setSelection(this.booleanValue(b));
- }
- }
-
- private boolean booleanValue(Boolean b) {
- return (b != null) ? b.booleanValue() : this.defaultValue;
- }
-
-
- // ********** button events **********
-
- /**
- * The button has been "selected" - synchronize the model.
- */
- /* CU private */ void buttonSelected() {
- if ( ! this.button.isDisposed()) {
- this.booleanModel.setValue(Boolean.valueOf(this.button.getSelection()));
- }
- }
-
- /* CU private */ void buttonDisposed() {
- // the button is not yet "disposed" when we receive this event
- // so we can still remove our listeners
- this.button.removeSelectionListener(this.buttonSelectionListener);
- this.button.removeDisposeListener(this.buttonDisposeListener);
- this.booleanModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.booleanChangeListener);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.booleanModel);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/BooleanStateController.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/BooleanStateController.java
deleted file mode 100644
index c8c5800cc4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/BooleanStateController.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.ui.internal.swt.DisposeAdapter;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.internal.RunnableAdapter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * This controller enables a boolean model to control either the
- * <em>enabled</em> or <em>visible</em> properties of SWT controls; i.e. the
- * controls' properties are kept in synch with the boolean model,
- * but <em>not</em> vice-versa.
- * <p>
- * Subclasses must manage the listeners; i.e. the engaging and disengaging of
- * the boolean model and the control(s).
- *
- * @see PropertyValueModel
- * @see Control#setEnabled(boolean)
- * @see Control#setVisible(boolean)
- */
-abstract class BooleanStateController {
-
- /**
- * The controlling boolean model.
- */
- private final PropertyValueModel<Boolean> booleanModel;
-
- /**
- * A listener that allows us to synchronize the control states with
- * changes in the value of the boolean model.
- */
- private final PropertyChangeListener booleanChangeListener;
-
- /**
- * A listener that allows us to stop listening to stuff when all the
- * controls are disposed. (Critical for preventing memory leaks.)
- */
- private final DisposeListener controlDisposeListener;
-
- /**
- * The default setting for the state; for when the underlying boolean model is
- * <code>null</code>. The default [default value] is <code>false<code>.
- */
- private final boolean defaultValue;
-
- /**
- * The adapter determines whether the 'enabled' or 'visible' property is
- * controlled.
- */
- private final Adapter adapter;
-
-
- // ********** constructor **********
-
- /**
- * Constructor - the boolean model and the adapter are required.
- */
- BooleanStateController(PropertyValueModel<Boolean> booleanModel, boolean defaultValue, Adapter adapter) {
- super();
- if ((booleanModel == null) || (adapter == null)) {
- throw new NullPointerException();
- }
- this.booleanModel = booleanModel;
- this.defaultValue = defaultValue;
- this.adapter = adapter;
-
- this.booleanChangeListener = this.buildBooleanChangeListener();
- this.controlDisposeListener = this.buildControlDisposeListener();
- }
-
-
- // ********** initialization **********
-
- private PropertyChangeListener buildBooleanChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildBooleanChangeListener_());
- }
-
- private PropertyChangeListener buildBooleanChangeListener_() {
- return new BooleanChangeListener();
- }
-
- /* CU private */ class BooleanChangeListener
- extends PropertyChangeAdapter
- {
- @Override
- public void propertyChanged(PropertyChangeEvent event) {
- BooleanStateController.this.booleanChanged(event);
- }
- }
-
- private DisposeListener buildControlDisposeListener() {
- return new ControlDisposeListener();
- }
-
- /* CU private */ class ControlDisposeListener
- extends DisposeAdapter
- {
- @Override
- public void widgetDisposed(DisposeEvent event) {
- // the control is not yet "disposed" when we receive this event
- // so we can still remove our listener
- BooleanStateController.this.controlDisposed((Control) event.widget);
- }
- }
-
-
- // ********** boolean model **********
-
- void engageBooleanModel() {
- this.booleanModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.booleanChangeListener);
- }
-
- void disengageBooleanModel() {
- this.booleanModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.booleanChangeListener);
- }
-
- /**
- * The boolean model has changed - synchronize the controls.
- * If the new boolean model value is <code>null</code>, use the controller's
- * default value (which is typically false).
- */
- /* CU private */ void booleanChanged(PropertyChangeEvent event) {
- this.setControlState((Boolean) event.getNewValue());
- }
-
-
- boolean getBooleanValue() {
- return this.booleanValue(this.booleanModel.getValue());
- }
-
- private boolean booleanValue(Boolean b) {
- return (b != null) ? b.booleanValue() : this.defaultValue;
- }
-
-
- // ********** control **********
-
- void engageControl(Control control) {
- control.addDisposeListener(this.controlDisposeListener);
- }
-
- void disengageControl(Control control) {
- control.removeDisposeListener(this.controlDisposeListener);
- }
-
- private void setControlState(Boolean controlState) {
- this.setControlState(this.booleanValue(controlState));
- }
-
- abstract void setControlState(boolean controlState);
-
- void setControlState(Control control, boolean controlState) {
- SWTUtil.execute(new SetControlStateRunnable(control, controlState));
- }
-
- /* CU private */ class SetControlStateRunnable
- extends RunnableAdapter
- {
- private final Control control;
- private final boolean controlState;
- SetControlStateRunnable(Control control, boolean controlState) {
- super();
- this.control = control;
- this.controlState = controlState;
- }
- @Override
- public void run() {
- BooleanStateController.this.setControlState_(this.control, this.controlState);
- }
- }
-
- /* CU private */ void setControlState_(Control control, boolean controlState) {
- if ( ! control.isDisposed()) {
- this.adapter.setState(control, controlState);
- }
- }
-
- void controlDisposed(Control control) {
- this.disengageControl(control);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.booleanModel);
- }
-
-
- // ********** adapter interface **********
-
- interface Adapter {
- void setState(Control control, boolean controlState);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/DropDownListBoxSelectionBinding.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/DropDownListBoxSelectionBinding.java
deleted file mode 100644
index 16b26cc3aa..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/DropDownListBoxSelectionBinding.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-
-/**
- * This binding can be used to keep a drop-down list box's selection
- * synchronized with a model. The selection can be modified by either the
- * drop-down list box or the model, so changes must be coordinated.
- * <p>
- * <strong>NB:</strong> A selected item value of <code>null</code> can be used
- * to clear the drop-down list box's selection. If <code>null</code> is a
- * valid item in the model list, an invalid selected item can be used to clear
- * the selection.
- *
- * @see ListValueModel
- * @see ModifiablePropertyValueModel
- * @see DropDownListBox
- * @see SWTTools
- */
-@SuppressWarnings("nls")
-final class DropDownListBoxSelectionBinding<E>
- implements ListWidgetModelBinding.SelectionBinding
-{
- // ***** model
- /**
- * The underlying list model.
- */
- private final ListValueModel<E> listModel;
-
- /**
- * A writable value model on the underlying model selection.
- */
- private final ModifiablePropertyValueModel<E> selectedItemModel;
-
- /**
- * A listener that allows us to synchronize the drop-down list box's
- * selection with the model selection.
- */
- private final PropertyChangeListener selectedItemChangeListener;
-
- // ***** UI
- /**
- * The drop-down list box whose selection we keep synchronized
- * with the model selection.
- */
- private final DropDownListBox dropdownListBox;
-
- /**
- * A listener that allows us to synchronize our selected item holder
- * with the drop-down list box's selection.
- */
- private final SelectionListener dropdownListBoxSelectionListener;
-
-
- // ********** constructor **********
-
- /**
- * Constructor - all parameters are required.
- */
- DropDownListBoxSelectionBinding(
- ListValueModel<E> listModel,
- ModifiablePropertyValueModel<E> selectedItemModel,
- DropDownListBox dropdownListBox
- ) {
- super();
- if ((listModel == null) || (selectedItemModel == null) || (dropdownListBox == null)) {
- throw new NullPointerException();
- }
- this.listModel = listModel;
- this.selectedItemModel = selectedItemModel;
- this.dropdownListBox = dropdownListBox;
-
- this.selectedItemChangeListener = this.buildSelectedItemChangeListener();
- this.selectedItemModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.selectedItemChangeListener);
-
- this.dropdownListBoxSelectionListener = this.buildDropDownListBoxSelectionListener();
- this.dropdownListBox.addSelectionListener(this.dropdownListBoxSelectionListener);
- }
-
-
- // ********** initialization **********
-
- private PropertyChangeListener buildSelectedItemChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildSelectedItemChangeListener_());
- }
-
- private PropertyChangeListener buildSelectedItemChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- DropDownListBoxSelectionBinding.this.selectedItemChanged(event);
- }
- @Override
- public String toString() {
- return "selected item listener";
- }
- };
- }
-
- private SelectionListener buildDropDownListBoxSelectionListener() {
- return new SelectionListener() {
- public void widgetSelected(SelectionEvent event) {
- DropDownListBoxSelectionBinding.this.dropDownListBoxSelectionChanged(event);
- }
- public void widgetDefaultSelected(SelectionEvent event) {
- DropDownListBoxSelectionBinding.this.dropDownListBoxDoubleClicked(event);
- }
- @Override
- public String toString() {
- return "drop-down list box selection listener";
- }
- };
- }
-
-
- // ********** ListWidgetModelBinding.SelectionBinding implementation **********
-
- /**
- * Modifying the drop-down lisb box's selected item programmatically does
- * not trigger a SelectionEvent.
- * <p>
- * Pre-condition: The drop-down list box is not disposed.
- */
- public void synchronizeListWidgetSelection() {
- int oldIndex = this.dropdownListBox.getSelectionIndex();
- E value = this.selectedItemModel.getValue();
- int newIndex = this.indexOf(value);
- if ((oldIndex != -1) && (newIndex != -1) && (newIndex != oldIndex)) {
- this.dropdownListBox.deselect(oldIndex);
- }
- if (newIndex == -1) {
- this.dropdownListBox.deselectAll();
- } else {
- if (newIndex != oldIndex) {
- this.dropdownListBox.select(newIndex);
- }
- }
- }
-
- public void dispose() {
- this.dropdownListBox.removeSelectionListener(this.dropdownListBoxSelectionListener);
- this.selectedItemModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.selectedItemChangeListener);
- }
-
-
- // ********** selected item **********
-
- void selectedItemChanged(PropertyChangeEvent event) {
- if ( ! this.dropdownListBox.isDisposed()) {
- this.selectedItemChanged_(event);
- }
- }
-
- /**
- * Modifying the drop-down list box's selected item programmatically does
- * not trigger a SelectionEvent.
- */
- private void selectedItemChanged_(@SuppressWarnings("unused") PropertyChangeEvent event) {
- this.synchronizeListWidgetSelection();
- }
-
- private int indexOf(E item) {
- int len = this.listModel.size();
- for (int i = 0; i < len; i++) {
- if (Tools.valuesAreEqual(this.listModel.get(i), item)) {
- return i;
- }
- }
- // if 'null' is not in the list, use it to clear the selection
- if (item == null) {
- return -1;
- }
- // We can get here via one of the following:
- // 1. The selected item model is invalid and not in sync with the list
- // model. This is not good and we don't make this (programming
- // error) obvious (e.g. via an exception). :-(
- // 2. If both the selected item model and the list model are dependent
- // on the same underlying model, the selected item model may receive
- // its event first, resulting in a missing item. This will resolve
- // itself once the list model receives its event and synchronizes
- // with the same underlying model. This situation is acceptable.
- return -1;
-
-// This is what we used to do:
-// throw new IllegalStateException("selected item not found: " + item);
- }
-
-
- // ********** combo-box events **********
-
- void dropDownListBoxSelectionChanged(SelectionEvent event) {
- if ( ! this.dropdownListBox.isDisposed()) {
- this.dropDownListBoxSelectionChanged_(event);
- }
- }
-
- void dropDownListBoxDoubleClicked(SelectionEvent event) {
- if ( ! this.dropdownListBox.isDisposed()) {
- this.dropDownListBoxSelectionChanged_(event);
- }
- }
-
- private void dropDownListBoxSelectionChanged_(@SuppressWarnings("unused") SelectionEvent event) {
- this.selectedItemModel.setValue(this.getDropDownListBoxSelectedItem());
- }
-
- private E getDropDownListBoxSelectedItem() {
- int selectionIndex = this.dropdownListBox.getSelectionIndex();
- return (selectionIndex == -1) ? null : this.listModel.get(selectionIndex);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.selectedItemModel);
- }
-
-
- // ********** adapter interface **********
-
- /**
- * Adapter used by the drop-down list box selection binding to query and manipulate
- * the drop-down list box.
- */
- interface DropDownListBox {
-
- /**
- * Return whether the combo-box is "disposed".
- */
- boolean isDisposed();
-
- /**
- * Add the specified selection listener to the combo-box.
- */
- void addSelectionListener(SelectionListener listener);
-
- /**
- * Remove the specified selection listener from the combo-box.
- */
- void removeSelectionListener(SelectionListener listener);
-
- /**
- * Return the index of the combo-box's selection.
- */
- int getSelectionIndex();
-
- /**
- * Select the item at the specified index in the combo-box.
- */
- void select(int index);
-
- /**
- * Deselect the item at the specified index in the combo-box.
- */
- void deselect(int index);
-
- /**
- * Clear the combo-box's selection.
- */
- void deselectAll();
-
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/ListBoxSelectionBinding.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/ListBoxSelectionBinding.java
deleted file mode 100644
index 2867624ba6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/ListBoxSelectionBinding.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import org.eclipse.jpt.common.ui.internal.listeners.SWTCollectionChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.List;
-
-/**
- * This binding can be used to keep a list box's selection
- * synchronized with a model. The selection can be modified by either the list
- * box or the model, so changes must be coordinated.
- *
- * @see ListValueModel
- * @see ModifiableCollectionValueModel
- * @see List
- * @see SWTTools
- */
-@SuppressWarnings("nls")
-final class ListBoxSelectionBinding<E>
- implements ListWidgetModelBinding.SelectionBinding
-{
- // ***** model
- /**
- * The underlying list model.
- */
- private final ListValueModel<E> listModel;
-
- /**
- * A writable value model on the underlying model selections.
- */
- private final ModifiableCollectionValueModel<E> selectedItemsModel;
-
- /**
- * A listener that allows us to synchronize the list box's selection with
- * the model selections.
- */
- private final CollectionChangeListener selectedItemsChangeListener;
-
- // ***** UI
- /**
- * The list box whose selection we keep synchronized with the model selections.
- */
- private final List listBox;
-
- /**
- * A listener that allows us to synchronize our selected items holder
- * with the list box's selection.
- */
- private final SelectionListener listBoxSelectionListener;
-
-
- // ********** constructor **********
-
- /**
- * Constructor - all parameters are required.
- */
- ListBoxSelectionBinding(
- ListValueModel<E> listModel,
- ModifiableCollectionValueModel<E> selectedItemsModel,
- List listBox
- ) {
- super();
- if ((listModel == null) || (selectedItemsModel == null) || (listBox == null)) {
- throw new NullPointerException();
- }
- this.listModel = listModel;
- this.selectedItemsModel = selectedItemsModel;
- this.listBox = listBox;
-
- this.selectedItemsChangeListener = this.buildSelectedItemsChangeListener();
- this.selectedItemsModel.addCollectionChangeListener(CollectionValueModel.VALUES, this.selectedItemsChangeListener);
-
- this.listBoxSelectionListener = this.buildListBoxSelectionListener();
- this.listBox.addSelectionListener(this.listBoxSelectionListener);
- }
-
-
- // ********** initialization **********
-
- private CollectionChangeListener buildSelectedItemsChangeListener() {
- return new SWTCollectionChangeListenerWrapper(this.buildSelectedItemsChangeListener_());
- }
-
- private CollectionChangeListener buildSelectedItemsChangeListener_() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent event) {
- ListBoxSelectionBinding.this.selectedItemsAdded(event);
- }
- public void itemsRemoved(CollectionRemoveEvent event) {
- ListBoxSelectionBinding.this.selectedItemsRemoved(event);
- }
- public void collectionCleared(CollectionClearEvent event) {
- ListBoxSelectionBinding.this.selectedItemsCleared(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- ListBoxSelectionBinding.this.selectedItemsChanged(event);
- }
- @Override
- public String toString() {
- return "selected items listener";
- }
- };
- }
-
- private SelectionListener buildListBoxSelectionListener() {
- return new SelectionListener() {
- public void widgetSelected(SelectionEvent event) {
- ListBoxSelectionBinding.this.listBoxSelectionChanged(event);
- }
- public void widgetDefaultSelected(SelectionEvent event) {
- ListBoxSelectionBinding.this.listBoxDoubleClicked(event);
- }
- @Override
- public String toString() {
- return "list box selection listener";
- }
- };
- }
-
-
- // ********** ListWidgetModelBinding.SelectionBinding implementation **********
-
- /**
- * Modifying the list box's selected items programmatically does not
- * trigger a SelectionEvent.
- *
- * Pre-condition: The list-box is not disposed.
- */
- public void synchronizeListWidgetSelection() {
- int selectedItemsSize = this.selectedItemsModel.size();
- int[] select = new int[selectedItemsSize];
- int i = 0;
- for (E item : this.selectedItemsModel) {
- select[i++] = this.indexOf(item);
- }
-
- int listSize = this.listModel.size();
- int[] deselect = new int[listSize - selectedItemsSize];
- i = 0;
- for (int j = 0; j < listSize; j++) {
- if ( ! ArrayTools.contains(select, j)) {
- deselect[i++] = j;
- }
- }
-
- int[] old = ArrayTools.sort(this.listBox.getSelectionIndices());
- select = ArrayTools.sort(select);
- if ( ! Arrays.equals(select, old)) {
- this.listBox.deselect(deselect);
- this.listBox.select(select);
- }
- }
-
- public void dispose() {
- this.listBox.removeSelectionListener(this.listBoxSelectionListener);
- this.selectedItemsModel.removeCollectionChangeListener(CollectionValueModel.VALUES, this.selectedItemsChangeListener);
- }
-
-
- // ********** selected items **********
-
- void selectedItemsAdded(CollectionAddEvent event) {
- if ( ! this.listBox.isDisposed()) {
- this.selectedItemsAdded_(event);
- }
- }
-
- /**
- * Modifying the list box's selected items programmatically does not
- * trigger a SelectionEvent.
- */
- private void selectedItemsAdded_(CollectionAddEvent event) {
- int[] indices = new int[event.getItemsSize()];
- int i = 0;
- for (E item : this.getItems(event)) {
- indices[i++] = this.indexOf(item);
- }
- this.listBox.select(indices);
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private Iterable<E> getItems(CollectionAddEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- void selectedItemsRemoved(CollectionRemoveEvent event) {
- if ( ! this.listBox.isDisposed()) {
- this.selectedItemsRemoved_(event);
- }
- }
-
- /**
- * Modifying the list box's selected items programmatically does not
- * trigger a SelectionEvent.
- */
- private void selectedItemsRemoved_(CollectionRemoveEvent event) {
- int[] indices = new int[event.getItemsSize()];
- int i = 0;
- for (E item : this.getItems(event)) {
- indices[i++] = this.indexOf(item);
- }
- this.listBox.deselect(indices);
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private Iterable<E> getItems(CollectionRemoveEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- void selectedItemsCleared(CollectionClearEvent event) {
- if ( ! this.listBox.isDisposed()) {
- this.selectedItemsCleared_(event);
- }
- }
-
- /**
- * Modifying the list box's selected items programmatically does not
- * trigger a SelectionEvent.
- */
- private void selectedItemsCleared_(@SuppressWarnings("unused") CollectionClearEvent event) {
- this.listBox.deselectAll();
- }
-
- void selectedItemsChanged(CollectionChangeEvent event) {
- if ( ! this.listBox.isDisposed()) {
- this.selectedItemsChanged_(event);
- }
- }
-
- private void selectedItemsChanged_(@SuppressWarnings("unused") CollectionChangeEvent event) {
- this.synchronizeListWidgetSelection();
- }
-
- private int indexOf(E item) {
- int len = this.listModel.size();
- for (int i = 0; i < len; i++) {
- if (Tools.valuesAreEqual(this.listModel.get(i), item)) {
- return i;
- }
- }
- // see comment in DropDownListBoxSelectionBinding.indexOf(E)
- return -1;
- }
-
-
- // ********** list box events **********
-
- void listBoxSelectionChanged(SelectionEvent event) {
- if ( ! this.listBox.isDisposed()) {
- this.listBoxSelectionChanged_(event);
- }
- }
-
- void listBoxDoubleClicked(SelectionEvent event) {
- if ( ! this.listBox.isDisposed()) {
- this.listBoxSelectionChanged_(event);
- }
- }
-
- private void listBoxSelectionChanged_(@SuppressWarnings("unused") SelectionEvent event) {
- this.selectedItemsModel.setValues(this.getListBoxSelectedItems());
- }
-
- private Iterable<E> getListBoxSelectedItems() {
- ArrayList<E> selectedItems = new ArrayList<E>(this.listBox.getSelectionCount());
- for (int selectionIndex : this.listBox.getSelectionIndices()) {
- selectedItems.add(this.listModel.get(selectionIndex));
- }
- return selectedItems;
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.selectedItemsModel);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/ListWidgetModelBinding.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/ListWidgetModelBinding.java
deleted file mode 100644
index 18b9e7c2d8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/ListWidgetModelBinding.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import java.util.ArrayList;
-
-import org.eclipse.jpt.common.ui.internal.listeners.SWTListChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.StringConverter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-
-/**
- * This binding can be used to keep a list widget's contents
- * synchronized with a model. The list widget never alters
- * its contents directly; all changes are driven by the model.
- *
- * @see ListValueModel
- * @see StringConverter
- * @see ListWidget
- * @see SelectionBinding
- * @see SWTTools
- */
-@SuppressWarnings("nls")
-final class ListWidgetModelBinding<E> {
-
- // ***** model
- /**
- * The underlying list model.
- */
- private final ListValueModel<E> listModel;
-
- /**
- * A listener that allows us to synchronize the list widget's contents with
- * the model list.
- */
- private final ListChangeListener listChangeListener;
-
- /**
- * A converter that converts items in the model list
- * to strings that can be put in the list widget.
- */
- private final StringConverter<E> stringConverter;
-
- // ***** UI
- /**
- * An adapter on the list widget we keep synchronized with the model list.
- */
- private final ListWidget listWidget;
-
- /**
- * A listener that allows us to stop listening to stuff when the list widget
- * is disposed. (Critical for preventing memory leaks.)
- */
- private final DisposeListener listWidgetDisposeListener;
-
- // ***** selection
- /**
- * Widget-specific selection binding.
- */
- private final SelectionBinding selectionBinding;
-
-
- // ********** constructor **********
-
- /**
- * Constructor - all parameters are required.
- */
- ListWidgetModelBinding(
- ListValueModel<E> listModel,
- ListWidget listWidget,
- StringConverter<E> stringConverter,
- SelectionBinding selectionBinding
- ) {
- super();
- if ((listModel == null) || (listWidget == null) || (stringConverter == null) || (selectionBinding == null)) {
- throw new NullPointerException();
- }
- this.listModel = listModel;
- this.listWidget = listWidget;
- this.stringConverter = stringConverter;
- this.selectionBinding = selectionBinding;
-
- this.listChangeListener = this.buildListChangeListener();
- this.listModel.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
-
- this.listWidgetDisposeListener = this.buildListWidgetDisposeListener();
- this.listWidget.addDisposeListener(this.listWidgetDisposeListener);
-
- this.synchronizeListWidget();
- }
-
-
- // ********** initialization **********
-
- private ListChangeListener buildListChangeListener() {
- return new SWTListChangeListenerWrapper(this.buildListChangeListener_());
- }
-
- private ListChangeListener buildListChangeListener_() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent event) {
- ListWidgetModelBinding.this.listItemsAdded(event);
- }
- public void itemsRemoved(ListRemoveEvent event) {
- ListWidgetModelBinding.this.listItemsRemoved(event);
- }
- public void itemsMoved(ListMoveEvent event) {
- ListWidgetModelBinding.this.listItemsMoved(event);
- }
- public void itemsReplaced(ListReplaceEvent event) {
- ListWidgetModelBinding.this.listItemsReplaced(event);
- }
- public void listCleared(ListClearEvent event) {
- ListWidgetModelBinding.this.listCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- ListWidgetModelBinding.this.listChanged(event);
- }
- @Override
- public String toString() {
- return "list listener";
- }
- };
- }
-
- private DisposeListener buildListWidgetDisposeListener() {
- return new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- ListWidgetModelBinding.this.listWidgetDisposed(event);
- }
- @Override
- public String toString() {
- return "list widget dispose listener";
- }
- };
- }
-
-
- // ********** list **********
-
- /**
- * Brute force synchronization of list widget with the model list.
- */
- private void synchronizeListWidget() {
- if ( ! this.listWidget.isDisposed()) {
- this.synchronizeListWidget_();
- }
- }
-
- private void synchronizeListWidget_() {
- ArrayList<String> items = new ArrayList<String>(this.listModel.size());
- for (E item : this.listModel) {
- items.add(this.convert(item));
- }
- this.listWidget.setItems(items.toArray(new String[items.size()]));
-
- // now that the list has changed, we need to synch the selection
- this.selectionBinding.synchronizeListWidgetSelection();
- }
-
- /**
- * The model has changed - synchronize the list widget.
- */
- void listItemsAdded(ListAddEvent event) {
- if ( ! this.listWidget.isDisposed()) {
- this.listItemsAdded_(event);
- }
- }
-
- private void listItemsAdded_(ListAddEvent event) {
- int i = event.getIndex();
- for (E item : this.getItems(event)) {
- this.listWidget.add(this.convert(item), i++);
- }
-
- // now that the list has changed, we need to synch the selection
- this.selectionBinding.synchronizeListWidgetSelection();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private Iterable<E> getItems(ListAddEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- /**
- * The model has changed - synchronize the list widget.
- */
- void listItemsRemoved(ListRemoveEvent event) {
- if ( ! this.listWidget.isDisposed()) {
- this.listItemsRemoved_(event);
- }
- }
-
- private void listItemsRemoved_(ListRemoveEvent event) {
- this.listWidget.remove(event.getIndex(), event.getIndex() + event.getItemsSize() - 1);
-
- // now that the list has changed, we need to synch the selection
- this.selectionBinding.synchronizeListWidgetSelection();
- }
-
- /**
- * The model has changed - synchronize the list widget.
- */
- void listItemsMoved(ListMoveEvent event) {
- if ( ! this.listWidget.isDisposed()) {
- this.listItemsMoved_(event);
- }
- }
-
- private void listItemsMoved_(ListMoveEvent event) {
- int target = event.getTargetIndex();
- int source = event.getSourceIndex();
- int len = event.getLength();
- int loStart = Math.min(target, source);
- int hiStart = Math.max(target, source);
- // make a copy of the affected items...
- String[] subArray = ArrayTools.subArray(this.listWidget.getItems(), loStart, hiStart + len);
- // ...move them around...
- subArray = ArrayTools.move(subArray, target - loStart, source - loStart, len);
- // ...and then put them back
- int i = loStart;
- for (String item : subArray) {
- this.listWidget.setItem(i++, item);
- }
-
- // now that the list has changed, we need to synch the selection
- this.selectionBinding.synchronizeListWidgetSelection();
- }
-
- /**
- * The model has changed - synchronize the list widget.
- */
- void listItemsReplaced(ListReplaceEvent event) {
- if ( ! this.listWidget.isDisposed()) {
- this.listItemsReplaced_(event);
- }
- }
-
- private void listItemsReplaced_(ListReplaceEvent event) {
- int i = event.getIndex();
- for (E item : this.getNewItems(event)) {
- this.listWidget.setItem(i++, this.convert(item));
- }
-
- // now that the list has changed, we need to synch the selection
- this.selectionBinding.synchronizeListWidgetSelection();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private Iterable<E> getNewItems(ListReplaceEvent event) {
- return (Iterable<E>) event.getNewItems();
- }
-
- /**
- * The model has changed - synchronize the list widget.
- */
- void listCleared(ListClearEvent event) {
- if ( ! this.listWidget.isDisposed()) {
- this.listCleared_(event);
- }
- }
-
- private void listCleared_(@SuppressWarnings("unused") ListClearEvent event) {
- this.listWidget.removeAll();
- }
-
- /**
- * The model has changed - synchronize the list widget.
- */
- void listChanged(ListChangeEvent event) {
- if ( ! this.listWidget.isDisposed()) {
- this.listChanged_(event);
- }
- }
-
- private void listChanged_(@SuppressWarnings("unused") ListChangeEvent event) {
- this.synchronizeListWidget_();
- }
-
- /**
- * Use the string converter to convert the specified item to a
- * string that can be added to the list widget.
- */
- private String convert(E item) {
- return this.stringConverter.convertToString(item);
- }
-
-
- // ********** list widget events **********
-
- void listWidgetDisposed(@SuppressWarnings("unused") DisposeEvent event) {
- // the list widget is not yet "disposed" when we receive this event
- // so we can still remove our listeners
- this.listWidget.removeDisposeListener(this.listWidgetDisposeListener);
- this.listModel.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- this.selectionBinding.dispose();
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listModel);
- }
-
-
- // ********** adapter interfaces **********
-
- /**
- * Adapter used by the list widget model binding to query and manipulate
- * the widget.
- */
- interface ListWidget {
-
- /**
- * Return whether the list widget is "disposed".
- */
- boolean isDisposed();
-
- /**
- * Add the specified dispose listener to the list widget.
- */
- void addDisposeListener(DisposeListener listener);
-
- /**
- * Remove the specified dispose listener from the list widget.
- */
- void removeDisposeListener(DisposeListener listener);
-
- /**
- * Return the list widget's items.
- */
- String[] getItems();
-
- /**
- * Set the list widget's item at the specified index to the specified item.
- */
- void setItem(int index, String item);
-
- /**
- * Set the list widget's items.
- */
- void setItems(String[] items);
-
- /**
- * Add the specified item to the list widget's items at the specified index.
- */
- void add(String item, int index);
-
- /**
- * Remove the specified range of items from the list widget's items.
- */
- void remove(int start, int end);
-
- /**
- * Remove all the items from the list widget.
- */
- void removeAll();
-
- }
-
-
- /**
- * Widget-specific selection binding that is controlled by the list widget
- * model binding.
- */
- interface SelectionBinding {
-
- /**
- * Synchronize the selection binding's widget with the selection model.
- * <p>
- * Pre-condition: The widget is not disposed.
- */
- void synchronizeListWidgetSelection();
-
- /**
- * The widget has been disposed; dispose the selection binding.
- */
- void dispose();
-
-
- /**
- * Useful for list boxes that ignore the selection.
- */
- final class Null implements SelectionBinding {
- public static final SelectionBinding INSTANCE = new Null();
- public static SelectionBinding instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void synchronizeListWidgetSelection() {
- // do nothing
- }
- public void dispose() {
- // do nothing
- }
- @Override
- public String toString() {
- return "SelectionBinding.Null"; //$NON-NLS-1$
- }
- }
-
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/MultiControlBooleanStateController.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/MultiControlBooleanStateController.java
deleted file mode 100644
index 0c48ad96b5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/MultiControlBooleanStateController.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import java.util.HashSet;
-import org.eclipse.jpt.common.utility.internal.iterables.SnapshotCloneIterable;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * This controller enables a boolean model to control either the
- * <em>enabled</em> or <em>visible</em> properties of a set of SWT controls;
- * i.e. the controls' properties are kept in synch with the boolean model,
- * but <em>not</em> vice-versa.
- *
- * @see PropertyValueModel
- * @see CollectionValueModel
- * @see Control#setEnabled(boolean)
- * @see Control#setVisible(boolean)
- */
-final class MultiControlBooleanStateController
- extends BooleanStateController
-{
- /**
- * The set of controls whose state is kept in sync with the boolean model.
- */
- private final CollectionValueModel<? extends Control> controlsModel;
-
- /**
- * A listener that allows clients to add/remove controls.
- */
- private final CollectionChangeListener controlsListener;
-
- /**
- * Cache of controls.
- */
- private final HashSet<Control> controls = new HashSet<Control>();
-
-
- // ********** constructor **********
-
- /**
- * Constructor - the boolean model, the controls model, and the adapter are required.
- */
- MultiControlBooleanStateController(
- PropertyValueModel<Boolean> booleanModel,
- CollectionValueModel<? extends Control> controlsModel,
- boolean defaultValue,
- Adapter adapter
- ) {
- super(booleanModel, defaultValue, adapter);
- if (controlsModel == null) {
- throw new NullPointerException();
- }
- this.controlsModel = controlsModel;
- this.controlsListener = this.buildControlsListener();
- this.addControls(controlsModel);
- }
-
-
- // ********** initialization **********
-
- private CollectionChangeListener buildControlsListener() {
- return new ControlsListener();
- }
-
- /* CU private */ class ControlsListener
- extends CollectionChangeAdapter
- {
- @Override
- @SuppressWarnings("unchecked")
- public void itemsAdded(CollectionAddEvent event) {
- MultiControlBooleanStateController.this.addControls((Iterable<? extends Control>) event.getItems());
- }
- @Override
- @SuppressWarnings("unchecked")
- public void itemsRemoved(CollectionRemoveEvent event) {
- MultiControlBooleanStateController.this.removeControls((Iterable<? extends Control>) event.getItems());
- }
- @Override
- public void collectionCleared(CollectionClearEvent event) {
- MultiControlBooleanStateController.this.clearControls();
- }
- @Override
- @SuppressWarnings("unchecked")
- public void collectionChanged(CollectionChangeEvent event) {
- MultiControlBooleanStateController.this.clearControls();
- MultiControlBooleanStateController.this.addControls((Iterable<? extends Control>) event.getCollection());
- }
- }
-
-
- // ********** controls **********
-
- @Override
- void setControlState(boolean controlState) {
- for (Control control : this.controls) {
- this.setControlState(control, controlState);
- }
- }
-
- /* CU private */ void addControls(Iterable<? extends Control> controls_) {
- for (Control control : controls_) {
- this.addControl(control);
- }
- }
-
- private void addControl(Control control) {
- if (this.controls.isEmpty()) {
- this.engageBooleanModel();
- this.controlsModel.addCollectionChangeListener(CollectionValueModel.VALUES, this.controlsListener);
- }
- if (this.controls.add(control)) {
- this.engageControl(control);
- // wait until the models are engaged to get the boolean value... :-)
- this.setControlState(control, this.getBooleanValue());
- } else {
- throw new IllegalArgumentException("duplicate control: " + control); //$NON-NLS-1$
- }
- }
-
- /* CU private */ void clearControls() {
- this.removeControls(new SnapshotCloneIterable<Control>(this.controls));
- }
-
- /* CU private */ void removeControls(Iterable<? extends Control> controls_) {
- for (Control control : controls_) {
- this.disengageControl(control);
- this.removeControl(control);
- }
- }
-
- private void removeControl(Control control) {
- this.controls.remove(control);
- if (this.controls.isEmpty()) {
- this.controlsModel.removeCollectionChangeListener(CollectionValueModel.VALUES, this.controlsListener);
- this.disengageBooleanModel();
- }
- }
-
- @Override
- void controlDisposed(Control control) {
- super.controlDisposed(control);
- this.removeControl(control);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTComboAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTComboAdapter.java
deleted file mode 100644
index 672524d2d2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTComboAdapter.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Combo;
-
-/**
- * Adapt an SWT {@link Combo} to the list widget expected by
- * {@link ListWidgetModelBinding} and the
- * drop-down list box expected by {@link DropDownListBoxSelectionBinding}.
- */
-final class SWTComboAdapter
- extends AbstractListWidgetAdapter<Combo>
- implements DropDownListBoxSelectionBinding.DropDownListBox
-{
- SWTComboAdapter(Combo combo) {
- super(combo);
- }
-
- // ********** ListWidgetModelBinding.ListWidget implementation **********
- public String[] getItems() {
- return this.widget.getItems();
- }
- public void setItem(int index, String item) {
- this.widget.setItem(index, item);
- }
- public void setItems(String[] items) {
- this.widget.setItems(items);
- }
- public void add(String item, int index) {
- this.widget.add(item, index);
- }
- public void remove(int start, int end) {
- this.widget.remove(start, end);
- }
- public void removeAll() {
- this.widget.removeAll();
- }
-
- // ********** ComboBoxSelectionBinding.ComboBox implementation **********
- public void addSelectionListener(SelectionListener listener) {
- this.widget.addSelectionListener(listener);
- }
- public void removeSelectionListener(SelectionListener listener) {
- this.widget.removeSelectionListener(listener);
- }
- public int getSelectionIndex() {
- return this.widget.getSelectionIndex();
- }
- public void select(int index) {
- this.widget.select(index);
- }
- public void deselect(int index) {
- this.widget.deselect(index);
- }
- public void deselectAll() {
- this.widget.deselectAll();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTListAdapter.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTListAdapter.java
deleted file mode 100644
index 767be1bb86..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTListAdapter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.List;
-
-/**
- * Adapt an SWT {@link List} to the list widget expected by
- * {@link ListWidgetModelBinding}.
- */
-final class SWTListAdapter
- extends AbstractListWidgetAdapter<List>
-{
- SWTListAdapter(List list) {
- super(list);
- }
- public void addSelectionListener(SelectionListener listener) {
- this.widget.addSelectionListener(listener);
- }
- public void removeSelectionListener(SelectionListener listener) {
- this.widget.removeSelectionListener(listener);
- }
- public String[] getItems() {
- return this.widget.getItems();
- }
- public void setItem(int index, String item) {
- this.widget.setItem(index, item);
- }
- public void setItems(String[] items) {
- this.widget.setItems(items);
- }
- public void add(String item, int index) {
- this.widget.add(item, index);
- }
- public void remove(int start, int end) {
- this.widget.remove(start, end);
- }
- public void removeAll() {
- this.widget.removeAll();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTTools.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTTools.java
deleted file mode 100644
index 4834bb80af..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SWTTools.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.common.utility.internal.BitTools;
-import org.eclipse.jpt.common.utility.internal.StringConverter;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ModifiablePropertyCollectionValueModelAdapter;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Widget;
-
-/**
- * Various SWT tools.
- */
-@SuppressWarnings("nls")
-public final class SWTTools {
-
- // ********** check-box/radio button/toggle button **********
-
- /**
- * Bind the specified button (check-box, radio button, or toggle button)
- * to the specified boolean model.
- * If the boolean model is <code>null<code>, the button's 'selection' state will
- * be <code>false<code>.
- */
- public static void bind(ModifiablePropertyValueModel<Boolean> booleanModel, Button button) {
- bind(booleanModel, button, false);
- }
-
- /**
- * Bind the specified button (check-box, radio button, or toggle button)
- * to the specified boolean model.
- * If the boolean model is <code>null<code>, the button's 'selection' state will
- * be the specified default value.
- */
- public static void bind(ModifiablePropertyValueModel<Boolean> booleanModel, Button button, boolean defaultValue) {
- // the new binding will add itself as a listener to the boolean model and the button
- new BooleanButtonModelBinding(booleanModel, button, defaultValue);
- }
-
-
- // ********** text field **********
-
- /**
- * Bind the specified text model to the specified text field.
- */
- public static <E> void bind(ModifiablePropertyValueModel<String> textModel, Text textField) {
- // the new binding will add itself as a listener to the text model and the text field
- new TextFieldModelBinding(textModel, textField);
- }
-
-
- // ********** list box **********
-
- /**
- * Bind the specified model list to the specified list box.
- * The list box selection is ignored.
- * Use the default string converter to convert the model items to strings
- * to be displayed in the list box, which calls {@link Object#toString()}
- * on the items in the model list.
- */
- public static <E> void bind(ListValueModel<E> listModel, List listBox) {
- bind(listModel, listBox, StringConverter.Default.<E>instance());
- }
-
- /**
- * Bind the specified model list to the specified list box.
- * The list box selection is ignored.
- * Use the specified string converter to convert the model items to strings
- * to be displayed in the list box.
- */
- public static <E> void bind(ListValueModel<E> listModel, List listBox, StringConverter<E> stringConverter) {
- bind(listModel, new SWTListAdapter(listBox), stringConverter);
- }
-
- /**
- * Bind the specified model list and selection to the specified list box.
- * Use the default string converter to convert the model items to strings
- * to be displayed in the list box, which calls {@link Object#toString()}
- * on the items in the model list.
- */
- public static <E> void bind(ListValueModel<E> listModel, ModifiablePropertyValueModel<E> selectedItemModel, List listBox) {
- bind(listModel, selectedItemModel, listBox, StringConverter.Default.<E>instance());
- }
-
- /**
- * Adapt the specified model list and selection to the specified list box.
- * Use the specified string converter to convert the model items to strings
- * to be displayed in the list box.
- */
- public static <E> void bind(ListValueModel<E> listModel, ModifiablePropertyValueModel<E> selectedItemModel, List listBox, StringConverter<E> stringConverter) {
- checkForSingleSelectionStyle(listBox);
- bind(listModel, new ModifiablePropertyCollectionValueModelAdapter<E>(selectedItemModel), listBox, stringConverter);
- }
-
- /**
- * Bind the specified model list and selections to the specified list box.
- * Use the default string converter to convert the model items to strings
- * to be displayed in the list box, which calls {@link Object#toString()}
- * on the items in the model list.
- */
- public static <E> void bind(ListValueModel<E> listModel, ModifiableCollectionValueModel<E> selectedItemsModel, List listBox) {
- bind(listModel, selectedItemsModel, listBox, StringConverter.Default.<E>instance());
- }
-
- /**
- * Bind the specified model list and selections to the specified list box.
- * Use the specified string converter to convert the model items to strings
- * to be displayed in the list box.
- */
- public static <E> void bind(ListValueModel<E> listModel, ModifiableCollectionValueModel<E> selectedItemsModel, List listBox, StringConverter<E> stringConverter) {
- bind(
- listModel,
- new SWTListAdapter(listBox),
- stringConverter,
- new ListBoxSelectionBinding<E>(listModel, selectedItemsModel, listBox)
- );
- }
-
- private static void checkForSingleSelectionStyle(List listBox) {
- if ( ! BitTools.flagIsSet(listBox.getStyle(), SWT.SINGLE)) {
- throw new IllegalStateException("list box must be single-selection: " + listBox);
- }
- }
-
-
- // ********** drop-down list box **********
-
- /**
- * Bind the specified model list and selection to the specified drop-down list box.
- * Use the default string converter to convert the model items to strings
- * to be displayed in the drop-down list box, which calls {@link Object#toString()}
- * on the items in the model list.
- */
- public static <E> void bind(ListValueModel<E> listModel, ModifiablePropertyValueModel<E> selectedItemModel, Combo dropDownListBox) {
- bind(listModel, selectedItemModel, dropDownListBox, StringConverter.Default.<E>instance());
- }
-
- /**
- * Adapt the specified model list and selection to the specified drop-down list box.
- * Use the specified string converter to convert the model items to strings
- * to be displayed in the drop-down list box.
- */
- public static <E> void bind(ListValueModel<E> listModel, ModifiablePropertyValueModel<E> selectedItemModel, Combo dropDownListBox, StringConverter<E> stringConverter) {
- checkForReadOnlyStyle(dropDownListBox);
- SWTComboAdapter comboAdapter = new SWTComboAdapter(dropDownListBox);
- bind(
- listModel,
- comboAdapter,
- stringConverter,
- new DropDownListBoxSelectionBinding<E>(listModel, selectedItemModel, comboAdapter)
- );
- }
-
- private static void checkForReadOnlyStyle(Widget comboBox) {
- if ( ! BitTools.flagIsSet(comboBox.getStyle(), SWT.READ_ONLY)) {
- throw new IllegalStateException("combo-box must be read-only: " + comboBox);
- }
- }
-
-
- // ********** list "widget" **********
-
- /**
- * Bind the specified model list to the specified list widget.
- * The list widget's selection is ignored.
- * Use the specified string converter to convert the model items to strings
- * to be displayed in the list box.
- */
- private static <E> void bind(ListValueModel<E> listModel, ListWidgetModelBinding.ListWidget listWidget, StringConverter<E> stringConverter) {
- bind(listModel, listWidget, stringConverter, ListWidgetModelBinding.SelectionBinding.Null.instance());
- }
-
- /**
- * Bind the specified model list to the specified list widget.
- * Use the specified selection binding to control the list widget's selection.
- * Use the specified string converter to convert the model items to strings
- * to be displayed in the list box.
- */
- private static <E> void bind(ListValueModel<E> listModel, ListWidgetModelBinding.ListWidget listWidget, StringConverter<E> stringConverter, ListWidgetModelBinding.SelectionBinding selectionBinding) {
- // the new binding will add itself as a listener to the value models and the list box
- new ListWidgetModelBinding<E>(listModel, listWidget, stringConverter, selectionBinding);
- }
-
-
- // ********** 'enabled' state **********
-
- /**
- * Control the <em>enabled</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>enabled</em> states will be <code>false<code>.
- */
- public static void controlEnabledState(PropertyValueModel<Boolean> booleanModel, Control... controls) {
- controlEnabledState(booleanModel, controls, false);
- }
-
- /**
- * Control the <em>enabled</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>enabled</em> states will be the specified default value.
- */
- public static void controlEnabledState(PropertyValueModel<Boolean> booleanModel, Control[] controls, boolean defaultValue) {
- switch (controls.length) {
- case 0:
- throw new IllegalArgumentException("empty controls array: " + Arrays.toString(controls));
- case 1:
- controlEnabledState(booleanModel, controls[0], defaultValue);
- break;
- default:
- controlEnabledState(booleanModel, new StaticCollectionValueModel<Control>(controls), defaultValue);
- break;
- }
- }
-
- /**
- * Control the <em>enabled</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>enabled</em> states will be <code>false<code>.
- */
- public static void controlEnabledState(PropertyValueModel<Boolean> booleanModel, Iterable<? extends Control> controls) {
- controlEnabledState(booleanModel, controls, false);
- }
-
- /**
- * Control the <em>enabled</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>enabled</em> states will be the specified default value.
- */
- public static void controlEnabledState(PropertyValueModel<Boolean> booleanModel, Iterable<? extends Control> controls, boolean defaultValue) {
- controlEnabledState(booleanModel, new StaticCollectionValueModel<Control>(controls), defaultValue);
- }
-
- /**
- * Control the <em>enabled</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>enabled</em> states will be <code>false<code>.
- */
- public static void controlEnabledState(PropertyValueModel<Boolean> booleanModel, CollectionValueModel<? extends Control> controlsModel) {
- controlEnabledState(booleanModel, controlsModel, false);
- }
-
- /**
- * Control the <em>enabled</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>enabled</em> states will be the specified default value.
- */
- public static void controlEnabledState(PropertyValueModel<Boolean> booleanModel, CollectionValueModel<? extends Control> controlsModel, boolean defaultValue) {
- control(booleanModel, controlsModel, defaultValue, ENABLED_ADAPTER);
- }
-
- /**
- * Control the <em>enabled</em> state of the specified control with the
- * specified boolean. If the boolean is <code>null<code>, the control's
- * <em>enabled</em> state will be the specified default value.
- */
- public static void controlEnabledState(PropertyValueModel<Boolean> booleanModel, Control control, boolean defaultValue) {
- control(booleanModel, control, defaultValue, ENABLED_ADAPTER);
- }
-
- private static final BooleanStateController.Adapter ENABLED_ADAPTER =
- new BooleanStateController.Adapter() {
- public void setState(Control control, boolean b) {
- control.setEnabled(b);
- }
- };
-
-
- // ********** 'visible' state **********
-
- /**
- * Control the <em>visible</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>visible</em> states will be <code>false<code>.
- */
- public static void controlVisibleState(PropertyValueModel<Boolean> booleanModel, Control... controls) {
- controlVisibleState(booleanModel, controls, false);
- }
-
- /**
- * Control the <em>visible</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>visible</em> states will be the specified default value.
- */
- public static void controlVisibleState(PropertyValueModel<Boolean> booleanModel, Control[] controls, boolean defaultValue) {
- switch (controls.length) {
- case 0:
- throw new IllegalArgumentException("empty controls array: " + Arrays.toString(controls));
- case 1:
- controlVisibleState(booleanModel, controls[0], defaultValue);
- break;
- default:
- controlVisibleState(booleanModel, new StaticCollectionValueModel<Control>(controls), defaultValue);
- break;
- }
- }
-
- /**
- * Control the <em>visible</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>visible</em> states will be <code>false<code>.
- */
- public static void controlVisibleState(PropertyValueModel<Boolean> booleanModel, Iterable<? extends Control> controls) {
- controlVisibleState(booleanModel, controls, false);
- }
-
- /**
- * Control the <em>visible</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>visible</em> states will be the specified default value.
- */
- public static void controlVisibleState(PropertyValueModel<Boolean> booleanModel, Iterable<? extends Control> controls, boolean defaultValue) {
- controlVisibleState(booleanModel, new StaticCollectionValueModel<Control>(controls), defaultValue);
- }
-
- /**
- * Control the <em>visible</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>visible</em> states will be <code>false<code>.
- */
- public static void controlVisibleState(PropertyValueModel<Boolean> booleanModel, CollectionValueModel<? extends Control> controlsModel) {
- controlVisibleState(booleanModel, controlsModel, false);
- }
-
- /**
- * Control the <em>visible</em> state of the specified controls with the
- * specified boolean. If the boolean is <code>null<code>, the controls'
- * <em>visible</em> states will be the specified default value.
- */
- public static void controlVisibleState(PropertyValueModel<Boolean> booleanModel, CollectionValueModel<? extends Control> controlsModel, boolean defaultValue) {
- control(booleanModel, controlsModel, defaultValue, VISIBLE_ADAPTER);
- }
-
- /**
- * Control the <em>visible</em> state of the specified control with the
- * specified boolean. If the boolean is <code>null<code>, the control's
- * <em>visible</em> state will be the specified default value.
- */
- public static void controlVisibleState(PropertyValueModel<Boolean> booleanModel, Control control, boolean defaultValue) {
- control(booleanModel, control, defaultValue, VISIBLE_ADAPTER);
- }
-
- private static final BooleanStateController.Adapter VISIBLE_ADAPTER =
- new BooleanStateController.Adapter() {
- public void setState(Control control, boolean b) {
- control.setVisible(b);
- }
- };
-
-
- // ********** boolean state controller **********
-
- private static void control(PropertyValueModel<Boolean> booleanModel, CollectionValueModel<? extends Control> controlsModel, boolean defaultValue, BooleanStateController.Adapter adapter) {
- // the new controller will add itself as a listener to the value model and the controls
- new MultiControlBooleanStateController(booleanModel, controlsModel, defaultValue, adapter);
- }
-
- private static void control(PropertyValueModel<Boolean> booleanModel, Control control, boolean defaultValue, BooleanStateController.Adapter adapter) {
- // the new controller will add itself as a listener to the value model and the controls
- new SimpleBooleanStateController(booleanModel, control, defaultValue, adapter);
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private SWTTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SimpleBooleanStateController.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SimpleBooleanStateController.java
deleted file mode 100644
index ea036488b5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/SimpleBooleanStateController.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * This controller enables a boolean model to control either the
- * <em>enabled</em> or <em>visible</em> properties of an SWT control; i.e. the
- * control's property is kept in synch with the boolean model,
- * but <em>not</em> vice-versa.
- * <p>
- * Once the control is disposed, this controller is kaput.
- *
- * @see PropertyValueModel
- * @see Control#setEnabled(boolean)
- * @see Control#setVisible(boolean)
- */
-final class SimpleBooleanStateController
- extends BooleanStateController
-{
- private final Control control;
-
-
- // ********** constructor **********
-
- /**
- * Constructor - the boolean model, the control, and the adapter are required.
- */
- SimpleBooleanStateController(
- PropertyValueModel<Boolean> booleanModel,
- Control control,
- boolean defaultValue,
- Adapter adapter
- ) {
- super(booleanModel, defaultValue, adapter);
- if (control == null) {
- throw new NullPointerException();
- }
- this.control = control;
- this.engageBooleanModel();
- this.engageControl(control);
- this.setControlState(control, this.getBooleanValue());
- }
-
-
- // ********** controls **********
-
- @Override
- void setControlState(boolean controlState) {
- this.setControlState(this.control, controlState);
- }
-
- @Override
- void controlDisposed(Control c) {
- super.controlDisposed(c);
- this.disengageBooleanModel();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/TextFieldModelBinding.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/TextFieldModelBinding.java
deleted file mode 100644
index a72ea8ab73..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/utility/swt/TextFieldModelBinding.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.utility.swt;
-
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * This binding can be used to keep a text field
- * synchronized with a model text/string.
- *
- * @see ModifiablePropertyValueModel
- * @see Text
- */
-@SuppressWarnings("nls")
-class TextFieldModelBinding {
-
- /**
- * The text model we keep synchronized with the text field.
- */
- private final ModifiablePropertyValueModel<String> textModel;
-
- /**
- * A listener that allows us to synchronize the text field's contents with
- * the text model.
- */
- private final PropertyChangeListener textModelChangeListener;
-
- /**
- * The text field we keep synchronized with the text model.
- */
- private final Text textField;
-
- /**
- * A listener that allows us to synchronize our text model
- * with the text field's contents.
- */
- private final ModifyListener textFieldModifyListener;
-
- /**
- * A listener that allows us to stop listening to stuff when the text field
- * is disposed.
- */
- private final DisposeListener textFieldDisposeListener;
-
- /**
- * Hmm...
- */
- private boolean settingTextFieldText = false;
-
-
- // ********** constructor **********
-
- /**
- * Constructor - the text model and text field are required.
- */
- TextFieldModelBinding(ModifiablePropertyValueModel<String> textModel, Text textField) {
- super();
- if ((textModel == null) || (textField == null)) {
- throw new NullPointerException();
- }
- this.textModel = textModel;
- this.textField = textField;
-
- this.textModelChangeListener = this.buildTextModelChangeListener();
- this.textModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.textModelChangeListener);
-
- this.textFieldModifyListener = this.buildTextFieldModifyListener();
- this.textField.addModifyListener(this.textFieldModifyListener);
-
- this.textFieldDisposeListener = this.buildTextFieldDisposeListener();
- this.textField.addDisposeListener(this.textFieldDisposeListener);
-
- this.setTextFieldText(textModel.getValue());
- }
-
-
- // ********** initialization **********
-
- private PropertyChangeListener buildTextModelChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildTextModelChangeListener_());
- }
-
- private PropertyChangeListener buildTextModelChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- TextFieldModelBinding.this.textModelChanged(event);
- }
- @Override
- public String toString() {
- return "text listener";
- }
- };
- }
-
- private ModifyListener buildTextFieldModifyListener() {
- return new ModifyListener() {
- public void modifyText(ModifyEvent event) {
- TextFieldModelBinding.this.textFieldModified();
- }
- @Override
- public String toString() {
- return "text field modify listener";
- }
- };
- }
-
- private DisposeListener buildTextFieldDisposeListener() {
- return new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- TextFieldModelBinding.this.textFieldDisposed();
- }
- @Override
- public String toString() {
- return "text field dispose listener";
- }
- };
- }
-
-
- // ********** text model events **********
-
- /* CU private */ void textModelChanged(PropertyChangeEvent event) {
- if ( ! this.textField.isDisposed()) { // ???
- this.setTextFieldText((String) event.getNewValue());
- }
- }
-
- private void setTextFieldText(String text) {
- // the text model can be null, but the text field cannot
- this.setTextFieldText_((text == null) ? "" : text);
- }
-
- private void setTextFieldText_(String text) {
- if ( ! text.equals(this.textField.getText())) { // ???
- this.setTextFieldText__(text);
- }
- }
-
- private void setTextFieldText__(String text) {
- this.settingTextFieldText = true;
- try {
- this.textField.setText(text);
- } finally {
- this.settingTextFieldText = false;
- }
- }
-
-
- // ********** text field events **********
-
- /* CU private */ void textFieldModified() {
- if ( ! this.settingTextFieldText) {
- this.setTextModelText(this.textField.getText());
- }
- }
-
- private void setTextModelText(String text) {
- if ( ! text.equals(this.textModel.getValue())) { // ???
- this.textModel.setValue(text);
- }
- }
-
- /* CU private */ void textFieldDisposed() {
- // the text field is not yet "disposed" when we receive this event
- // so we can still remove our listeners
- this.textField.removeDisposeListener(this.textFieldDisposeListener);
- this.textField.removeModifyListener(this.textFieldModifyListener);
- this.textModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.textModelChangeListener);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.textModel);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveListPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveListPane.java
deleted file mode 100644
index 6109579f70..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveListPane.java
+++ /dev/null
@@ -1,554 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.ui.internal.swt.ColumnAdapter;
-import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter;
-import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter.SelectionChangeEvent;
-import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter.SelectionChangeListener;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-
-/**
- * This implementation of the <code>AddRemovePane</code> uses a <code>Table</code>
- * as its main widget, a <code>List</code> can't be used because it doesn't
- * support showing images. However, the table is displayed like a list.
- * <p>
- * Here the layot of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | ------------------------------------------------------------- ----------- |
- * | | Item 1 | | Add... | |
- * | | ... | ----------- |
- * | | Item n | ----------- |
- * | | | | Edit... | |
- * | | | ----------- |
- * | | | ----------- |
- * | | | | Remove | |
- * | | | ----------- |
- * | ------------------------------------------------------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @version 2.0
- * @since 1.0
- */
-@SuppressWarnings("nls")
-public class AddRemoveListPane<T extends Model> extends AddRemovePane<T>
-{
-
- /**
- * The main widget of this add/remove pane.
- */
- private Table table;
-
- /**
- * Creates a new <code>AddRemoveListPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param adapter
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the table holder's items
- */
- public AddRemoveListPane(Pane<? extends T> parentPane,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- ILabelProvider labelProvider) {
-
- super(parentPane,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider);
- }
-
- /**
- * Creates a new <code>AddRemoveListPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param adapter
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the table holder's items
- * @param helpId The topic help ID to be registered with this pane
- */
- public AddRemoveListPane(Pane<? extends T> parentPane,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- ILabelProvider labelProvider,
- String helpId) {
-
- super(parentPane,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider,
- helpId);
- }
-
- /**
- * Creates a new <code>AddRemoveListPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param adapter
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the table holder's items
- * @param helpId The topic help ID to be registered with this pane
- * @param parentManagePane <code>true</code> to have the parent pane manage
- * the enabled state of this pane
- */
- public AddRemoveListPane(Pane<? extends T> parentPane,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- ILabelProvider labelProvider,
- String helpId,
- boolean parentManagePane) {
-
- super(parentPane,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider,
- helpId,
- parentManagePane);
- }
-
- /**
- * Creates a new <code>AddRemoveListPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of the subject
- * @param adapter
- * @param parent The parent container
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the table holder's items
- */
- public AddRemoveListPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- ILabelProvider labelProvider) {
-
- super(parentPane,
- subjectHolder,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider);
- }
-
- /**
- * Creates a new <code>AddRemoveListPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of the subject
- * @param adapter
- * @param parent The parent container
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the table holder's items
- * @param helpId The topic help ID to be registered with this pane
- */
- public AddRemoveListPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- ILabelProvider labelProvider,
- String helpId) {
-
- super(parentPane,
- subjectHolder,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider,
- helpId);
- }
-
- private ColumnAdapter<Object> buildColumnAdapter() {
- return new ColumnAdapter<Object>() {
- public ModifiablePropertyValueModel<?>[] cellModels(Object subject) {
- ModifiablePropertyValueModel<?>[] valueHolders = new ModifiablePropertyValueModel<?>[1];
- valueHolders[0] = new SimplePropertyValueModel<Object>(subject);
- return valueHolders;
- }
-
- public int columnCount() {
- return 1;
- }
-
- public String columnName(int columnIndex) {
- return "";
- }
- };
- }
-
- @Override
- protected void itemsAdded(ListAddEvent e) {
- super.itemsAdded(e);
- revalidateLayout();
- }
-
- @Override
- protected void itemsMoved(ListMoveEvent e) {
- super.itemsMoved(e);
- revalidateLayout();
- }
-
- @Override
- protected void itemsRemoved(ListRemoveEvent e) {
- super.itemsRemoved(e);
- revalidateLayout();
- }
-
- @Override
- protected void itemsReplaced(ListReplaceEvent e) {
- super.itemsReplaced(e);
- revalidateLayout();
- }
-
- @Override
- protected void listChanged(ListChangeEvent e) {
- super.listChanged(e);
- revalidateLayout();
- }
-
- @Override
- protected void listCleared(ListClearEvent e) {
- super.listCleared(e);
- revalidateLayout();
- }
-
- /**
- * Revalidates the table layout after the list of items has changed. The
- * layout has to be done in a new UI thread because our listener might be
- * notified before the table has been updated (table column added or removed).
- */
- private void revalidateLayout() {
- SWTUtil.asyncExec(new Runnable() { public void run() {
- if (!table.isDisposed()) {
- table.getParent().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- table.getParent().layout();
- }
- }});
- }
-
- private PropertyChangeListener buildSelectedItemPropertyChangeListener() {
- return new SWTPropertyChangeListenerWrapper(
- buildSelectedItemPropertyChangeListener_()
- );
- }
-
- private PropertyChangeListener buildSelectedItemPropertyChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- if (table.isDisposed()) {
- return;
- }
- getSelectionModel().setSelectedValue(e.getNewValue());
- updateButtons();
- }
- };
- }
-
- private SelectionChangeListener<Object> buildSelectionListener() {
- return new SelectionChangeListener<Object>() {
- public void selectionChanged(SelectionChangeEvent<Object> e) {
- AddRemoveListPane.this.selectionChanged();
- }
- };
- }
-
- private Composite addTableContainer(Composite container) {
-
- container = addPane(container, buildTableContainerLayout());
- container.setLayoutData(new GridData(GridData.FILL_BOTH));
- return container;
- }
-
- private Layout buildTableContainerLayout() {
- return new Layout() {
- @Override
- protected Point computeSize(Composite composite,
- int widthHint,
- int heightHint,
- boolean flushCache) {
-
- Table table = (Table) composite.getChildren()[0];
- TableColumn tableColumn = table.getColumn(0);
- int columnWidth = tableColumn.getWidth();
- packColumn(table);
-
- // Calculate the table size and adjust it with the hints
- Point size = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- if (widthHint != SWT.DEFAULT) {
- size.x = widthHint;
- }
-
- if (heightHint != SWT.DEFAULT) {
- size.y = heightHint;
- }
-
- // Revert the column's width to its current value
- table.setRedraw(false);
- table.setLayoutDeferred(true);
- tableColumn.setWidth(columnWidth);
- table.setLayoutDeferred(false);
- table.setRedraw(true);
-
- return size;
- }
-
- private boolean isVerticalScrollbarBarVisible(Table table,
- Rectangle clientArea) {
-
- // Get the height of all the rows
- int height = table.getItemCount() * table.getItemHeight();
-
- // Remove the border from the height
- height += (table.getBorderWidth() * 2);
-
- return (clientArea.height < height);
- }
-
- @Override
- protected void layout(Composite composite, boolean flushCache) {
-
- Rectangle bounds = composite.getClientArea();
-
- if (bounds.width > 0) {
-
- Table table = (Table) composite.getChildren()[0];
- table.setBounds(0, 0, bounds.width, bounds.height);
-
- updateTableColumnWidth(
- table,
- bounds.width,
- isVerticalScrollbarBarVisible(table, bounds)
- );
- }
- }
-
- private void packColumn(Table table) {
-
- TableColumn tableColumn = table.getColumn(0);
-
- table.setRedraw(false);
- table.setLayoutDeferred(true);
- tableColumn.pack();
- table.setLayoutDeferred(false);
- table.setRedraw(true);
-
- // Cache the column width so it can be used in
- // updateTableColumnWidth() when determine which width to use
- table.setData(
- "column.width",
- Integer.valueOf(tableColumn.getWidth())
- );
- }
-
- private void updateTableColumnWidth(Table table,
- int width,
- boolean verticalScrollbarBarVisible) {
-
- // Remove the border from the width
- width -= (table.getBorderWidth() * 2);
-
- // Remove the scrollbar from the width if it is shown
- if (verticalScrollbarBarVisible) {
- width -= table.getVerticalBar().getSize().x;
- }
-
- TableColumn tableColumn = table.getColumn(0);
-
- // Retrieve the cached column width, which is required for
- // determining which width to use (the column width or the
- // calculated width)
- Integer columnWitdh = (Integer) table.getData("column.width");
-
- // Use the calculated width if the column is smaller, otherwise
- // use the column width and a horizontal scroll bar will show up
- width = Math.max(width, columnWitdh);
-
- // Adjust the column width
- tableColumn.setWidth(width);
- }
- };
- }
-
- private ITableLabelProvider buildTableLabelProvider(IBaseLabelProvider labelProvider) {
- return new TableLabelProvider((ILabelProvider) labelProvider);
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public Table getMainControl() {
- return table;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- @SuppressWarnings("unchecked")
- protected void initializeMainComposite(Composite container,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- IBaseLabelProvider labelProvider,
- String helpId) {
-
- table = addUnmanagedTable(
- addTableContainer(container),
- SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI,
- helpId
- );
-
-
- TableModelAdapter model = TableModelAdapter.adapt(
- (ListValueModel<Object>) listHolder,
- getSelectedItemHolder(),
- table,
- buildColumnAdapter(),
- buildTableLabelProvider(labelProvider)
- );
-
- model.addSelectionChangeListener(buildSelectionListener());
-
- selectedItemHolder.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- buildSelectedItemPropertyChangeListener()
- );
-
- initializeTable(table);
- }
-
- /**
- * Initializes the given table, which acts like a list in our case.
- *
- * @param table The main widget of this pane
- */
- protected void initializeTable(Table table) {
-
- table.setData("column.width", new Integer(0));
- table.setHeaderVisible(false);
- table.setLinesVisible(false);
- }
-
- /**
- * The selection has changed, update (1) the selected item holder, (2) the
- * selection model and (3) the buttons.
- */
- private void selectionChanged() {
- ModifiablePropertyValueModel<Object> selectedItemHolder = getSelectedItemHolder();
- ObjectListSelectionModel selectionModel = getSelectionModel();
- int selectionCount = this.table.getSelectionCount();
-
- if (selectionCount == 0) {
- selectedItemHolder.setValue(null);
- selectionModel.clearSelection();
- }
- else if (selectionCount != 1) {
- selectedItemHolder.setValue(null);
- selectionModel.clearSelection();
-
- for (int index : this.table.getSelectionIndices()) {
- selectionModel.addSelectionInterval(index, index);
- }
- }
- else {
- int selectedIndex = this.table.getSelectionIndex();
- Object selectedItem = getListHolder().get(selectedIndex);
-
- selectedItemHolder.setValue(selectedItem);
- selectionModel.setSelectedValue(selectedItem);
- }
-
- updateButtons();
- }
-
- /**
- * This label provider simply delegates the rendering to the provided
- * <code>ILabelProvider</code>.
- */
- private class TableLabelProvider extends LabelProvider
- implements ITableLabelProvider {
-
- private ILabelProvider labelProvider;
-
- TableLabelProvider(ILabelProvider labelProvider) {
- super();
- this.labelProvider = labelProvider;
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- return labelProvider.getImage(element);
- }
-
- public String getColumnText(Object element, int columnIndex) {
- return labelProvider.getText(element);
- }
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemovePane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemovePane.java
deleted file mode 100644
index a9d766187a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemovePane.java
+++ /dev/null
@@ -1,923 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import java.util.Arrays;
-
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTListChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * The abstract definition of a pane that has buttons for adding, removing and
- * possibly editing the items.
- *
- * @see AddRemoveListPane
- *
- * @version 1.0
- * @since 2.0
- */
-public abstract class AddRemovePane<T extends Model> extends Pane<T>
-{
- private Adapter adapter;
- private Button addButton;
- private Composite container;
- private boolean enabled;
- private IBaseLabelProvider labelProvider;
- private ListValueModel<?> listHolder;
- private Button optionalButton;
- private Button removeButton;
- private ModifiablePropertyValueModel<Object> selectedItemHolder;
- private ObjectListSelectionModel selectionModel;
-
- /**
- * Creates a new <code>AddRemovePane</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param adapter This <code>Adapter</code> is used to dictacte the behavior
- * of this <code>AddRemovePane</code> and by delegating to it some of the
- * behavior
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- */
- protected AddRemovePane(Pane<? extends T> parentPane,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- IBaseLabelProvider labelProvider) {
-
- this(parentPane,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider,
- null);
- }
-
- /**
- * Creates a new <code>AddRemovePane</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param adapter This <code>Adapter</code> is used to dictacte the behavior
- * of this <code>AddRemovePane</code> and by delegating to it some of the
- * behavior
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- * @param helpId The topic help ID to be registered with this pane
- */
- protected AddRemovePane(Pane<? extends T> parentPane,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- IBaseLabelProvider labelProvider,
- String helpId) {
-
- this(parentPane,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider,
- helpId,
- true);
- }
- /**
- * Creates a new <code>AddRemovePane</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param adapter This <code>Adapter</code> is used to dictacte the behavior
- * of this <code>AddRemovePane</code> and by delegating to it some of the
- * behavior
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- * @param helpId The topic help ID to be registered with this pane
- * @param parentManagePane <code>true</code> to have the parent pane manage
- * the enabled state of this pane
- */
- protected AddRemovePane(Pane<? extends T> parentPane,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- IBaseLabelProvider labelProvider,
- String helpId,
- boolean parentManagePane) {
-
- super(parentPane, parent, true, parentManagePane);
-
- initialize(
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider
- );
-
- initializeLayout(
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider,
- helpId
- );
- }
-
- /**
- * Creates a new <code>AddRemovePane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of the subject
- * @param adapter This <code>Adapter</code> is used to dictacte the behavior
- * of this <code>AddRemovePane</code> and by delegating to it some of the
- * behavior
- * @param parent The parent container
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- */
- protected AddRemovePane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- IBaseLabelProvider labelProvider) {
-
- this(parentPane,
- subjectHolder,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider,
- null);
- }
-
- /**
- * Creates a new <code>AddRemovePane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of the subject
- * @param adapter This <code>Adapter</code> is used to dictacte the behavior
- * of this <code>AddRemovePane</code> and by delegating to it some of the
- * behavior
- * @param parent The parent container
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- * @param helpId The topic help ID to be registered with this pane
- */
- protected AddRemovePane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- IBaseLabelProvider labelProvider,
- String helpId) {
-
- super(parentPane, subjectHolder, parent);
-
- initialize(
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider
- );
-
- initializeLayout(
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider,
- helpId
- );
- }
-
- /**
- * Gives the possibility to add buttons after the Add button and before the
- * optional button.
- *
- * @param container The parent container
- * @param helpId The topic help ID to be registered with the buttons
- *
- * @category Layout
- */
- protected void addCustomButtonAfterAddButton(Composite container,
- String helpId) {
- }
-
- /**
- * Gives the possibility to add buttons after the optional button and before
- * the Remove button.
- *
- * @param container The parent container
- * @param helpId The topic help ID to be registered with the buttons
- *
- * @category Layout
- */
- protected void addCustomButtonAfterOptionalButton(Composite container,
- String helpId) {
- }
-
- /**
- * @category Add
- */
- protected void addItem() {
- adapter.addNewItem(selectionModel);
- }
-
- /**
- * @category Initialize
- */
- protected Adapter buildAdapter() {
- return adapter;
- }
-
- /**
- * @category Add
- */
- protected Button addAddButton(Composite parent) {
- return addUnmanagedButton(
- parent,
- adapter.addButtonText(),
- buildAddItemAction()
- );
- }
-
- /**
- * @category Add
- */
- private Runnable buildAddItemAction() {
- return new Runnable() {
- public void run() {
- AddRemovePane.this.addItem();
- }
- };
- }
-
- private ListChangeListener buildListChangeListener() {
- return new SWTListChangeListenerWrapper(buildListChangeListener_());
- }
-
- private ListChangeListener buildListChangeListener_() {
- return new ListChangeListener() {
-
- public void itemsAdded(ListAddEvent e) {
- AddRemovePane.this.itemsAdded(e);
- }
-
- public void itemsMoved(ListMoveEvent e) {
- AddRemovePane.this.itemsMoved(e);
- }
-
- public void itemsRemoved(ListRemoveEvent e) {
- AddRemovePane.this.itemsRemoved(e);
- }
-
- public void itemsReplaced(ListReplaceEvent e) {
- AddRemovePane.this.itemsReplaced(e);
- }
-
- public void listChanged(ListChangeEvent e) {
- AddRemovePane.this.listChanged(e);
- }
-
- public void listCleared(ListClearEvent e) {
- AddRemovePane.this.listCleared(e);
- }
- };
- }
-
- protected void itemsAdded(ListAddEvent e) {
-
- }
-
- protected void itemsMoved(ListMoveEvent e) {
-
- }
-
- protected void itemsRemoved(ListRemoveEvent e) {
- Object selectedItem = this.selectedItemHolder.getValue();
-
- if (selectedItem == null) {
- updateButtons();
- return;
- }
-
- if (CollectionTools.contains(e.getItems(), selectedItem)) {
- this.selectedItemHolder.setValue(null);
- updateButtons();
- }
- }
-
- protected void itemsReplaced(ListReplaceEvent e) {
-
- }
-
- protected void listChanged(ListChangeEvent e) {
-
- }
-
- protected void listCleared(ListClearEvent e) {
- this.selectedItemHolder.setValue(null);
- updateButtons();
- }
-
-
- /**
- * @category Option
- */
- private Runnable buildOptionalAction() {
- return new Runnable() {
- public void run() {
- AddRemovePane.this.editItem();
- }
- };
- }
-
- /**
- * @category Option
- */
- protected Button addOptionalButton(Composite container) {
- return addUnmanagedButton(
- container,
- adapter.optionalButtonText(),
- buildOptionalAction()
- );
- }
-
- /**
- * @category Add
- */
- protected Button addRemoveButton(Composite parent) {
- return addUnmanagedButton(
- parent,
- adapter.removeButtonText(),
- buildRemoveItemsAction()
- );
- }
-
- /**
- * @category Remove
- */
- private Runnable buildRemoveItemsAction() {
- return new Runnable() {
- public void run() {
- AddRemovePane.this.removeItems();
- }
- };
- }
-
- protected ObjectListSelectionModel buildRowSelectionModel(ListValueModel<?> listModel) {
- return new ObjectListSelectionModel(new ListModelAdapter(listModel));
- }
-
- /**
- * @category Option
- */
- protected void editItem() {
- this.adapter.optionOnSelection(getSelectionModel());
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public void enableWidgets(boolean enabled) {
-
- super.enableWidgets(enabled);
- this.enabled = enabled;
-
- if (!this.getMainControl().isDisposed()) {
- this.getMainControl().setEnabled(enabled);
- }
-
- this.updateButtons();
- }
-
- protected final Composite getContainer() {
- return container;
- }
-
- protected IBaseLabelProvider getLabelProvider() {
- return labelProvider;
- }
-
- protected final ListValueModel<?> getListHolder() {
- return listHolder;
- }
-
- /**
- * Returns
- *
- * @return
- */
- public abstract Composite getMainControl();
-
- protected final ModifiablePropertyValueModel<Object> getSelectedItemHolder() {
- return selectedItemHolder;
- }
-
- public final ObjectListSelectionModel getSelectionModel() {
- return selectionModel;
- }
-
- /**
- * Initializes this add/remove pane.
- *
- * @param adapter This <code>Adapter</code> is used to dictacte the behavior
- * of this <code>AddRemovePane</code> and by delegating to it some of the
- * behavior
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- *
- * @category Initialization
- */
- @SuppressWarnings("unchecked")
- protected void initialize(Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- IBaseLabelProvider labelProvider)
- {
- this.listHolder = listHolder;
- this.labelProvider = labelProvider;
- this.adapter = (adapter == null) ? buildAdapter() : adapter;
- this.selectedItemHolder = (ModifiablePropertyValueModel<Object>) selectedItemHolder;
- this.selectionModel = new ObjectListSelectionModel(new ListModelAdapter(listHolder));
-
- this.listHolder.addListChangeListener(
- ListValueModel.LIST_VALUES,
- buildListChangeListener()
- );
- }
-
- /**
- * Initializes the pane containing the buttons (Add, optional (if required)
- * and Remove).
- *
- * @param container The parent container
- * @param helpId The topic help ID to be registered with the buttons
- *
- * @category Layout
- */
- protected void initializeButtonPane(Composite container, String helpId) {
-
- container = addSubPane(container);
-
- GridData gridData = new GridData();
- gridData.grabExcessVerticalSpace = true;
- gridData.verticalAlignment = SWT.TOP;
- container.setLayoutData(gridData);
-
- // Add button
- this.addButton = addAddButton(container);
- addAlignRight(this.addButton);
-
- // Custom button
- addCustomButtonAfterAddButton(container, helpId);
-
- // Optional button
- if (this.adapter.hasOptionalButton()) {
- this.optionalButton = addOptionalButton(container);
- addAlignRight(this.optionalButton);
- }
-
- // Custom button
- addCustomButtonAfterOptionalButton(container, helpId);
-
- // Remove button
- removeButton = addRemoveButton(container);
- addAlignRight(removeButton);
-
- // Update the help topic ID
- if (helpId != null) {
- getHelpSystem().setHelp(addButton, helpId);
- getHelpSystem().setHelp(removeButton, helpId);
-
- if (optionalButton != null) {
- getHelpSystem().setHelp(optionalButton, helpId);
- }
- }
- }
-
- /**
- * Initializes this add/remove pane by creating the widgets. The subclass is
- * required to build the main widget.
- *
- * @param adapter This <code>Adapter</code> is used to dictacte the behavior
- * of this <code>AddRemovePane</code> and by delegating to it some of the
- * behavior
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- * @param helpId The topic help ID to be registered with this pane
- *
- * @category Layout
- */
- protected void initializeLayout(Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- IBaseLabelProvider labelProvider,
- String helpId) {
-
- initializeMainComposite(
- container,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider,
- helpId);
-
- initializeButtonPane(container, helpId);
- enableWidgets(getSubject() != null);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void initializeLayout(Composite container) {
- this.container = addSubPane(container, 2, 0, 0, 0, 0);
- }
-
- /**
- * Initializes the main widget of this add/remove pane.
- *
- * @param container The parent container
- * @param adapter This <code>Adapter</code> is used to dictacte the behavior
- * of this <code>AddRemovePane</code> and by delegating to it some of the
- * behavior
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- * @param helpId The topic help ID to be registered with this pane or
- * <code>null</code> if it was not specified
- *
- * @category Layout
- */
- protected abstract void initializeMainComposite(Composite container,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- IBaseLabelProvider labelProvider,
- String helpId);
-
- /**
- * @category Remove
- */
- protected void removeItems() {
-
- // Keep track of the selected indices so we can select an item
- // before the lowest index
- int[] indices = selectionModel.selectedIndices();
- Arrays.sort(indices);
-
- // Notify the adapter to remove the selected items
- adapter.removeSelectedItems(selectionModel);
-
- // Select a new item
- if (getListHolder().size() > 0) {
- int index = Math.min(indices[0], getListHolder().size() - 1);
- Object item = getListHolder().get(index);
- selectedItemHolder.setValue(item);
- }
- // The list is empty, clear the value
- else {
- selectedItemHolder.setValue(null);
- }
- }
-
- /**
- * Selects the given value, which can be <code>null</code>.
- *
- * @param value The new selected value
- */
- public void setSelectedItem(Object value) {
- selectedItemHolder.setValue(value);
- }
-
- /**
- * @category UpdateButtons
- */
- protected void updateAddButton(Button addButton) {
- addButton.setEnabled(enabled);
- }
-
- /**
- * @category UpdateButtons
- */
- protected void updateButtons() {
- if (!container.isDisposed()) {
- updateAddButton(addButton);
- updateRemoveButton(removeButton);
- updateOptionalButton(optionalButton);
- }
- }
-
- /**
- * @category UpdateButtons
- */
- protected void updateOptionalButton(Button optionalButton) {
- if (optionalButton != null) {
- optionalButton.setEnabled(
- enabled &&
- adapter.enableOptionOnSelectionChange(selectionModel)
- );
- }
- }
-
- /**
- * @category UpdateButtons
- */
- protected void updateRemoveButton(Button removeButton) {
- removeButton.setEnabled(
- enabled &&
- adapter.enableRemoveOnSelectionChange(selectionModel)
- );
- }
-
- /**
- * An abstract implementation of <code>Adapter</code>.
- */
- public static abstract class AbstractAdapter implements Adapter {
-
- /**
- * The text of the add button.
- */
- private String addButtonText;
-
- /**
- * Determines whether the optional button should be shown or not.
- */
- private boolean hasOptionalButton;
-
- /**
- * The text of the optional button, if used.
- */
- private String optionalButtonText;
-
- /**
- * The text of the remove button.
- */
- private String removeButtonText;
-
- /**
- * Creates a new <code>AbstractAdapter</code> with default text for the
- * add and remove buttons.
- */
- public AbstractAdapter() {
- this(JptCommonUiMessages.AddRemovePane_AddButtonText,
- JptCommonUiMessages.AddRemovePane_RemoveButtonText);
- }
-
- /**
- * Creates a new <code>AbstractAdapter</code> with default text for the
- * add and remove buttons.
- *
- * @param hasOptionalButton <code>true</code> to show an optional button
- * and to use the behavior related to the optional button;
- * <code>false</code> to not use it
- */
- public AbstractAdapter(boolean hasOptionalButton) {
- this();
- this.setHasOptionalButton(hasOptionalButton);
- }
-
- /**
- * Creates a new <code>AbstractAdapter</code> with default text for the
- * add and remove buttons.
- *
- * @param optionalButtonText The text of the optional button, which means
- * the optional button will be shown
- */
- public AbstractAdapter(String optionalButtonText) {
- this(true);
- this.setOptionalButtonText(optionalButtonText);
- }
-
- /**
- * Creates a new <code>AbstractAdapter</code>.
- *
- * @param addButtonText The add button's text
- * @param removeButtonText The remove button's text
- */
- public AbstractAdapter(String addButtonText,
- String removeButtonText) {
-
- super();
- this.addButtonText = addButtonText;
- this.removeButtonText = removeButtonText;
- }
-
- /**
- * Creates a new <code>AbstractAdapter</code>.
- *
- * @param addButtonText The add button's text
- * @param removeButtonText The remove button's text
- * @param optionalButtonText The text of the optional button, which means
- * the optional button will be shown
- */
- public AbstractAdapter(String addButtonText,
- String removeButtonText,
- String optionalButtonText) {
-
- this(optionalButtonText);
- this.setAddButtonText(addButtonText);
- this.setRemoveButtonText(removeButtonText);
- }
-
- /*
- * (non-Javadoc)
- */
- public String addButtonText() {
- return addButtonText;
- }
-
- /*
- * (non-Javadoc)
- */
- public boolean enableOptionOnSelectionChange(ObjectListSelectionModel listSelectionModel) {
- return listSelectionModel.selectedValuesSize() == 1;
- }
-
- public boolean enableRemoveOnSelectionChange(ObjectListSelectionModel listSelectionModel) {
- return listSelectionModel.selectedValue() != null;
- }
-
- /*
- * (non-Javadoc)
- */
- public boolean hasOptionalButton() {
- return hasOptionalButton;
- }
-
- /*
- * (non-Javadoc)
- */
- public String optionalButtonText() {
- return optionalButtonText;
- }
-
- /*
- * (non-Javadoc)
- */
- public void optionOnSelection(ObjectListSelectionModel listSelectionModel) {
- }
-
- /*
- * (non-Javadoc)
- */
- public String removeButtonText() {
- return removeButtonText;
- }
-
- /**
- * Changes the text of the add button. This method has to be called before
- * the <code>AddRemoveListPane</code> is initialized.
- *
- * @param addButtonText The add button's text
- */
- public void setAddButtonText(String addButtonText) {
- this.addButtonText = addButtonText;
- }
-
- /**
- * Changes the state of the optional button, meaning if it should be shown
- * between the add and remove buttons or not.
- *
- * @param hasOptionalButton <code>true</code> to show an optional button
- * and to use the behavior related to the optional button;
- * <code>false</code> to not use it
- */
- public void setHasOptionalButton(boolean hasOptionalButton) {
- this.hasOptionalButton = hasOptionalButton;
- }
-
- /**
- * Changes the text of the optional button. This method has to be called
- * before the <code>AddRemoveListPane</code> is initialized. This does not
- * make the optional button visible.
- *
- * @param optionalButtonText The optional button's text
- */
- public void setOptionalButtonText(String optionalButtonText) {
- this.optionalButtonText = optionalButtonText;
- }
-
- /**
- * Changes the text of the remove button. This method has to be called
- * before the <code>AddRemoveListPane</code> is initialized.
- *
- * @param removeButtonText The remove button's text
- */
- public void setRemoveButtonText(String removeButtonText) {
- this.removeButtonText = removeButtonText;
- }
- }
-
- /**
- * This adapter is used to perform the actual action when adding a new item
- * or removing the selected items. It is possible to add an optional button.
- */
- public static interface Adapter {
-
- /**
- * The add button's text.
- *
- * @return The text shown on the add button
- */
- String addButtonText();
-
- /**
- * Invoked when the user selects the Add button.
- */
- void addNewItem(ObjectListSelectionModel listSelectionModel);
-
- /**
- * Invoked when selection changes. Implementation dictates whether button
- * should be enabled.
- */
- boolean enableOptionOnSelectionChange(ObjectListSelectionModel listSelectionModel);
-
- /**
- * Invoked when selection changes. Implementation dictates whether remove button
- * should be enabled.
- */
- boolean enableRemoveOnSelectionChange(ObjectListSelectionModel listSelectionModel);
-
- /**
- * Determines whether an optional button should be added between the add
- * and remove buttons.
- *
- * @return <code>true</code> to show an optional button and to use the
- * behavior related to the optional button; <code>false</code> to not use
- * it
- */
- boolean hasOptionalButton();
-
- /**
- * Resource string key for the optional button.
- */
- String optionalButtonText();
-
- /**
- * Invoked when the user selects the optional button
- */
- void optionOnSelection(ObjectListSelectionModel listSelectionModel);
-
- /**
- * The remove button's text.
- *
- * @return The text shown on the remove button
- */
- String removeButtonText();
-
- /**
- * Invoked when the user selects the Remove button.
- */
- void removeSelectedItems(ObjectListSelectionModel listSelectionModel);
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveTablePane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveTablePane.java
deleted file mode 100644
index 7b568094df..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/AddRemoveTablePane.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.ui.internal.swt.ColumnAdapter;
-import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter;
-import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter.SelectionChangeEvent;
-import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter.SelectionChangeListener;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-
-/**
- * This implementation of the <code>AddRemovePane</code> uses a <code>Table</code>
- * as its main widget.
- * <p>
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | ------------------------------------------------------------- ----------- |
- * | | Column 1 | Column 2 | ... | Column i | ... | Colunm n | | Add... | |
- * | |-----------------------------------------------------------| ----------- |
- * | | | | | | | | ----------- |
- * | |-----------------------------------------------------------| | Edit... | |
- * | | | | | | | | ----------- |
- * | |-----------------------------------------------------------| ----------- |
- * | | | | | | | | | Remove | |
- * | |-----------------------------------------------------------| ----------- |
- * | ------------------------------------------------------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @version 2.0
- * @since 1.0
- */
-public abstract class AddRemoveTablePane<T extends Model> extends AddRemovePane<T>
-{
- /**
- * Flag used to prevent circular
- */
- private boolean locked;
-
- /**
- * The main widget of this add/remove pane.
- */
- private Table table;
-
- /**
- * Creates a new <code>AddRemoveTablePane</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param adapter
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- */
- public AddRemoveTablePane(Pane<? extends T> parentPane,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- ITableLabelProvider labelProvider) {
-
- super(parentPane,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider);
-
- }
-
- /**
- * Creates a new <code>AddRemoveTablePane</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param adapter
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- * @param helpId The topic help ID to be registered with this pane
- */
- public AddRemoveTablePane(Pane<? extends T> parentPane,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- ITableLabelProvider labelProvider,
- String helpId) {
-
- super(parentPane,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider,
- helpId);
- }
-
- /**
- * Creates a new <code>AddRemoveTablePane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of the subject
- * @param adapter
- * @param parent The parent container
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- */
- public AddRemoveTablePane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- ITableLabelProvider labelProvider) {
-
- super(parentPane,
- subjectHolder,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider);
- }
-
- /**
- * Creates a new <code>AddRemoveTablePane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of the subject
- * @param adapter
- * @param parent The parent container
- * @param listHolder The <code>ListValueModel</code> containing the items
- * @param selectedItemHolder The holder of the selected item, if more than
- * one item or no items are selected, then <code>null</code> will be passed
- * @param labelProvider The renderer used to format the list holder's items
- * @param helpId The topic help ID to be registered with this pane
- */
- public AddRemoveTablePane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- ITableLabelProvider labelProvider,
- String helpId) {
-
- super(parentPane,
- subjectHolder,
- parent,
- adapter,
- listHolder,
- selectedItemHolder,
- labelProvider,
- helpId);
- }
-
- protected abstract ColumnAdapter<?> buildColumnAdapter();
-
- private ModifiablePropertyValueModel<Object> buildSelectedItemHolder() {
- return new SimplePropertyValueModel<Object>();
- }
-
- private PropertyChangeListener buildSelectedItemPropertyChangeListener() {
- return new SWTPropertyChangeListenerWrapper(
- buildSelectedItemPropertyChangeListener_()
- );
- }
-
- private PropertyChangeListener buildSelectedItemPropertyChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- if (table.isDisposed()) {
- return;
- }
-
- if (!locked) {
- locked = true;
-
- try {
- Object value = e.getNewValue();
- getSelectionModel().setSelectedValue(e.getNewValue());
- int index = -1;
-
- if (value != null) {
- index = CollectionTools.indexOf(getListHolder().iterator(), value);
- }
-
- table.select(index);
- updateButtons();
- }
- finally {
- locked = false;
- }
- }
- }
- };
- }
-
- private SelectionChangeListener<Object> buildSelectionListener() {
- return new SelectionChangeListener<Object>() {
- public void selectionChanged(SelectionChangeEvent<Object> e) {
- AddRemoveTablePane.this.selectionChanged();
- }
- };
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public Table getMainControl() {
- return table;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- @SuppressWarnings("unchecked")
- protected void initializeMainComposite(Composite container,
- Adapter adapter,
- ListValueModel<?> listHolder,
- ModifiablePropertyValueModel<?> selectedItemHolder,
- IBaseLabelProvider labelProvider,
- String helpId)
- {
- table = addUnmanagedTable(container, helpId);
- table.setHeaderVisible(true);
-
- TableModelAdapter<Object> tableModel = TableModelAdapter.adapt(
- (ListValueModel<Object>) listHolder,
- buildSelectedItemHolder(),
- table,
- (ColumnAdapter<Object>) buildColumnAdapter(),
- (ITableLabelProvider) labelProvider
- );
-
- tableModel.addSelectionChangeListener(buildSelectionListener());
-
- selectedItemHolder.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- buildSelectedItemPropertyChangeListener()
- );
- }
-
- /**
- * The selection has changed, update (1) the selected item holder, (2) the
- * selection model and (3) the buttons.
- */
- private void selectionChanged() {
-
- if (locked) {
- return;
- }
-
- locked = true;
-
- try {
- ModifiablePropertyValueModel<Object> selectedItemHolder = getSelectedItemHolder();
- ObjectListSelectionModel selectionModel = getSelectionModel();
- int selectionCount = table.getSelectionCount();
-
- if (selectionCount == 0) {
- selectedItemHolder.setValue(null);
- selectionModel.clearSelection();
- }
- else if (selectionCount != 1) {
- selectedItemHolder.setValue(null);
- selectionModel.clearSelection();
-
- for (int index : table.getSelectionIndices()) {
- selectionModel.addSelectionInterval(index, index);
- }
- }
- else {
- int selectedIndex = table.getSelectionIndex();
- Object selectedItem = getListHolder().get(selectedIndex);
-
- selectedItemHolder.setValue(selectedItem);
- selectionModel.setSelectedValue(selectedItem);
- }
-
- updateButtons();
- }
- finally {
- locked = false;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ChooserPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ChooserPane.java
deleted file mode 100644
index d9a2fa753e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ChooserPane.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * A chooser is simply a pane with three widgets, the label on the left, a main
- * widget, usually a text field, and a right widget which is usually a browse
- * button.
- *
- * @see ClassChooserPane
- * @see PackageChooserPane
- *
- * @version 3.0
- * @since 2.0
- */
-public abstract class ChooserPane<T extends Model> extends Pane<T>
-{
- /**
- * The control shown after the label (left control).
- */
- private Control mainControl;
-
- /**
- * The control shown after the main control.
- */
- private Control rightControl;
-
- /**
- * Creates a new <code>ChooserPane</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public ChooserPane(Pane<? extends T> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>ChooserPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public ChooserPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(parentPane, subjectHolder, parent);
- }
-
- /**
- * Creates a new <code>ChooserPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public ChooserPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- PropertyValueModel<Boolean> enabledModel) {
-
- super(parentPane, subjectHolder, parent, enabledModel);
- }
-
- @Override
- protected void initializeLayout(Composite container) {
-
- this.mainControl = addMainControl(container);
- this.rightControl = addRightControl(container);
-
- addLabeledComposite(
- container,
- addLeftControl(container),
- this.mainControl,
- this.rightControl,
- getHelpId()
- );
- }
-
- /**
- * Creates the left control. By default a label is created and its text is
- * retrieved by {@link #getLabelText()}.
- *
- * @param container The parent container
- * @return The newly created left control
- */
- protected Control addLeftControl(Composite container) {
- return addLabel(container, getLabelText());
- }
-
- /**
- * The text of the label. This method is called by
- * {@link #buildLeftControl(Composite)}.
- *
- * @return The localized text of the left control (which is a label by
- * default)
- */
- protected abstract String getLabelText();
-
- /**
- * Creates the main control of this pane.
- *
- * @param container The parent container
- * @return The newly created main control
- */
- protected abstract Control addMainControl(Composite container);
-
- /**
- * Creates the right control. By default a browse button is created and its
- * action is performed by {@link #buildBrowseAction()} and its text is
- * retrieved by {@link #getBrowseButtonText()}.
- *
- * @param container The parent container
- * @return The newly created right control
- */
- protected Control addRightControl(Composite container) {
- return addButton(
- container,
- getBrowseButtonText(),
- buildBrowseAction()
- );
- }
-
- /**
- * Returns the text of the browse button. This method is called by
- * {@link #buildRightControl(Composite)}.
- *
- * @return "Browse..."
- */
- protected String getBrowseButtonText() {
- return JptCommonUiMessages.ChooserPane_browseButton;
- }
-
- /**
- * Creates the action responsible to perform the action when the Browse is
- * clicked.
- *
- * @return A new <code>Runnable</code> performing the actual action of the
- * button
- */
- protected abstract Runnable buildBrowseAction();
-
- /**
- * Returns the help topic ID for the controls of this pane.
- *
- * @return <code>null</code> is returned otherwise the subclass can return an ID
- */
- protected String getHelpId() {
- return null;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ClassChooserComboPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ClassChooserComboPane.java
deleted file mode 100644
index f50eb3b64f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ClassChooserComboPane.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.jpt.common.utility.internal.StringConverter;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * This chooser allows the user to choose a type when browsing and it adds code
- * completion support to the text field, which is the main component.
- * <p>
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | ---------------------------------------------------- ------------- |
- * | Label: | I X | | Browse... | |
- * | ---------------------------------------------------- ------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @version 2.0
- * @since 2.0
- */
-public abstract class ClassChooserComboPane<T extends Model> extends ClassChooserPane<T>
-{
-
- /**
- * Creates a new <code>ClassChooserPane</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public ClassChooserComboPane(Pane<? extends T> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>ClassChooserPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public ClassChooserComboPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(parentPane, subjectHolder, parent);
- }
-
- @Override
- protected Control addMainControl(Composite container) {
- Composite subPane = addSubPane(container);
- Combo combo = this.addClassCombo(subPane);
-
- ControlContentAssistHelper.createComboContentAssistant(
- combo,
- javaTypeCompletionProcessor
- );
-
- return subPane;
- }
-
- protected Combo addClassCombo(Composite container) {
- return this.addEditableCombo(
- container,
- this.buildClassListHolder(),
- this.buildTextHolder(),
- this.buildClassConverter()
- );
- }
-
- protected abstract ListValueModel<String> buildClassListHolder();
-
- protected StringConverter<String> buildClassConverter() {
- return StringConverter.Default.instance();
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ClassChooserPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ClassChooserPane.java
deleted file mode 100644
index be2c54218a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ClassChooserPane.java
+++ /dev/null
@@ -1,394 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.search.IJavaSearchScope;
-import org.eclipse.jdt.core.search.SearchEngine;
-import org.eclipse.jdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.jdt.internal.ui.refactoring.contentassist.JavaTypeCompletionProcessor;
-import org.eclipse.jdt.internal.ui.wizards.NewClassCreationWizard;
-import org.eclipse.jdt.ui.IJavaElementSearchConstants;
-import org.eclipse.jdt.ui.JavaUI;
-import org.eclipse.jdt.ui.wizards.NewClassWizardPage;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.jpt.common.core.internal.utility.JDTTools;
-import org.eclipse.jpt.common.ui.JptCommonUiPlugin;
-import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.ClassName;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.SelectionDialog;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-
-/**
- * This chooser allows the user to choose a type when browsing and it adds code
- * completion support to the text field, which is the main component.
- * <p>
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | ---------------------------------------------------- ------------- |
- * | Label: | I | | Browse... | |
- * | ---------------------------------------------------- ------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @version 2.3
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public abstract class ClassChooserPane<T extends Model> extends ChooserPane<T>
-{
- /**
- * The code completion manager.
- */
- protected JavaTypeCompletionProcessor javaTypeCompletionProcessor;
-
- private PropertyChangeListener subjectChangeListener;
-
- /**
- * Creates a new <code>ClassChooserPane</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public ClassChooserPane(Pane<? extends T> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>ClassChooserPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public ClassChooserPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(parentPane, subjectHolder, parent);
- }
-
- /**
- * Creates a new <code>ClassChooserPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public ClassChooserPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- PropertyValueModel<Boolean> enabledModel) {
-
- super(parentPane, subjectHolder, parent, enabledModel);
- }
-
- @Override
- protected void initialize() {
- super.initialize();
-
- // TODO bug 156185 - when this is fixed there should be api for this
- this.javaTypeCompletionProcessor = buildJavaTypeCompletionProcessor();
-
- this.subjectChangeListener = this.buildSubjectChangeListener();
- this.getSubjectHolder().addPropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
-
- this.classChooserSubjectChanged(getSubject());
- }
-
- protected JavaTypeCompletionProcessor buildJavaTypeCompletionProcessor() {
- return new JavaTypeCompletionProcessor(false, false);
- }
-
- private PropertyChangeListener buildSubjectChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildSubjectChangeListener_());
- }
-
- private PropertyChangeListener buildSubjectChangeListener_() {
- return new PropertyChangeListener() {
- @SuppressWarnings("unchecked")
- public void propertyChanged(PropertyChangeEvent e) {
- ClassChooserPane.this.classChooserSubjectChanged((T) e.getNewValue());
- }
- };
- }
-
- protected void classChooserSubjectChanged(T newSubject) {
- IPackageFragment packageFragment = null;
- if (newSubject != null) {
- IPackageFragmentRoot root = getPackageFragmentRoot();
- if (root != null) {
- packageFragment = root.getPackageFragment("");
- }
- }
- this.javaTypeCompletionProcessor.setPackageFragment(packageFragment);
- }
-
- @Override
- protected Control addLeftControl(Composite container) {
- if( ! this.allowTypeCreation()) {
- return super.addLeftControl(container);
- }
- Hyperlink labelLink = this.addHyperlink(container,
- this.getLabelText(),
- this.buildHyperLinkAction()
- );
- return labelLink;
- }
-
- private Runnable buildHyperLinkAction() {
- return new Runnable() {
- public void run() {
- ClassChooserPane.this.hyperLinkSelected();
- }
- };
- }
-
- protected void hyperLinkSelected() {
- IType type = resolveJdtType();
- if (type != null) {
- openInEditor(type);
- }
- else if (allowTypeCreation()){
- createType();
- }
- }
-
- protected IType resolveJdtType() {
- String className = this.getFullyQualifiedClassName();
- if (className == null) {
- return null;
- }
- return JDTTools.findType(this.getJavaProject(), className);
- }
-
- protected void createType() {
- StructuredSelection selection = new StructuredSelection(getJavaProject().getProject());
-
- NewClassWizardPage newClassWizardPage = new NewClassWizardPage();
- newClassWizardPage.init(selection);
- newClassWizardPage.setSuperClass(getSuperclassName(), true);
- newClassWizardPage.setSuperInterfaces(getSuperInterfaceNames(), true);
- String qualifiedClassName = this.getFullyQualifiedClassName();
- if (!StringTools.stringIsEmpty(qualifiedClassName)) {
- newClassWizardPage.setTypeName(ClassName.getSimpleName(qualifiedClassName), true);
- String packageName = ClassName.getPackageName(qualifiedClassName);
- newClassWizardPage.setPackageFragment(getFirstJavaSourceFolder().getPackageFragment(packageName), true);
- }
- NewClassCreationWizard wizard = new NewClassCreationWizard(newClassWizardPage, false);
- wizard.init(PlatformUI.getWorkbench(), selection);
-
- WizardDialog dialog = new WizardDialog(getShell(), wizard);
- dialog.create();
- int dResult = dialog.open();
- if (dResult == Window.OK) {
- String className = (newClassWizardPage.getCreatedType()).getFullyQualifiedName(getEnclosingTypeSeparator());
- setClassName(className);
- }
- }
-
- protected abstract void setClassName(String className);
-
- /**
- * Override this to change the enclosing type separator
- */
- protected char getEnclosingTypeSeparator() {
- return '$';
- }
-
- /**
- * Override this to set a superclass in the New Class wizard. If no class is chosen,
- * clicking the hyperlink label will open the new class wizard.
- */
- protected String getSuperclassName() {
- return "";
- }
-
- /**
- * Override this to set a super interface in the New Class wizard. If no class is chosen,
- * clicking the hyperlink label will open the new class wizard.
- * @see getSuperInterfaceName
- */
- protected List<String> getSuperInterfaceNames() {
- return getSuperInterfaceName() != null ? Collections.singletonList(getSuperInterfaceName()) : Collections.<String>emptyList();
- }
-
- /**
- * Override this to set a super interface in the New Class wizard. If no class is chosen,
- * clicking the hyperlink label will open the new class wizard.
- */
- protected String getSuperInterfaceName() {
- return null;
- }
-
- /**
- * Override this if it does not make sense to allow the user to create a new type.
- * This will determine whether clicking the hyperlink opens the New Class wizard
- * @return
- */
- protected boolean allowTypeCreation() {
- return true;
- }
-
- protected void openInEditor(IType type) {
- try {
- JavaUI.openInEditor(type, true, true);
- }
- catch (JavaModelException e) {
- JptCommonUiPlugin.log(e);
- }
- catch (PartInitException e) {
- JptCommonUiPlugin.log(e);
- }
- }
-
- protected abstract IJavaProject getJavaProject();
-
- @Override
- protected final Runnable buildBrowseAction() {
- return new Runnable() {
- public void run() {
- promptType();
- }
- };
- }
-
- @Override
- protected Control addMainControl(Composite container) {
- Composite subPane = addSubPane(container);
- Text text = addText(subPane, buildTextHolder());
-
- ControlContentAssistHelper.createTextContentAssistant(
- text,
- javaTypeCompletionProcessor
- );
-
- return subPane;
- }
-
- /**
- * Creates the value holder of the subject's property.
- *
- * @return The holder of the class name
- */
- protected abstract ModifiablePropertyValueModel<String> buildTextHolder();
-
- /**
- * Prompts the user the Open Type dialog.
- *
- * @return Either the selected type or <code>null</code> if the user
- * cancelled the dialog
- */
- protected IType chooseType() {
- IJavaElement[] elements = new IJavaElement[] { getJavaProject() };
- IJavaSearchScope scope = SearchEngine.createJavaSearchScope(elements);
- SelectionDialog typeSelectionDialog;
-
- try {
- typeSelectionDialog = JavaUI.createTypeDialog(
- getShell(),
- PlatformUI.getWorkbench().getProgressService(),
- scope,
- getTypeDialogStyle(),
- false,
- StringTools.stringIsEmpty(getClassName()) ? "" : ClassName.getSimpleName(getClassName())
- );
- }
- catch (JavaModelException e) {
- JptCommonUiPlugin.log(e);
- return null;
- }
-
- typeSelectionDialog.setTitle(JptCommonUiMessages.ClassChooserPane_dialogTitle);
- typeSelectionDialog.setMessage(JptCommonUiMessages.ClassChooserPane_dialogMessage);
-
- if (typeSelectionDialog.open() == Window.OK) {
- return (IType) typeSelectionDialog.getResult()[0];
- }
-
- return null;
- }
-
- protected int getTypeDialogStyle() {
- return IJavaElementSearchConstants.CONSIDER_CLASSES;
- }
-
- /**
- * Returns the class name from its subject.
- *
- * @return The class name or <code>null</code> if none is defined
- */
- protected abstract String getClassName();
-
- /**
- * Return the fully qualified class name ('.' qualification)
- * Override this method if getClassName() does not return the fully qualified name
- */
- protected String getFullyQualifiedClassName() {
- return this.getClassName() == null ? null : this.getClassName().replace('$', '.');
- }
-
- protected IPackageFragmentRoot getFirstJavaSourceFolder() {
- Iterator<IPackageFragmentRoot> i = JDTTools.getJavaSourceFolders(getJavaProject()).iterator();
- return i.hasNext() ? i.next() : null;
- }
-
- /**
- * The browse button was clicked, its action invokes this action which should
- * prompt the user to select a class and set it.
- */
- protected void promptType() {
- IType type = this.chooseType();
-
- if (type != null) {
- String className = type.getFullyQualifiedName(getEnclosingTypeSeparator());
- setClassName(className);
- }
- }
-
- protected IPackageFragmentRoot getPackageFragmentRoot() {
- try {
- return this.getJavaProject().getPackageFragmentRoots()[0];
- } catch (JavaModelException ex) {
- JptCommonUiPlugin.log(ex);
- return null;
- }
- }
-
- @Override
- public void dispose() {
- this.getSubjectHolder().removePropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
- super.dispose();
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ComboPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ComboPane.java
deleted file mode 100644
index 4046ed13ba..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ComboPane.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * Pane with combo box support for automatic updating of:
- * - selected value
- * - default value
- * - value choices
- */
-public abstract class ComboPane<T extends Model>
- extends Pane<T>
-{
- /**
- * The main (only) widget of this pane.
- */
- protected Combo comboBox;
-
-
- // **************** constructors ******************************************
-
- protected ComboPane(
- Pane<? extends T> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- protected ComboPane(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(parentPane, subjectHolder, parent);
- }
-
- protected ComboPane(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- PropertyValueModel<Boolean> enabledModel) {
-
- super(parentPane, subjectHolder, parent, enabledModel);
- }
-
-
- // **************** initialization ****************************************
-
- @Override
- protected void initializeLayout(Composite container) {
- this.comboBox = this.addEditableCombo(container);
- this.comboBox.addModifyListener(this.buildModifyListener());
- SWTUtil.attachDefaultValueHandler(this.comboBox);
- }
-
- protected ModifyListener buildModifyListener() {
- return new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- ComboPane.this.comboBoxModified();
- }
- };
- }
-
-
- // **************** typical overrides *************************************
-
- /**
- * Return the possible values to be added to the combo during
- * population.
- */
- protected abstract Iterable<String> getValues();
-
- /**
- * Return whether the combo is to add a default value to the choices
- */
- protected boolean usesDefaultValue() {
- // default response is 'true'
- return true;
- }
-
- /**
- * Return the default value, or <code>null</code> if no default is
- * specified. This method is only called when the subject is non-null.
- */
- protected abstract String getDefaultValue();
-
- /**
- * Return the current value from the subject.
- * This method is only called when the subject is non-null.
- */
- protected abstract String getValue();
-
- /**
- * Set the specified value as the new value on the subject.
- */
- protected abstract void setValue(String value);
-
-
- // **************** overrides *********************************************
-
- @Override
- protected void propertyChanged(String propertyName) {
- super.propertyChanged(propertyName);
- this.updateSelectedItem();
- }
-
- @Override
- protected void doPopulate() {
- super.doPopulate();
- this.populateComboBox();
- }
-
-
- // **************** populating ********************************************
-
- /**
- * Populate the combo-box list by clearing it, then adding first the default
- * value, if available, and then the possible choices.
- */
- protected void populateComboBox() {
- this.comboBox.removeAll();
-
- if (usesDefaultValue()) {
- this.comboBox.add(this.buildDefaultValueEntry());
- }
-
- for (String value : this.getValues()) {
- this.comboBox.add(value);
- }
-
- this.updateSelectedItem_();
- }
-
- protected String buildDefaultValueEntry() {
- if (getSubject() == null) {
- return JptCommonUiMessages.NoneSelected;
- }
- String defaultValue = this.getDefaultValue();
- return (defaultValue == null) ? this.buildNullDefaultValueEntry() : this.buildNonNullDefaultValueEntry(defaultValue);
- }
-
- protected String buildNullDefaultValueEntry() {
- return JptCommonUiMessages.DefaultEmpty;
- }
-
- protected String buildNonNullDefaultValueEntry(String defaultValue) {
- return NLS.bind(
- JptCommonUiMessages.DefaultWithOneParam,
- defaultValue);
- }
-
- protected void updateSelectedItem() {
- // make sure the default value is up to date (??? ~bjv)
- if (usesDefaultValue()) {
- String defaultValueEntry = this.buildDefaultValueEntry();
- if ( ! this.comboBox.getItem(0).equals(defaultValueEntry)) {
- this.comboBox.remove(0);
- this.comboBox.add(defaultValueEntry, 0);
- }
- }
-
- this.updateSelectedItem_();
- }
-
- /**
- * Updates the selected item by selecting the current value, if not
- * <code>null</code>, or select the default value if one is available,
- * otherwise remove the selection.
- */
- protected void updateSelectedItem_() {
- String value = (this.getSubject() == null) ? null : this.getValue();
- if (value == null) {
- if (usesDefaultValue()) {
- // select the default value
- this.comboBox.select(0);
- }
- else {
- this.comboBox.setText("");
- }
- } else {
- // select the new value
- if ( ! value.equals(this.comboBox.getText())) {
- // This prevents the cursor from being set back to the beginning of the line (bug 234418).
- // The reason we are hitting this method at all is because the
- // context model is updating from the resource model in a way
- // that causes change notifications to be fired (the annotation
- // is added to the resource model, change notification occurs
- // on the update thread, and then the name is set, these 2
- // threads can get in the wrong order).
- // The #valueChanged() method sets the populating flag to true,
- // but in this case it is already set back to false when we
- // receive notification back from the model because it has
- // moved to the update thread and then jumps back on the UI thread.
- this.comboBox.setText(value);
- }
- }
- }
-
- protected void repopulateComboBox() {
- if ( ! this.comboBox.isDisposed()) {
- this.repopulate();
- }
- }
-
-
- // **************** combo-box listener callback ***************************
-
- protected void comboBoxModified() {
- if ( ! this.isPopulating()) {
- this.valueChanged(this.comboBox.getText());
- }
- }
-
- /**
- * The combo-box selection has changed, update the model if necessary.
- * If the value has changed and the subject is null, we can build a subject
- * before setting the value.
- */
- protected void valueChanged(String newValue) {
- T subject = this.getSubject();
- String oldValue;
- if (subject == null) {
- if (this.nullSubjectIsNotAllowed()) {
- return; // no subject to set the value on
- }
- oldValue = null;
- } else {
- oldValue = this.getValue();
- }
-
- // convert empty string or default to null
- if (StringTools.stringIsEmpty(newValue) || this.valueIsDefault(newValue)) {
- newValue = null;
- }
-
- // set the new value if it is different from the old value
- if (Tools.valuesAreDifferent(oldValue, newValue)) {
- this.setPopulating(true);
-
- try {
- this.setValue(newValue);
- } finally {
- this.setPopulating(false);
- }
- }
- }
-
- /**
- * Return whether we can set the value when the subject is null
- * (i.e. #setValue(String) will construct the subject if necessary).
- */
- protected boolean nullSubjectIsAllowed() {
- return false;
- }
-
- protected final boolean nullSubjectIsNotAllowed() {
- return ! this.nullSubjectIsAllowed();
- }
-
- /**
- * pre-condition: value is not null
- */
- protected boolean valueIsDefault(String value) {
- if (! usesDefaultValue()) {
- return false;
- }
- return (this.comboBox.getItemCount() > 0)
- && value.equals(this.comboBox.getItem(0));
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java
deleted file mode 100644
index 97f4dc388c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DefaultWidgetFactory.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.DateTime;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Spinner;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.widgets.FormText;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.forms.widgets.TableWrapData;
-import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
-/**
- * This <code>WidgetFactory</code> simply creates plain SWT widgets.
- *
- * @version 2.0
- * @since 2.0
- */
-public class DefaultWidgetFactory implements WidgetFactory {
-
- /**
- * The singleton instance of this <code>IWidgetFactory</code>
- */
- private static final WidgetFactory INSTANCE = new DefaultWidgetFactory();
-
- /**
- * Creates a new <code>DefaultWidgetFactory</code>.
- */
- private DefaultWidgetFactory() {
- super();
- }
-
- /**
- * Returns the singleton instance of this <code>IWidgetFactory</code>.
- *
- * @return The singleton instance of this <code>IWidgetFactory</code>
- */
- public static WidgetFactory instance() {
- return INSTANCE;
- }
-
- /**
- * {@inheritDoc}
- */
- public Button createButton(Composite parent, String text) {
- return this.createButton(parent, text, SWT.NULL);
- }
-
- /**
- * Creates a new button.
- *
- * @param parent The parent container
- * @param text The button's text
- * @param style The style to apply to the button, which determines its type:
- * toggle, push, check box, radio
- * @return The newly created <code>Button</code>
- */
- private Button createButton(Composite parent, String text, int style) {
- Button button = new Button(parent, style);
- button.setText(text);
- return button;
- }
-
- /**
- * {@inheritDoc}
- */
- @Deprecated
- public CCombo createCCombo(Composite parent) {
- return new CCombo(parent, SWT.BORDER | SWT.READ_ONLY);
- }
-
- /**
- * {@inheritDoc}
- */
- public Button createCheckBox(Composite parent, String text) {
- return this.createButton(parent, text, SWT.CHECK);
- }
-
- /**
- * {@inheritDoc}
- */
- public Combo createCombo(Composite parent) {
- return new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
- }
-
- /**
- * {@inheritDoc}
- */
- public Composite createComposite(Composite parent) {
- return new Composite(parent, SWT.NULL);
- }
-
- /**
- * {@inheritDoc}
- */
- public DateTime createDateTime(Composite parent, int style) {
- return new DateTime(parent, style);
- }
-
- /**
- * {@inheritDoc}
- */
- @Deprecated
- public CCombo createEditableCCombo(Composite parent) {
- return new CCombo(parent, SWT.BORDER);
- }
-
- /**
- * {@inheritDoc}
- */
- public Combo createEditableCombo(Composite parent) {
- return new Combo(parent, SWT.BORDER);
- }
-
- /**
- * {@inheritDoc}
- */
- public Group createGroup(Composite parent, String title) {
- Group group = new Group(parent, SWT.NULL);
- group.setText(title);
- return group;
- }
-
- /**
- * {@inheritDoc}
- */
- public Hyperlink createHyperlink(Composite parent, String text) {
- Hyperlink hyperlink = new Hyperlink(parent, SWT.NULL);
- hyperlink.setText(text);
- return hyperlink;
- }
-
- /**
- * {@inheritDoc}
- */
- public Label createLabel(Composite parent, String labelText) {
- Label label = new Label(parent, SWT.WRAP);
- label.setText(labelText);
- return label;
- }
-
- /**
- * {@inheritDoc}
- */
- public List createList(Composite parent, int style) {
- return new List(parent, SWT.BORDER | style);
- }
-
- /**
- * {@inheritDoc}
- */
- public FormText createMultiLineLabel(Composite parent, String labelText) {
-
- Composite container = new Composite(parent, SWT.NONE);
-
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- container.setLayoutData(gridData);
-
- TableWrapLayout layout = new TableWrapLayout();
- layout.numColumns = 1;
- layout.bottomMargin = 0;
- layout.leftMargin = 0;
- layout.rightMargin = 0;
- layout.topMargin = 0;
- container.setLayout(layout);
-
- FormToolkit widgetFactory = new FormToolkit(parent.getDisplay());
- FormText text = widgetFactory.createFormText(container, true);
- text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
- text.setText(labelText, false, false);
-
- return text;
- }
-
- /**
- * {@inheritDoc}
- */
- public Text createMultiLineText(Composite parent) {
- return new Text(parent, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
- }
-
- /**
- * {@inheritDoc}
- */
- public Text createPasswordText(Composite parent) {
- return new Text(parent, SWT.BORDER | SWT.PASSWORD);
- }
-
- /**
- * {@inheritDoc}
- */
- public Button createPushButton(Composite parent, String text) {
- return this.createButton(parent, text, SWT.PUSH);
- }
-
- /**
- * {@inheritDoc}
- */
- public Button createRadioButton(Composite parent, String text) {
- return this.createButton(parent, text, SWT.RADIO);
- }
-
- /**
- * {@inheritDoc}
- */
- public Section createSection(Composite parent, int style) {
- return new Section(parent, style);
- }
-
- /**
- * {@inheritDoc}
- */
- public Spinner createSpinner(Composite parent) {
- return new Spinner(parent, SWT.NULL);
- }
-
- /**
- * {@inheritDoc}
- */
- public Table createTable(Composite parent, int style) {
- return new Table(parent, SWT.BORDER | style);
- }
-
- /**
- * {@inheritDoc}
- */
- public Text createText(Composite parent) {
- return new Text(parent, SWT.BORDER);
- }
-
- /**
- * {@inheritDoc}
- */
- public Button createTriStateCheckBox(Composite parent, String text) {
- TriStateCheckBox checkBox = new TriStateCheckBox(parent, text, this);
- return checkBox.getCheckBox();
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Dialog.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Dialog.java
deleted file mode 100644
index 22ecaf58be..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Dialog.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.node.Node;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.help.IWorkbenchHelpSystem;
-
-/**
- * The abstract implementation of a dialog using a "state object" (model object)
- * for behavior.
- * <p>
- * The main pane of this dialog should be extending <code>DialogPane</code>
- * for creating the right type of widgets and it has the "state object" (subject)
- * behavior built-in.
- *
- * @see Node
- * @see DialogPane
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public abstract class Dialog<T extends Node> extends TitleAreaDialog
-{
- /**
- * The main content pane of this dialog.
- */
- private DialogPane<?> pane;
-
- /**
- * The holder of the "state object" used by this dialog.
- */
- private ModifiablePropertyValueModel<T> subjectHolder;
-
- /**
- * Caches the title text until the dialog is created and the dialog's shell
- * needs to be configured.
- */
- private String title;
-
- /**
- * Creates a new <code>Dialog</code>.
- *
- * @param parent The parent shell
- */
- protected Dialog(Shell parent) {
- this(parent, "");
- }
-
- /**
- * Creates a new <code>Dialog</code>.
- *
- * @param parent The parent shell
- * @param title The dialog's title
- */
- protected Dialog(Shell parent, String title) {
- super(parent);
- this.title = title;
- initialize();
- }
-
- /**
- * Initializes the main pane of this dialog. This method is invoked only
- * when the dialog is requested to show on screen and not during
- * initialization.
- *
- * @param container The container to which the widgets should be added to,
- * the layout is already set
- */
- protected abstract DialogPane<?> buildLayout(Composite container);
-
- /**
- * Creates the state object (model object) that will be used to keep track
- * of the information entered in this dialog. The state object will be stored
- * in the subject holder and can be retrieved using {@link #subject()}.
- *
- * @return A new state object
- */
- protected T buildStateObject() {
- return null;
- }
-
- /**
- * Creates the <code>Validator</code> that will be notified when changes are
- * made to the state object.
- *
- * @return The validator that will be set on the state object
- */
- Node.Validator buildValidator() {
- return Node.NULL_VALIDATOR;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public boolean close() {
-
- // Dispose the pane in order to remove any listeners that could
- // have been installed outside the scrope of the state object
- if (pane != null) {
- pane.dispose();
- pane = null;
- }
-
- return super.close();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(getTitle());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void create() {
- super.create();
- installSubject();
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected Control createContents(Composite parent) {
- if (hasTitleArea()) {
- return super.createContents(parent);
- }
-
- return createDefaultContent(parent);
- }
-
- /**
- * Creates the default main container of this dialog when the title area is
- * not required. The top part is the dialog area populated by the subclass
- * and the lower part is the button pane having the OK and Cancel buttons.
- *
- * @param parent The parent container
- * @return The
- */
- private Composite createDefaultContent(Composite parent) {
-
- Composite composite = new Composite(parent, SWT.NULL);
-
- GridLayout layout = new GridLayout(1, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.verticalSpacing = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- applyDialogFont(composite);
- initializeDialogUnits(composite);
- dialogArea = createDialogArea(composite);
- buttonBar = createButtonBar(composite);
-
- return composite;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected Composite createDialogArea(Composite parent) {
-
- // If the title area needs to be shown, then leave the superclass to
- // create the necessary widgets
- if (hasTitleArea()) {
- parent = (Composite) super.createDialogArea(parent);
- }
-
- // Create the main area's container
- Composite container = new Composite(parent, SWT.NULL);
- container.setLayout(new GridLayout(1, false));
-
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.verticalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- container.setLayoutData(gridData);
-
- // Initialize the content pane
- pane = buildLayout(container);
-
- // Initialize the UI part, which requires the widgets being created
- initializeUI();
-
- return parent;
- }
-
- /**
- * Determines whether the description area (where a title, description and
- * image) should be visible or hidden. <code>ValidatingDialog</code>
- * automatically show the description area in order to show problems.
- *
- * @return <code>false</code> by default, which means the methods used to
- * update the title, description and image shouldn't be called; <code>true</code>
- * to make the description pane visible
- */
- protected boolean hasTitleArea() {
- return false;
- }
-
- /**
- * Returns the helps system.
- *
- * @return The platform's help system
- *
- * @category Helper
- */
- protected final IWorkbenchHelpSystem getHelpSystem() {
- return PlatformUI.getWorkbench().getHelpSystem();
- }
-
- /**
- * Initializes this dialog.
- */
- protected void initialize() {
- this.subjectHolder = new SimplePropertyValueModel<T>();
- }
-
- /**
- * Initializes the UI part of this dialog, this is called after the widgets
- * have been created.
- */
- protected void initializeUI() {
- }
-
- /**
- * Creates the state object, if one is needed and install a <code>Validator</code>
- * in order to receive notification of changes done to that state object. The
- * subject can be retrieved from the subject holder.
- */
- private void installSubject() {
-
- T subject = buildStateObject();
-
- if (subject != null) {
- subject.setValidator(buildValidator());
- }
-
- subjectHolder.setValue(subject);
- }
-
- /**
- * Gives access to the dialog's main pane.
- *
- * @return The pane showing the custom widgets
- */
- protected DialogPane<?> getPane() {
- return pane;
- }
-
- /**
- * Returns the subject of this dialog.
- *
- * @return The subject of this dialog or <code>null</code> if no subject was
- * used
- */
- public T getSubject() {
- return subjectHolder.getValue();
- }
-
- /**
- * Returns the holder of the subject.
- *
- * @return The subject holder used to be passed to the dialog pane, which is
- * an instance of <code>DialogPane</code>
- */
- protected final PropertyValueModel<T> getSubjectHolder() {
- return subjectHolder;
- }
-
- /**
- * Retrieves the dialog's title. The title passed to the constructor will be
- * returned by default but if it wasn't specified, this method can be used
- * to return it.
- *
- * @return Either the title passed to the constructor or a different title
- */
- protected String getTitle() {
- return title;
- }
-
- /**
- * Determines whether the dialog was cancelled or not.
- *
- * @return <code>true</code> if the dialog was cancelled; <code>false</code>
- * if it was confirmed
- */
- public final boolean wasCancelled() {
- return getReturnCode() == CANCEL;
- }
-
- /**
- * Determines whether the dialog was confirmed or not.
- *
- * @return <code>true</code> if the dialog was confirmed; <code>false</code>
- * if it was cancelled
- */
- public final boolean wasConfirmed() {
- return getReturnCode() == OK;
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DialogPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DialogPane.java
deleted file mode 100644
index 823cd0c183..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/DialogPane.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jpt.common.utility.internal.node.Node;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * The abstract pane to use when the pane is shown in an <code>Dialog</code>.
- *
- * @see Dialog
- *
- * @version 2.0
- * @since 2.0
- */
-public abstract class DialogPane<T extends Node> extends Pane<T> {
-
- /**
- * Creates a new <code>DialogPane</code>.
- *
- * @param parentPane The parent controller of this one
- * @param parent The parent container
- *
- * @category Constructor
- */
- protected DialogPane(DialogPane<? extends T> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>DialogPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- * @param automaticallyAlignWidgets <code>true</code> to make the widgets
- * this pane aligned with the widgets of the given parent controller;
- * <code>false</code> to not align them
- *
- * @category Constructor
- */
- protected DialogPane(DialogPane<? extends T> parentPane,
- Composite parent,
- boolean automaticallyAlignWidgets) {
-
- super(parentPane, parent, automaticallyAlignWidgets);
- }
-
- /**
- * Creates a new <code>DialogPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- *
- * @category Constructor
- */
- protected DialogPane(DialogPane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(parentPane, subjectHolder, parent);
- }
-
- /**
- * Creates a new <code>DialogPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- * @param automaticallyAlignWidgets <code>true</code> to make the widgets
- * this pane aligned with the widgets of the given parent controller;
- * <code>false</code> to not align them
- *
- * @category Constructor
- */
- protected DialogPane(DialogPane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- boolean automaticallyAlignWidgets) {
-
- super(parentPane, subjectHolder, parent, automaticallyAlignWidgets);
- }
-
- /**
- * Creates a new <code>DialogPane</code>.
- *
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- *
- * @category Constructor
- */
- protected DialogPane(PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(subjectHolder, parent, DefaultWidgetFactory.instance());
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumComboViewer.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumComboViewer.java
deleted file mode 100644
index 2c42ef3ee2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumComboViewer.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import java.util.Arrays;
-import java.util.Comparator;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Composite;
-import com.ibm.icu.text.Collator;
-
-/**
- * This pane simply shows a combo where its data is populating through
- * {@link #choices()} and a default value can also be added.
- * <p>
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | ------------------------------------------------------------------------- |
- * | | I |v| |
- * | ------------------------------------------------------------------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @version 2.0
- * @since 1.0
- */
-@SuppressWarnings("nls")
-abstract class EnumComboViewer<T extends Model, V> extends Pane<T>
-{
- /**
- * The main widget of this pane.
- */
- private ComboViewer comboViewer;
-
- /**
- * A constant used to represent the <code>null</code> value.
- */
- public static final String NULL_VALUE = "null";
-
- /**
- * Creates a new <code>EnumComboViewer</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- */
- EnumComboViewer(Pane<? extends T> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>EnumComboViewer</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- */
- EnumComboViewer(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(parentPane, subjectHolder, parent);
- }
-
- /**
- * Creates a new <code>EnumComboViewer</code>.
- *
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- */
- EnumComboViewer(PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super(subjectHolder, parent, widgetFactory);
- }
-
- /**
- * Creates the list of choices and add an extra element that represents the
- * default value.
- *
- * @return The combo's choices including the default value
- */
- private Object[] buildChoices() {
- V[] choices = getChoices();
- if (sortChoices()) {
- Arrays.sort(choices, buildComparator());
- }
-
- Object[] extendedChoices = new Object[choices.length + 1];
- System.arraycopy(choices, 0, extendedChoices, 1, choices.length);
- extendedChoices[0] = NULL_VALUE;
-
- return extendedChoices;
- }
-
- /**
- * Return true to sort the choices in alphabetical order
- * @return
- */
- protected boolean sortChoices() {
- return true;
- }
-
- /**
- * Creates the <code>ComboViewer</code> with the right combo widgets.
- *
- * @param container The container of the combo
- * @return A new <code>ComboViewer</code> containing the right combo widget
- */
- protected ComboViewer addComboViewer(Composite container) {
- return addComboViewer(container, buildLabelProvider());
- }
-
- private Comparator<Object> buildComparator() {
- return new Comparator<Object>() {
- final LabelProvider labelProvider = buildLabelProvider();
-
- public int compare(Object value1, Object value2) {
- String displayString1 = this.labelProvider.getText(value1);
- String displayString2 = this.labelProvider.getText(value2);
- return Collator.getInstance().compare(displayString1, displayString2);
- }
- };
- }
-
- /**
- * Creates the display string for the given element. If the element is the
- * virtual <code>null</code> value then its display string will be "Default"
- * appended by the actual default value, if it exists.
- *
- * @param value The value to convert into a human readable string
- * @return The string representation of the given element
- */
- @SuppressWarnings("unchecked")
- private String buildDisplayString(Object value) {
- if (value == NULL_VALUE) {
- V defaultValue = (getSubject() != null) ? getDefaultValue() : null;
-
- if (defaultValue != null) {
- String displayString = displayString(defaultValue);
- return NLS.bind(JptCommonUiMessages.EnumComboViewer_defaultWithDefault, displayString);
- }
- return nullDisplayString();
- }
-
- return displayString((V) value);
- }
-
- final LabelProvider buildLabelProvider() {
- return new LabelProvider() {
- @Override
- public String getText(Object element) {
- return buildDisplayString(element);
- }
- };
- }
-
- private ISelection buildSelection() {
- Object value = (getSubject() != null) ? getValue() : null;
-
- if (value == null) {
- value = NULL_VALUE;
- }
-
- return new StructuredSelection(value);
- }
-
- private ISelectionChangedListener buildSelectionChangedListener() {
- return new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent e) {
- if (!isPopulating()) {
- StructuredSelection selection = (StructuredSelection) e.getSelection();
- valueChanged(selection.getFirstElement());
- }
- }
- };
- }
-
- /**
- * Returns the possible choices to show in the viewer.
- *
- * @return The items to show in the combos
- */
- protected abstract V[] getChoices();
-
- /**
- * Returns the default value, this method is not called if the subject is
- * <code>null</code>.
- *
- * @return The value that is declared as being the default when it is not
- * defined or <code>null</code> if there is no default value
- */
- protected abstract V getDefaultValue();
-
- /**
- * Returns the displayable string for the given value.
- *
- * @param value The value to translate into a human readable string
- * @return The localized text representing the given value
- */
- protected abstract String displayString(V value);
-
- /**
- * Returns the displayable string for a null value.
- */
- protected String nullDisplayString() {
- return null; //I would rather display nothing than "Default()"
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void doPopulate() {
- super.doPopulate();
- this.populateCombo();
- }
-
- /**
- * Returns
- *
- * @return
- */
- final ComboViewer getComboViewer() {
- return this.comboViewer;
- }
-
- /**
- * Retrieves the subject's value. The subject is never <code>null</code>.
- *
- * @return The subject' value, which can be <code>null</code>
- */
- protected abstract V getValue();
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected final void initializeLayout(Composite container) {
-
- this.comboViewer = this.addComboViewer(container);
- this.comboViewer.addSelectionChangedListener(buildSelectionChangedListener());
- }
-
- /**
- * Populates the combo by re-adding all the items.
- */
- private void populateCombo() {
-
- removeAll();
- this.comboViewer.add(buildChoices());
- updateSelection();
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void propertyChanged(String propertyName) {
- super.propertyChanged(propertyName);
- this.populateCombo();
- }
-
- /**
- * Removes all the items from the combo.
- */
- abstract void removeAll();
-
- /**
- * Requests the given new value be set on the subject.
- *
- * @param value The new value to be set
- */
- protected abstract void setValue(V value);
-
- /**
- * Updates the cursor, which is required to show the entire selected item
- * within the combo's area.
- */
- abstract void updateCursor();
-
- /**
- * Updates the combo's selected item.
- */
- private void updateSelection() {
- this.comboViewer.setSelection(buildSelection());
- updateCursor();
- }
-
- /**
- * The selection changes, notify the subclass to set the value.
- *
- * @param value The new selected item
- */
- @SuppressWarnings("unchecked")
- private void valueChanged(Object value) {
-
- // Convert the default "null" value to a real null
- if (value == NULL_VALUE) {
- value = null;
- }
-
- setPopulating(true);
-
- try {
- setValue((V) value);
- }
- finally {
- setPopulating(false);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumDialogComboViewer.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumDialogComboViewer.java
deleted file mode 100644
index b9dc901834..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumDialogComboViewer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * This <code>EnumComboViewer</code> should be used within a dialog pane.
- *
- * @version 2.0
- * @since 2.0
- */
-public abstract class EnumDialogComboViewer<T extends Model, V>
- extends EnumComboViewer<T, V>
-{
- /**
- * Creates a new <code>EnumDialogComboViewer</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- */
- protected EnumDialogComboViewer(DialogPane<? extends T> parentPane,
- Composite parent
- ) {
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>EnumDialogComboViewer</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- */
- protected EnumDialogComboViewer(DialogPane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent
- ) {
- super(parentPane, subjectHolder, parent);
- }
-
- protected final Combo getCombo() {
- return getComboViewer().getCombo();
- }
-
- @Override
- void removeAll() {
- getCombo().removeAll();
- }
-
- @Override
- void updateCursor() {
- getCombo().setSelection(new Point(0, 0));
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumFormComboViewer.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumFormComboViewer.java
deleted file mode 100644
index 25a1c0e350..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/EnumFormComboViewer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * This <code>EnumComboViewer</code> should be used within a form pane.
- *
- * @version 2.3
- * @since 1.0
- */
-public abstract class EnumFormComboViewer<T extends Model, V>
- extends EnumComboViewer<T, V>
-{
- /**
- * Creates a new <code>EnumFormComboViewer</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- */
- protected EnumFormComboViewer(Pane<? extends T> parentPane,
- Composite parent
- ) {
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>EnumFormComboViewer</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- */
- protected EnumFormComboViewer(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent
- ) {
- super(parentPane, subjectHolder, parent);
- }
-
- protected final Combo getCombo() {
- return this.getComboViewer().getCombo();
- }
-
- @Override
- void removeAll() {
- getCombo().removeAll();
- }
-
- @Override
- void updateCursor() {
- getCombo().setSelection(new Point(0, 0));
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserComboPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserComboPane.java
deleted file mode 100644
index 4b47bad407..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserComboPane.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2010 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.StringConverter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * This chooser allows the user to choose a file when browsing.
- * <p>
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | ---------------------------------------------------- ------------- |
- * | Label: | I |v| | | Browse... | |
- * | ---------------------------------------------------- ------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @version 3.0
- * @since 3.0
- */
-public abstract class FileChooserComboPane<T extends Model> extends FileChooserPane<T>
-{
- /**
- * Creates a new <code>FileChooserComboPane</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public FileChooserComboPane(Pane<? extends T> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>FileChooserComboPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public FileChooserComboPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(parentPane, subjectHolder, parent);
- }
-
- @Override
- protected Control addMainControl(Composite container) {
-
- return addEditableCombo(
- container,
- this.buildListHolder(),
- this.getTextHolder(),
- this.buildStringConverter()
- );
- }
-
- /**
- * Creates the list holder of the combo box.
- */
- protected ListValueModel<String> buildListHolder() {
- return new SimpleListValueModel<String>(
- this.buildDefaultList()
- );
- }
-
- /**
- * Creates the default list of the combo box.
- */
- protected List<String> buildDefaultList() {
- return Arrays.asList(this.getDefaultString());
- }
-
- /**
- * Returns the default value of the combo box.
- */
- protected abstract String getDefaultString();
-
- /**
- * The converter responsible to transform each combo box item
- * into a string representation
- */
- protected StringConverter<String> buildStringConverter() {
- return StringConverter.Default.<String>instance();
- }
-
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserPane.java
deleted file mode 100644
index 8aebfc1748..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FileChooserPane.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.jpt.common.ui.JptCommonUiPlugin;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.ui.dialogs.ISelectionStatusValidator;
-
-/**
- * This chooser allows the user to choose a file when browsing.
- * <p>
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | ---------------------------------------------------- ------------- |
- * | Label: | I | | Browse... | |
- * | ---------------------------------------------------- ------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public abstract class FileChooserPane<T extends Model> extends ChooserPane<T>
-{
- private ModifiablePropertyValueModel<String> textHolder;
-
- /**
- * Creates a new <code>FileChooserPane</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public FileChooserPane(Pane<? extends T> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>FileChooserPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public FileChooserPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(parentPane, subjectHolder, parent);
- }
-
- @Override
- protected final Runnable buildBrowseAction() {
- return new Runnable() {
- public void run() {
- promptFile();
- }
- };
- }
-
- /**
- * Creates the <code>ViewerFilter</code> that will filter the content of the
- * dialog and only displays what is valid.
- *
- * @return A new <code>ViewerFilter</code>
- */
- protected ViewerFilter buildFilter() {
- return new ViewerFilter() {
- @Override
- public boolean select(Viewer viewer,
- Object parentElement,
- Object element) {
-
- return true;
- }
- };
- }
-
- @Override
- protected Control addMainControl(Composite container) {
- return this.addText(container, this.textHolder);
- }
-
- /**
- * Creates the value holder of the subject's property.
- *
- * @return The holder of the class name
- */
- protected abstract ModifiablePropertyValueModel<String> buildTextHolder();
-
- /**
- * Creates the validator that will show a status message based on what is
- * selected in the selection dialog.
- *
- * @return A new <code>ISelectionStatusValidator</code>
- */
- protected ISelectionStatusValidator buildValidator() {
- return new ISelectionStatusValidator() {
- public IStatus validate(Object[] selection) {
-
- if (selection.length != 1) {
- return new Status(IStatus.ERROR, JptCommonUiPlugin.PLUGIN_ID, "");
- }
-
- return new Status(IStatus.OK, JptCommonUiPlugin.PLUGIN_ID, "");
- }
- };
- }
-
- /**
- * Returns the selection dialog's title.
- *
- * @return A non-<code>null</code> string
- */
- protected abstract String getDialogTitle();
-
- /**
- * Retrieves the project path that will be used by the selection dialog.
- *
- * @return The project path used to display its content in a selection dialog
- */
- protected abstract String getProjectPath();
-
- protected ModifiablePropertyValueModel<String> getTextHolder() {
- return this.textHolder;
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.textHolder = this.buildTextHolder();
- }
-
- /**
- * The browse button was clicked, its action invokes this action which should
- * prompt the user to select a file and set it.
- */
- protected void promptFile() {
- String projectPath= this.getProjectPath();
-
- FileDialog dialog = new FileDialog(getShell());
- dialog.setText(this.getDialogTitle());
- dialog.setFilterPath(projectPath);
- String filePath = dialog.open();
- if (filePath != null) {
- FileChooserPane.this.textHolder.setValue(filePath);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FolderChooserComboPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FolderChooserComboPane.java
deleted file mode 100644
index d7cce8ab4d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FolderChooserComboPane.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2010 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.StringConverter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-
-/**
- * This chooser allows the user to choose a folder when browsing.
- * <p>
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | ---------------------------------------------------- ------------- |
- * | Label: | I |v| | | Browse... | |
- * | ---------------------------------------------------- ------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @version 3.0
- * @since 3.0
- */
-public abstract class FolderChooserComboPane<T extends Model> extends FolderChooserPane<T>
-{
- /**
- * Creates a new <code>FolderChooserComboPane</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public FolderChooserComboPane(Pane<? extends T> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>FolderChooserComboPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public FolderChooserComboPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(parentPane, subjectHolder, parent);
- }
-
- @Override
- protected Control addMainControl(Composite container) {
-
- return addEditableCombo(
- container,
- this.buildListHolder(),
- this.getTextHolder(),
- this.buildStringConverter()
- );
- }
-
- /**
- * Creates the list holder of the combo box.
- */
- protected ListValueModel<String> buildListHolder() {
- return new SimpleListValueModel<String>(
- this.buildDefaultList()
- );
- }
-
- /**
- * Creates the default list of the combo box.
- */
- protected List<String> buildDefaultList() {
- return Arrays.asList(this.getDefaultString());
- }
-
- /**
- * Returns the default value of the combo box.
- */
- protected abstract String getDefaultString();
-
- /**
- * The converter responsible to transform each combo box item
- * into a string representation
- */
- protected StringConverter<String> buildStringConverter() {
- return StringConverter.Default.<String>instance();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FolderChooserPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FolderChooserPane.java
deleted file mode 100644
index 9902d33753..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FolderChooserPane.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-
-/**
- * This chooser allows the user to choose a folder when browsing.
- * <p>
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | ---------------------------------------------------- ------------- |
- * | Label: | I | | Browse... | |
- * | ---------------------------------------------------- ------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @version 3.0
- * @since 2.0
- */
-public abstract class FolderChooserPane<T extends Model> extends ChooserPane<T>
-{
- private ModifiablePropertyValueModel<String> textHolder;
-
- /**
- * Creates a new <code>FolderChooserPane</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public FolderChooserPane(Pane<? extends T> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>FolderChooserPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public FolderChooserPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(parentPane, subjectHolder, parent);
- }
-
- @Override
- protected final Runnable buildBrowseAction() {
- return new Runnable() {
- public void run() {
- promptFolder();
- }
- };
- }
-
- @Override
- protected Control addMainControl(Composite container) {
- return this.addText(container, this.textHolder);
- }
-
- /**
- * Creates the value holder of the subject's property.
- *
- * @return The holder of the class name
- */
- protected abstract ModifiablePropertyValueModel<String> buildTextHolder();
-
- /**
- * Returns the message to be shown in the selection dialog.
- *
- * @return A non-<code>null</code> string shown above the text field of the
- * selection dialog
- */
- protected abstract String getDialogMessage();
-
- /**
- * Returns the selection dialog's title.
- *
- * @return A non-<code>null</code> string
- */
- protected abstract String getDialogTitle();
-
- /**
- * Returns the path that the dialog will use to filter the directories it
- * shows to the argument, which may be null. If the string is null, then the
- * operating system's default filter path will be used.
- * <p>
- * Note that the path string is platform dependent. For convenience, either
- * '/' or '\' can be used as a path separator.
- * </p>
- *
- * @return The filter path
- */
- protected String filterPath() {
- return null;
- }
-
- protected ModifiablePropertyValueModel<String> getTextHolder() {
- return this.textHolder;
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.textHolder = this.buildTextHolder();
- }
-
- /**
- * The browse button was clicked, its action invokes this action which should
- * prompt the user to select a folder and set it.
- */
- protected void promptFolder() {
-
- DirectoryDialog dialog = new DirectoryDialog(getShell());
- dialog.setMessage(this.getDialogMessage());
- dialog.setText(this.getDialogTitle());
- dialog.setFilterPath(this.filterPath());
- String directory = dialog.open();
-
- if (directory != null) {
- this.textHolder.setValue(directory);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java
deleted file mode 100644
index ea1302f7df..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/FormWidgetFactory.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.DateTime;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Spinner;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.forms.widgets.FormText;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.forms.widgets.TableWrapData;
-import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
-/**
- * This <code>WidgetFactory</code> is responsible to create the widgets
- * using the <code>FormToolkit</code> in order use the form style (flat-style)
- * look and feel.
- *
- * @see FormToolkit
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public class FormWidgetFactory implements WidgetFactory {
-
- /**
- * The actual factory responsible for creating the new widgets.
- */
- private final FormToolkit widgetFactory;
-
- /**
- * Creates a new <code>FormWidgetFactory</code>.
- *
- * @param widgetFactory The actual factory responsible for creating the new
- * widgets
- */
- public FormWidgetFactory(FormToolkit widgetFactory) {
- super();
-
- Assert.isNotNull(widgetFactory, "The widget factory cannot be null");
- this.widgetFactory = widgetFactory;
- }
-
- /**
- * Wraps the given <code>Composite</code> into a new <code>Composite</code>
- * in order to have the widgets' border painted. Except for <code>CCombo</code>,
- * the top and bottom margins have to be 2 pixel and the left and right
- * margins have to be 1 pixel.
- *
- * @param container The parent of the sub-pane
- * @return A new <code>Composite</code> that has the necessary space to paint
- * the border
- */
- protected Composite createBorderContainer(Composite container) {
- return createBorderContainer(container, 2, 1);
- }
-
- protected Composite createBorderContainer(Composite container, int marginHeight, int marginWidth) {
-
- GridLayout layout = new GridLayout(1, false);
- layout.marginHeight = marginHeight;
- layout.marginWidth = marginWidth;
-
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
-
- container = widgetFactory.createComposite(container);
- container.setLayoutData(gridData);
- container.setLayout(layout);
-
- return container;
- }
-
- /**
- * {@inheritDoc}
- */
- public Button createButton(Composite parent, String text) {
- return createButton(parent, text, SWT.NULL);
- }
-
- /**
- * Creates a new button.
- *
- * @param parent The parent container
- * @param text The button's text
- * @param style The style to apply to the button, which determines its type:
- * toggle, push, check box, radio
- * @return The newly created <code>Button</code>
- */
- protected Button createButton(Composite parent, String text, int style) {
- return widgetFactory.createButton(parent, text, SWT.FLAT | style);
- }
-
- /**
- * {@inheritDoc}
- */
- @Deprecated
- public CCombo createCCombo(Composite parent) {
- return createCCombo(parent, SWT.READ_ONLY);
- }
-
- /**
- * Creates a new combo.
- *
- * @param parent The parent container
- * @param style The style to apply to the combo, usually read-only, flat
- * @return The newly created <code>CCombo</code>
- */
- protected CCombo createCCombo(Composite parent, int style) {
- parent = createBorderContainer(parent, 1, 1);
-
- CCombo combo = new CCombo(parent, style);
- widgetFactory.adapt(combo, true, false);
-
- // Bugzilla 145837 - workaround for no borders on Windows XP
- if (widgetFactory.getBorderStyle() == SWT.BORDER) {
- combo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- }
-
- return combo;
- }
-
- /**
- * {@inheritDoc}
- */
- public Button createCheckBox(Composite parent, String text) {
- return createButton(parent, text, SWT.CHECK);
- }
-
- /**
- * {@inheritDoc}
- */
- public Combo createCombo(Composite parent) {
- return new Combo(parent, SWT.READ_ONLY | SWT.FLAT);
- }
-
- /**
- * {@inheritDoc}
- */
- public Composite createComposite(Composite parent) {
- return this.widgetFactory.createComposite(parent);
- }
- /**
- * {@inheritDoc}
- */
- public DateTime createDateTime(Composite parent, int style) {
- parent = createBorderContainer(parent);
-
- DateTime dateTime = new DateTime(parent, style | SWT.FLAT);
- dateTime.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- this.widgetFactory.adapt(dateTime, true, false);
-
- return dateTime;
- }
-
- /**
- * {@inheritDoc}
- */
- @Deprecated
- public CCombo createEditableCCombo(Composite parent) {
- return createCCombo(parent, SWT.NULL);
- }
-
- /**
- * {@inheritDoc}
- */
- public Combo createEditableCombo(Composite parent) {
- Combo combo = new Combo(parent, SWT.FLAT);
- return combo;
- }
-
- /**
- * {@inheritDoc}
- */
- public Group createGroup(Composite parent, String title) {
- Group group = new Group(parent, SWT.NULL);
- group.setText(title);
- return group;
- }
-
- /**
- * {@inheritDoc}
- */
- public Hyperlink createHyperlink(Composite parent, String text) {
- return widgetFactory.createHyperlink(parent, text, SWT.FLAT);
- }
-
- /**
- * {@inheritDoc}
- */
- public Label createLabel(Composite container, String labelText) {
- return widgetFactory.createLabel(container, labelText, SWT.WRAP);
- }
-
- /**
- * {@inheritDoc}
- */
- public List createList(Composite container, int style) {
- List list = new List(container, SWT.FLAT | style);
- list.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- return list;
- }
-
- /**
- * {@inheritDoc}
- */
- public FormText createMultiLineLabel(Composite parent, String labelText) {
-
- Composite container = widgetFactory.createComposite(parent, SWT.NONE);
-
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- container.setLayoutData(gridData);
-
- TableWrapLayout layout = new TableWrapLayout();
- layout.numColumns = 1;
- layout.bottomMargin = 0;
- layout.leftMargin = 0;
- layout.rightMargin = 0;
- layout.topMargin = 0;
- container.setLayout(layout);
-
- FormText text = widgetFactory.createFormText(container, true);
- text.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
- text.setText(labelText, false, false);
-
- return text;
- }
-
- /**
- * {@inheritDoc}
- */
- public Text createMultiLineText(Composite parent) {
- return createText(parent, SWT.MULTI | SWT.V_SCROLL);
- }
-
- /**
- * {@inheritDoc}
- */
- public Text createPasswordText(Composite parent) {
- return createText(parent, SWT.PASSWORD);
- }
-
- /**
- * {@inheritDoc}
- */
- public Button createPushButton(Composite parent, String text) {
- return createButton(parent, text, SWT.PUSH);
- }
-
- /**
- * {@inheritDoc}
- */
- public Button createRadioButton(Composite parent, String text) {
- return createButton(parent, text, SWT.RADIO);
- }
-
- /**
- * {@inheritDoc}
- */
- public Section createSection(Composite parent, int style) {
- return widgetFactory.createSection(parent, SWT.FLAT | style);
- }
-
- /**
- * {@inheritDoc}
- */
- public Spinner createSpinner(Composite parent) {
- parent = createBorderContainer(parent);
-
- Spinner spinner = new Spinner(parent, SWT.FLAT);
- spinner.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- widgetFactory.adapt(spinner, true, false);
-
- return spinner;
- }
-
- /**
- * {@inheritDoc}
- */
- public Table createTable(Composite parent, int style) {
- Table table = this.widgetFactory.createTable(parent, SWT.BORDER | style);
- table.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
- return table;
- }
-
- /**
- * {@inheritDoc}
- */
- public Text createText(Composite parent) {
- return createText(parent, SWT.NONE);
- }
-
- protected Text createText(Composite parent, int style) {
- return widgetFactory.createText(parent, null, SWT.BORDER | SWT.FLAT | style);
- }
-
- /**
- * {@inheritDoc}
- */
- public Button createTriStateCheckBox(Composite parent, String text) {
- TriStateCheckBox checkBox = new TriStateCheckBox(parent, text, this);
- return checkBox.getCheckBox();
- }
-
- /**
- * Returns the actual factory responsible for creating the new widgets.
- *
- * @return The factory creating the widgets with the form style (flat-style)
- */
- public FormToolkit getWidgetFactory() {
- return widgetFactory;
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/IntegerCombo.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/IntegerCombo.java
deleted file mode 100644
index 03aef4031b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/IntegerCombo.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
-import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationWritablePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * This is a replacement for a Spinner. It is a combo that only accepts integers.
- * It also includes a Default option in the combo.
- */
-public abstract class IntegerCombo<T extends Model>
- extends Pane<T>
-{
-
- /**
- * The main (only) widget of this pane.
- */
- private Combo comboBox;
-
-
- private PropertyValueModel<String> defaultValueHolder;
-
- // ********** constructors **********
-
- protected IntegerCombo(
- Pane<? extends T> parentPane,
- Composite parent
- ) {
- super(parentPane, parent);
- }
-
- protected IntegerCombo(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent
- ) {
- super(parentPane, subjectHolder, parent);
- }
-
- public Combo getCombo() {
- return this.comboBox;
- }
-
- // ********** initialization **********
-
- @Override
- protected void initializeLayout(Composite container) {
- this.defaultValueHolder = buildDefaultStringHolder();
- this.comboBox = this.addIntegerCombo(container);
-
- int margin = FieldDecorationRegistry.getDefault().getMaximumDecorationWidth();
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
- gridData.horizontalIndent = margin;
- gridData.grabExcessHorizontalSpace = false;
- this.comboBox.setLayoutData(gridData);
-
- this.comboBox.addVerifyListener(this.buildVerifyListener());
- SWTUtil.attachDefaultValueHandler(this.comboBox);
- }
-
- protected Combo addIntegerCombo(Composite container) {
- return this.addLabeledEditableCombo(
- container,
- getLabelText(),
- buildDefaultListHolder(),
- buildSelectedItemStringHolder(),
- getHelpId()
- );
-
- }
-
- protected VerifyListener buildVerifyListener() {
- return new VerifyListener() {
- public void verifyText(VerifyEvent e) {
- IntegerCombo.this.verifyComboBox(e);
- }
- };
- }
-
- protected ListValueModel<String> buildDefaultListHolder() {
- return new PropertyListValueModelAdapter<String>(this.defaultValueHolder);
- }
-
- private PropertyValueModel<String> buildDefaultStringHolder() {
- return new TransformationPropertyValueModel<Integer, String>(buildDefaultHolder()) {
- @Override
- protected String transform(Integer value) {
- if (value == null) {
- return JptCommonUiMessages.NoneSelected;
- }
- return super.transform(value);
- }
- @Override
- protected String transform_(Integer value) {
- return getDefaultValueString(value);
- }
- };
- }
-
- private String getDefaultValueString(Integer defaultValue) {
- return NLS.bind(
- JptCommonUiMessages.DefaultWithOneParam,
- defaultValue
- );
- }
-
- /* CU private */ String getDefaultValueString() {
- return this.defaultValueHolder.getValue();
- }
-
- protected ModifiablePropertyValueModel<String> buildSelectedItemStringHolder() {
- return new TransformationWritablePropertyValueModel<Integer, String>(buildSelectedItemHolder()) {
- @Override
- protected String transform(Integer v) {
- return (v == null) ? getDefaultValueString() : v.toString();
- }
-
- @Override
- protected Integer reverseTransform_(String v) {
- try {
- return Integer.valueOf(v);
- } catch (NumberFormatException ex) {
- // if the default is selected from the combo, set length to null
- return null;
- }
- }
- };
- }
-
- // ********** abstract methods **********
-
- protected abstract String getLabelText();
-
- protected abstract String getHelpId();
-
- protected abstract PropertyValueModel<Integer> buildDefaultHolder();
-
- protected abstract ModifiablePropertyValueModel<Integer> buildSelectedItemHolder();
-
- // ********** combo-box verify listener callback **********
-
- protected void verifyComboBox(VerifyEvent e) {
- if (e.character == '\b') {
- //ignore backspace
- return;
- }
- if (e.text.equals("") //DefaultValueHandler sets the text to "" //$NON-NLS-1$
- || e.text.equals(this.defaultValueHolder.getValue())) {
- return;
- }
- try {
- Integer.parseInt(e.text);
- }
- catch (NumberFormatException exception) {
- e.doit = false;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameDialog.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameDialog.java
deleted file mode 100644
index c87ce21752..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameDialog.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import java.util.Collection;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * The dialog used to requests a name from the user.
- *
- * @version 2.0
- * @since 2.0
- */
-public class NewNameDialog extends ValidatingDialog<NewNameStateObject>
-{
- private String description;
- private Image descriptionImage;
- private String descriptionTitle;
- private String labelText;
- private String name;
- private Collection<String> names;
-
- /**
- * Creates a new <code>NewNameDialog</code>.
- *
- * @param parentShell
- * @param dialogTitle
- * @param descriptionTitle
- * @param descriptionImage
- * @param description
- * @param labelText
- * @param name
- * @param names
- */
- NewNameDialog(Shell parentShell,
- String dialogTitle,
- String descriptionTitle,
- Image descriptionImage,
- String description,
- String labelText,
- String name,
- Collection<String> names)
- {
- super(parentShell, dialogTitle);
-
- this.name = name;
- this.names = names;
- this.labelText = labelText;
- this.description = description;
- this.descriptionImage = descriptionImage;
- this.descriptionTitle = descriptionTitle;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected DialogPane<NewNameStateObject> buildLayout(Composite container) {
- return new NewNameDialogPane(container);
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected NewNameStateObject buildStateObject() {
- return new NewNameStateObject(name, names);
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public void create() {
- super.create();
-
- NewNameDialogPane pane = (NewNameDialogPane) getPane();
- pane.selectAll();
-
- getButton(OK).setEnabled(false);
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected String getDescription() {
- return description;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected Image getDescriptionImage() {
- return descriptionImage;
- }
-
- /* (non-Javadoc)
- */
- @Override
- protected String getDescriptionTitle() {
- return descriptionTitle;
- }
-
- /**
- * Returns the text field's input, which is the new name the user entered.
- *
- * @return The name the user entered
- */
- public String getName() {
- return getSubject().getName();
- }
-
- private class NewNameDialogPane extends DialogPane<NewNameStateObject> {
-
- private Text text;
-
- NewNameDialogPane(Composite parent) {
- super(NewNameDialog.this.getSubjectHolder(), parent);
- }
-
- private ModifiablePropertyValueModel<String> buildNameHolder() {
- return new PropertyAspectAdapter<NewNameStateObject, String>(getSubjectHolder(), NewNameStateObject.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return subject.getName();
- }
-
- @Override
- protected void setValue_(String value) {
- subject.setName(value);
- }
- };
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeLayout(Composite container) {
-
- text = addLabeledText(
- container,
- labelText,
- buildNameHolder()
- );
- }
-
- void selectAll() {
- text.selectAll();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameDialogBuilder.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameDialogBuilder.java
deleted file mode 100644
index 4142c07709..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameDialogBuilder.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * This builder is responsible to create a fully initialized
- * <code>NewNameDialog</code> once all the properties have been set.
- *
- * @see NewNameDialog
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public final class NewNameDialogBuilder {
-
- /**
- * The message to show in the description area.
- */
- private String description;
-
- /**
- * The image of the description area.
- */
- private Image descriptionImage;
-
- /**
- * The title to show in the description area.
- */
- private String descriptionTitle;
-
- /**
- * The title of the new name dialog.
- */
- private String dialogTitle;
-
- /**
- * The text field's label.
- */
- private String labelText;
-
- /**
- * The initial input or <code>null</code> if no initial value can be
- * specified.
- */
- private String name;
-
- /**
- * The collection of names that can't be used or an empty collection if none
- * are available.
- */
- private Collection<String> names;
-
- /**
- * The parent shell of the new name dialog.
- */
- private Shell parentShell;
-
- /**
- * Creates a new <code>NewNameDialogBuilder</code>.
- *
- * @param parentShell The parent shell of the new name dialog
- */
- public NewNameDialogBuilder(Shell parentShell) {
- super();
- initialize(parentShell);
- }
-
- /**
- * Creates the dialog that will be used to request a new name from the user.
- *
- * @return The initialized dialog
- */
- public NewNameDialog buildDialog() {
- return new NewNameDialog(
- parentShell,
- dialogTitle,
- descriptionTitle,
- descriptionImage,
- description,
- labelText,
- name,
- names
- );
- }
-
- /**
- * Initializes this builder.
- *
- * @param parentShell The parent shell of the new name dialog
- */
- protected void initialize(Shell parentShell) {
-
- Assert.isNotNull(parentShell, "The parent shell cannot be null");
-
- this.parentShell = parentShell;
- this.names = Collections.emptyList();
- }
-
- /**
- * Sets the description to be shown in the description area under the title.
- *
- * @param description The message to show in the description area
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * Sets the image to be shown to the right side of the description area.
- *
- * @param descriptionImage The image of the description area
- */
- public void setDescriptionImage(Image descriptionImage) {
- this.descriptionImage = descriptionImage;
- }
-
- /**
- * Sets the title to be shown in the description area.
- *
- * @param descriptionTitle The title to show in the description area
- */
- public void setDescriptionTitle(String descriptionTitle) {
- this.descriptionTitle = descriptionTitle;
- }
-
- /**
- * Sets the dialog's title.
- *
- * @param dialogTitle The title of the new name dialog
- */
- public void setDialogTitle(String dialogTitle) {
- this.dialogTitle = dialogTitle;
- }
-
- /**
- * Sets the existing names that will be used to validate the text field's
- * input and prevent the user from using it.
- *
- * @param names The collection of names that can't be used
- */
- public void setExistingNames(Iterator<String> names) {
- this.names = CollectionTools.collection(names);
- }
-
- /**
- * Sets the text to label the text field.
- *
- * @param labelText The text field's label
- */
- public void setLabelText(String labelText) {
- this.labelText = labelText;
- }
-
- /**
- * Sets the initial name if one exists. It is valid to leave this
- * <code>null</code> when the user has to enter something.
- *
- * @param name The initial input
- */
- public void setName(String name) {
- this.name = name;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameStateObject.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameStateObject.java
deleted file mode 100644
index f86bae2e11..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/NewNameStateObject.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.node.AbstractNode;
-import org.eclipse.jpt.common.utility.internal.node.Node;
-import org.eclipse.jpt.common.utility.internal.node.Problem;
-
-/**
- * This is the state object used by the <code>NewNameDialog</code>, which stores
- * the current name and validates it when it is modified.
- *
- * @see NewNameDialog
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-final class NewNameStateObject extends AbstractNode
-{
- /**
- * The initial input or <code>null</code> if no initial value can be
- * specified.
- */
- private String name;
-
- /**
- * The collection of names that can't be used or an empty collection if none
- * are available.
- */
- private Collection<String> names;
-
- /**
- * The <code>Validator</code> used to validate this state object.
- */
- private Validator validator;
-
- /**
- * Notifies a change in the name property.
- */
- static final String NAME_PROPERTY = "name";
-
- /**
- * Creates a new <code>NewNameStateObject</code>.
- *
- * @param name The initial input or <code>null</code> if no initial value can
- * be specified
- * @param names The collection of names that can't be used or an empty
- * collection if none are available
- */
- NewNameStateObject(String name, Collection<String> names) {
- super(null);
-
- this.name = name;
- this.names = names;
- }
-
- /**
- * Validates the name property.
- *
- * @param currentProblems The list to which <code>Problem</code>s can be
- * added
- */
- private void addNameProblems(List<Problem> currentProblems) {
-
- if (StringTools.stringIsEmpty(name)) {
- currentProblems.add(buildProblem(JptCommonUiMessages.NewNameStateObject_nameMustBeSpecified, IMessageProvider.ERROR));
- }
- else if (names.contains(name.trim())) {
- currentProblems.add(buildProblem(JptCommonUiMessages.NewNameStateObject_nameAlreadyExists, IMessageProvider.ERROR));
- }
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void addProblemsTo(List<Problem> currentProblems)
- {
- super.addProblemsTo(currentProblems);
- addNameProblems(currentProblems);
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void checkParent(Node parentNode) {
- }
-
- /*
- * (non-Javadoc)
- */
- public String displayString() {
- return null;
- }
-
- /**
- * Returns the current name stored in this state object.
- *
- * @return The current name or <code>null</code>
- */
- String getName() {
- return name;
- }
-
- /**
- * Sets the current name stored in this state object or <code>null</code> to
- * clear it.
- *
- * @param name The new name or <code>null</code>
- */
- public void setName(String name) {
- String oldName = this.name;
- this.name = name;
- firePropertyChanged(NAME_PROPERTY, oldName, name);
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public void setValidator(Validator validator) {
- this.validator = validator;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- public Validator getValidator() {
- return validator;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PackageChooserPane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PackageChooserPane.java
deleted file mode 100644
index a998f337d2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PackageChooserPane.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.internal.ui.refactoring.contentassist.ControlContentAssistHelper;
-import org.eclipse.jdt.internal.ui.refactoring.contentassist.JavaPackageCompletionProcessor;
-import org.eclipse.jdt.ui.JavaElementLabelProvider;
-import org.eclipse.jdt.ui.JavaUI;
-import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.common.ui.JptCommonUiPlugin;
-import org.eclipse.jpt.common.ui.internal.JptCommonUiMessages;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-/**
- * This chooser allows the user to choose a package when browsing and it adds
- * code completion support to the text field, which is the main component.
- * <p>
- * Here the layout of this pane:
- * <pre>
- * -----------------------------------------------------------------------------
- * | !---------------------------------------------------- ------------- |
- * | Label: | I | | Browse... | |
- * | ---------------------------------------------------- ------------- |
- * -----------------------------------------------------------------------------</pre>
- *
- * @version 2.0
- * @since 2.0
- */
-public abstract class PackageChooserPane<T extends Model> extends ChooserPane<T>
-{
- /**
- * The code completion manager.
- */
- private JavaPackageCompletionProcessor javaPackageCompletionProcessor;
-
- private PropertyChangeListener subjectChangeListener;
-
- /**
- * Creates a new <code>PackageChooserPane</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- */
- public PackageChooserPane(Pane<? extends T> parentPane,
- Composite parent) {
-
- super(parentPane, parent);
- }
-
- /**
- * Creates a new <code>PackageChooserPane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- */
- public PackageChooserPane(Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- super(parentPane, subjectHolder, parent);
- }
-
- @Override
- protected void initialize() {
- super.initialize();
-
- // TODO bug 156185 - when this is fixed there should be api for this
- this.javaPackageCompletionProcessor = new JavaPackageCompletionProcessor(
- new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_ROOT)
- );
- this.subjectChangeListener = this.buildSubjectChangeListener();
- this.getSubjectHolder().addPropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
- this.packageChooserSubjectChanged(getSubject());
- }
-
- private PropertyChangeListener buildSubjectChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildSubjectChangeListener_());
- }
-
- private PropertyChangeListener buildSubjectChangeListener_() {
- return new PropertyChangeListener() {
- @SuppressWarnings("unchecked")
- public void propertyChanged(PropertyChangeEvent e) {
- PackageChooserPane.this.packageChooserSubjectChanged((T) e.getNewValue());
- }
- };
- }
-
- protected void packageChooserSubjectChanged(T newSubject) {
- IPackageFragmentRoot root = null;
- if (newSubject != null) {
- root = getPackageFragmentRoot();
- }
- this.javaPackageCompletionProcessor.setPackageFragmentRoot(root);
- }
-
- @Override
- protected final Runnable buildBrowseAction() {
- return new Runnable() {
- public void run() {
- promptPackage();
- }
- };
- }
-
- @Override
- protected Control addMainControl(Composite container) {
- Composite subPane = addSubPane(container);
-
- Text text = addText(subPane, buildTextHolder());
-
- Image image = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL).getImage();
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalIndent = image.getBounds().width;
- text.setLayoutData(data);
-
- ControlContentAssistHelper.createTextContentAssistant(
- text,
- javaPackageCompletionProcessor
- );
-
- return subPane;
- }
-
- /**
- * Creates the value holder of the subject's property.
- *
- * @return The holder of the package name
- */
- protected abstract ModifiablePropertyValueModel<String> buildTextHolder();
-
- /**
- * Prompts the user the Open Package dialog.
- *
- * @return Either the selected package or <code>null</code> if the user
- * cancelled the dialog
- */
- protected IPackageFragment choosePackage() {
-
- SelectionDialog selectionDialog;
-
- try {
- selectionDialog = JavaUI.createPackageDialog(
- getShell(),
- getPackageFragmentRoot()
- );
- }
- catch (JavaModelException e) {
- JptCommonUiPlugin.log(e);
- return null;
- }
-
- selectionDialog.setTitle(JptCommonUiMessages.PackageChooserPane_dialogTitle);
- selectionDialog.setMessage(JptCommonUiMessages.PackageChooserPane_dialogMessage);
-
- IPackageFragment pack = getPackageFragment();
-
- if (pack != null) {
- selectionDialog.setInitialSelections(new Object[] { pack });
- }
-
- if (selectionDialog.open() == Window.OK) {
- return (IPackageFragment) selectionDialog.getResult()[0];
- }
-
- return null;
- }
-
- protected abstract IJavaProject getJavaProject();
-
- /**
- * Returns the package name from its subject.
- *
- * @return The package name or <code>null</code> if none is defined
- */
- protected abstract String getPackageName();
-
- /**
- * The browse button was clicked, its action invokes this action which should
- * prompt the user to select a package and set it.
- */
- protected void promptPackage() {
- IPackageFragment packageFragment = choosePackage();
-
- if (packageFragment != null) {
- String packageName = packageFragment.getElementName();
- this.setPackageName(packageName);
- }
- }
-
- protected abstract void setPackageName(String packageName);
-
- private IPackageFragment getPackageFragment() {
- String packageName = getPackageName();
-
- if (packageName == null) {
- return null;
- }
-
- return getPackageFragmentRoot().getPackageFragment(packageName);
- }
-
- protected IPackageFragmentRoot getPackageFragmentRoot() {
- try {
- return this.getJavaProject().getPackageFragmentRoots()[0];
- } catch (JavaModelException ex) {
- JptCommonUiPlugin.log(ex);
- return null;
- }
- }
-
- @Override
- public void dispose() {
- this.getSubjectHolder().removePropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
- super.dispose();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java
deleted file mode 100644
index f4f6f52da3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/Pane.java
+++ /dev/null
@@ -1,3746 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.jpt.common.ui.internal.Tracing;
-import org.eclipse.jpt.common.ui.internal.listeners.SWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.ui.internal.swt.ComboModelAdapter;
-import org.eclipse.jpt.common.ui.internal.swt.DateTimeModelAdapter;
-import org.eclipse.jpt.common.ui.internal.swt.SpinnerModelAdapter;
-import org.eclipse.jpt.common.ui.internal.swt.TriStateCheckBoxModelAdapter;
-import org.eclipse.jpt.common.ui.internal.util.ControlAligner;
-import org.eclipse.jpt.common.ui.internal.util.LabeledButton;
-import org.eclipse.jpt.common.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
-import org.eclipse.jpt.common.utility.internal.NonNullBooleanTransformer;
-import org.eclipse.jpt.common.utility.internal.StringConverter;
-import org.eclipse.jpt.common.utility.internal.model.value.CompositeBooleanPropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DateTime;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Spinner;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.FormText;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.help.IWorkbenchHelpSystem;
-import org.eclipse.ui.part.PageBook;
-
-/**
- * The abstract definition of a pane which holds onto a <code>PropertyValueModel</code>
- * that contains the subject of this pane.
- * <p>
- * It also contains convenience methods for building buttons, labels, check
- * boxes, and radio buttons, etc.
- * <p>
- * It is possible to easily listen to any property changes coming from the
- * subject, {@link #addPropertyNames(Collection)} is specify which properties
- * are of interest and {@link #propertyChanged(String)} is used to notify the
- * pane when the property has changed.
- *
- * @see FormPane
- * @see DialogPane
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public abstract class Pane<T extends Model>
-{
- /**
- * The listener registered with the subject in order to be notified when a
- * property has changed, the property names are determined by
- * {@link #propertyNames()}.
- */
- private PropertyChangeListener aspectChangeListener;
-
- /**
- * The container of this composite.
- */
- private final Composite container;
-
- /**
- * The aligner responsible to align the left controls.
- */
- private ControlAligner leftControlAligner;
-
- /**
- * Flag used to stop the circular population of widgets.
- */
- private boolean populating;
-
- /**
- * The aligner responsible to align the left controls.
- */
- private ControlAligner rightControlAligner;
-
- /**
- * This listener is registered with the subject holder in order to
- * automatically repopulate this pane with the new subject.
- */
- private PropertyChangeListener subjectChangeListener;
-
- /**
- * The subject of this pane.
- */
- private PropertyValueModel<T> subjectHolder;
-
- /**
- * The collection of registered sub-panes will be automatically notified
- * when listeners need to be engaged or disengaged or when to populate its
- * widgets.
- */
- private Collection<Pane<?>> subPanes;
-
- /**
- * The factory used to create various common widgets.
- */
- private WidgetFactory widgetFactory;
-
- /**
- * The collection of <code>Control</code>s that are displayed in this pane,
- * which will have their enablement state updated when
- * {@link #enableWidgets(boolean)} is called.
- */
- private ArrayList<Control> managedWidgets;
-
- /**
- * The collection of <code>Pane</code>s that are displayed in this pane,
- * which will have their enablement state updated when
- * {@link #enableWidgets(boolean)} is called.
- */
- private ArrayList<Pane<?>> managedSubPanes;
-
- /**
- * This enabled model is used to store the pane's base enablement state.
- * If API is called to set the pane enabled, this model gets updated. If the pane is thereby
- * fully enabled (controller enabled model is also in agreement) the pane's widgets are set
- * enabled.
- * @see #getCombinedEnabledModel()
- */
- private final ModifiablePropertyValueModel<Boolean> baseEnabledModel
- = new SimplePropertyValueModel<Boolean>(Boolean.TRUE);
-
- /**
- * This enabled model is used to define the pane's enablement as controlled by other widgets,
- * tests, etc. (for example a radio button)
- * If this model is changed, and the pane is thereby fully enabled (base enabled model is also
- * in agreement) the pane's widgets are set enabled.
- * @see #getCombinedEnabledModel()
- */
- private PropertyValueModel<Boolean> controllerEnabledModel;
-
- /**
- * The "and" combination of {@link #baseEnabledModel} and {@link #controllerEnabledModel}
- */
- private PropertyValueModel<Boolean> combinedEnabledModel;
-
- private PropertyChangeListener combinedEnabledModelListener;
-
- /**
- * Creates a new <code>Pane</code>.
- *
- * @param parentPane The parent pane of this one
- * @param parent The parent container
- *
- * @category Constructor
- */
- protected Pane(
- Pane<? extends T> parentPane,
- Composite parent) {
-
- this(parentPane, parent, true);
- }
-
- /**
- * Creates a new <code>Pane</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- * @param automaticallyAlignWidgets <code>true</code> to make the widgets
- * this pane aligned with the widgets of the given parent pane;
- * <code>false</code> to not align them
- *
- * @category Constructor
- */
- protected Pane(
- Pane<? extends T> parentPane,
- Composite parent,
- boolean automaticallyAlignWidgets) {
-
- this(
- parentPane,
- parentPane.getSubjectHolder(),
- parent,
- automaticallyAlignWidgets);
- }
-
- /**
- * Creates a new <code>Pane</code>.
- *
- * @param parentPane The parent container of this one
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- * @param automaticallyAlignWidgets <code>true</code> to make the widgets
- * this pane aligned with the widgets of the given parent pane;
- * <code>false</code> to not align them
- *
- * @category Constructor
- */
- protected Pane(
- Pane<? extends T> parentPane,
- Composite parent,
- boolean automaticallyAlignWidgets,
- boolean parentManagePane) {
-
- this(
- parentPane,
- parentPane.getSubjectHolder(),
- parent,
- automaticallyAlignWidgets,
- parentManagePane);
- }
-
- /**
- * Creates a new <code>Pane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- *
- * @category Constructor
- */
- protected Pane(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent) {
-
- this(parentPane, subjectHolder, parent, true);
- }
-
- protected Pane(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- PropertyValueModel<Boolean> enabledModel) {
-
- this(parentPane, subjectHolder, parent, true, enabledModel);
- }
-
- /**
- * Creates a new <code>Pane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- * @param automaticallyAlignWidgets <code>true</code> to make the widgets
- * this pane aligned with the widgets of the given parent pane;
- * <code>false</code> to not align them
- *
- * @category Constructor
- */
- protected Pane(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- boolean automaticallyAlignWidgets) {
-
- this(parentPane, subjectHolder, parent, automaticallyAlignWidgets, true);
- }
-
- protected Pane(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- boolean automaticallyAlignWidgets,
- PropertyValueModel<Boolean> enabledModel) {
-
- this(parentPane, subjectHolder, parent, automaticallyAlignWidgets, true, enabledModel);
- }
-
- /**
- * Creates a new <code>Pane</code>.
- *
- * @param parentPane The parent container of this one
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- * @param widgetFactory The factory used to create various widgets
- * @param automaticallyAlignWidgets <code>true</code> to make the widgets
- * this pane aligned with the widgets of the given parent pane;
- * <code>false</code> to not align them
- * @param parentManagePane <code>true</code> to have the parent pane manage
- * the enabled state of this pane
- *
- * @category Constructor
- */
- protected Pane(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- boolean automaticallyAlignWidgets,
- boolean parentManagePane) {
-
- this(subjectHolder, parent, parentPane.getWidgetFactory());
- this.initialize(parentPane, automaticallyAlignWidgets, parentManagePane);
- }
-
- protected Pane(
- Pane<?> parentPane,
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- boolean automaticallyAlignWidgets,
- boolean parentManagePane,
- PropertyValueModel<Boolean> enabledModel) {
-
- this(subjectHolder, parent, parentPane.getWidgetFactory());
- this.initialize(parentPane, automaticallyAlignWidgets, parentManagePane);
- this.initializeEnabledModel(enabledModel);
- }
-
- /**
- * Creates a new <code>Pane</code>.
- *
- * @param subjectHolder The holder of this pane's subject
- * @param parent The parent container
- * @param widgetFactory The factory used to create various common widgets
- *
- * @category Constructor
- */
- protected Pane(
- PropertyValueModel<? extends T> subjectHolder,
- Composite parent,
- WidgetFactory widgetFactory) {
-
- super();
- this.initialize(subjectHolder, widgetFactory);
- this.container = this.addContainer(parent);
- this.initializeLayout(this.container);
- this.engageSubjectHolder();
- this.engageListeners(getSubject());
- this.populate();
- }
-
-
- // ********** initialization **********
-
- @SuppressWarnings("unchecked")
- private void initialize(
- PropertyValueModel<? extends T> subjectHolder,
- WidgetFactory widgetFactory) {
-
- Assert.isNotNull(subjectHolder, "The subject holder cannot be null");
-
- this.subjectHolder = (PropertyValueModel<T>) subjectHolder;
- this.widgetFactory = widgetFactory;
- this.subPanes = new ArrayList<Pane<?>>();
- this.managedWidgets = new ArrayList<Control>();
- this.managedSubPanes = new ArrayList<Pane<?>>();
- this.leftControlAligner = new ControlAligner();
- this.rightControlAligner = new ControlAligner();
- this.subjectChangeListener = this.buildSubjectChangeListener();
- this.aspectChangeListener = this.buildAspectChangeListener();
-
- this.initialize();
- }
-
- protected void initialize() {
- // do nothing by default
- }
-
- /**
- * Registers this pane with the parent pane.
- *
- * @param parentPane The parent pane
- * @param automaticallyAlignWidgets <code>true</code> to make the widgets
- * this pane aligned with the widgets of the given parent pane;
- * <code>false</code> to not align them
- * @param parentManagePane <code>true</code> to have the parent pane manage
- * the enabled state of this pane
- *
- * @category Initialization
- */
- private void initialize(
- Pane<?> parentPane,
- boolean automaticallyAlignWidgets,
- boolean parentManagePane) {
-
- // Register this pane with the parent pane, it will call the methods
- // automatically (engageListeners(), disengageListeners(), populate(),
- // dispose(), etc)
- parentPane.registerSubPane(this);
-
- if (parentManagePane) {
- parentPane.manageSubPane(this);
- }
-
- // Align the left and right controls with the controls from the parent
- // pane
- if (automaticallyAlignWidgets) {
- parentPane.addAlignLeft(this);
- parentPane.addAlignRight(this);
- }
- }
-
- private void initializeEnabledModel(PropertyValueModel<Boolean> enabledModel) {
- this.controllerEnabledModel = enabledModel;
- this.combinedEnabledModel =
- CompositeBooleanPropertyValueModel.and(this.baseEnabledModel, this.controllerEnabledModel);
- this.combinedEnabledModelListener = buildCombinedEnabledModelListener();
- this.combinedEnabledModel.addPropertyChangeListener(
- PropertyValueModel.VALUE, this.combinedEnabledModelListener);
- enableWidgets_(getCombinedEnablement());
- }
-
- private PropertyChangeListener buildCombinedEnabledModelListener() {
- return new SWTPropertyChangeListenerWrapper(buildControllerEnabledModelListener_());
- }
-
- private PropertyChangeListener buildControllerEnabledModelListener_() {
- return new PropertyChangeListener() {
- @SuppressWarnings("unchecked")
- public void propertyChanged(PropertyChangeEvent e) {
- Pane.this.controllerEnablementChanged();
- }
- };
- }
-
- /**
- * Initializes the layout of this pane.
- *
- * @param container The parent container
- *
- * @category Layout
- */
- protected abstract void initializeLayout(Composite container);
-
- private void manageWidget(Control control) {
- if (this.managedWidgets.contains(control)) {
- throw new IllegalStateException();
- }
- this.managedWidgets.add(control);
- }
-
- private void manageSubPane(Pane<?> subPane) {
- if (this.managedSubPanes.contains(subPane)) {
- throw new IllegalStateException();
- }
- this.managedSubPanes.add(subPane);
- }
-
- /**
- * Adds the given pane's widgets (those that were registered with its
- * left <code>ControlAligner</code>) to this pane's left
- * <code>ControlAligner</code> so that their width can be adjusted to have
- * the width of the widest widget.
- *
- * @param pane The pane containing the widgets to add
- *
- * @category Layout
- */
- protected final void addAlignLeft(Pane<?> container) {
- this.leftControlAligner.add(container.leftControlAligner);
- }
-
- /**
- * Adds the given control to the collection of widgets that have their width
- * adjust with the width of the widest widget. The left alignment is usually
- * used for labels.
- *
- * @param pane The pane to add
- *
- * @category Layout
- */
- protected final void addAlignLeft(Control control) {
- this.leftControlAligner.add(control);
- }
-
- /**
- * Adds the given pane's widgets (those that were registered with its
- * right <code>ControlAligner</code>) to this pane's right
- * <code>ControlAligner</code> so that their width can be adjusted to have
- * the width of the widest widget.
- *
- * @param pane The pane containing the widgets to add
- *
- * @category Layout
- */
- protected final void addAlignRight(Pane<?> container) {
- this.rightControlAligner.add(container.rightControlAligner);
- }
-
- /**
- * Adds the given control to the collection of widgets that have their width
- * adjust with the width of the widest widget. The left alignment is usually
- * used for buttons.
- *
- * @param pane The pane to add
- *
- * @category Layout
- */
- protected final void addAlignRight(Control control) {
- this.rightControlAligner.add(control);
- }
-
- /**
- * Adds the given pane's controls (those that were registered for
- * alignment) from this pane.
- *
- * @param pane The pane containing the widgets to add for
- * alignment
- *
- * @category Layout
- */
- protected final void addPaneForAlignment(Pane<?> container) {
- addAlignLeft(container);
- addAlignRight(container);
- }
-
- /**
- * Adds any property names to the given collection in order to be notified
- * when the actual property changes in the subject.
- *
- * @param propertyNames The collection of property names to register with the
- * subject
- */
- protected void addPropertyNames(Collection<String> propertyNames) {
- }
-
- private PropertyChangeListener buildAspectChangeListener() {
- return new SWTPropertyChangeListenerWrapper(buildAspectChangeListener_());
- }
-
- private PropertyChangeListener buildAspectChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- //subject() could have changed or is null because of the possibility of
- //"jumping" on the UI thread here and a selection change occuring
- if (e.getSource() == getSubject()) {
- updatePane(e.getPropertyName());
- }
- }
- };
- }
-
- /**
- * Creates a new button using the given information.
- *
- * @param parent The parent container
- * @param buttonText The button's text
- * @param buttonAction The action to be invoked when the button is pressed
- * @return The newly created <code>Button</code>
- *
- * @category Layout
- */
- protected final Button addButton(Composite container,
- String text,
- final Runnable buttonAction) {
-
- return this.addButton(container, text, null, buttonAction);
- }
-
- /**
- * Creates a new unmanaged <code>Button</code> widget. Unmanaged means
- * that this Pane will not handle the enabling/disabling of this widget.
- * The owning object will handle it with its own PaneEnabler or ControlEnabler.
- *
- * @param parent The parent container
- * @param buttonText The button's text
- * @param buttonAction The action to be invoked when the button is pressed
- * @return The newly created <code>Button</code>
- *
- * @category Layout
- */
- protected final Button addUnmanagedButton(Composite container,
- String text,
- final Runnable buttonAction) {
-
- return this.addUnmanagedButton(container, text, null, buttonAction);
- }
-
- /**
- * Creates a new button using the given information.
- *
- * @param parent The parent container
- * @param buttonText The button's text
- * @param helpId The topic help ID to be registered for the new check box
- * @param buttonAction The action to be invoked when the button is pressed
- * @return The newly created <code>Button</code>
- *
- * @category Layout
- */
- protected final Button addButton(Composite container,
- String text,
- String helpId,
- final Runnable buttonAction) {
-
- Button button = addUnmanagedButton(container, text, helpId, buttonAction);
- this.manageWidget(button);
-
- return button;
- }
-
- /**
- * Creates a new unmanaged <code>Button</code> widget. Unmanaged means
- * that this Pane will not handle the enabling/disabling of this widget.
- * The owning object will handle it with its own PaneEnabler or ControlEnabler.
- *
- * @param parent The parent container
- * @param buttonText The button's text
- * @param helpId The topic help ID to be registered for the new check box
- * @param buttonAction The action to be invoked when the button is pressed
- * @return The newly created <code>Button</code>
- *
- * @category Layout
- */
- private Button addUnmanagedButton(Composite container,
- String text,
- String helpId,
- final Runnable buttonAction) {
-
- Button button = this.widgetFactory.createButton(container, text);
- button.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- buttonAction.run();
- }
- });
-
- if (helpId != null) {
- getHelpSystem().setHelp(button, helpId);
- }
-
- GridData gridData = new GridData();
- gridData.grabExcessHorizontalSpace = false;
- gridData.horizontalAlignment = GridData.FILL;
- button.setLayoutData(gridData);
-
- return button;
- }
-
- /**
- * This layout will leave space for decorations on widgets.
- * Whether decorated or not, all of the widgets need the same indent
- * so that they align properly.
- */
- protected GridData getFieldGridData() {
- int margin = FieldDecorationRegistry.getDefault()
- .getMaximumDecorationWidth();
- GridData data = new GridData();
- data.horizontalAlignment = SWT.FILL;
- data.widthHint = IDialogConstants.ENTRY_FIELD_WIDTH + margin;
- data.horizontalIndent = margin;
- data.grabExcessHorizontalSpace = true;
- return data;
- }
-
- /**
- * Creates a new check box using the given information.
- *
- * @param parent The parent container
- * @param buttonText The button's text
- * @param booleanHolder The holder of the selection state
- * @param helpId The topic help ID to be registered for the new check box
- * @return The newly created <code>Button</code>
- *
- * @category Layout
- */
- protected final Button addCheckBox(
- Composite parent,
- String buttonText,
- ModifiablePropertyValueModel<Boolean> booleanHolder,
- String helpId) {
-
- return this.addToggleButton(
- parent,
- buttonText,
- booleanHolder,
- helpId,
- SWT.CHECK);
- }
-
- protected final Button addCheckBox(
- Composite parent,
- String buttonText,
- ModifiablePropertyValueModel<Boolean> booleanHolder,
- String helpId,
- PropertyValueModel<Boolean> enabledModel) {
-
- Button button = this.addUnmanagedToggleButton(parent, buttonText, booleanHolder, helpId, SWT.CHECK);
- this.controlEnabledState(enabledModel, button);
- return button;
- }
-
- /**
- * Creates a new <code>Section</code> that can be collapsed. A sub-pane is
- * automatically added as its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addCollapsibleSection(
- Composite container,
- String sectionText) {
-
- return this.addCollapsibleSection(
- container,
- sectionText,
- new SimplePropertyValueModel<Boolean>(Boolean.FALSE));
- }
-
- /**
- * Creates a new <code>Section</code> that can be collapsed. A sub-pane is
- * automatically added as its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param description The section's description or <code>null</code> if none
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addCollapsibleSection(Composite container,
- String sectionText,
- String description) {
-
- return this.addCollapsibleSection(
- container,
- sectionText,
- description,
- new SimplePropertyValueModel<Boolean>(Boolean.FALSE)
- );
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param type The type of section to create
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- private Composite addCollapsibleSection(Composite container,
- String sectionText,
- int type,
- PropertyValueModel<Boolean> expandedStateHolder) {
-
- return addCollapsibleSection(container, sectionText, null, type, expandedStateHolder);
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param description The section's description or <code>null</code> if none
- * was provided
- * @param type The type of section to create
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- private Composite addCollapsibleSection(Composite container,
- String sectionText,
- String description,
- int type,
- PropertyValueModel<Boolean> expandedStateHolder) {
-
- Composite subPane = this.addSection(
- container,
- sectionText,
- description,
- ExpandableComposite.TWISTIE | type
- );
-
- Section section = (Section) subPane.getParent();
-
- expandedStateHolder.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- buildExpandedStateChangeListener(section)
- );
-
- section.setExpanded(
- expandedStateHolder.getValue() != null ? expandedStateHolder.getValue() : true
- );
-
- return subPane;
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addCollapsibleSection(Composite container,
- String sectionText,
- PropertyValueModel<Boolean> expandedStateHolder) {
-
- return this.addCollapsibleSection(
- container,
- sectionText,
- ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE,
- expandedStateHolder
- );
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param description The section's description or <code>null</code> if none
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addCollapsibleSection(Composite container,
- String sectionText,
- String description,
- PropertyValueModel<Boolean> expandedStateHolder) {
-
- return this.addCollapsibleSection(
- container,
- sectionText,
- description,
- ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE,
- expandedStateHolder
- );
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client which can be typed cast directly as a <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addCollapsibleSubSection(Composite container,
- String sectionText,
- PropertyValueModel<Boolean> expandedStateHolder) {
-
- return this.addCollapsibleSection(
- container,
- sectionText,
- SWT.NULL,
- expandedStateHolder
- );
- }
-
- /**
- * Creates a new non-editable <code>Combo</code>.
- *
- * @param container The parent container
- * @return The newly created <code>Combo</code>
- *
- * @category Layout
- */
- protected final Combo addCombo(Composite container) {
- Combo combo = this.addUnmanagedCombo(container);
- this.manageWidget(combo);
- return combo;
- }
-
- /**
- * Creates a new non-editable <code>Combo</code>.
- *
- * @param container The parent container
- * @return The newly created <code>Combo</code>
- *
- * @category Layout
- */
- private Combo addUnmanagedCombo(Composite container) {
- Combo combo = this.widgetFactory.createCombo(container);
- combo.setLayoutData(getFieldGridData());
- return combo;
- }
-
- /**
- * Creates a new non-editable <code>Combo</code>.
- *
- * @param container The parent container
- * @param listHolder The <code>ListValueHolder</code>
- * @param selectedItemHolder The holder of the selected item
- * @param stringConverter The converter responsible to transform each item
- * into a string representation
- * @return The newly created <code>Combo</code>
- *
- * @category Layout
- */
- protected final <V> Combo addCombo(Composite container,
- ListValueModel<V> listHolder,
- ModifiablePropertyValueModel<V> selectedItemHolder,
- StringConverter<V> stringConverter) {
-
- Combo combo = this.addCombo(container);
-
- ComboModelAdapter.adapt(
- listHolder,
- selectedItemHolder,
- combo,
- stringConverter
- );
-
- return combo;
- }
-
- /**
- * Creates a new non-editable <code>Combo</code>.
- *
- * @param container The parent container
- * @param listHolder The <code>ListValueHolder</code>
- * @param selectedItemHolder The holder of the selected item
- * @param stringConverter The converter responsible to transform each item
- * into a string representation
- * @return The newly created <code>Combo</code>
- *
- * @category Layout
- */
- private <V> Combo addUnmanagedCombo(Composite container,
- ListValueModel<V> listHolder,
- ModifiablePropertyValueModel<V> selectedItemHolder,
- StringConverter<V> stringConverter) {
-
- Combo combo = this.addUnmanagedCombo(container);
-
- ComboModelAdapter.adapt(
- listHolder,
- selectedItemHolder,
- combo,
- stringConverter
- );
-
- return combo;
- }
-
- protected final <V> Combo addCombo(
- Composite container,
- ListValueModel<V> listHolder,
- ModifiablePropertyValueModel<V> selectedItemHolder,
- StringConverter<V> stringConverter,
- PropertyValueModel<Boolean> enabledModel) {
-
- Combo combo = this.addUnmanagedCombo(container, listHolder, selectedItemHolder, stringConverter);
- this.controlEnabledState(enabledModel, combo);
- return combo;
- }
-
- /**
- * Creates a new <code>ComboViewer</code> using a <code>Combo</code>.
- *
- * @param container The parent container
- * @param labelProvider The provider responsible to convert the combo's items
- * into human readable strings
- * @return The newly created <code>ComboViewer</code>
- *
- * @category Layout
- */
- protected final ComboViewer addComboViewer(Composite container,
- IBaseLabelProvider labelProvider) {
-
- Combo combo = this.addCombo(container);
- ComboViewer viewer = new ComboViewer(combo);
- viewer.setLabelProvider(labelProvider);
- return viewer;
- }
-
- /**
- * Creates the main container of this pane. The layout and layout data are
- * automatically set.
- *
- * @param parent The parent container
- * @return The newly created <code>Composite</code> that will holds all the
- * widgets created by this pane through {@link #initializeLayout(Composite)}
- *
- * @category Layout
- */
- protected Composite addContainer(Composite parent) {
- return this.addSubPane(parent);
- }
-
- protected final <V> Combo addEditableCombo(
- Composite container,
- ListValueModel<V> listHolder,
- ModifiablePropertyValueModel<V> selectedItemHolder,
- StringConverter<V> stringConverter,
- PropertyValueModel<Boolean> enabledModel) {
-
- Combo combo = this.addUnmanagedEditableCombo(container, listHolder, selectedItemHolder, stringConverter);
- this.controlEnabledState(enabledModel, combo);
- return combo;
- }
-
- protected final Combo addEditableCombo(
- Composite container) {
-
- Combo combo = this.widgetFactory.createEditableCombo(container);
- combo.setLayoutData(getFieldGridData());
- this.manageWidget(combo);
- return combo;
- }
-
- /**
- * Creates a new editable <code>Combo</code>.
- *
- * @param container The parent container
- * @param listHolder The <code>ListValueHolder</code>
- * @param selectedItemHolder The holder of the selected item
- * @param stringConverter The converter responsible to transform each item
- * into a string representation
- * @return The newly created <code>Combo</code>
- *
- * @category Layout
- */
- protected final <V> Combo addEditableCombo(Composite container,
- ListValueModel<V> listHolder,
- ModifiablePropertyValueModel<V> selectedItemHolder,
- StringConverter<V> stringConverter) {
-
- Combo combo = this.addEditableCombo(container);
-
- ComboModelAdapter.adapt(
- listHolder,
- selectedItemHolder,
- combo,
- stringConverter
- );
-
- return combo;
- }
-
- /**
- * Creates a new editable <code>ComboViewer</code> using a <code>Combo</code>.
- *
- * @param container The parent container
- * @param labelProvider The provider responsible to convert the combo's items
- * into human readable strings
- * @return The newly created <code>ComboViewer</code>
- *
- * @category Layout
- */
- protected final ComboViewer addEditableComboViewer(Composite container,
- IBaseLabelProvider labelProvider) {
-
- Combo combo = this.addEditableCombo(container);
- ComboViewer viewer = new ComboViewer(combo);
- viewer.setLabelProvider(labelProvider);
- return viewer;
- }
-
- private PropertyChangeListener buildExpandedStateChangeListener(final Section section) {
- return new SWTPropertyChangeListenerWrapper(buildExpandedStateChangeListener_(section));
- }
-
- private PropertyChangeListener buildExpandedStateChangeListener_(final Section section) {
- return new PropertyChangeListener() {
- public void propertyChanged(final PropertyChangeEvent e) {
- Boolean value = (Boolean) e.getNewValue();
- if (value == null) {
- value = Boolean.TRUE;
- }
- section.setExpanded(value);
- }
- };
- }
-
- /**
- * Creates a new <code>Hyperlink</code> that will invoked the given
- * <code>Runnable</code> when selected. The given action is always invoked
- * from the UI thread.
- *
- * @param parent The parent container
- * @param text The hyperlink's text
- * @param hyperLinkAction The action to be invoked when the link was selected
- * return The newly created <code>Hyperlink</code>
- *
- * @category Layout
- */
- protected final Hyperlink addHyperlink(Composite parent,
- String text,
- final Runnable hyperLinkAction) {
-
- Hyperlink link = this.widgetFactory.createHyperlink(parent, text);
- this.manageWidget(link);
-
- link.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
-
- Hyperlink hyperLink = (Hyperlink) e.widget;
-
- if (hyperLink.isEnabled()) {
- hyperLinkAction.run();
- }
- }
- });
-
- return link;
- }
-
- /**
- * Creates a new label using the given information.
- *
- * @param parent The parent container
- * @param labelText The label's text
- *
- * @category Layout
- */
- protected final Label addLabel(Composite container,
- String labelText) {
-
- Label label = addUnmanagedLabel(container, labelText);
- manageWidget(label);
- return label;
- }
-
- protected final Label addLabel(
- Composite container,
- String labelText,
- PropertyValueModel<Boolean> enabledModel
- ) {
- Label label = this.addUnmanagedLabel(container, labelText);
- this.controlEnabledState(enabledModel, label);
- return label;
- }
-
- /**
- * Creates a new unmanaged <code>Label</code> widget. Unmanaged means
- * that this Pane will not handle the enabling/disabling of this widget.
- * The owning object will handle it with its own PaneEnabler or ControlEnabler.
- *
- * @param parent The parent container
- * @param labelText The label's text
- *
- * @category Layout
- */
- private Label addUnmanagedLabel(Composite container,
- String labelText) {
-
- return this.widgetFactory.createLabel(container, labelText);
- }
-
- /**
- * Creates a new container that will have a non-editable combo labeled with
- * the given text.
- *
- * @param container The parent container
- * @param labelText The text of the label
- * @param listHolder The <code>ListValueHolder</code>
- * @param selectedItemHolder The holder of the selected item
- * @param rightControl The control shown to the right of the main widget
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The container of the label and the given center control
- *
- * @category Layout
- */
- protected final <V> Combo addLabeledCombo(Composite container,
- String labelText,
- ListValueModel<V> listHolder,
- ModifiablePropertyValueModel<V> selectedItemHolder,
- StringConverter<V> stringConverter,
- Control rightControl,
- String helpId) {
-
- Combo combo = this.addCombo(
- container,
- listHolder,
- selectedItemHolder,
- stringConverter
- );
-
- this.addLabeledComposite(
- container,
- labelText,
- (combo.getParent() != container) ? combo.getParent() : combo,
- rightControl,
- helpId
- );
-
- return combo;
- }
-
- /**
- * Creates a new container that will have a non-editable combo labeled with
- * the given text.
- *
- * @param container The parent container
- * @param labelText The text of the label
- * @param listHolder The <code>ListValueHolder</code>
- * @param selectedItemHolder The holder of the selected item
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The container of the label and the given center control
- *
- * @category Layout
- */
- protected final <V> Combo addLabeledCombo(Composite container,
- String labelText,
- ListValueModel<V> listHolder,
- ModifiablePropertyValueModel<V> selectedItemHolder,
- StringConverter<V> stringConverter,
- String helpId) {
-
- return this.addLabeledCombo(
- container,
- labelText,
- listHolder,
- selectedItemHolder,
- stringConverter,
- null,
- helpId
- );
- }
-
- /**
- * Creates a new container that will have the given center control labeled
- * with the given label.
- *
- * @param container The parent container
- * @param leftControl The widget shown to the left of the main widget
- * @param centerControl The main widget
- * @param rightControl The control shown to the right of the main widget
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The container of the label and the given center control
- *
- * @category Layout
- */
- protected final Composite addLabeledComposite(Composite container,
- Control leftControl,
- Control centerControl,
- Control rightControl,
- String helpId) {
-
- // Container for the label and main composite
- container = this.addSubPane(container, 3, 0, 0, 0, 0);
-
- // Left control
- GridData gridData = new GridData();
- gridData.horizontalAlignment = GridData.BEGINNING;
- gridData.grabExcessHorizontalSpace = false;
- leftControl.setLayoutData(gridData);
-
- // Re-parent the left control to the new sub pane
- leftControl.setParent(container);
- this.addAlignLeft(leftControl);
-
-
- // Re-parent the center control to the new sub pane
- centerControl.setParent(container);
-
- // Register the help id for the center control
- if (helpId != null) {
- getHelpSystem().setHelp(centerControl, helpId);
- }
-
- // Right control
- if (rightControl == null) {
- Composite spacer = this.addPane(container);
- spacer.setLayout(this.buildSpacerLayout());
- rightControl = spacer;
- }
- else {
- rightControl.setParent(container);
-
- // Register the help id for the right control
- if (helpId != null) {
- getHelpSystem().setHelp(rightControl, helpId);
- }
- }
-
- gridData = new GridData();
- gridData.horizontalAlignment = GridData.FILL_HORIZONTAL;
- gridData.grabExcessHorizontalSpace = false;
-
- rightControl.setLayoutData(gridData);
- this.addAlignRight(rightControl);
-
- return container;
- }
-
- /**
- * Creates a new container that will have the given center control labeled
- * with the given label.
- *
- * @param container The parent container
- * @param label The label used to describe the center control
- * @param centerControl The main widget
- * @param helpId The topic help ID to be registered for the given center
- * control
- * @return The container of the label and the given center control
- *
- * @category Layout
- */
- protected final Composite addLabeledComposite(Composite container,
- Control label,
- Control centerControl,
- String helpId) {
-
- return this.addLabeledComposite(
- container,
- label,
- centerControl,
- null,
- helpId
- );
- }
-
- /**
- * Creates a new container that will have the given center composite labeled
- * with the given label text.
- *
- * @param container The parent container
- * @param labelText The text to label the main composite
- * @param centerPane The main widget
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The container of the label and the given center control
- *
- * @category Layout
- */
- protected final Composite addLabeledComposite(Composite container,
- String labelText,
- Pane<?> centerPane,
- String helpId) {
-
- return this.addLabeledComposite(
- container,
- labelText,
- centerPane.getControl(),
- helpId
- );
- }
-
- /**
- * Creates a new container that will have the given center composite labeled
- * with the given label text.
- *
- * @param container The parent container
- * @param labelText The text to label the main composite
- * @param centerControl The main widget
- * @return The container of the label and the given center control
- *
- * @category Layout
- */
- protected final Composite addLabeledComposite(Composite container,
- String labelText,
- Control centerControl) {
-
-
- return this.addLabeledComposite(
- container,
- labelText,
- centerControl,
- null,
- null
- );
- }
-
- /**
- * Creates a new container that will have the given center composite labeled
- * with the given label text.
- *
- * @param container The parent container
- * @param labelText The text to label the main composite
- * @param centerControl The main widget
- * @param rightControl The control shown to the right of the main widget
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The container of the label and the given center control
- *
- * @category Layout
- */
- protected final Composite addLabeledComposite(Composite container,
- String labelText,
- Control centerControl,
- Control rightControl,
- String helpId) {
-
- return this.addLabeledComposite(
- container,
- this.addLabel(container, labelText),
- centerControl,
- rightControl,
- helpId
- );
- }
-
- /**
- * Creates a new container that will have the given center composite labeled
- * with the given label text.
- *
- * @param container The parent container
- * @param labelText The text to label the main composite
- * @param centerControl The main widget
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The container of the label and the given center control
- *
- * @category Layout
- */
- protected final Composite addLabeledComposite(Composite container,
- String labelText,
- Control centerControl,
- String helpId) {
-
- Label label = this.addLabel(container, labelText);
-
- return this.addLabeledComposite(
- container,
- label,
- centerControl,
- helpId
- );
- }
-
- /**
- * Creates a new container that will have the given center control labeled
- * with the given label.
- *
- * @param container The parent container
- * @param leftControl The widget shown to the left of the main widget
- * @param centerControl The main widget
- * @param rightControl The control shown to the right of the main widget
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The newly created <code>CCombo</code>
- *
- * @category Layout
- */
- protected final Combo addLabeledEditableCombo(Composite container,
- String labelText,
- ModifyListener comboListener,
- Control rightControl,
- String helpId) {
-
- Combo combo = this.addEditableCombo(container);
- combo.addModifyListener(comboListener);
-
- this.addLabeledComposite(
- container,
- labelText,
- (combo.getParent() != container) ? combo.getParent() : combo,
- rightControl,
- helpId
- );
-
- return combo;
- }
-
- /**
- * Creates a new container that will have an editable combo labeled with the
- * given text.
- *
- * @param container The parent container
- * @param labelText The text of the label
- * @param comboListener The listener that will be notified when the selection
- * changes
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The newly created <code>CCombo</code>
- *
- * @category Layout
- */
- protected final Combo addLabeledEditableCombo(Composite container,
- String labelText,
- ModifyListener comboListener,
- String helpId) {
-
- return this.addLabeledEditableCombo(
- container,
- labelText,
- comboListener,
- null,
- helpId
- );
- }
-
- /**
- * Creates a new container that will have the given center control labeled
- * with the given label.
- *
- * @param container The parent container
- * @param leftControl The widget shown to the left of the main widget
- * @param centerControl The main widget
- * @param labelProvider The provider responsible to convert the combo's items
- * into human readable strings
- * @param rightControl The control shown to the right of the main widget
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The newly created <code>CCombo</code>
- *
- * @category Layout
- */
- protected final Combo addLabeledEditableComboViewer(Composite container,
- String labelText,
- ModifyListener comboListener,
- ILabelProvider labelProvider,
- Control rightControl,
- String helpId) {
-
- ComboViewer comboViewer = this.addEditableComboViewer(
- container,
- labelProvider
- );
-
- Combo combo = comboViewer.getCombo();
- combo.addModifyListener(comboListener);
-
- this.addLabeledComposite(
- container,
- labelText,
- (combo.getParent() != container) ? combo.getParent() : combo,
- rightControl,
- helpId
- );
-
- return combo;
- }
-
- /**
- * Creates a new container that will have an editable combo labeled with the
- * given text.
- *
- * @param container The parent container
- * @param labelText The text of the label
- * @param comboListener The listener that will be notified when the selection
- * changes
- * @param labelProvider The provider responsible to convert the combo's items
- * into human readable strings
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The newly created <code>CCombo</code>
- *
- * @category Layout
- */
- protected final Combo addLabeledEditableComboViewer(Composite container,
- String labelText,
- ModifyListener comboListener,
- ILabelProvider labelProvider,
- String helpId) {
-
- return this.addLabeledEditableComboViewer(
- container,
- labelText,
- comboListener,
- labelProvider,
- null,
- helpId
- );
- }
-
- /**
- * Creates a new container that will have an editable combo labeled with the
- * given text.
- *
- * @param container The parent container
- * @param labelText The text of the label
- * @param listHolder The <code>ListValueHolder</code>
- * @param selectedItemHolder The holder of the selected item
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The newly created <code>CCombo</code>
- *
- * @category Layout
- */
- protected final <V> Combo addLabeledEditableCombo(Composite container,
- String labelText,
- ListValueModel<V> listHolder,
- ModifiablePropertyValueModel<V> selectedItemHolder,
- String helpId) {
-
- return this.addLabeledEditableCombo(
- container,
- labelText,
- listHolder,
- selectedItemHolder,
- StringConverter.Default.<V>instance(),
- null,
- helpId
- );
- }
-
- /**
- * Creates a new container that will have the given center control labeled
- * with the given label.
- *
- * @param container The parent container
- * @param labelText The text of the label
- * @param listHolder The <code>ListValueHolder</code>
- * @param selectedItemHolder The holder of the selected item
- * @param stringConverter The converter responsible to transform each item
- * into a string representation
- * @param rightControl The control shown to the right of the main widget
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The newly created <code>Combo</code>
- *
- * @category Layout
- */
- protected final <V> Combo addLabeledEditableCombo(Composite container,
- String labelText,
- ListValueModel<V> listHolder,
- ModifiablePropertyValueModel<V> selectedItemHolder,
- StringConverter<V> stringConverter,
- Control rightControl,
- String helpId) {
-
- Combo combo = this.addEditableCombo(
- container,
- listHolder,
- selectedItemHolder,
- stringConverter
- );
-
- this.addLabeledComposite(
- container,
- labelText,
- (combo.getParent() != container) ? combo.getParent() : combo,
- rightControl,
- helpId
- );
-
- return combo;
- }
-
- /**
- * Creates a new container that will have an editable combo labeled with the
- * given text.
- *
- * @param container The parent container
- * @param labelText The text of the label
- * @param listHolder The <code>ListValueHolder</code>
- * @param selectedItemHolder The holder of the selected item
- * @param stringConverter The converter responsible to transform each item
- * into a string representation
- * @param helpId The topic help ID to be registered for the given center
- * composite
- * @return The newly created <code>Combo</code>
- *
- * @category Layout
- */
- protected final <V> Combo addLabeledEditableCombo(Composite container,
- String labelText,
- ListValueModel<V> listHolder,
- ModifiablePropertyValueModel<V> selectedItemHolder,
- StringConverter<V> stringConverter,
- String helpId) {
-
- return this.addLabeledEditableCombo(
- container,
- labelText,
- listHolder,
- selectedItemHolder,
- stringConverter,
- null,
- helpId
- );
- }
-
- /**
- * Creates a new container that will have a text field as the center control
- * labeled with the given label.
- *
- * @param container The parent container
- * @param labelText The text area's label
- * @param textHolder The holder of the text field's input
- * @param lineCount The number of lines the text area should display
- * @param helpId The topic help ID to be registered for the text field
- * @return The newly created <code>Text</code>
- *
- * @category Layout
- */
- protected final Text addLabeledMultiLineText(Composite container,
- String labelText,
- ModifiablePropertyValueModel<String> textHolder,
- int lineCount,
- String helpId) {
-
- Text text = this.addMultiLineText(container, textHolder, lineCount);
-
- container = this.addLabeledComposite(
- container,
- labelText,
- text,
- helpId
- );
-
- int textHeight = text.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
-
- // Specify the number of lines the text area should display
- GridData gridData = (GridData) text.getLayoutData();
- gridData.heightHint = text.getLineHeight() * lineCount;
-
- // Move the label to the top of its cell
- Control label = container.getChildren()[0];
- int labelHeight = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
-
- gridData = (GridData) label.getLayoutData();
- gridData.verticalAlignment = SWT.TOP;
- gridData.verticalIndent += (Math.abs(textHeight - labelHeight) / 2);
-
- return text;
- }
-
- /**
- * Creates a new container that will have a text field as the center control
- * labeled with the given label.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @return The newly created <code>Text</code>
- *
- * @category Layout
- */
- protected final Text addLabeledPasswordText(Composite container,
- String labelText,
- ModifiablePropertyValueModel<String> textHolder) {
-
- return this.addLabeledPasswordText(
- container,
- labelText,
- textHolder,
- null
- );
- }
-
- /**
- * Creates a new container that will have a text field as the center control
- * labeled with the given label.
- *
- * @param container The parent container
- * @param labelText The text field's label
- * @param rightComponent The component to be placed to the right of the text
- * field
- * @param textHolder The holder of the text field's input
- * @param helpId The topic help ID to be registered for the text field
- * @return The newly created <code>Text</code>
- *
- * @category Layout
- */
- protected final Text addLabeledPasswordText(Composite container,
- String labelText,
- ModifiablePropertyValueModel<String> textHolder,
- Control rightControl,
- String helpId) {
-
- Text text = this.addPasswordText(container, textHolder);
-
- this.addLabeledComposite(
- container,
- labelText,
- text,
- rightControl,
- helpId
- );
-
- return text;
- }
-
- /**
- * Creates a new container that will have a text field as the center control
- * labeled with the given label.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @param helpId The topic help ID to be registered for the text field
- * @return The newly created <code>Text</code>
- *
- * @category Layout
- */
- protected final Text addLabeledPasswordText(Composite container,
- String labelText,
- ModifiablePropertyValueModel<String> textHolder,
- String helpId) {
-
- return this.addLabeledPasswordText(
- container,
- labelText,
- textHolder,
- null,
- helpId
- );
- }
-
- /**
- * Creates a new spinner.
- *
- * @param parent The parent container
- * @param labelText The label's text
- * @param numberHolder The holder of the integer value
- * @param defaultValue The value shown when the holder has <code>null</code>
- * @param minimumValue The minimum value that the spinner will allow
- * @param maximumValue The maximum value that the spinner will allow
- * @param rightControl The widget to be placed to the right of spinner
- * @param helpId The topic help ID to be registered for the spinner
- * @return The newly created <code>Spinner</code>
- *
- * @category Layout
- */
- protected final Spinner addLabeledSpinner(Composite parent,
- String labelText,
- ModifiablePropertyValueModel<Integer> numberHolder,
- int defaultValue,
- int minimumValue,
- int maximumValue,
- Control rightControl,
- String helpId) {
-
- Spinner spinner = this.addSpinner(
- parent,
- numberHolder,
- defaultValue,
- minimumValue,
- maximumValue,
- helpId
- );
- Label label = addLabel(parent, labelText);
- addLabeledComposite(
- parent,
- label,
- (spinner.getParent() != parent) ? spinner.getParent() : spinner,
- rightControl,
- helpId
- );
-
- GridData gridData = (GridData) spinner.getLayoutData();
- gridData.horizontalAlignment = GridData.BEGINNING;
-
- return spinner;
- }
-
- /**
- * Creates a new managed spinner. Managed means that this Pane will
- * handle enabling/disabling of this widget if a PaneEnabler is used.
- *
- * @param parent The parent container
- * @param numberHolder The holder of the integer value
- * @param defaultValue The value shown when the holder has <code>null</code>
- * @param minimumValue The minimum value that the spinner will allow
- * @param maximumValue The maximum value that the spinner will allow
- * @param helpId The topic help ID to be registered for the new button
- * @return The newly created <code>Spinner</code>
- *
- * @category Layout
- */
- protected final Spinner addSpinner(Composite parent,
- ModifiablePropertyValueModel<Integer> numberHolder,
- int defaultValue,
- int minimumValue,
- int maximumValue,
- String helpId) {
-
- Spinner spinner = addUnmanagedSpinner(parent, numberHolder, defaultValue, minimumValue, maximumValue, helpId);
- this.manageWidget(spinner);
- return spinner;
- }
-
- /**
- * Creates a new unmanaged spinner. Unmanaged means that this Pane will
- * not handle the enabling/disabling of this widget. The owning object will handle
- * it with its own PaneEnabler or ControlEnabler.
- *
- * @param parent The parent container
- * @param numberHolder The holder of the integer value
- * @param defaultValue The value shown when the holder has <code>null</code>
- * @param minimumValue The minimum value that the spinner will allow
- * @param maximumValue The maximum value that the spinner will allow
- * @param helpId The topic help ID to be registered for the new button
- * @return The newly created <code>Spinner</code>
- *
- * @category Layout
- */
- private Spinner addUnmanagedSpinner(Composite parent,
- ModifiablePropertyValueModel<Integer> numberHolder,
- int defaultValue,
- int minimumValue,
- int maximumValue,
- String helpId) {
-
- Spinner spinner = this.widgetFactory.createSpinner(parent);
- spinner.setMinimum(minimumValue);
- spinner.setMaximum(maximumValue);
- GridData gridData = getFieldGridData();
- gridData.grabExcessHorizontalSpace = false;
- spinner.setLayoutData(gridData);
-
- SpinnerModelAdapter.adapt(numberHolder, spinner, defaultValue);
-
- if (helpId != null) {
- getHelpSystem().setHelp(spinner, helpId);
- }
-
- return spinner;
- }
-
- /**
- * Creates a new managed DateTime of type SWT.TIME. Managed means that this Pane will
- * handle enabling/disabling of this widget if a PaneEnabler is used.
- *
- * @param parent The parent container
- * @param hoursHolder The holder of the hours integer value
- * @param minutesHolder The holder of the minutes integer value
- * @param secondsHolder The holder of the seconds integer value
- * @param helpId The topic help ID to be registered for the new dateTime
- * @return The newly created <code>DateTime</code>
- *
- * @category Layout
- */
- protected final DateTime addDateTime(Composite parent,
- ModifiablePropertyValueModel<Integer> hoursHolder,
- ModifiablePropertyValueModel<Integer> minutesHolder,
- ModifiablePropertyValueModel<Integer> secondsHolder,
- String helpId) {
-
- DateTime dateTime = this.addUnmanagedDateTime(parent, hoursHolder, minutesHolder, secondsHolder, helpId);
- this.manageWidget(dateTime);
-
- return dateTime;
- }
-
- protected final DateTime addDateTime(
- Composite parent,
- ModifiablePropertyValueModel<Integer> hoursHolder,
- ModifiablePropertyValueModel<Integer> minutesHolder,
- ModifiablePropertyValueModel<Integer> secondsHolder,
- String helpId,
- PropertyValueModel<Boolean> enabledModel
- ) {
- DateTime dateTime = this.addUnmanagedDateTime(parent, hoursHolder, minutesHolder, secondsHolder, helpId);
- this.controlEnabledState(enabledModel, dateTime);
- return dateTime;
- }
-
- /**
- * Creates a new unmanaged DateTime of type SWT.TIME. Unmanaged means that this Pane will
- * not handle the enabling/disabling of this widget. The owning object will handle
- * it with its own PaneEnabler or ControlEnabler.
- *
- * @param parent The parent container
- * @param hoursHolder The holder of the hours integer value
- * @param minutesHolder The holder of the minutes integer value
- * @param secondsHolder The holder of the seconds integer value
- * @param helpId The topic help ID to be registered for the new dateTime
- * @return The newly created <code>DateTime</code>
- *
- * @category Layout
- */
- private DateTime addUnmanagedDateTime(Composite parent,
- ModifiablePropertyValueModel<Integer> hoursHolder,
- ModifiablePropertyValueModel<Integer> minutesHolder,
- ModifiablePropertyValueModel<Integer> secondsHolder,
- String helpId) {
-
- DateTime dateTime = this.widgetFactory.createDateTime(parent, SWT.TIME);
-
- DateTimeModelAdapter.adapt(hoursHolder, minutesHolder, secondsHolder, dateTime);
-
- if (helpId != null) {
- getHelpSystem().setHelp(dateTime, helpId);
- }
-
- return dateTime;
- }
- /**
- * Creates a new editable <code>Combo</code>.
- *
- * @param container The parent container
- * @param listHolder The <code>ListValueHolder</code>
- * @param selectedItemHolder The holder of the selected item
- * @param stringConverter The converter responsible to transform each item
- * into a string representation
- * @return The newly created <code>CCombo</code>
- *
- * @category Layout
- */
- private <V> Combo addUnmanagedEditableCombo(Composite container,
- ListValueModel<V> listHolder,
- ModifiablePropertyValueModel<V> selectedItemHolder,
- StringConverter<V> stringConverter) {
-
- Combo combo = addUnmanagedEditableCombo(container);
-
- ComboModelAdapter.adapt(
- listHolder,
- selectedItemHolder,
- combo,
- stringConverter
- );
-
- return combo;
- }
-
-
- /**
- * Creates a new editable <code>Combo</code>.
- *
- * @param container The parent container
- * @return The newly created <code>CCombo</code>
- *
- * @category Layout
- */
- private Combo addUnmanagedEditableCombo(Composite container) {
-
- Combo combo = this.widgetFactory.createEditableCombo(container);
- combo.setLayoutData(getFieldGridData());
- return combo;
- }
-
- /**
- * Creates a new container that will have a text field as the center control
- * labeled with the given label.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @return The newly created <code>Text</code>
- *
- * @category Layout
- */
- protected final Text addLabeledText(Composite container,
- String labelText,
- ModifiablePropertyValueModel<String> textHolder) {
-
- return this.addLabeledText(container, labelText, textHolder, null);
- }
-
- /**
- * Creates a new container that will have a text field as the center control
- * labeled with the given label.
- *
- * @param container The parent container
- * @param labelText The text field's label
- * @param rightComponent The component to be placed to the right of the text
- * field
- * @param textHolder The holder of the text field's input
- * @param helpId The topic help ID to be registered for the text field
- * @return The newly created <code>Text</code>
- *
- * @category Layout
- */
- protected final Text addLabeledText(Composite container,
- String labelText,
- ModifiablePropertyValueModel<String> textHolder,
- Control rightComponent,
- String helpId) {
-
- Text text = this.addText(container, textHolder);
-
- this.addLabeledComposite(
- container,
- labelText,
- text,
- rightComponent,
- helpId
- );
-
- return text;
- }
- /**
- *
- * Creates a new container that will have a text field as the center control
- * labeled with the given label.
- *
- * @param container The parent container
- * @param labelText The text field's label
- * @param rightComponent The component to be placed to the right of the text
- * field
- * @param textHolder The holder of the text field's input
- * @param helpId The topic help ID to be registered for the text field
- * @return The newly created <code>Text</code>
- *
- * @category Layout
- */
- protected final Text addLabeledText(Composite container,
- Label label,
- ModifiablePropertyValueModel<String> textHolder,
- Control rightComponent,
- String helpId) {
-
- Text text = this.addText(container, textHolder);
-
- this.addLabeledComposite(
- container,
- label,
- text,
- rightComponent,
- helpId
- );
-
- return text;
- }
-
- /**
- * Creates a new container that will have a text field as the center control
- * labeled with the given label.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @param helpId The topic help ID to be registered for the text field
- * @return The newly created <code>Text</code>
- *
- * @category Layout
- */
- protected final Text addLabeledText(Composite container,
- String labelText,
- ModifiablePropertyValueModel<String> textHolder,
- String helpId) {
-
- return this.addLabeledText(
- container,
- labelText,
- textHolder,
- null,
- helpId
- );
- }
-
- /**
- * Creates a new container that will have a text field as the center control
- * labeled with the given label.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @param helpId The topic help ID to be registered for the text field
- * @return The newly created <code>Text</code>
- *
- * @category Layout
- */
- protected final Text addLabeledText(Composite container,
- Label label,
- ModifiablePropertyValueModel<String> textHolder,
- String helpId) {
-
- return this.addLabeledText(
- container,
- label,
- textHolder,
- null,
- helpId
- );
- }
-
- /**
- * Creates a new list and notify the given selection holder when the
- * selection changes. If the selection count is different than one than the
- * holder will receive <code>null</code>.
- *
- * @param container The parent container
- * @param helpId The topic help ID to be registered for the new radio button
- * @return The newly created <code>List</code>
- *
- * @category Layout
- */
- protected final List addList(Composite container, String helpId) {
-
- return this.addList(
- container,
- new SimplePropertyValueModel<String>(),
- helpId
- );
- }
-
- /**
- * Creates a new list and notify the given selection holder when the
- * selection changes. If the selection count is different than one than the
- * holder will receive <code>null</code>.
- *
- * @param container The parent container
- * @param selectionHolder The holder of the unique selected item
- * @param helpId The topic help ID to be registered for the new radio button
- * @return The newly created <code>List</code>
- *
- * @category Layout
- */
- protected final List addList(Composite container,
- ModifiablePropertyValueModel<String> selectionHolder,
- String helpId) {
-
- List list = this.addUnmanagedList(container, selectionHolder, helpId);
- this.manageWidget(list);
-
- return list;
- }
-
- /**
- * Creates a new unmanaged list and notify the given selection holder when the
- * selection changes. If the selection count is different than one than the
- * holder will receive <code>null</code>.
- * Unmanaged means that this Pane will not handle the enabling/disabling of this widget.
- * The owning object will handle it with its own PaneEnabler or ControlEnabler.
- *
- * @param container The parent container
- * @param selectionHolder The holder of the unique selected item
- * @param helpId The topic help ID to be registered for the new radio button
- * @return The newly created <code>List</code>
- *
- * @category Layout
- */
- private List addUnmanagedList(Composite container,
- ModifiablePropertyValueModel<String> selectionHolder,
- String helpId) {
-
- List list = this.widgetFactory.createList(
- container,
- SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI
- );
-
- list.addSelectionListener(buildSelectionListener(selectionHolder));
- list.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- if (helpId != null) {
- getHelpSystem().setHelp(list, helpId);
- }
-
- return list;
- }
-
- /**
- * Creates a new lable expanding on multiple lines.
- *
- * @param parent The parent container
- * @param labelText The label's text
- *
- * @category Layout
- */
- protected final FormText addMultiLineLabel(Composite container,
- String labelText) {
-
- FormText label = this.widgetFactory.createMultiLineLabel(container, labelText);
- manageWidget(label);
- return label;
- }
-
- /**
- * Creates a new <code>Text</code> widget that has multiple lines.
- *
- * @param container The parent container
- * @return The newly created <code>Text</code> widget
- *
- */
- protected final Text addMultiLineText(Composite container) {
-
- Text text = this.widgetFactory.createMultiLineText(container);
- text.setLayoutData(getFieldGridData());
- this.manageWidget(text);
-
- return text;
- }
-
- /**
- * Creates a new <code>Text</code> widget that has multiple lines.
- *
- * @param container The parent container
- * @param lineCount The number of lines the text area should display
- * @param helpId The topic help ID to be registered for the new text
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- protected final Text addMultiLineText(Composite container,
- int lineCount,
- String helpId) {
-
- Text text = this.addMultiLineText(container);
- adjustMultiLineTextLayout(container, lineCount, text, text.getLineHeight());
-
- if (helpId != null) {
- getHelpSystem().setHelp(text, helpId);
- }
-
- return text;
- }
-
- /**
- * Creates a new <code>Text</code> widget that has multiple lines.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @param lineCount The number of lines the text area should display
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- protected final Text addMultiLineText(Composite container,
- ModifiablePropertyValueModel<String> textHolder,
- int lineCount) {
-
- return this.addMultiLineText(container, textHolder, lineCount, null);
- }
-
- /**
- * Creates a new <code>Text</code> widget that has multiple lines.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @param helpId The topic help ID to be registered for the new text
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- protected final Text addMultiLineText(Composite container,
- ModifiablePropertyValueModel<String> textHolder,
- int lineCount,
- String helpId) {
-
- Text text = this.addMultiLineText(container, lineCount, helpId);
- SWTTools.bind(textHolder, text);
- return text;
- }
-
- /**
- * Adjusts the layout of the given container so that the text control has the correct amount of
- * lines by default.
- */
- protected final void adjustMultiLineTextLayout(Composite container,
- int lineCount,
- Control text,
- int lineHeight) {
-
- int textHeight = text.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
-
- // Specify the number of lines the text area should display
- GridData gridData = (GridData) text.getLayoutData();
- if (gridData == null) {
- gridData = this.getFieldGridData();
- text.setLayoutData(gridData);
- }
- gridData.heightHint = lineHeight * lineCount;
-
- // Move the label to the top of its cell
- Control label = container.getChildren()[0];
- int labelHeight = label.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
-
- gridData = (GridData) label.getLayoutData();
- gridData.verticalAlignment = SWT.TOP;
- gridData.verticalIndent += (Math.abs(textHeight - labelHeight) / 2);
- }
- /**
- * Creates a new <code>PageBook</code> and set the proper layout and layout
- * data.
- *
- * @param container The parent container
- * @return The newly created <code>PageBook</code>
- *
- * @category Layout
- */
- protected final PageBook addPageBook(Composite container) {
-
- PageBook pageBook = new PageBook(container, SWT.NULL);
- pageBook.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- return pageBook;
- }
-
- /**
- * Creates a new container without specifying any layout manager.
- *
- * @param container The parent of the new container
- * @return The newly created <code>Composite</code>
- *
- * @category Layout
- */
- protected final Composite addPane(Composite parent) {
- return this.widgetFactory.createComposite(parent);
- }
-
- /**
- * Creates a new container using the given layout manager.
- *
- * @param parent The parent of the new container
- * @param layout The layout manager of the new container
- * @return The newly created container
- *
- * @category Layout
- */
- protected final Composite addPane(Composite container, Layout layout) {
-
- container = this.addPane(container);
- container.setLayout(layout);
- container.setLayoutData(new GridData(GridData.FILL_BOTH));
- return container;
- }
-
- /**
- * Creates a new <code>Text</code> widget.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- protected final Text addPasswordText(Composite container,
- ModifiablePropertyValueModel<String> textHolder) {
-
- Text text = this.addPasswordText(container);
- SWTTools.bind(textHolder, text);
-
- return text;
- }
-
- /**
- * Creates a new <code>Text</code> widget.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- protected final Text addPasswordText(Composite container) {
-
- Text text = this.widgetFactory.createPasswordText(container);
- text.setLayoutData(getFieldGridData());
-
- this.manageWidget(text);
- return text;
- }
-
- /**
- * Creates a new push button using the given information.
- *
- * @param parent The parent container
- * @param buttonText The button's text
- * @param buttonAction The action to be invoked when the button is pressed
- * @return The newly created <code>Button</code>
- *
- * @category Layout
- */
- protected final Button addPushButton(Composite parent,
- String buttonText,
- final Runnable buttonAction) {
-
- return this.addPushButton(parent, buttonText, null, buttonAction);
- }
-
- /**
- * Creates a new push button using the given information.
- *
- * @param parent The parent container
- * @param buttonText The button's text
- * @param buttonAction The action to be invoked when the button is pressed
- * @param helpId The topic help ID to be registered for the new radio button
- * @return The newly created <code>Button</code>
- *
- * @category Layout
- */
- protected final Button addPushButton(Composite parent,
- String buttonText,
- String helpId,
- final Runnable buttonAction) {
-
- Button button = this.widgetFactory.createPushButton(parent, buttonText);
- manageWidget(button);
- button.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- buttonAction.run();
- }
- });
-
- button.setLayoutData(new GridData());
-
- if (helpId != null) {
- getHelpSystem().setHelp(button, helpId);
- }
-
- return button;
- }
-
- /**
- * Creates a new check box using the given information.
- *
- * @param parent The parent container
- * @param buttonText The button's text
- * @param booleanHolder The holder of the selection state
- * @param helpId The topic help ID to be registered for the new radio button
- * @return The newly created <code>Button</code>
- *
- * @category Layout
- */
- protected final Button addRadioButton(Composite parent,
- String buttonText,
- ModifiablePropertyValueModel<Boolean> booleanHolder,
- String helpId) {
-
- return this.addToggleButton(
- parent,
- buttonText,
- booleanHolder,
- helpId,
- SWT.RADIO
- );
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addSection(Composite container,
- String sectionText) {
-
- return this.addSection(
- container,
- sectionText,
- ExpandableComposite.TITLE_BAR
- );
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param type The type of section to create
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- private Composite addSection(Composite container,
- String sectionText,
- int type) {
-
- return this.addSection(container, sectionText, null, type);
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param description The section's description
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addSection(Composite container,
- String sectionText,
- String description) {
-
- return this.addSection(
- container,
- sectionText,
- description,
- ExpandableComposite.TITLE_BAR
- );
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client and is the returned <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @param description The section's description or <code>null</code> if none
- * was provider
- * @param type The type of section to create
- * @param expandedStateHolder The holder of the boolean that will dictate
- * when to expand or collapse the section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- private Composite addSection(Composite container,
- String sectionText,
- String description,
- int type) {
-
- Section section = this.widgetFactory.createSection(container, type | ((description != null) ? Section.DESCRIPTION : SWT.NULL));
- section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- section.setText(sectionText);
- section.marginWidth = 0;
- section.marginHeight = 0;
-
- if (description != null) {
- section.setDescription(description);
- }
-
- Composite subPane = this.addSubPane(section);
- section.setClient(subPane);
-
- return subPane;
- }
-
- private SelectionListener buildSelectionListener(final ModifiablePropertyValueModel<String> selectionHolder) {
- return new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- List list = (List) e.widget;
- String[] selectedItems = list.getSelection();
- if ((selectedItems == null) || (selectedItems.length != 1)) {
- selectionHolder.setValue(null);
- }
- else {
- selectionHolder.setValue(selectedItems[0]);
- }
- }
- };
- }
-
- /**
- * Creates the layout responsible to compute the size of the spacer created
- * for the right control when none was given. The spacer helps to align all
- * the right controls.
- *
- * @category Layout
- */
- private Layout buildSpacerLayout() {
- return new Layout() {
- @Override
- protected Point computeSize(Composite composite,
- int widthHint,
- int heightHint,
- boolean flushCache) {
-
- return new Point(widthHint, heightHint);
- }
-
- @Override
- protected void layout(Composite composite, boolean flushCache) {
- GridData data = (GridData) composite.getLayoutData();
- composite.setBounds(0, 0, data.widthHint, data.heightHint);
- }
- };
- }
-
- private PropertyChangeListener buildSubjectChangeListener() {
- return new SWTPropertyChangeListenerWrapper(this.buildSubjectChangeListener_());
- }
-
- private PropertyChangeListener buildSubjectChangeListener_() {
- return new PropertyChangeListener() {
- @SuppressWarnings("unchecked")
- public void propertyChanged(PropertyChangeEvent e) {
- Pane.this.subjectChanged((T) e.getOldValue(), (T) e.getNewValue());
- }
- };
- }
-
- /**
- * Creates a new <code>Composite</code> used as a sub-pane.
- *
- * @param container The parent container
- * @return The newly created <code>Composite</code> used as a sub-pane
- *
- * @category Layout
- */
- protected final Composite addSubPane(Composite container) {
- return this.addSubPane(container, 0);
- }
-
- /**
- * Creates a new <code>Composite</code> used as a sub-pane.
- *
- * @param container The parent container
- * @param topMargin The extra spacing to add at the top of the pane
- * @return The newly created <code>Composite</code> used as a sub-pane
- *
- * @category Layout
- */
- protected final Composite addSubPane(Composite container, int topMargin) {
- return this.addSubPane(container, topMargin, 0);
- }
-
- /**
- * Creates a new <code>Composite</code> used as a sub-pane.
- *
- * @param container The parent container
- * @param topMargin The extra spacing to add at the top of the pane
- * @param leftMargin The extra spacing to add to the left of the pane
- * @return The newly created <code>Composite</code> used as a sub-pane
- *
- * @category Layout
- */
- protected final Composite addSubPane(Composite container,
- int topMargin,
- int leftMargin) {
-
- return this.addSubPane(container, topMargin, leftMargin, 0, 0);
- }
-
- /**
- * Creates a new <code>Composite</code> used as a sub-pane, the new widget
- * will have its layout and layout data already initialized, the layout will
- * be a <code>GridLayout</code> with 1 column.
- *
- * @param container The parent container
- * @param topMargin The extra spacing to add at the top of the pane
- * @param leftMargin The extra spacing to add to the left of the pane
- * @param bottomMargin The extra spacing to add at the bottom of the pane
- * @param rightMargin The extra spacing to add to the right of the pane
- * @return The newly created <code>Composite</code> used as a sub-pane
- *
- * @category Layout
- */
- protected final Composite addSubPane(Composite container,
- int topMargin,
- int leftMargin,
- int bottomMargin,
- int rightMargin) {
-
- return this.addSubPane(
- container,
- 1,
- topMargin,
- leftMargin,
- bottomMargin,
- rightMargin);
- }
-
- /**
- * Creates a new <code>Composite</code> used as a sub-pane, the new widget
- * will have its layout and layout data already initialized, the layout will
- * be a <code>GridLayout</code> with 1 column.
- *
- * @param container The parent container
- * @param topMargin The extra spacing to add at the top of the pane
- * @param leftMargin The extra spacing to add to the left of the pane
- * @param bottomMargin The extra spacing to add at the bottom of the pane
- * @param rightMargin The extra spacing to add to the right of the pane
- * @return The newly created <code>Composite</code> used as a sub-pane
- *
- * @category Layout
- */
- protected final Composite addSubPane(Composite container,
- int columnCount,
- int topMargin,
- int leftMargin,
- int bottomMargin,
- int rightMargin) {
-
- GridLayout layout = new GridLayout(columnCount, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.marginTop = topMargin;
- layout.marginLeft = leftMargin;
- layout.marginBottom = bottomMargin;
- layout.marginRight = rightMargin;
-
- container = this.addPane(container, layout);
-
- return container;
- }
-
- /**
- * Creates a new <code>Section</code>. A sub-pane is automatically added as
- * its client which can be typed cast directly as a <code>Composite</code>.
- *
- * @param container The container of the new widget
- * @param sectionText The text of the new section
- * @return The <code>Section</code>'s sub-pane
- *
- * @category Layout
- */
- protected final Composite addSubSection(Composite container,
- String sectionText) {
-
- return this.addCollapsibleSubSection(
- container,
- sectionText,
- new SimplePropertyValueModel<Boolean>(Boolean.TRUE)
- );
- }
-
- /**
- * Creates a new table.
- *
- * @param container The parent container
- * @param style The style to apply to the table
- * @param helpId The topic help ID to be registered for the new table or
- * <code>null</code> if no help ID is required
- * @return The newly created <code>Table</code>
- *
- * @category Layout
- */
- protected final Table addTable(Composite container,
- int style,
- String helpId) {
-
- Table table = addUnmanagedTable(container, style, helpId);
- this.manageWidget(table);
-
- return table;
- }
- /**
- * Creates a new unmanaged table. Unmanaged means that this Pane will
- * not handle the enabling/disabling of this widget. The owning object will handle
- * it with its own PaneEnabler or ControlEnabler.
- *
- * @param container The parent container
- * @param style The style to apply to the table
- * @param helpId The topic help ID to be registered for the new table or
- * <code>null</code> if no help ID is required
- * @return The newly created <code>Table</code>
- *
- * @category Layout
- */
- protected final Table addUnmanagedTable(Composite container,
- int style,
- String helpId) {
-
- Table table = this.widgetFactory.createTable(container, style);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- GridData gridData = new GridData(GridData.FILL_BOTH);
- gridData.heightHint = table.getItemHeight() * 4;
- table.setLayoutData(gridData);
-
- if (helpId != null) {
- getHelpSystem().setHelp(table, helpId);
- }
-
- return table;
- }
-
- /**
- * Creates a new table.
- *
- * @param container The parent container
- * @param helpId The topic help ID to be registered for the new table or
- * <code>null</code> if no help ID is required
- * @return The newly created <code>Table</code>
- *
- * @category Layout
- */
- protected final Table addTable(Composite container, String helpId) {
-
- return this.addTable(
- container,
- SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI,
- helpId
- );
- }
-
- /**
- * Creates a new unmanaged table. Unmanaged means that this Pane will
- * not handle the enabling/disabling of this widget. The owning object will handle
- * it with its own PaneEnabler or ControlEnabler.
- *
- * @param container The parent container
- * @param helpId The topic help ID to be registered for the new table or
- * <code>null</code> if no help ID is required
- * @return The newly created <code>Table</code>
- *
- * @category Layout
- */
- protected final Table addUnmanagedTable(Composite container, String helpId) {
-
- return this.addUnmanagedTable(
- container,
- SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI,
- helpId
- );
- }
-
- /**
- * Creates a new managed <code>Text</code> widget.
- *
- * @param container The parent container
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- protected final Text addText(Composite container) {
- Text text = this.addUnmanagedText(container);
- this.manageWidget(text);
- return text;
- }
-
- /**
- * Creates a new unmanaged <code>Text</code> widget. Unmanaged means
- * that this Pane will not handle the enabling/disabling of this widget.
- * The owning object will handle it with its own PaneEnabler or ControlEnabler.
- *
- * @param container The parent container
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- private Text addUnmanagedText(Composite container) {
- Text text = this.widgetFactory.createText(container);
- text.setLayoutData(getFieldGridData());
- return text;
- }
-
- /**
- * Creates a new <code>Text</code> widget.
- *
- * @param container The parent container
- * @param helpId The topic help ID to be registered for the new text
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- protected final Text addText(Composite container, String helpId) {
-
- Text text = this.addText(container);
-
- if (helpId != null) {
- getHelpSystem().setHelp(text, helpId);
- }
-
- return text;
- }
-
- /**
- * Creates a new unmanaged <code>Text</code> widget. Unmanaged means
- * that this Pane will not handle the enabling/disabling of this widget.
- * The owning object will handle it with its own PaneEnabler or ControlEnabler.
- *
- * @param container The parent container
- * @param helpId The topic help ID to be registered for the new text
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- private Text addUnmanagedText(Composite container, String helpId) {
-
- Text text = this.addUnmanagedText(container);
-
- if (helpId != null) {
- getHelpSystem().setHelp(text, helpId);
- }
-
- return text;
- }
-
- /**
- * Creates a new <code>Text</code> widget.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- protected final Text addText(Composite container,
- ModifiablePropertyValueModel<String> textHolder) {
-
- return this.addText(container, textHolder, null);
- }
-
- /**
- * Creates a new <code>Text</code> widget.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @param helpId The topic help ID to be registered for the new text
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- protected final Text addText(Composite container,
- ModifiablePropertyValueModel<String> textHolder,
- String helpId) {
-
- Text text = this.addText(container, helpId);
- SWTTools.bind(textHolder, text);
-
- return text;
- }
-
- protected final Text addText(
- Composite container,
- ModifiablePropertyValueModel<String> textHolder,
- String helpId,
- PropertyValueModel<Boolean> enabledModel
- ) {
- Text text = this.addUnmanagedText(container, textHolder, helpId);
- this.controlEnabledState(enabledModel, text);
- return text;
- }
-
- /**
- * Creates a new unmanaged <code>Text</code> widget. Unmanaged means
- * that this Pane will not handle the enabling/disabling of this widget.
- * The owning object will handle it with its own PaneEnabler or ControlEnabler.
- *
- * @param container The parent container
- * @param textHolder The holder of the text field's input
- * @param helpId The topic help ID to be registered for the new text
- * @return The newly created <code>Text</code> widget
- *
- * @category Layout
- */
- private Text addUnmanagedText(Composite container,
- ModifiablePropertyValueModel<String> textHolder,
- String helpId) {
-
- Text text = this.addUnmanagedText(container, helpId);
- SWTTools.bind(textHolder, text);
-
- return text;
- }
-
- /**
- * Creates a new container with a titled border.
- *
- * @param title The text of the titled border
- * @param container The parent container
- * @return The newly created <code>Composite</code> with a titled border
- *
- * @category Layout
- */
- protected final Group addTitledGroup(Composite container, String title) {
- return this.addTitledGroup(container, title, null);
- }
-
- /**
- * Creates a new container with a titled border.
- *
- * @param title The text of the titled border
- * @param container The parent container
- * @param helpId The topic help ID to be registered for the new group
- * @return The newly created <code>Composite</code> with a titled border
- *
- * @category Layout
- */
- protected final Group addTitledGroup(Composite container,
- String title,
- String helpId) {
-
- return addTitledGroup(container, title, 1, helpId);
- }
-
- /**
- * Creates a new container with a titled border.
- *
- * @param title The text of the titled border
- * @param container The parent container
- * @param helpId The topic help ID to be registered for the new group
- * @return The newly created <code>Composite</code> with a titled border
- *
- * @category Layout
- */
- protected final Group addTitledGroup(Composite container,
- String title,
- int columnCount,
- String helpId) {
-
- Group group = this.widgetFactory.createGroup(container, title);
- //manageWidget(group); TODO unsure if I want to manage groups,
- //also should probably rename this addUnmanagedTitledPane
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridLayout layout = new GridLayout(columnCount, false);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.marginTop = 5;
- layout.marginLeft = 5;
- layout.marginBottom = 5;
- layout.marginRight = 5;
- group.setLayout(layout);
-
- if (helpId != null) {
- getHelpSystem().setHelp(group, helpId);
- }
-
- return group;
- }
-
- /**
- * Creates a new unmanaged new toggle button (radio button or check box).
- * Unmanaged means that this Pane will not handle the enabling/disabling
- * of this widget. The owning object will handle it with its own PaneEnabler
- * or ControlEnabler.
- *
- * @param parent The parent container
- * @param buttonText The button's text
- * @param booleanHolder The holder of the selection state
- * @param helpId The topic help ID to be registered for the new button
- * @return The newly created <code>Button</code>
- *
- * @category Layout
- */
- private Button addUnmanagedToggleButton(
- Composite parent,
- String buttonText,
- ModifiablePropertyValueModel<Boolean> booleanHolder,
- String helpId,
- int toggleButtonType) {
-
- Button button;
-
- if (toggleButtonType == SWT.PUSH) {
- button = this.widgetFactory.createPushButton(parent, buttonText);
- }
- else if (toggleButtonType == SWT.RADIO) {
- button = this.widgetFactory.createRadioButton(parent, buttonText);
- }
- else if (toggleButtonType == SWT.CHECK) {
- button = this.widgetFactory.createCheckBox(parent, buttonText);
- }
- else {
- button = this.widgetFactory.createButton(parent, buttonText);
- }
-
- button.setLayoutData(new GridData());
- SWTTools.bind(booleanHolder, button);
-
- if (helpId != null) {
- getHelpSystem().setHelp(button, helpId);
- }
-
- return button;
- }
-
- /**
- * Creates a new toggle button (radio button or check box) using the given
- * information.
- *
- * @param parent The parent container
- * @param buttonText The button's text
- * @param booleanHolder The holder of the selection state
- * @param helpId The topic help ID to be registered for the new button
- * @return The newly created <code>Button</code>
- *
- * @category Layout
- */
- private Button addToggleButton(
- Composite parent,
- String buttonText,
- ModifiablePropertyValueModel<Boolean> booleanHolder,
- String helpId,
- int toggleButtonType) {
-
- Button button = addUnmanagedToggleButton(
- parent,
- buttonText,
- booleanHolder,
- helpId,
- toggleButtonType);
- this.manageWidget(button);
- return button;
- }
-
- /**
- * Creates a new check box that can have 3 selection states (selected,
- * unselected and partially selected.
- *
- * @param parent The parent container
- * @param text The button's text
- * @param booleanHolder The holder of the boolean value where <code>null</code>
- * means partially selected
- * @param helpId The topic help ID to be registered for the new check box
- * @return The newly created <code>TriStateCheckBox</code>
- *
- * @category Layout
- */
- protected final TriStateCheckBox addTriStateCheckBox(Composite parent,
- String text,
- ModifiablePropertyValueModel<Boolean> booleanHolder,
- String helpId) {
-
- TriStateCheckBox checkBox = new TriStateCheckBox(
- parent,
- text,
- this.getWidgetFactory()
- );
-
- this.manageWidget(checkBox.getCheckBox());
-
- TriStateCheckBoxModelAdapter.adapt(
- booleanHolder,
- checkBox
- );
-
- if (helpId != null) {
- getHelpSystem().setHelp(checkBox.getCheckBox(), helpId);
- }
-
- return checkBox;
- }
-
- /**
- * Creates a new check box that can have 3 selection states (selected,
- * unselected and partially selected.
- *
- * @param parent The parent container
- * @param text The button's text
- * @param booleanHolder The holder of the boolean value where <code>null</code>
- * means partially selected
- * @param stringHolder The holder of the string to put in parenthesis after
- * the check box's text when it is partially selected
- * @param helpId The topic help ID to be registered for the new check box
- * @return The newly created <code>TriStateCheckBox</code>
- *
- * @category Layout
- */
- protected final TriStateCheckBox addTriStateCheckBoxWithDefault(Composite parent,
- String text,
- ModifiablePropertyValueModel<Boolean> booleanHolder,
- PropertyValueModel<String> stringHolder,
- String helpId) {
-
- TriStateCheckBox checkBox = this.addTriStateCheckBox(
- parent,
- text,
- booleanHolder,
- helpId
- );
-
- new LabeledControlUpdater(
- new LabeledButton(checkBox.getCheckBox()),
- stringHolder
- );
-
- return checkBox;
- }
-
- /**
- * Requests this pane to populate its widgets with the subject's values.
- *
- * @category Populate
- */
- protected void doPopulate() {
- this.log(Tracing.UI_LAYOUT, " ->doPopulate()");
- }
-
- private void controlEnabledState(PropertyValueModel<Boolean> booleanModel, Control... controls) {
- this.controlEnabledState_(this.wrapEnabledModel(booleanModel), controls);
- }
-
- /**
- * Assume the "enabled" models can return null (which is typical with aspect
- * adapters etc.).
- */
- private PropertyValueModel<Boolean> wrapEnabledModel(PropertyValueModel<Boolean> booleanModel) {
- return new TransformationPropertyValueModel<Boolean, Boolean>(booleanModel, NonNullBooleanTransformer.FALSE);
- }
-
- private void controlEnabledState_(PropertyValueModel<Boolean> booleanModel, Control... controls) {
- SWTTools.controlEnabledState(this.andEnabledModel(booleanModel), controls);
- }
-
- private PropertyValueModel<Boolean> getCombinedEnabledModel() {
- return (this.combinedEnabledModel != null) ? this.combinedEnabledModel : this.baseEnabledModel;
- }
-
- private boolean getCombinedEnablement() {
- Boolean enabled = getCombinedEnabledModel().getValue();
- return (enabled == null) ? true : enabled.booleanValue();
- }
-
- private PropertyValueModel<Boolean> andEnabledModel(PropertyValueModel<Boolean> booleanModel) {
- return CompositeBooleanPropertyValueModel.and(getCombinedEnabledModel(), booleanModel);
- }
-
- protected void controllerEnablementChanged() {
- enableWidgets_(getCombinedEnablement());
- }
-
- /**
- * Changes the enablement state of the widgets of this pane.
- *
- * @param enabled <code>true</code> to enable the widgets or <code>false</code>
- * to disable them
- *
- * @category Layout
- */
- public void enableWidgets(boolean enabled) {
- this.baseEnabledModel.setValue(Boolean.valueOf(enabled));
- enableWidgets_(getCombinedEnablement());
- }
-
- private void enableWidgets_(boolean enabled) {
- if (! this.container.isDisposed()) {
- for (Control control : this.managedWidgets) {
- control.setEnabled(enabled);
- }
-
- for (Pane<?> subPane : this.managedSubPanes) {
- subPane.enableWidgets(enabled);
- }
- }
- }
-
- private void engageSubjectHolder() {
- this.subjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
- }
-
- /**
- * engage the specified subject
- */
- protected void engageListeners(T subject) {
- if (subject != null) {
- this.engageListeners_(subject);
- }
- }
-
- /**
- * specified subject is not null
- */
- protected void engageListeners_(T subject) {
- this.log(Tracing.UI_LAYOUT, " ->engageListeners_(" + subject + ')');
-
- for (String propertyName : this.getPropertyNames()) {
- subject.addPropertyChangeListener(propertyName, this.aspectChangeListener);
- }
- }
-
- /**
- * disengage the specified subject
- */
- protected void disengageListeners(T subject) {
- if (subject != null) {
- this.disengageListeners_(subject);
- }
- }
-
- /**
- * specified subject is not null
- */
- protected void disengageListeners_(T subject) {
- this.log(Tracing.UI_LAYOUT, " ->disengageListeners_(" + subject + ')');
-
- for (String propertyName : this.getPropertyNames()) {
- subject.removePropertyChangeListener(propertyName, this.aspectChangeListener);
- }
- }
-
- private void disengageSubjectHolder() {
- this.subjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.subjectChangeListener);
- }
-
- /**
- * Returns the main <code>Control</code> of this pane.
- *
- * @return The main container
- *
- * @category Layout
- */
- public Composite getControl() {
- return this.container;
- }
-
- /**
- * Returns the subject holder used by this pane.
- *
- * @return The holder of the subject
- *
- * @category Populate
- */
- protected final PropertyValueModel<T> getSubjectHolder() {
- return this.subjectHolder;
- }
-
- /**
- * Returns the factory responsible for creating the widgets.
- *
- * @return The factory used by this pane to create the widgets
- *
- * @category Layout
- */
- protected final WidgetFactory getWidgetFactory() {
- return this.widgetFactory;
- }
-
- /**
- * Returns the margin taken by a group box, which is the number of pixel the
- * group box border and its margin takes before displaying its widgets plus
- * 5 pixels since the widgets inside of the group box and the border should
- * have that extra 5 pixels.
- *
- * @return The width taken by the group box border with its margin
- *
- * @category Layout
- */
- protected final int getGroupBoxMargin() {
- Group group = this.widgetFactory.createGroup(SWTUtil.getShell(), "");
- Rectangle clientArea = group.getClientArea();
- group.dispose();
- return clientArea.x + 5;
- }
-
- /**
- * Returns the helps system.
- *
- * @return The platform's help system
- *
- * @category Helper
- */
- protected final IWorkbenchHelpSystem getHelpSystem() {
- return PlatformUI.getWorkbench().getHelpSystem();
- }
-
-
- /**
- * Determines whether
- *
- * @return
- *
- * @category Populate
- */
- protected final boolean isPopulating() {
- return this.populating;
- }
-
- /**
- * Logs the given message if the <code>Tracing.DEBUG_LAYOUT</code> is enabled.
- *
- * @param flag
- * @param message The logging message
- */
- protected void log(String flag, String message) {
- if (flag.equals(Tracing.UI_LAYOUT) && Tracing.booleanDebugOption(Tracing.UI_LAYOUT)) {
- this.log(message);
- }
- }
-
- protected void log(String message) {
- Class<?> thisClass = this.getClass();
- String className = thisClass.getSimpleName();
-
- if (thisClass.isAnonymousClass()) {
- className = className.substring(0, className.indexOf('$'));
- className += "->" + thisClass.getSuperclass().getSimpleName();
- }
-
- Tracing.log(className + ": " + message);
- }
-
- /**
- * Notifies this pane to populate itself using the subject's information.
- *
- * @category Populate
- */
- private void populate() {
- if (!this.container.isDisposed()) {
- this.log(Tracing.UI_LAYOUT, "populate()");
- this.repopulate();
- }
- }
-
- /**
- * Notifies the subject's property associated with the given property name
- * has changed.
- *
- * @param propertyName The property name associated with the property change
- *
- * @category Populate
- */
- protected void propertyChanged(String propertyName) {
- }
-
- /**
- * Returns the list of names to listen for properties changing from the
- * subject.
- *
- * @return A non-<code>null</code> list of property names
- *
- * @category Populate
- */
- protected Collection<String> getPropertyNames() {
- ArrayList<String> propertyNames = new ArrayList<String>();
- addPropertyNames(propertyNames);
- return propertyNames;
- }
-
- /**
- * Removes the given pane's widgets (those that were registered with
- * its left <code>ControlAligner</code>) from this pane's left
- * <code>ControlAligner</code> so that their width will no longer be adjusted
- * with the width of the widest widget.
- *
- * @param pane The pane containing the widgets to remove
- *
- * @category Layout
- */
- protected final void removeAlignLeft(Pane<?> pane) {
- this.leftControlAligner.remove(pane.leftControlAligner);
- }
-
- /**
- * Removes the given control from the collection of widgets that are aligned
- * to have the same width when they are shown to the left side of the 3
- * widget colums.
- *
- * @param pane The pane to remove, its width will no longer be
- * ajusted to be the width of the longest widget
- *
- * @category Layout
- */
- protected final void removeAlignLeft(Control control) {
- this.leftControlAligner.remove(control);
- }
-
- /**
- * Removes the given pane's widgets (those that were registered with
- * its right <code>ControlAligner</code>) from this pane's right
- * <code>ControlAligner</code> so that their width will no longer be adjusted
- * with the width of the widest widget.
- *
- * @param pane The pane containing the widgets to remove
- *
- * @category Layout
- */
- protected final void removeAlignRight(Pane<?> pane) {
- this.rightControlAligner.remove(pane.rightControlAligner);
- }
-
- /**
- * Removes the given control from the collection of widgets that are aligned
- * to have the same width when they are shown to the right side of the 3
- * widget colums.
- *
- * @param pane The pane to remove, its width will no longer be
- * ajusted to be the width of the longest widget
- *
- * @category Layout
- */
- protected final void removeAlignRight(Control control) {
- this.rightControlAligner.remove(control);
- }
-
- /**
- * Removes the given pane's controls (those that were registered for
- * alignment) from this pane.
- *
- * @param pane The pane containing the widgets that no longer
- * requires their width adjusted with the width of the longest widget
- *
- * @category Layout
- */
- protected final void removePaneForAlignment(Pane<?> pane) {
- removeAlignLeft(pane);
- removeAlignRight(pane);
- }
-
- /**
- * This method is called (perhaps internally) when this needs to repopulate
- * but the object of interest has not changed.
- *
- * @category Populate
- */
- protected final void repopulate() {
-
- this.log(Tracing.UI_LAYOUT, " ->repopulate()");
-
- // Populate this pane
- try {
- setPopulating(true);
- doPopulate();
- }
- finally {
- setPopulating(false);
- }
-
- // Ask the sub-panes to repopulate themselves
- for (Pane<?> subPane : this.subPanes) {
- subPane.repopulate();
- }
- }
-
- /**
- * Sets the internal flag that is used to determine whether the pane is being
- * populated or not. During population, it is required to not update the
- * widgets when the model is updated nor to update the model when the widgets
- * are being synchronized with the model's values.
- *
- * @param populating
- *
- * @category Populate
- */
- protected final void setPopulating(boolean populating) {
- this.populating = populating;
- }
-
- /**
- * Either show or hides this pane.
- *
- * @param visible The new visibility state
- */
- public void setVisible(boolean visible) {
- if (!this.container.isDisposed()) {
- this.container.setVisible(visible);
- }
- }
-
- /**
- * Returns the nearest <code>Shell</code> displaying the main widget of this
- * pane.
- *
- * @return The nearest window displaying this pane
- */
- public final Shell getShell() {
- return this.container.getShell();
- }
-
- /**
- * Returns the subject of this pane.
- *
- * @return The subject if this pane was not disposed; <code>null</code>
- * if it was
- *
- * @category Populate
- */
- public T getSubject() {
- return this.subjectHolder.getValue();
- }
-
- /**
- * The subject has changed, disconnects any listeners from the old subject
- * and connects those listeners onto the new subject.
- *
- * @param oldsubject The old subject or <code>null</code> if none was set
- * @param newSubject The new subject or <code>null</code> if none needs to be
- * set
- *
- * @category Populate
- */
- protected final void subjectChanged(T oldSubject, T newSubject) {
- if (!this.container.isDisposed()) {
-
- this.log(Tracing.UI_LAYOUT, "subjectChanged()");
- this.disengageListeners(oldSubject);
-
- this.repopulate();
-
- this.engageListeners(newSubject);
- }
- }
-
-
- /**
- * Registers another <code>Pane</code> with this one so it can
- * be automatically notified about certain events such as engaging or
- * disengaging the listeners, etc.
- *
- * @param subPane The sub-pane to register
- *
- * @category Controller
- */
- protected final void registerSubPane(Pane<?> subPane) {
- this.subPanes.add(subPane);
- }
-
- /**
- * Unregisters the given <code>Pane</code> from this one so it
- * can no longer be automatically notified about certain events such as
- * engaging or disengaging the listeners, etc.
- *
- * @param subPane The sub-pane to unregister
- *
- * @category Controller
- */
- protected final void unregisterSubPane(Pane<?> subPane) {
- this.subPanes.remove(subPane);
- }
-
- private void updatePane(String propertyName) {
- if (!isPopulating() && !this.container.isDisposed()) {
- this.populating = true;
-
- try {
- propertyChanged(propertyName);
- }
- finally {
- this.populating = false;
- }
- }
- }
-
- public void dispose() {
- this.log(Tracing.UI_LAYOUT, "dispose()");
-
- // Dispose this pane
- this.disengageListeners(getSubject());
- this.disengageSubjectHolder();
-
- if (this.combinedEnabledModel != null && this.combinedEnabledModelListener != null) {
- this.combinedEnabledModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.combinedEnabledModelListener);
- }
-
- this.leftControlAligner.dispose();
- this.rightControlAligner.dispose();
-
- // Ask the sub-panes to dispose themselves
- for (Pane<?> subPane : this.subPanes) {
- subPane.dispose();
- }
- }
-
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PropertySheetWidgetFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PropertySheetWidgetFactory.java
deleted file mode 100644
index 82313fb8fa..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/PropertySheetWidgetFactory.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
-
-/**
- * This <code>WidgetFactory</code> is responsible to create the widgets using
- * <code>TabbedPropertySheetWidgetFactory</code> in order use the form style
- * (flat-style) look and feel.
- *
- * @see TabbedPropertySheetWidgetFactory
- *
- * @version 2.0
- * @since 2.0
- */
-public class PropertySheetWidgetFactory
- extends FormWidgetFactory
-{
- /**
- * Creates a new <code>PropertySheetWidgetFactory</code>.
- */
- public PropertySheetWidgetFactory() {
- this(new TabbedPropertySheetWidgetFactory());
- }
-
- /**
- * Creates a new <code>PropertySheetWidgetFactory</code>.
- */
- public PropertySheetWidgetFactory(TabbedPropertySheetWidgetFactory widgetFactory) {
- super(widgetFactory);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Composite createComposite(Composite parent) {
- return getWidgetFactory().createComposite(parent);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Group createGroup(Composite parent, String title) {
- return getWidgetFactory().createGroup(parent, title);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TabbedPropertySheetWidgetFactory getWidgetFactory() {
- return (TabbedPropertySheetWidgetFactory) super.getWidgetFactory();
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/TriStateCheckBox.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/TriStateCheckBox.java
deleted file mode 100644
index 725357029b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/TriStateCheckBox.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import org.eclipse.jpt.common.ui.WidgetFactory;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * This <code>TriStateCheckBox</code> can display one of three states:
- * unchecked, checked, or partially checked. It can be modified via a mouse
- * selection, via a keyboard selection, or programmatically. The selection state is
- * represented by a <code>Boolean</code> value where a <code>null</code>
- * value means partially checked.
- * <p>
- * The order of state changes is: unchecked -> partially checked -> checked.
- *
- * @version 2.0
- * @since 2.0
- */
-@SuppressWarnings("nls")
-public final class TriStateCheckBox {
- /**
- * A check box button.
- */
- private final Button button;
-
- /**
- * The current selection state.
- */
- private TriState state;
-
- /**
- * The possible selections.
- */
- enum TriState {
- CHECKED,
- PARTIALLY_CHECKED,
- UNCHECKED
- }
-
- /**
- * Creates a new <code>TriStateCheckBox</code> with no text.
- *
- * @param parent The parent composite
- * @param widgetFactory The factory used to create the check box
- */
- public TriStateCheckBox(Composite parent, WidgetFactory widgetFactory) {
- this(parent, null, widgetFactory);
- }
-
- /**
- * Creates a new <code>TriStateCheckBox</code>.
- *
- * @param parent The parent composite
- * @param text The check box's text
- * @param widgetFactory The factory used to create the check box
- */
- public TriStateCheckBox(Composite parent,
- String text,
- WidgetFactory widgetFactory) {
- super();
- this.state = TriState.UNCHECKED;
- this.button = widgetFactory.createCheckBox(parent, text);
- this.button.addSelectionListener(this.buildSelectionListener());
- }
-
- /**
- * Convenience method: Adds a dispose listener to the check box.
- * The source of any events sent to the listener will be the check box widget.
- */
- public void addDisposeListener(DisposeListener disposeListener) {
- this.button.addDisposeListener(disposeListener);
- }
-
- /**
- * Convenience method: Adds a selection listener to the check box.
- * The source of any events sent to the listener will be the check box widget.
- */
- public void addSelectionListener(SelectionListener selectionListener) {
- this.button.addSelectionListener(selectionListener);
- }
-
- private SelectionListener buildSelectionListener() {
- return new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- TriStateCheckBox.this.checkBoxClicked();
- }
- };
- }
-
- /**
- * The check box was clicked, change the tri-state to the next value and
- * update the check box's state.
- */
- void checkBoxClicked() {
- this.state = this.nextState();
- this.updateCheckBox();
- }
-
- /**
- * Disposes the check box widget.
- */
- public void dispose() {
- this.button.dispose();
- }
-
- /**
- * Returns the <code>Button</code> used to show a tri-state check box.
- *
- * @return The <code>Button</code> used to show a tri-state check box
- */
- public Button getCheckBox() {
- return this.button;
- }
-
- /**
- * Returns the check box's image.
- *
- * @return The check box's image.
- */
- public Image getImage() {
- return this.button.getImage();
- }
-
- /**
- * Returns the check box's selection state.
- *
- * @return Either <code>true</code> or <code>false</code> for checked or
- * unchecked; or <code>null</code> for partially selected
- */
- public Boolean getSelection() {
- return (this.state == TriState.PARTIALLY_CHECKED) ? null : Boolean.valueOf(this.state == TriState.CHECKED);
- }
-
- /**
- * Returns the check box's text.
- *
- * @return The text of the check box
- */
- public String getText() {
- return this.button.getText();
- }
-
- /**
- * Returns whether the check box is disposed.
- *
- * @return <code>true</code> if the check box is disposed; <code>false</code>
- * otherwise
- */
- public boolean isDisposed() {
- return this.button.isDisposed();
- }
-
- /**
- * Returns whether the check box is enabled.
- *
- * @return <code>true</code> if the check box is enabled; <code>false</code>
- * otherwise
- */
- public boolean isEnabled() {
- return this.button.isEnabled();
- }
-
- /**
- * Returns the next state:
- * UNCHECKED -> PARTIALLY_CHECKED
- * PARTIALLY_CHECKED -> CHECKED
- * CHECKED -> UNCHECKED
- */
- private TriState nextState() {
- switch (this.state) {
- case UNCHECKED:
- return TriState.PARTIALLY_CHECKED;
- case PARTIALLY_CHECKED:
- return TriState.CHECKED;
- case CHECKED:
- return TriState.UNCHECKED;
- }
- throw new IllegalStateException("unknown state: " + this.state);
- }
-
- /**
- * Convenience method: Removes a dispose listener from the check box.
- */
- public void removeDisposeListener(DisposeListener disposeListener) {
- this.button.removeDisposeListener(disposeListener);
- }
-
- /**
- * Convenience method: Removes a selection listener from the check box.
- */
- public void removeSelectionListener(SelectionListener selectionListener) {
- this.button.removeSelectionListener(selectionListener);
- }
-
- /**
- * Changes the check box's enablement state.
- *
- * @param enabled <code>true</code> to enable the check box or <code>false</code>
- * to disable it
- */
- public void setEnabled(boolean enabled) {
- this.button.setEnabled(enabled);
- }
-
- /**
- * Sets the check box's image.
- *
- * @param image The new image of the check box
- */
- public void setImage(Image image) {
- this.button.setImage(image);
- }
-
- /**
- * Changes the check box's selection state.
- *
- * @param selection Either <code>true</code> or <code>false</code> for
- * checked and unchecked; or <code>null</code> for partially selected
- */
- public void setSelection(Boolean selection) {
- TriState old = this.state;
- this.state = this.stateForBoolean(selection);
- if (old != this.state) {
- this.updateCheckBox();
- }
- }
-
- /**
- * Sets the check box's text.
- *
- * @param text The new text of the check box
- */
- public void setText(String text) {
- this.button.setText(text);
- }
-
- /**
- * Returns the tri-state corresponding to the boolean.
- *
- * @param selection The boolean to be converted to a tri-state
- */
- private TriState stateForBoolean(Boolean selection) {
- return (selection == null) ? TriState.PARTIALLY_CHECKED :
- selection.booleanValue() ? TriState.CHECKED : TriState.UNCHECKED;
- }
-
- /**
- * Updates the selection state of the of the check box based on the tri-state
- * value.
- */
- void updateCheckBox() {
- switch (this.state) {
- case UNCHECKED:
- this.button.setSelection(false);
- this.button.setGrayed(false);
- break;
- case PARTIALLY_CHECKED:
- this.button.setSelection(true);
- this.button.setGrayed(true);
- break;
- case CHECKED:
- this.button.setSelection(true);
- this.button.setGrayed(false);
- break;
- default:
- throw new IllegalStateException("unknown state: " + this.state);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ValidatingDialog.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ValidatingDialog.java
deleted file mode 100644
index b4b6cdf73e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/widgets/ValidatingDialog.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.widgets;
-
-import java.util.ListIterator;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jpt.common.utility.internal.node.Node;
-import org.eclipse.jpt.common.utility.internal.node.Problem;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * This dialog is similar to it superclass, <code>Dialog</code>, with
- * the added value of an error message label below the main panel. A subclass
- * can set this error message as needed so that it can inform the user something
- * incorrect has been entered.
- * <p>
- * If there is an error message, it will be shown. If there is a warning
- * message, it will only be shown if there is no error message. Warning messages
- * have a different icon than error messages.
- *
- * @version 2.0
- * @since 2.0
- */
-public abstract class ValidatingDialog<T extends Node> extends Dialog<T> {
-
- /**
- * Creates a new <code>ValidatingDialog</code>.
- *
- * @param parent The parent shell
- */
- public ValidatingDialog(Shell parent) {
- super(parent);
- }
-
- /**
- * Creates a new <code>ValidatingDialog</code>.
- *
- * @param parent The parent shell
- * @param title The dialog's title
- */
- public ValidatingDialog(Shell parent, String title) {
- super(parent, title);
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- final Node.Validator buildValidator() {
- return new Node.Validator() {
- public void pause() {
- }
-
- public void resume() {
- }
-
- public void validate() {
- ValidatingDialog.this.validate();
- }
- };
- }
-
- /**
- * Clears the messages from the description pane
- */
- protected final void clearMessage(){
- setMessage(getDescription());
- }
-
- /**
- * Clears the error message from the description pane.
- */
- protected final void clearErrorMessage() {
- setErrorMessage(null);
- }
-
- /**
- * Returns the description shown in the description pane.
- *
- * @return The description under the description's title
- */
- protected String getDescription() {
- return null;
- }
-
- /**
- * Returns the image shown in the description pane.
- *
- * @return The image of the description pane or <code>null</code> if none is
- * required
- */
- protected Image getDescriptionImage() {
- return null;
- }
-
- /**
- * Returns the title of the description pane.
- *
- * @return The title shown in the description pane
- */
- protected String getDescriptionTitle() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected Point getInitialSize() {
- Point result = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Point paneSize = getPane().getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT);
- int width = convertHorizontalDLUsToPixels(400);
- result.x = Math.max(width, paneSize.x);
- return result;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected final boolean hasTitleArea() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- */
- @Override
- protected void initializeUI() {
-
- super.initializeUI();
-
- // Update the description title
- String descriptionTitle = getDescriptionTitle();
-
- if (descriptionTitle != null) {
- setTitle(descriptionTitle);
- }
-
- // Update the description title
- String description = getDescription();
-
- if (description != null) {
- setMessage(description);
- }
-
- // Update the description image
- Image image = getDescriptionImage();
-
- if (image != null) {
- setTitleImage(image);
- }
- }
-
- /**
- * Updates the description pane by showing the given error message and format
- * the text with the given list of arguments if any exists.
- *
- * @param errorMessage The error message to show in the description pane
- * @param arguments The list of arguments used to format the error message
- */
- protected final void setErrorMessage(String errorMessage, Object... arguments) {
- setErrorMessage(NLS.bind(errorMessage, arguments));
- }
-
- /**
- * Updates the description pane by showing the given warning message and format
- * the text with the given list of arguments if any exists.
- *
- * @param warningMessage The warning message to show in the description pane
- * @param arguments The list of arguments used to format the error message
- */
-
- protected final void setWarningMessage(String warningMessage, Object... arguments) {
- setMessage(NLS.bind(warningMessage, arguments), IMessageProvider.WARNING);
- }
-
- /**
- * Updates the error message, either shows the first error problem or hides
- * the error pane. If the progress bar is shown, then the error message will
- * not be shown.
- */
- private void updateMessage() {
- if (getSubject().branchProblemsSize() == 0) {
- clearMessage();
- } else {
- for (ListIterator<Problem> problems = getSubject().branchProblems(); problems.hasNext();){
- Problem problem = problems.next();
- if (problem.messageType() == IMessageProvider.ERROR){
- this.setErrorMessage(problem.messageKey(), problem.messageArguments());
- }
- else if (problem.messageType() == IMessageProvider.WARNING){
- this.setWarningMessage(problem.messageKey(), problem.messageArguments());
- }
- }
- }
- if (!this.containsErrorMessage()){
- clearErrorMessage();
- }
- }
-
- public final boolean containsErrorMessage(){
- boolean error = false;
- for (ListIterator<Problem> problems = getSubject().branchProblems(); problems.hasNext();){
- Problem problem = problems.next();
- if (problem.messageType() ==IMessageProvider.ERROR){
- error = true;
- }
- }
- return error;
- }
- /**
- * Validates the state object and based on its status, update the description
- * pane to show the first error if any exists and update the enablement of
- * the OK button.
- */
- private void validate() {
- getSubject().validateBranch();
- updateMessage();
- getButton(OK).setEnabled(!containsErrorMessage());
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/wizards/JavaProjectWizardPage.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/wizards/JavaProjectWizardPage.java
deleted file mode 100644
index 510957a1b2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/internal/wizards/JavaProjectWizardPage.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2010, 2011 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.common.ui.internal.wizards;
-
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * JavaProjectWizardPage
- */
-public class JavaProjectWizardPage extends WizardPage {
-
- private IJavaProject javaProject;
- private String destinationLabel;
- private Table projectTable;
- private TableViewer projectTableViewer;
-
- private static String SELECT_PROJECT_PAGE_NAME = "SelectJavaProject"; //$NON-NLS-1$
- private static int PROJECT_NAME_COLUMN_INDEX = 0;
-
- // ********** constructor **********
-
- public JavaProjectWizardPage(IJavaProject javaProject) {
- super(SELECT_PROJECT_PAGE_NAME);
-
- this.javaProject = javaProject;
- }
-
- // ********** IDialogPage implementation **********
-
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- composite.setLayout(layout);
-
- this.buildLabel(composite, this.destinationLabel);
-
- this.projectTable = this.buildProjectTable(composite, this.buildProjectTableSelectionListener());
-
- this.projectTableViewer = this.buildProjectTableViewer(
- this.projectTable,
- this.buildProjectTableLabelProvider(),
- this.buildProjectTableContentProvider());
- this.fillProjectList();
- this.setControl(composite);
- this.setTableSelection(this.javaProject);
- this.validate();
- }
-
- // ********** listeners **********
-
- private SelectionListener buildProjectTableSelectionListener() {
- return new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedProjectChanged();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- @Override
- public String toString() {
- return "PromptProjectWizardPage project table selection listener"; //$NON-NLS-1$
- }
- };
- }
-
- // ********** listener callbacks **********
-
- protected void selectedProjectChanged() {
- if(this.projectTable.getSelectionIndex() != -1) {
- TableItem item = this.projectTable.getItem(this.projectTable.getSelectionIndex());
- String projectName = item.getText(0);
- if( ! StringTools.stringIsEmpty(projectName)) {
-
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- this.setJavaProject(JavaCore.create(project));
- this.validate();
- }
- }
- }
-
- // ********** intra-wizard methods **********
-
- public IJavaProject getJavaProject() {
- return this.javaProject;
- }
-
- public void setDestinationLabel(String destinationLabel) {
- this.destinationLabel = destinationLabel;
- }
-
- // ********** protected methods **********
-
- protected void setTableSelection(IJavaProject javaProject) {
- if(javaProject != null) {
- String projectName = javaProject.getProject().getName();
- for(TableItem item: this.projectTable.getItems()) {
- if(item.getText(0).equals(projectName)) {
- this.projectTable.setSelection(item);
- }
- }
- }
- }
-
- protected void fillProjectList() {
- this.projectTableViewer.setInput(this.getSortedJavaProjectsNames());
- }
-
- // ********** internal methods **********
-
- private void validate() {
- this.setPageComplete(this.projectTable.getSelectionIndex() != -1);
- }
-
- private void setJavaProject(IJavaProject project) {
- this.javaProject = project;
- }
-
- private String[] getSortedJavaProjectsNames() {
- return ArrayTools.sort(this.getJavaProjectsNames());
- }
-
- private String[] getJavaProjectsNames() {
- return ArrayTools.array(
- new TransformationIterable<IProject, String>(this.getJavaProjects()) {
- @Override
- protected String transform(IProject project) {
- return project.getName();
- }
- },
- new String[0]);
- }
-
- protected Iterable<IProject> getJavaProjects() {
- return new FilteringIterable<IProject>(CollectionTools.collection(this.getProjects())) {
- @Override
- protected boolean accept(IProject next) {
- try {
- return next.hasNature(JavaCore.NATURE_ID);
- }
- catch (CoreException e) {
- return false;
- }
- }
- };
- }
-
- protected Iterator<IProject> getProjects() {
- return new ArrayIterator<IProject>(ResourcesPlugin.getWorkspace().getRoot().getProjects());
- }
-
- // ********** inner classes **********
-
- private final class ProjectTableLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- public Image getColumnImage(Object element, int columnIndex) {
- if(columnIndex == PROJECT_NAME_COLUMN_INDEX)
- return PlatformUI.getWorkbench().getSharedImages().getImage(org.eclipse.ui.ide.IDE.SharedImages.IMG_OBJ_PROJECT);
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- assert element instanceof String;
- String projectName = (String)element;
- if(columnIndex == PROJECT_NAME_COLUMN_INDEX)
- return projectName;
- return null;
- }
- }
-
- private final class ProjectTableContentProvider implements IStructuredContentProvider {
-
- public Object[] getElements(Object inputElement) {
- return ((String[])inputElement);
- }
-
- public void dispose() {}
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
- }
-
- // ********** UI components **********
-
- private ITableLabelProvider buildProjectTableLabelProvider() {
- return new ProjectTableLabelProvider();
- }
-
- private IStructuredContentProvider buildProjectTableContentProvider() {
- return new ProjectTableContentProvider();
- }
-
- private Label buildLabel(Composite parent, String text) {
- Label label = new Label( parent, SWT.NONE );
- label.setText(text);
- return label;
- }
-
- private Table buildProjectTable(Composite parent, SelectionListener listener) {
- TableViewer tableViewer = new TableViewer(parent,
- SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL);
-
- Table table = tableViewer.getTable();
- table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- table.addSelectionListener(listener);
- return table;
- }
-
- private TableViewer buildProjectTableViewer(Table parent, ITableLabelProvider labelProvider, IStructuredContentProvider contentProvider) {
-
- TableViewer tableViewer = new TableViewer(parent);
- tableViewer.setLabelProvider(labelProvider);
- tableViewer.setContentProvider(contentProvider);
- return tableViewer;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ExtendedLabelProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ExtendedLabelProvider.java
deleted file mode 100644
index 6a96068edf..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ExtendedLabelProvider.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.ui.navigator.IDescriptionProvider;
-
-/**
- * Combine provider interfaces to be implemented by a single provider that can
- * be used as both a label and description provider for a tree.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ExtendedLabelProvider
- extends ILabelProvider, IDescriptionProvider
-{
- // combine interfaces
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemExtendedLabelProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemExtendedLabelProvider.java
deleted file mode 100644
index ef9445953b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemExtendedLabelProvider.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-/**
- * Implementations of this interface can be used to maintain the label (image
- * and text) and description of a specific item. The implementation will monitor
- * the item for any changes that affect the description and forward them
- * appropriately to the {@link Manager}.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @see org.eclipse.jface.viewers.ILabelProvider
- * @see org.eclipse.ui.navigator.IDescriptionProvider
- */
-public interface ItemExtendedLabelProvider
- extends ItemLabelProvider
-{
- /**
- * Return the description for the provider's item.
- *
- * @see org.eclipse.ui.navigator.IDescriptionProvider#getDescription(Object)
- */
- String getDescription();
-
- /**
- * An item extended label provider's manager is notified whenever the item's
- * description has changed.
- */
- interface Manager
- extends ItemLabelProvider.Manager
- {
- /**
- * The description for the specified item has changed. Update appropriately.
- */
- void updateDescription(Object item);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemExtendedLabelProviderFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemExtendedLabelProviderFactory.java
deleted file mode 100644
index ad675de6f8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemExtendedLabelProviderFactory.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-/**
- * Factory interface for constructing item extended label providers.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ItemExtendedLabelProviderFactory {
- /**
- * Build an extended label provider for the specified item.
- */
- ItemExtendedLabelProvider buildProvider(Object item, ItemExtendedLabelProvider.Manager manager);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemLabelProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemLabelProvider.java
deleted file mode 100644
index 921a8e5712..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemLabelProvider.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Implementations of this interface can be used to maintain the label (image,
- * and text) of a specific item. The implementation will monitor
- * the item for any changes that affect the label and forward them appropriately
- * to the {@link Manager}.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @see org.eclipse.jface.viewers.ILabelProvider
- */
-public interface ItemLabelProvider {
- /**
- * Return the image for the provider's item.
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(Object)
- */
- Image getImage();
-
- /**
- * Return the text for the provider's item.
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(Object)
- */
- public String getText();
-
- /**
- * Dispose the item label provider.
- * Remove any item listeners as appropriate.
- */
- void dispose();
-
-
- /**
- * An item label provider's manager is notified whenever the item's
- * label has changed.
- */
- interface Manager {
- /**
- * The label (image and/or text) for the specified item has changed.
- * Update appropriately.
- */
- void updateLabel(Object item);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemLabelProviderFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemLabelProviderFactory.java
deleted file mode 100644
index 36c25d38a4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemLabelProviderFactory.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-/**
- * Factory interface for constructing item label providers.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ItemLabelProviderFactory {
- /**
- * Build a label provider for the specified item.
- */
- ItemLabelProvider buildProvider(Object item, ItemLabelProvider.Manager manager);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemStructuredContentProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemStructuredContentProvider.java
deleted file mode 100644
index 0ddbfe980c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemStructuredContentProvider.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Implementations of this interface can be used to maintain the elements
- * of a specific input element. The implementation will monitor
- * the item for any changes that affect the elements and forward them
- * appropriately to the {@link Manager}.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @see org.eclipse.jface.viewers.IContentProvider
- * @see org.eclipse.jface.viewers.IStructuredContentProvider
- */
-public interface ItemStructuredContentProvider {
- /**
- * Return the input element's elements.
- * <strong>NB:</strong>
- * When this method is called, the item is an <em>input</em> element.
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, Object, Object)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(Object)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object)
- */
- Object[] getElements();
-
- /**
- * Dispose the item content provider.
- * Remove any item listeners as appropriate.
- */
- void dispose();
-
-
- /**
- * Convenience constant for when no children are present.
- */
- Object[] EMPTY_ARRAY = new Object[0];
-
-
- /**
- * An item structured content provider's manager is notified whenever the
- * input element's elements have changed.
- */
- interface Manager {
- /**
- * The elements for the specified input element have changed.
- * Update appropriately.
- */
- void updateElements(Object inputElement);
-
- /**
- * The specified element has been removed from the input element.
- * Dispose of the element's providers, if necessary.
- */
- void dispose(Object element);
- }
-
-
- /**
- * A "null" item structured content provider that has no elements.
- */
- final class Null
- implements ItemStructuredContentProvider, Serializable
- {
- public static final ItemStructuredContentProvider INSTANCE = new Null();
- public static ItemStructuredContentProvider instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public Object[] getElements() {
- return EMPTY_ARRAY;
- }
- public void dispose() {
- // NOP
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemStructuredContentProviderFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemStructuredContentProviderFactory.java
deleted file mode 100644
index 31f168e131..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemStructuredContentProviderFactory.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-/**
- * Factory interface for constructing item content providers.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ItemStructuredContentProviderFactory {
- /**
- * Build a structured content provider for the specified item.
- */
- ItemStructuredContentProvider buildProvider(Object item, ItemStructuredContentProvider.Manager manager);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeContentProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeContentProvider.java
deleted file mode 100644
index 32c3d90c05..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeContentProvider.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Implementations of this interface can be used to maintain the content of a
- * specific tree element. The implementation will monitor the element for any
- * changes that affect the element's children and forward them
- * appropriately to the {@link Manager}.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @see org.eclipse.jface.viewers.IContentProvider
- * @see org.eclipse.jface.viewers.IStructuredContentProvider
- * @see org.eclipse.jface.viewers.ITreeContentProvider
- */
-public interface ItemTreeContentProvider
- extends ItemStructuredContentProvider
-{
- /**
- * Return the item's parent.
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(Object)
- */
- Object getParent();
-
- /**
- * Return whether the item has children.
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(Object)
- */
- boolean hasChildren();
-
- /**
- * Return the item's children.
- *
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object)
- */
- Object[] getChildren();
-
-
- /**
- * An item tree content provider's manager is notified whenever the
- * item's children have changed.
- */
- interface Manager
- extends ItemStructuredContentProvider.Manager
- {
- /**
- * The children for the specified element have changed.
- * Update appropriately.
- */
- void updateChildren(Object element);
- }
-
-
- /**
- * A "null" item tree content provider that has no elements, parent,
- * or parent.
- */
- final class Null
- implements ItemTreeContentProvider, Serializable
- {
- public static final ItemStructuredContentProvider INSTANCE = new Null();
- public static ItemStructuredContentProvider instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public Object[] getElements() {
- return EMPTY_ARRAY;
- }
- public Object getParent() {
- return null;
- }
- public Object[] getChildren() {
- return EMPTY_ARRAY;
- }
- public boolean hasChildren() {
- return false;
- }
- public void dispose() {
- // NOP
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeContentProviderFactory.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeContentProviderFactory.java
deleted file mode 100644
index 027a2b4110..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeContentProviderFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-/**
- * Factory interface for constructing item tree content providers.
- * Typically used by {@link ItemTreeContentProvider.Manager item tree content
- * provider managers}.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ItemTreeContentProviderFactory {
- /**
- * Build a tree content provider for the specified item.
- * Return <code>null</code> if there is no provider for the specified item.
- */
- ItemTreeContentProvider buildProvider(Object item, ItemTreeContentProvider.Manager manager);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeStateProviderFactoryProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeStateProviderFactoryProvider.java
deleted file mode 100644
index e866a7f669..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/ItemTreeStateProviderFactoryProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-/**
- * This provider supplies the factories used by a tree view to build
- * the content and labels its tree.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ItemTreeStateProviderFactoryProvider {
- /**
- * Return a factory to be used to create {@link ItemTreeContentProvider}s
- * for a tree view.
- */
- ItemTreeContentProviderFactory getItemContentProviderFactory();
-
- /**
- * Return a factory to be used to create {@link ItemExtendedLabelProvider}s
- * for a tree view.
- */
- ItemExtendedLabelProviderFactory getItemLabelProviderFactory();
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/StructuredStateProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/StructuredStateProvider.java
deleted file mode 100644
index 027b876ebd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/StructuredStateProvider.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-
-/**
- * Combine all the various provider interfaces to be implemented by a single
- * provider that can be used as both a content and label provider for a
- * structured viewer.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface StructuredStateProvider
- extends IStructuredContentProvider, ExtendedLabelProvider
-{
- /**
- * Convenience constant for when no elements are present.
- */
- Object[] EMPTY_ARRAY = new Object[0];
-}
diff --git a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/TreeStateProvider.java b/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/TreeStateProvider.java
deleted file mode 100644
index b36e432137..0000000000
--- a/common/plugins/org.eclipse.jpt.common.ui/src/org/eclipse/jpt/common/ui/jface/TreeStateProvider.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.jface;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-
-/**
- * Combine all the various provider interfaces to be implemented by a single
- * provider that can be used as both a content and label provider for a
- * tree viewer.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface TreeStateProvider
- extends StructuredStateProvider, ITreeContentProvider
-{
- // combine interfaces
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/.classpath b/common/plugins/org.eclipse.jpt.common.utility/.classpath
deleted file mode 100644
index 304e86186a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/common/plugins/org.eclipse.jpt.common.utility/.cvsignore b/common/plugins/org.eclipse.jpt.common.utility/.cvsignore
deleted file mode 100644
index ba077a4031..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/common/plugins/org.eclipse.jpt.common.utility/.project b/common/plugins/org.eclipse.jpt.common.utility/.project
deleted file mode 100644
index dbe6e576b1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.utility</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/common/plugins/org.eclipse.jpt.common.utility/.settings/org.eclipse.jdt.core.prefs b/common/plugins/org.eclipse.jpt.common.utility/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index a45314f1e6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Tue Mar 08 12:06:51 EST 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
diff --git a/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF
deleted file mode 100644
index 15b0ba4fe1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,122 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.common.utility
-Bundle-Version: 2.1.0.qualifier
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Dali-Comment-1: *NO* EclipseLink friends!
-Dali-Comment-2: the UI-related packages are friends with only UI plug-ins
-Export-Package: org.eclipse.jpt.common.utility,
- org.eclipse.jpt.common.utility.command,
- org.eclipse.jpt.common.utility.internal;
- x-friends:="org.eclipse.jpt.common.core,
- org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.core,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jpa.db,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.gen,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.command;
- x-friends:="org.eclipse.jpt.common.core,
- org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.core,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jpa.db,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.gen,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.enumerations;
- x-friends:="org.eclipse.jpt.common.core,
- org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.core,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jpa.db,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.gen,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.iterables;
- x-friends:="org.eclipse.jpt.common.core,
- org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.core,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jpa.db,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.gen,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.iterators;
- x-friends:="org.eclipse.jpt.common.core,
- org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.core,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jpa.db,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.gen,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.model;
- x-friends:="org.eclipse.jpt.common.core,
- org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.core,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jpa.db,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.gen,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.model.listener.awt;
- x-friends:="org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.model.value;
- x-friends:="org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.model.value.prefs;
- x-friends:="org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.model.value.swing;
- x-friends:="org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.node;
- x-friends:="org.eclipse.jpt.common.core,
- org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.core,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jpa.db,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.gen,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.swing;
- x-friends:="org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.internal.synchronizers;
- x-friends:="org.eclipse.jpt.common.core,
- org.eclipse.jpt.common.ui,
- org.eclipse.jpt.jaxb.core,
- org.eclipse.jpt.jaxb.ui,
- org.eclipse.jpt.jpa.core,
- org.eclipse.jpt.jpa.db,
- org.eclipse.jpt.jpa.db.ui,
- org.eclipse.jpt.jpa.gen,
- org.eclipse.jpt.jpa.ui",
- org.eclipse.jpt.common.utility.model,
- org.eclipse.jpt.common.utility.model.event,
- org.eclipse.jpt.common.utility.model.listener,
- org.eclipse.jpt.common.utility.model.value,
- org.eclipse.jpt.common.utility.synchronizers
diff --git a/common/plugins/org.eclipse.jpt.common.utility/about.html b/common/plugins/org.eclipse.jpt.common.utility/about.html
deleted file mode 100644
index be534ba44f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>May 02, 2008</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/common/plugins/org.eclipse.jpt.common.utility/build.properties b/common/plugins/org.eclipse.jpt.common.utility/build.properties
deleted file mode 100644
index d0244655ed..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/build.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-source.. = src/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- about.html,\
- plugin.properties
diff --git a/common/plugins/org.eclipse.jpt.common.utility/component.xml b/common/plugins/org.eclipse.jpt.common.utility/component.xml
deleted file mode 100644
index 80c3a500b9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/component.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2007, 2010 Oracle. All rights reserved.
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0, which accompanies this distribution
- and is available at http://www.eclipse.org/legal/epl-v10.html.
-
- Contributors:
- Oracle - initial API and implementation
- -->
-<component xmlns="http://eclipse.org/wtp/releng/tools/component-model" name="org.eclipse.jpt.common.utility"><description url=""></description><component-depends unrestricted="true"></component-depends><plugin id="org.eclipse.jpt.common.utility" fragment="false"/></component> \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.utility/plugin.properties b/common/plugins/org.eclipse.jpt.common.utility/plugin.properties
deleted file mode 100644
index 1693cd4eb6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/plugin.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2009 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = Dali Java Persistence Tools - Common Utility
-providerName = Eclipse Web Tools Platform
-
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/BooleanReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/BooleanReference.java
deleted file mode 100644
index 0a73528e4e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/BooleanReference.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility;
-
-import java.io.Serializable;
-
-/**
- * Interface for a container for holding a <code>boolean</code> that cannot be
- * changed by clients.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface BooleanReference {
-
- /**
- * Return the current <code>boolean</code> value.
- */
- boolean getValue();
-
- /**
- * Return whether the current <code>boolean</code> value is equal to the
- * specified value.
- */
- boolean is(boolean value);
-
- /**
- * Return whether the current <code>boolean</code> value is not equal to
- * the specified value.
- */
- boolean isNot(boolean value);
-
- /**
- * Return whether the current <code>boolean</code> value is
- * <code>true</code>.
- */
- boolean isTrue();
-
- /**
- * Return whether the current <code>boolean</code> value is
- * <code>false</code>.
- */
- boolean isFalse();
-
-
- /**
- * Convenience method.
- */
- final class Value {
- public static BooleanReference of(boolean value) {
- return value ? True.instance() : False.instance();
- }
- }
-
-
- /**
- * Singleton implementation of the read-only boolean reference interface
- * whose value is always <code>true</code>.
- */
- final class True
- implements BooleanReference, Serializable
- {
- public static final BooleanReference INSTANCE = new True();
-
- public static BooleanReference instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private True() {
- super();
- }
-
- public boolean getValue() {
- return true;
- }
-
- public boolean is(boolean value) {
- return value;
- }
-
- public boolean isNot(boolean value) {
- return ! value;
- }
-
- public boolean isTrue() {
- return true;
- }
-
- public boolean isFalse() {
- return false;
- }
-
- @Override
- public String toString() {
- return "[true]"; //$NON-NLS-1$
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
-
- /**
- * Singleton implementation of the read-only boolean reference interface
- * whose value is always <code>false</code>.
- */
- final class False
- implements BooleanReference, Serializable
- {
- public static final BooleanReference INSTANCE = new False();
-
- public static BooleanReference instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private False() {
- super();
- }
-
- public boolean getValue() {
- return false;
- }
-
- public boolean is(boolean value) {
- return ! value;
- }
-
- public boolean isNot(boolean value) {
- return value;
- }
-
- public boolean isTrue() {
- return false;
- }
-
- public boolean isFalse() {
- return false;
- }
-
- @Override
- public String toString() {
- return "[false]"; //$NON-NLS-1$
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ExceptionHandler.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ExceptionHandler.java
deleted file mode 100644
index c91948a4c9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ExceptionHandler.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Simple interface for allowing clients to pass an exception handler to a
- * service (e.g. to log the exception). This is particularly helpful if the
- * service executes on another, possibly inaccessible, thread.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ExceptionHandler {
-
- /**
- * The specified exception was thrown. Handle it appropriately.
- */
- void handleException(Throwable t);
-
- /**
- * Singleton implementation of the exception handler interface that does
- * nothing with the exception.
- */
- final class Null
- implements ExceptionHandler, Serializable
- {
- public static final ExceptionHandler INSTANCE = new Null();
- public static ExceptionHandler instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void handleException(Throwable t) {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- /**
- * Singleton implementation of the exception handler interface that
- * wraps the exception in a runtime exception and throws it.
- */
- final class Runtime
- implements ExceptionHandler, Serializable
- {
- public static final ExceptionHandler INSTANCE = new Runtime();
- public static ExceptionHandler instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Runtime() {
- super();
- }
- public void handleException(Throwable t) {
- // re-throw the exception unchecked
- if (t instanceof RuntimeException) {
- throw (RuntimeException) t;
- }
- throw new RuntimeException(t);
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/Filter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/Filter.java
deleted file mode 100644
index bae01f6240..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/Filter.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Used by various "pluggable" classes to filter objects.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <T> the type of objects to be filtered
- */
-public interface Filter<T> {
-
- /**
- * Return whether the specified object is "accepted" by the
- * filter. The semantics of "accept" is determined by the
- * contract between the client and the server.
- */
- boolean accept(T o);
-
-
- /**
- * Singleton implementation of the filter interface that accepts all the
- * objects (i.e. it does no filtering).
- */
- final class Transparent<S>
- implements Filter<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Filter INSTANCE = new Transparent();
- @SuppressWarnings("unchecked")
- public static <R> Filter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Transparent() {
- super();
- }
- // nothing is filtered - everything is accepted
- public boolean accept(S o) {
- return true;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- /**
- * Singleton implementation of the filter interface that accepts none of the
- * objects (i.e. it filters out all the objects).
- */
- final class Opaque<S>
- implements Filter<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Filter INSTANCE = new Opaque();
- @SuppressWarnings("unchecked")
- public static <R> Filter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Opaque() {
- super();
- }
- // everything is filtered - nothing is accepted
- public boolean accept(S o) {
- return false;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- /**
- * Singleton implementation of the filter interface that throws an exception
- * if called.
- */
- final class Disabled<S>
- implements Filter<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Filter INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> Filter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public boolean accept(S o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/IndentingPrintWriter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/IndentingPrintWriter.java
deleted file mode 100644
index 730a01ae5a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/IndentingPrintWriter.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility;
-
-import java.io.PrintWriter;
-import java.io.Writer;
-
-/**
- * Extend {@link PrintWriter} to automatically indent new lines.
- */
-public class IndentingPrintWriter
- extends PrintWriter
-{
- private final String indent;
- private int indentLevel;
- private boolean needsIndent;
-
- public static String DEFAULT_INDENT = "\t"; //$NON-NLS-1$
-
-
- /**
- * Construct a writer that indents with tabs.
- */
- public IndentingPrintWriter(Writer out) {
- this(out, DEFAULT_INDENT);
- }
-
- /**
- * Construct a writer that indents with the specified string.
- */
- public IndentingPrintWriter(Writer out, String indent) {
- this(out, indent, 0);
- }
-
- /**
- * Construct a writer that indents with the specified string
- * and begins with the specified indent level.
- */
- public IndentingPrintWriter(Writer out, String indent, int initialIndentLevel) {
- super(out);
- this.indent = indent;
- this.indentLevel = initialIndentLevel;
- this.needsIndent = true;
- }
-
- /**
- * Set flag so following line is indented.
- */
- @Override
- public void println() {
- synchronized (this.lock) {
- super.println();
- this.needsIndent = true;
- }
- }
-
- /**
- * Print the appropriate indent.
- * Pre-condition: synchronized
- */
- private void printIndent() {
- if (this.needsIndent) {
- this.needsIndent = false;
- for (int i = this.indentLevel; i-- > 0; ) {
- this.print(this.indent);
- }
- }
- }
-
- /**
- * Write a portion of an array of characters.
- */
- @Override
- public void write(char buf[], int off, int len) {
- synchronized (this.lock) {
- this.printIndent();
- super.write(buf, off, len);
- }
- }
-
- /**
- * Write a single character.
- */
- @Override
- public void write(int c) {
- synchronized (this.lock) {
- this.printIndent();
- super.write(c);
- }
- }
-
- /**
- * Write a portion of a string.
- */
- @Override
- public void write(String s, int off, int len) {
- synchronized (this.lock) {
- this.printIndent();
- super.write(s, off, len);
- }
- }
-
- /**
- * Bump the indent level.
- */
- public void indent() {
- this.incrementIndentLevel();
- }
-
- /**
- * Decrement the indent level.
- */
- public void undent() {
- this.decrementIndentLevel();
- }
-
- /**
- * Bump the indent level.
- */
- public void incrementIndentLevel() {
- synchronized (this.lock) {
- this.indentLevel++;
- }
- }
-
- /**
- * Decrement the indent level.
- */
- public void decrementIndentLevel() {
- synchronized (this.lock) {
- this.indentLevel--;
- }
- }
-
- /**
- * Return the current indent level.
- */
- public int getIndentLevel() {
- synchronized (this.lock) {
- return this.indentLevel;
- }
- }
-
- /**
- * Allow the indent level to be set directly.
- * Return the previous indent level.
- */
- public int setIndentLevel(int indentLevel) {
- synchronized (this.lock) {
- int old = this.indentLevel;
- this.indentLevel = indentLevel;
- return old;
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/JavaType.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/JavaType.java
deleted file mode 100644
index fb019d5ebe..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/JavaType.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility;
-
-import java.io.PrintWriter;
-
-/**
- * This interface describes a Java type; i.e. its "element type"
- * and its "array depth". The element type is referenced by name,
- * allowing us to reference classes that are not (or cannot be) loaded.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- * <p>
- * This interface is not intended to be implemented by clients.
- */
-public interface JavaType {
-
- /**
- * Return the name of the type's "element type".
- * A member type will have one or more <code>'$'</code> characters in its name.
- */
- String getElementTypeName();
-
- /**
- * Return the type's "array depth".
- */
- int getArrayDepth();
-
- /**
- * Return whether the type is an array (i.e. its "array depth" is greater
- * than zero).
- */
- boolean isArray();
-
- /**
- * Return whether the type is a "primitive" (e.g. <code>int</code>, <code>float</code>).
- * <p>
- * <strong>NB:</strong> <code>void.class.isPrimitive() == true</code>
- */
- boolean isPrimitive();
-
- /**
- * Return whether the type is a "primitive wrapper" (e.g. {@link java.lang.Integer},
- * {@link java.lang.Float}).
- * <p>
- * <strong>NB:</strong> <code>void.class.isPrimitive() == true</code>
- */
- boolean isPrimitiveWrapper();
-
- /**
- * Return whether the type is a "variable primitive" (e.g. <code>int</code>, <code>float</code>,
- * but not <code>void</code>).
- * <p>
- * <strong>NB:</strong> variables cannot be declared <code>void</code>
- */
- boolean isVariablePrimitive();
-
- /**
- * Return whether the type is a "variable primitive wrapper" (e.g.
- * {@link java.lang.Integer}, {@link java.lang.Float},
- * but not {@link java.lang.Void}).
- * <p>
- * <strong>NB:</strong> variables cannot be declared <code>void</code>
- */
- boolean isVariablePrimitiveWrapper();
-
- /**
- * Return the class corresponding to the type's element type and array depth.
- */
- Class<?> getJavaClass() throws ClassNotFoundException;
-
- /**
- * Return the version of the type's name that matches that
- * returned by {@link java.lang.Class#getName()}
- * (e.g. <code>"[[J"</code>, <code>"[Ljava.lang.Object;"</code>,
- * <code>"java.util.Map$Entry"</code>).
- */
- String getJavaClassName();
-
- /**
- * Return whether the type is equal to the specified type.
- */
- boolean equals(String otherElementTypeName, int otherArrayDepth);
-
- /**
- * Return whether the type describes to the specified type.
- */
- boolean describes(String className);
-
- /**
- * Return whether the type describes to the specified type.
- */
- boolean describes(Class<?> javaClass);
-
- /**
- * Return whether the type is equal to the specified type.
- */
- boolean equals(JavaType other);
-
- /**
- * Return the version of the type's name that can be used in source code:<ul>
- * <li><code>"[[J"</code> => <code>"long[][]"</code>
- * <li><code>"java.util.Map$Entry"</code> => <code>"java.util.Map.Entry"</code>
- * </ul>
- */
- String declaration();
-
- /**
- * Append the version of the type's name that can be used in source code:<ul>
- * <li><code>"[[J"</code> => <code>"long[][]"</code>
- * <li><code>"java.util.Map$Entry"</code> => <code>"java.util.Map.Entry"</code>
- * </ul>
- */
- void appendDeclarationTo(StringBuilder sb);
-
- /**
- * Print the version of the type's name that can be used in source code:<ul>
- * <li><code>"[[J"</code> => <code>"long[][]"</code>
- * <li><code>"java.util.Map$Entry"</code> => <code>"java.util.Map.Entry"</code>
- * </ul>
- */
- void printDeclarationOn(PrintWriter pw);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/MethodSignature.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/MethodSignature.java
deleted file mode 100644
index 32e793a071..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/MethodSignature.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility;
-
-import java.io.PrintWriter;
-import java.lang.reflect.Method;
-
-/**
- * This interface describes a Java method signature; i.e. its "name"
- * and its "parameter types". The parameter types are referenced by name,
- * allowing us to reference classes that are not (or cannot be) loaded.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- * <p>
- * This interface is not intended to be implemented by clients.
- */
-public interface MethodSignature {
-
- /**
- * Return the method's name.
- */
- String getName();
-
- /**
- * Return the method's parameter types.
- */
- JavaType[] getParameterTypes();
-
- /**
- * Return whether the method signature describes the specified method.
- */
- boolean describes(Method method);
-
- /**
- * Return whether the method signature equals the specified signature.
- */
- boolean equals(String otherName, JavaType[] otherParameterTypes);
-
- /**
- * Return whether the method signature equals the specified signature.
- */
- boolean equals(MethodSignature other);
-
- /**
- * Return a string representation of the method's signature:<p>
- * <code>"foo(int, java.lang.String)"</code>
- */
- String getSignature();
-
- /**
- * Append a string representation of the method's signature:<p>
- * <code>"foo(int, java.lang.String)"</code>
- */
- void appendSignatureTo(StringBuilder sb);
-
- /**
- * Print a string representation of the method's signature:<p>
- * <code>"foo(int, java.lang.String)"</code>
- */
- void printSignatureOn(PrintWriter pw);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ModifiableObjectReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ModifiableObjectReference.java
deleted file mode 100644
index 3bbd0a735c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ModifiableObjectReference.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility;
-
-/**
- * Provide a container for passing an object that can be changed by the recipient.
- */
-public interface ModifiableObjectReference<V>
- extends ObjectReference<V>
-{
- /**
- * Set the value.
- * Return the previous value.
- */
- V setValue(V value);
-
- /**
- * Set the value to <code>null</code>.
- * Return the previous value.
- */
- V setNull();
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ObjectReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ObjectReference.java
deleted file mode 100644
index 54b6ba49f9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/ObjectReference.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility;
-
-/**
- * Provide a container for holding an object that cannot be changed.
- *
- * @see ModifiableObjectReference
- */
-public interface ObjectReference<V> {
- /**
- * Return the current value.
- */
- V getValue();
-
- /**
- * Return whether the current value is equal to the specified value.
- */
- boolean valueEquals(Object object);
-
- /**
- * Return whether the current value is not equal to the specified value.
- */
- boolean valueNotEqual(Object object);
-
- /**
- * Return whether the current value is <code>null</code>.
- */
- boolean isNull();
-
- /**
- * Return whether the current value is not <code>null</code>.
- */
- boolean isNotNull();
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/Command.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/Command.java
deleted file mode 100644
index ba7bd56d46..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/Command.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Simple interface for implementing the GOF Command design pattern,
- * and it doesn't carry the baggage of {@link java.lang.Runnable}.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface Command
- extends InterruptibleCommand
-{
- /**
- * Execute the command. The semantics of the command
- * is determined by the contract between the client and server.
- */
- void execute();
-
-
- /**
- * Singleton implementation of the command interface that will do nothing
- * when executed.
- */
- final class Null
- implements Command, Serializable
- {
- public static final Command INSTANCE = new Null();
- public static Command instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void execute() {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- /**
- * Singleton implementation of the command interface that will throw an
- * exception when executed.
- */
- final class Disabled
- implements Command, Serializable
- {
- public static final Command INSTANCE = new Disabled();
- public static Command instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public void execute() {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/CommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/CommandExecutor.java
deleted file mode 100644
index c8c8af64ac..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/CommandExecutor.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This interface allows clients to control how a command is executed.
- * This is useful when the server provides the command but the client provides
- * the context (e.g. the client would like to dispatch the command to the UI
- * thread).
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface CommandExecutor {
-
- /**
- * Execute the specified command, synchronously or asynchronously.
- * The commands themselves must be executed in the order in which
- * they are passed to the command executor (at least when passed
- * from clients executing on the same thread).
- */
- void execute(Command command);
-
-
- /**
- * Singleton implementation of the command executor interface
- * that simply executes the command without any sort of enhancement.
- */
- final class Default
- implements CommandExecutor, Serializable
- {
- public static final CommandExecutor INSTANCE = new Default();
- public static CommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- public void execute(Command command) {
- command.execute();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
-
- /**
- * Singleton implementation of the command executor interface
- * that ignores any commands.
- */
- final class Inactive
- implements CommandExecutor, Serializable
- {
- public static final CommandExecutor INSTANCE = new Inactive();
- public static CommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Inactive() {
- super();
- }
- public void execute(Command command) {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/ExtendedCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/ExtendedCommandExecutor.java
deleted file mode 100644
index fabb5c5d05..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/ExtendedCommandExecutor.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This interface extends the normal command executor; it allows the client
- * to specify when a command <em>must</em> be executed synchronously.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ExtendedCommandExecutor
- extends CommandExecutor
-{
- /**
- * Suspend the current thread until the specified command is executed.
- * The command itself must be executed <em>after</em> any other commands
- * previously passed to the command executor (at least when passed
- * from clients executing on the same thread).
- * @see #execute(Command)
- */
- void waitToExecute(Command command) throws InterruptedException;
-
- /**
- * Suspend the current thread until the specified command is executed
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the command was executed in the allotted time;
- * return <code>false</code> if a time-out occurred and the command was
- * <em>not</em> executed.
- * If the time-out is zero, wait indefinitely.
- * <p>
- * The command itself must be executed <em>after</em> any other commands
- * previously passed to the command executor (at least when passed
- * from clients executing on the same thread).
- * @see #execute(Command)
- */
- boolean waitToExecute(Command command, long timeout) throws InterruptedException;
-
-
- /**
- * Singleton implementation of the command executor interface
- * that simply executes the command without any sort of enhancement.
- */
- final class Default
- implements ExtendedCommandExecutor, Serializable
- {
- public static final ExtendedCommandExecutor INSTANCE = new Default();
- public static ExtendedCommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- public void execute(Command command) {
- command.execute();
- }
- public void waitToExecute(Command command) {
- command.execute();
- }
- public boolean waitToExecute(Command command, long timeout) {
- command.execute();
- return true;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
-
- /**
- * Singleton implementation of the command executor interface
- * that ignores any commands.
- */
- final class Inactive
- implements ExtendedCommandExecutor, Serializable
- {
- public static final ExtendedCommandExecutor INSTANCE = new Inactive();
- public static ExtendedCommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Inactive() {
- super();
- }
- public void execute(Command command) {
- // do nothing
- }
- public void waitToExecute(Command command) {
- // do nothing
- }
- public boolean waitToExecute(Command command, long timeout) {
- // do nothing
- return true;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/InterruptibleCommand.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/InterruptibleCommand.java
deleted file mode 100644
index c7bfaa78f4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/InterruptibleCommand.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Simple interface for implementing the GOF Command design pattern
- * and allows for the command to throw an {@link InterruptedException}.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @see org.eclipse.jpt.common.utility.command.Command
- */
-public interface InterruptibleCommand {
-
- /**
- * Execute the command. The semantics of the command
- * is determined by the contract between the client and server.
- */
- void execute() throws InterruptedException;
-
-
- /**
- * Singleton implementation of the interruptible command interface that
- * will throw an interrupted exception when executed.
- */
- final class Interrupted
- implements InterruptibleCommand, Serializable
- {
- public static final InterruptibleCommand INSTANCE = new Interrupted();
- public static InterruptibleCommand instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Interrupted() {
- super();
- }
- // throw an exception
- public void execute() throws InterruptedException {
- throw new InterruptedException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/InterruptibleCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/InterruptibleCommandExecutor.java
deleted file mode 100644
index 14ec4d1445..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/InterruptibleCommandExecutor.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This interface allows clients to control how an interruptible command is executed.
- * This is useful when the server provides the command but the client provides
- * the context (e.g. the client would like to dispatch the command to the UI
- * thread).
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @see org.eclipse.jpt.common.utility.command.CommandExecutor
- */
-public interface InterruptibleCommandExecutor {
-
- /**
- * Execute the specified command.
- */
- void execute(InterruptibleCommand command) throws InterruptedException;
-
-
- /**
- * Singleton implementation of the interruptible command executor interface
- * that simply executes the command without any sort of enhancement.
- */
- final class Default
- implements InterruptibleCommandExecutor, Serializable
- {
- public static final InterruptibleCommandExecutor INSTANCE = new Default();
- public static InterruptibleCommandExecutor instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- public void execute(InterruptibleCommand command) throws InterruptedException {
- command.execute();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/NotifyingRepeatingCommand.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/NotifyingRepeatingCommand.java
deleted file mode 100644
index 7076a20e8e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/NotifyingRepeatingCommand.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.command;
-
-import java.io.Serializable;
-import java.util.EventListener;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Extend the repeating command to support listeners that are notified
- * when an execution "cycle" is complete; i.e. the command has,
- * for the moment, handled every execution request and quiesced.
- * This notification is <em>not</em> guaranteed to occur with <em>every</em>
- * execution "cycle"; since other, unrelated, executions can be triggered
- * concurrently, causing the "cycle" to continue.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface NotifyingRepeatingCommand
- extends RepeatingCommand
-{
- /**
- * Add the specified listener.
- */
- void addListener(Listener listener);
-
- /**
- * Remove the specified listener.
- */
- void removeListener(Listener listener);
-
-
- // ********** listener **********
-
- /**
- * Interface implemented by listeners to be notified whenever the
- * command has quiesced.
- */
- public interface Listener
- extends EventListener
- {
- /**
- * The specified command has quiesced.
- */
- void executionQuiesced(Command command);
- }
-
-
- // ********** null singleton **********
-
- /**
- * Singleton implementation of the notifying repeating command interface
- * that will do nothing when executed.
- */
- final class Null
- implements NotifyingRepeatingCommand, Serializable
- {
- public static final NotifyingRepeatingCommand INSTANCE = new Null();
- public static NotifyingRepeatingCommand instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void start() {
- // do nothing
- }
- public void execute() {
- // do nothing
- }
- public void stop() {
- // do nothing
- }
- public void addListener(Listener listener) {
- // do nothing
- }
- public void removeListener(Listener listener) {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/RepeatingCommand.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/RepeatingCommand.java
deleted file mode 100644
index c73f2c11a5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/RepeatingCommand.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.command;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This command will execute repeatedly the minimum
- * number of times. The assumption is the command's effects are
- * cumulative(?); i.e. the cumulative result of multiple executions of the
- * command is no different than the result of a single execution of the command.
- * Once the command is executing, any further requests to execute simply trigger
- * a re-execution of the command once it has finished its current execution.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface RepeatingCommand
- extends Command
-{
- /**
- * Start the command, allowing it to begin executing with the next call to
- * {@link #execute()}.
- * @exception IllegalStateException when the command is not stopped
- */
- void start();
-
- /**
- * Stop the command; ignore further calls to {@link #execute()}.
- * @exception IllegalStateException when the command executor is not started
- */
- void stop() throws InterruptedException;
-
-
- /**
- * Singleton implementation of the repeating command interface that will do
- * nothing when executed.
- */
- final class Null
- implements RepeatingCommand, Serializable
- {
- public static final RepeatingCommand INSTANCE = new Null();
- public static RepeatingCommand instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void start() {
- // do nothing
- }
- public void execute() {
- // do nothing
- }
- public void stop() {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/StatefulCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/StatefulCommandExecutor.java
deleted file mode 100644
index a7e66f7366..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/StatefulCommandExecutor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.command;
-
-/**
- * Add the ability to start and stop the command executor.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface StatefulCommandExecutor
- extends CommandExecutor
-{
- /**
- * Start the command executor.
- * @exception IllegalStateException when the command executor is not stopped
- */
- void start();
-
- /**
- * Stop the command executor.
- * @exception IllegalStateException when the command executor is not started
- */
- void stop() throws InterruptedException;
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/StatefulExtendedCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/StatefulExtendedCommandExecutor.java
deleted file mode 100644
index d2874face3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/command/StatefulExtendedCommandExecutor.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.command;
-
-/**
- * Add the ability to start and stop the command executor.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface StatefulExtendedCommandExecutor
- extends StatefulCommandExecutor, ExtendedCommandExecutor
-{
- // combine interfaces
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractAssociation.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractAssociation.java
deleted file mode 100644
index 744d95c727..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractAssociation.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Implement some of the methods in {@link Association} that can
- * be defined in terms of the other methods.
- */
-public abstract class AbstractAssociation<K, V>
- implements Association<K, V>
-{
- /**
- * Default constructor.
- */
- protected AbstractAssociation() {
- super();
- }
-
- @Override
- public synchronized boolean equals(Object o) {
- if ( ! (o instanceof Association<?, ?>)) {
- return false;
- }
- Association<?, ?> other = (Association<?, ?>) o;
- return this.keyEquals(other) && this.valueEquals(other);
- }
-
- protected boolean keyEquals(Association<?, ?> other) {
- Object key = this.getKey();
- return (key == null) ?
- (other.getKey() == null) :
- key.equals(other.getKey());
- }
-
- protected boolean valueEquals(Association<?, ?> other) {
- Object value = this.getValue();
- return (value == null) ?
- (other.getValue() == null) :
- value.equals(other.getValue());
- }
-
- @Override
- public synchronized int hashCode() {
- return this.keyHashCode() ^ this.valueHashCode();
- }
-
- protected int keyHashCode() {
- Object key = this.getKey();
- return (key == null) ? 0 : key.hashCode();
- }
-
- protected int valueHashCode() {
- Object value = this.getValue();
- return (value == null) ? 0 : value.hashCode();
- }
-
- @Override
- public synchronized String toString() {
- return this.getKey() + " => " + this.getValue(); //$NON-NLS-1$
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractBooleanReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractBooleanReference.java
deleted file mode 100644
index 5e6f1b1ad6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractBooleanReference.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Convenience abstract class for boolean reference implementations.
- * Subclasses need only implement<ul>
- * <li>{@link #getValue()}
- * <li>{@link #setValue(boolean)}
- * </ul>
- */
-public abstract class AbstractBooleanReference
- implements ModifiableBooleanReference
-{
- protected AbstractBooleanReference() {
- super();
- }
-
- public boolean is(boolean value) {
- return this.getValue() == value;
- }
-
- public boolean isNot(boolean value) {
- return this.getValue() != value;
- }
-
- public boolean isTrue() {
- return this.getValue();
- }
-
- public boolean isFalse() {
- return ! this.getValue();
- }
-
- public boolean flip() {
- return this.setValue( ! this.getValue());
- }
-
- public boolean setNot(boolean value) {
- return this.setValue( ! value);
- }
-
- public boolean setTrue() {
- return this.setValue(true);
- }
-
- public boolean setFalse() {
- return this.setValue(false);
- }
-
-
- // ********** standard methods **********
-
- /**
- * Object identity is critical to boolean references.
- * There is no reason for two different boolean references to be
- * <em>equal</em>.
- *
- * @see #is(boolean)
- */
- @Override
- public boolean equals(Object obj) {
- return super.equals(obj);
- }
-
- /**
- * @see #equals(Object)
- */
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-
- @Override
- public String toString() {
- return '[' + String.valueOf(this.getValue()) + ']';
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractTransformer.java
deleted file mode 100644
index b6a4e2a2de..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/AbstractTransformer.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Convenience transformer that returns <code>null</code> if the original
- * object is <code>null</code>; otherwise it calls {@link #transform_(Object)},
- * which is to be implemented by subclasses.
- */
-public abstract class AbstractTransformer<T1, T2>
- extends TransformerAdapter<T1, T2>
-{
- @Override
- public final T2 transform(T1 o) {
- return (o == null) ? null : this.transform_(o);
- }
-
- /**
- * Transform the specified object; its value is guaranteed to be not
- * <code>null</code>.
- */
- protected abstract T2 transform_(T1 o);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ArrayTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ArrayTools.java
deleted file mode 100644
index 4f152023e7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ArrayTools.java
+++ /dev/null
@@ -1,3122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Random;
-
-/**
- * Array-related utility methods.
- */
-public final class ArrayTools {
- public static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
- public static final char[] EMPTY_CHAR_ARRAY = new char[0];
- public static final int[] EMPTY_INT_ARRAY = new int[0];
-
- // ********** instantiation **********
-
- /**
- * Return a new array with the same length
- * and the same component type as the specified array.
- * <p>
- * <code>Arrays.newArray(Object[] array)</code>
- */
- public static <E> E[] newArray(E[] array) {
- return newArray(array, array.length);
- }
-
- /**
- * Return a new array with the specified length
- * and the same component type as the specified array.
- * <p>
- * <code>Arrays.newArray(Object[] array, int length)</code>
- */
- public static <E> E[] newArray(E[] array, int length) {
- return newArray(componentType(array), length);
- }
-
- /**
- * Return the specified array's component type, with appropriate support
- * for generics.
- */
- public static <E> Class<? extends E> componentType(E[] array) {
- Class<?> rawComponentType = array.getClass().getComponentType();
- @SuppressWarnings("unchecked")
- Class<? extends E> componentType = (Class<? extends E>) rawComponentType;
- return componentType;
- }
-
- /**
- * Return a new array with the specified component type and length,
- * with appropriate support for generics. The component type cannot be a
- * primitive type.
- */
- public static <E> E[] newArray(Class<? extends E> componentType, int length) {
- if (componentType.isPrimitive()) {
- throw new IllegalArgumentException("Array class cannot be primitive: " + componentType); //$NON-NLS-1$
- }
- return newArray_(componentType, length);
- }
-
- /**
- * assume the component type is not a primitive class
- */
- @SuppressWarnings("unchecked")
- private static <E> E[] newArray_(Class<? extends E> componentType, int length) {
- return (E[]) ((componentType == OBJECT_CLASS) ?
- new Object[length] :
- Array.newInstance(componentType, length));
- }
- private static final Class<Object> OBJECT_CLASS = Object.class;
-
-
- // ********** conversion **********
-
- /**
- * Return an array corresponding to the specified iterable.
- * <p>
- * <code>Iterable.toArray()</code>
- * @see Collection#toArray()
- */
- public static Object[] array(Iterable<?> iterable) {
- return array(iterable.iterator());
- }
-
- /**
- * Return an array corresponding to the specified iterable.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Iterable.toArray()</code>
- * @see Collection#toArray()
- */
- public static Object[] array(Iterable<?> iterable, int iterableSize) {
- return array(iterable.iterator(), iterableSize);
- }
-
- /**
- * Return an array corresponding to the specified iterable;
- * the runtime type of the returned array is that of the specified array.
- * If the iterable fits in the specified array, it is returned therein.
- * Otherwise, a new array is allocated with the runtime type of the
- * specified array and the size of the iterable.
- * <p>
- * <code>Iterable.toArray(Object[])</code>
- * @see Collection#toArray(Object[])
- */
- public static <E> E[] array(Iterable<? extends E> iterable, E[] array) {
- return array(iterable.iterator(), array);
- }
-
- /**
- * Return an array corresponding to the specified iterable;
- * the runtime type of the returned array is that of the specified array.
- * If the iterable fits in the specified array, it is returned therein.
- * Otherwise, a new array is allocated with the runtime type of the
- * specified array and the size of the iterable.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Iterable.toArray(Object[])</code>
- * @see Collection#toArray(Object[])
- */
- public static <E> E[] array(Iterable<? extends E> iterable, int iterableSize, E[] array) {
- return array(iterable.iterator(), iterableSize, array);
- }
-
- /**
- * Return an array corresponding to the specified iterator.
- * <p>
- * <code>Iterator.toArray()</code>
- * @see Collection#toArray()
- */
- public static Object[] array(Iterator<?> iterator) {
- return iterator.hasNext() ?
- CollectionTools.list(iterator).toArray() :
- EMPTY_OBJECT_ARRAY;
- }
-
- /**
- * Return an array corresponding to the specified iterator.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Iterator.toArray()</code>
- * @see Collection#toArray()
- */
- public static Object[] array(Iterator<?> iterator, int iteratorSize) {
- return iterator.hasNext() ?
- CollectionTools.list(iterator, iteratorSize).toArray() :
- EMPTY_OBJECT_ARRAY;
- }
-
- /**
- * Return an array corresponding to the specified iterator;
- * the runtime type of the returned array is that of the specified array.
- * If the iterator fits in the specified array, it is returned therein.
- * Otherwise, a new array is allocated with the runtime type of the
- * specified array and the size of the iterator.
- * <p>
- * <code>Iterator.toArray(Object[])</code>
- * @see Collection#toArray(Object[])
- */
- public static <E> E[] array(Iterator<? extends E> iterator, E[] array) {
- return iterator.hasNext() ?
- CollectionTools.list(iterator).toArray(array) :
- emptyArray(array);
- }
-
- /**
- * Return an array corresponding to the specified iterator;
- * the runtime type of the returned array is that of the specified array.
- * If the iterator fits in the specified array, it is returned therein.
- * Otherwise, a new array is allocated with the runtime type of the
- * specified array and the size of the iterator.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Iterator.toArray(Object[])</code>
- * @see Collection#toArray(Object[])
- */
- public static <E> E[] array(Iterator<? extends E> iterator, int iteratorSize, E[] array) {
- return iterator.hasNext() ?
- CollectionTools.list(iterator, iteratorSize).toArray(array) :
- emptyArray(array);
- }
-
- /**
- * If the specified array is empty, return it;
- * otherwise, set its first element to null.
- * @see Collection#toArray(Object[])
- */
- private static <E> E[] emptyArray(E[] array) {
- return (array.length == 0) ? array : clearFirst(array);
- }
-
- /**
- * Set the specified array's first element to null and and return the array.
- * Assume the array length > 0.
- */
- private static <E> E[] clearFirst(E[] array) {
- array[0] = null;
- return array;
- }
-
-
- // ********** add **********
-
- /**
- * Return a new array containing the elements in the
- * specified array followed by the specified object to be added.
- * <p>
- * <code>Arrays.add(Object[] array, Object o)</code>
- */
- public static <E> E[] add(E[] array, E value) {
- int len = array.length;
- E[] result = newArray(array, len + 1);
- if (len > 0) {
- System.arraycopy(array, 0, result, 0, len);
- }
- result[len] = value;
- return result;
- }
-
- /**
- * Return a new array containing the elements in the
- * specified array with the specified object added at the specified index.
- * <p>
- * <code>Arrays.add(Object[] array, int index, Object o)</code>
- */
- public static <E> E[] add(E[] array, int index, E value) {
- int len = array.length;
- E[] result = newArray(array, len + 1);
- if (index > 0) {
- System.arraycopy(array, 0, result, 0, index);
- }
- result[index] = value;
- if (index < len) {
- System.arraycopy(array, index, result, index + 1, len - index);
- }
- return result;
- }
-
- /**
- * Return a new array containing the elements in the
- * specified array followed by the specified value to be added.
- * <p>
- * <code>Arrays.add(char[] array, char value)</code>
- */
- public static char[] add(char[] array, char value) {
- int len = array.length;
- char[] result = new char[len + 1];
- if (len > 0) {
- System.arraycopy(array, 0, result, 0, len);
- }
- result[len] = value;
- return result;
- }
-
- /**
- * Return a new array containing the elements in the
- * specified array with the specified value added at the specified index.
- * <p>
- * <code>Arrays.add(char[] array, int index, char value)</code>
- */
- public static char[] add(char[] array, int index, char value) {
- int len = array.length;
- char[] result = new char[len + 1];
- if (index > 0) {
- System.arraycopy(array, 0, result, 0, index);
- }
- result[index] = value;
- if (index < len) {
- System.arraycopy(array, index, result, index + 1, len - index);
- }
- return result;
- }
-
- /**
- * Return a new array containing the elements in the
- * specified array followed by the specified value to be added.
- * <p>
- * <code>Arrays.add(int[] array, int value)</code>
- */
- public static int[] add(int[] array, int value) {
- int len = array.length;
- int[] result = new int[len + 1];
- if (len > 0) {
- System.arraycopy(array, 0, result, 0, len);
- }
- result[len] = value;
- return result;
- }
-
- /**
- * Return a new array containing the elements in the
- * specified array with the specified value added at the specified index.
- * <p>
- * <code>Arrays.add(int[] array, int index, int value)</code>
- */
- public static int[] add(int[] array, int index, int value) {
- int len = array.length;
- int[] result = new int[len + 1];
- if (index > 0) {
- System.arraycopy(array, 0, result, 0, index);
- }
- result[index] = value;
- if (index < len) {
- System.arraycopy(array, index, result, index + 1, len - index);
- }
- return result;
- }
-
-
- // ********** add all **********
-
- /**
- * Return an array containing the elements in the
- * specified array followed by the elements
- * in the specified collection.
- *<p>
- * <code>Arrays.addAll(Object[] array, Collection collection)</code>
- */
- public static <E> E[] addAll(E[] array, Collection<? extends E> collection) {
- return addAll(array, collection, collection.size());
- }
-
- /**
- * check collection size
- */
- private static <E> E[] addAll(E[] array, Collection<? extends E> collection, int collectionSize) {
- return (collectionSize == 0) ? array : addAll_(array, collection, collectionSize);
- }
-
- /**
- * assume the collection is non-empty
- */
- private static <E> E[] addAll_(E[] array, Collection<? extends E> collection) {
- return addAll_(array, collection, collection.size());
- }
-
- /**
- * assume collection size > zero
- */
- private static <E> E[] addAll_(E[] array, Collection<? extends E> collection, int collectionSize) {
- return addAll(array, collection, array.length, collectionSize);
- }
-
- /**
- * assume collection size > zero; check array length
- */
- private static <E> E[] addAll(E[] array, Collection<? extends E> collection, int arrayLength, int collectionSize) {
- return (arrayLength == 0) ?
- collection.toArray(newArray(array, collectionSize)) :
- addAll_(array, collection, arrayLength, collectionSize);
- }
-
- /**
- * assume array length and collection size > zero
- */
- private static <E> E[] addAll_(E[] array, Collection<? extends E> collection, int arrayLength, int collectionSize) {
- E[] result = newArray(array, arrayLength + collectionSize);
- System.arraycopy(array, 0, result, 0, arrayLength);
- int i = arrayLength;
- for (E element : collection) {
- result[i++] = element;
- }
- return result;
- }
-
- /**
- * Return an array containing the elements in the
- * specified array followed by the elements
- * in the specified iterable.
- * <p>
- * <code>Arrays.addAll(Object[] array, Iterable iterable)</code>
- */
- public static <E> E[] addAll(E[] array, Iterable<? extends E> iterable) {
- return addAll(array, iterable.iterator());
- }
-
- /**
- * Return an array containing the elements in the
- * specified array followed by the elements
- * in the specified iterable.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Arrays.addAll(Object[] array, Iterable iterable)</code>
- */
- public static <E> E[] addAll(E[] array, Iterable<? extends E> iterable, int iterableSize) {
- return addAll(array, iterable.iterator(), iterableSize);
- }
-
- /**
- * Return an array containing the elements in the
- * specified array followed by the elements
- * in the specified iterator.
- * <p>
- * <code>Arrays.addAll(Object[] array, Iterator iterator)</code>
- */
- public static <E> E[] addAll(E[] array, Iterator<? extends E> iterator) {
- return iterator.hasNext() ? addAll_(array, CollectionTools.list(iterator)) : array;
- }
-
- /**
- * Return an array containing the elements in the
- * specified array followed by the elements
- * in the specified iterator.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Arrays.addAll(Object[] array, Iterator iterator)</code>
- */
- public static <E> E[] addAll(E[] array, Iterator<? extends E> iterator, int iteratorSize) {
- return iterator.hasNext() ? addAll_(array, CollectionTools.list(iterator, iteratorSize)) : array;
- }
-
- /**
- * Return an array containing the elements in the
- * specified array 1 followed by the elements
- * in the specified array 2.
- * <p>
- * <code>Arrays.addAll(Object[] array1, Object[] array2)</code>
- */
- public static <E> E[] addAll(E[] array1, E... array2) {
- return addAll(array1, array2, array2.length);
- }
-
- /**
- * check array 2 length
- */
- private static <E> E[] addAll(E[] array1, E[] array2, int array2Length) {
- return (array2Length == 0) ? array1 : addAll_(array1, array2, array2Length);
- }
-
- /**
- * assume array 2 length > 0
- */
- private static <E> E[] addAll_(E[] array1, E[] array2, int array2Length) {
- return addAll(array1, array2, array1.length, array2Length);
- }
-
- /**
- * assume array 2 length > 0; check array 1 length
- */
- private static <E> E[] addAll(E[] array1, E[] array2, int array1Length, int array2Length) {
- return (array1Length == 0) ? array2 : addAll_(array1, array2, array1Length, array2Length);
- }
-
- /**
- * assume both array lengths > 0
- */
- private static <E> E[] addAll_(E[] array1, E[] array2, int array1Length, int array2Length) {
- E[] result = newArray(array1, array1Length + array2Length);
- System.arraycopy(array1, 0, result, 0, array1Length);
- System.arraycopy(array2, 0, result, array1Length, array2Length);
- return result;
- }
-
- /**
- * Return an array containing the elements in the
- * first specified array with the objects in the second
- * specified array added at the specified index.
- * <p>
- * <code>Arrays.addAll(Object[] array1, int index, Object[] array2)</code>
- */
- public static <E> E[] addAll(E[] array1, int index, E... array2) {
- return addAll(array1, index, array2, array2.length);
- }
-
- /**
- * check array 2 length
- */
- private static <E> E[] addAll(E[] array1, int index, E[] array2, int array2Length) {
- return (array2Length == 0) ? array1 : addAll_(array1, index, array2, array2Length);
- }
-
- /**
- * assume array 2 length > 0
- */
- private static <E> E[] addAll_(E[] array1, int index, E[] array2, int array2Length) {
- return addAll(array1, index, array2, array1.length, array2Length);
- }
-
- /**
- * assume array 2 length > 0; check array 1 length
- */
- private static <E> E[] addAll(E[] array1, int index, E[] array2, int array1Length, int array2Length) {
- return (array1Length == 0) ?
- array2 :
- (index == array1Length) ? // 'array2' added to end of 'array1'
- addAll_(array1, array2, array1Length, array2Length) :
- addAll_(array1, index, array2, array1Length, array2Length);
- }
-
- /**
- * assume both array lengths > 0 and index != array 1 length
- */
- private static <E> E[] addAll_(E[] array1, int index, E[] array2, int array1Length, int array2Length) {
- E[] result = newArray(array1, array1Length + array2Length);
- System.arraycopy(array1, 0, result, 0, index);
- System.arraycopy(array2, 0, result, index, array2Length);
- System.arraycopy(array1, index, result, index + array2Length, array1Length - index);
- return result;
- }
-
- /**
- * Return an array containing the elements in the
- * specified array with the elements
- * in the specified collection inserted at the specified index.
- * <p>
- * <code>Arrays.addAll(Object[] array, int index, Collection c)</code>
- */
- public static <E> E[] addAll(E[] array, int index, Collection<? extends E> collection) {
- return addAll(array, index, collection, collection.size());
- }
-
- /**
- * check collection size
- */
- private static <E> E[] addAll(E[] array, int index, Collection<? extends E> collection, int collectionSize) {
- return (collectionSize == 0) ? array : addAll_(array, index, collection, collectionSize);
- }
-
- /**
- * assume collection size > 0
- */
- private static <E> E[] addAll_(E[] array, int index, Collection<? extends E> collection, int collectionSize) {
- return addAll(array, index, collection, array.length, collectionSize);
- }
-
- /**
- * assume collection size > 0; check array length
- */
- private static <E> E[] addAll(E[] array, int index, Collection<? extends E> collection, int arrayLength, int collectionSize) {
- if (arrayLength == 0) {
- if (index == 0) {
- return collection.toArray(newArray(array, collectionSize));
- }
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: 0"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return (index == arrayLength) ? // 'collection' added to end of 'array'
- addAll_(array, collection, arrayLength, collectionSize) :
- addAll_(array, index, collection, arrayLength, collectionSize);
- }
-
- /**
- * assume array length and collection size > 0 and index != array length
- */
- private static <E> E[] addAll_(E[] array, int index, Collection<? extends E> collection, int arrayLength, int collectionSize) {
- E[] result = newArray(array, arrayLength + collectionSize);
- System.arraycopy(array, 0, result, 0, index);
- int i = index;
- for (E item : collection) {
- result[i++] = item;
- }
- System.arraycopy(array, index, result, index + collectionSize, arrayLength - index);
- return result;
- }
-
- /**
- * Return an array containing the elements in the
- * specified array with the elements
- * in the specified iterable inserted at the specified index.
- * <p>
- * <code>Arrays.addAll(Object[] array, int index, Iterable iterable)</code>
- */
- public static <E> E[] addAll(E[] array, int index, Iterable<? extends E> iterable) {
- return addAll(array, index, iterable.iterator());
- }
-
- /**
- * Return an array containing the elements in the
- * specified array with the elements
- * in the specified iterable inserted at the specified index.
- * <p>
- * <code>Arrays.addAll(Object[] array, int index, Iterable iterable)</code>
- */
- public static <E> E[] addAll(E[] array, int index, Iterable<? extends E> iterable, int iterableSize) {
- return addAll(array, index, iterable.iterator(), iterableSize);
- }
-
- /**
- * Return an array containing the elements in the
- * specified array with the elements
- * in the specified iterator inserted at the specified index.
- * <p>
- * <code>Arrays.addAll(Object[] array, int index, Iterator iterator)</code>
- */
- public static <E> E[] addAll(E[] array, int index, Iterator<? extends E> iterator) {
- return iterator.hasNext() ? addAll_(array, index, CollectionTools.list(iterator)) : array;
- }
-
- /**
- * Return an array containing the elements in the
- * specified array with the elements
- * in the specified iterator inserted at the specified index.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Arrays.addAll(Object[] array, int index, Iterator iterator)</code>
- */
- public static <E> E[] addAll(E[] array, int index, Iterator<? extends E> iterator, int iteratorSize) {
- return iterator.hasNext() ? addAll_(array, index, CollectionTools.list(iterator, iteratorSize)) : array;
- }
-
- /**
- * assume collection is non-empty
- */
- private static <E> E[] addAll_(E[] array, int index, Collection<? extends E> collection) {
- return addAll_(array, index, collection, collection.size());
- }
-
- /**
- * Return an array containing the elements in the
- * specified array 1 followed by the elements
- * in the specified array 2.
- * <p>
- * <code>Arrays.addAll(char[] array1, char[] array2)</code>
- */
- public static char[] addAll(char[] array1, char... array2) {
- return addAll(array1, array2, array2.length);
- }
-
- /**
- * check array 2 length
- */
- private static char[] addAll(char[] array1, char[] array2, int array2Length) {
- return (array2Length == 0) ? array1 : addAll_(array1, array2, array2Length);
- }
-
- /**
- * assume array 2 length > 0
- */
- private static char[] addAll_(char[] array1, char[] array2, int array2Length) {
- return addAll(array1, array2, array1.length, array2Length);
- }
-
- /**
- * assume array 2 length > 0; check array 1 length
- */
- private static char[] addAll(char[] array1, char[] array2, int array1Length, int array2Length) {
- return (array1Length == 0) ? array2 : addAll_(array1, array2, array1Length, array2Length);
- }
-
- /**
- * assume both array lengths > 0
- */
- private static char[] addAll_(char[] array1, char[] array2, int array1Length, int array2Length) {
- char[] result = new char[array1Length + array2Length];
- System.arraycopy(array1, 0, result, 0, array1Length);
- System.arraycopy(array2, 0, result, array1Length, array2Length);
- return result;
- }
-
- /**
- * Return an array containing the elements in the
- * first specified array with the objects in the second
- * specified array added at the specified index.
- * <p>
- * <code>Arrays.add(char[] array1, int index, char[] array2)</code>
- */
- public static char[] addAll(char[] array1, int index, char... array2) {
- return addAll(array1, index, array2, array2.length);
- }
-
- /**
- * check array 2 length
- */
- private static char[] addAll(char[] array1, int index, char[] array2, int array2Length) {
- return (array2Length == 0) ? array1 : addAll_(array1, index, array2, array2Length);
- }
-
- /**
- * assume array 2 length > 0
- */
- private static char[] addAll_(char[] array1, int index, char[] array2, int array2Length) {
- return addAll(array1, index, array2, array1.length, array2Length);
- }
-
- /**
- * assume array 2 length > 0; check array 1 length
- */
- private static char[] addAll(char[] array1, int index, char[] array2, int array1Length, int array2Length) {
- return (array1Length == 0) ?
- array2 :
- (index == array1Length) ? // 'array2' added to end of 'array1'
- addAll_(array1, array2, array1Length, array2Length) :
- addAll_(array1, index, array2, array1Length, array2Length);
- }
-
- /**
- * assume both array lengths > 0 and index != array 1 length
- */
- private static char[] addAll_(char[] array1, int index, char[] array2, int array1Length, int array2Length) {
- char[] result = new char[array1Length + array2Length];
- System.arraycopy(array1, 0, result, 0, index);
- System.arraycopy(array2, 0, result, index, array2Length);
- System.arraycopy(array1, index, result, index + array2Length, array1Length - index);
- return result;
- }
-
- /**
- * Return an array containing the elements in the
- * specified array 1 followed by the elements
- * in the specified array 2.
- * <p>
- * <code>Arrays.addAll(int[] array1, int[] array2)</code>
- */
- public static int[] addAll(int[] array1, int... array2) {
- return addAll(array1, array2, array2.length);
- }
-
- /**
- * check array 2 length
- */
- private static int[] addAll(int[] array1, int[] array2, int array2Length) {
- return (array2Length == 0) ? array1 : addAll_(array1, array2, array2Length);
- }
-
- /**
- * assume array 2 length > 0
- */
- private static int[] addAll_(int[] array1, int[] array2, int array2Length) {
- return addAll(array1, array2, array1.length, array2Length);
- }
-
- /**
- * assume array 2 length > 0; check array 1 length
- */
- private static int[] addAll(int[] array1, int[] array2, int array1Length, int array2Length) {
- return (array1Length == 0) ? array2 : addAll_(array1, array2, array1Length, array2Length);
- }
-
- /**
- * assume both array lengths > 0
- */
- private static int[] addAll_(int[] array1, int[] array2, int array1Length, int array2Length) {
- int[] result = new int[array1Length + array2Length];
- System.arraycopy(array1, 0, result, 0, array1Length);
- System.arraycopy(array2, 0, result, array1Length, array2Length);
- return result;
- }
-
- /**
- * Return an array containing the elements in the
- * first specified array with the objects in the second
- * specified array added at the specified index.
- * <p>
- * <code>Arrays.add(int[] array1, int index, int[] array2)</code>
- */
- public static int[] addAll(int[] array1, int index, int... array2) {
- return addAll(array1, index, array2, array2.length);
- }
-
- /**
- * check array 2 length
- */
- private static int[] addAll(int[] array1, int index, int[] array2, int array2Length) {
- return (array2Length == 0) ? array1 : addAll_(array1, index, array2, array2Length);
- }
-
- /**
- * assume array 2 length > 0
- */
- private static int[] addAll_(int[] array1, int index, int[] array2, int array2Length) {
- return addAll(array1, index, array2, array1.length, array2Length);
- }
-
- /**
- * assume array 2 length > 0; check array 1 length
- */
- private static int[] addAll(int[] array1, int index, int[] array2, int array1Length, int array2Length) {
- return (array1Length == 0) ?
- array2 :
- (index == array1Length) ? // 'array2' added to end of 'array1'
- addAll_(array1, array2, array1Length, array2Length) :
- addAll_(array1, index, array2, array1Length, array2Length);
- }
-
- /**
- * assume both array lengths > 0 and index != array 1 length
- */
- private static int[] addAll_(int[] array1, int index, int[] array2, int array1Length, int array2Length) {
- int[] result = new int[array1Length + array2Length];
- System.arraycopy(array1, 0, result, 0, index);
- System.arraycopy(array2, 0, result, index, array2Length);
- System.arraycopy(array1, index, result, index + array2Length, array1Length - index);
- return result;
- }
-
-
- // ********** clear **********
-
- /**
- * Return an empty array with the same component type as the specified array.
- * <p>
- * <code>Arrays.clear(Object[] array)</code>
- */
- public static <E> E[] clear(E[] array) {
- return (array.length == 0) ? array : newArray(array, 0);
- }
-
-
- // ********** concatenate **********
-
- /**
- * Return an array containing all the elements in all the
- * specified arrays, concatenated in the specified order.
- * This is useful for building constant arrays out of other constant arrays.
- * <p>
- * <code>Arrays.concatenate(Object[]... arrays)</code>
- */
- public static <E> E[] concatenate(E[]... arrays) {
- int len = 0;
- for (E[] array : arrays) {
- len += array.length;
- }
- E[] result = newArray(arrays[0], len);
- if (len == 0) {
- return result;
- }
- int current = 0;
- for (E[] array : arrays) {
- int arrayLength = array.length;
- if (arrayLength > 0) {
- System.arraycopy(array, 0, result, current, arrayLength);
- current += arrayLength;
- }
- }
- return result;
- }
-
- /**
- * Return an array containing all the elements in all the
- * specified arrays, concatenated in the specified order.
- * This is useful for building constant arrays out other constant arrays.
- * <p>
- * <code>Arrays.concatenate(char[]... arrays)</code>
- */
- public static char[] concatenate(char[]... arrays) {
- int len = 0;
- for (char[] array : arrays) {
- len += array.length;
- }
- if (len == 0) {
- return EMPTY_CHAR_ARRAY;
- }
- char[] result = new char[len];
- int current = 0;
- for (char[] array : arrays) {
- int arrayLength = array.length;
- if (arrayLength != 0) {
- System.arraycopy(array, 0, result, current, arrayLength);
- current += arrayLength;
- }
- }
- return result;
- }
-
- /**
- * Return an array containing all the elements in all the
- * specified arrays, concatenated in the specified order.
- * This is useful for building constant arrays out other constant arrays.
- * <p>
- * <code>Arrays.concatenate(int[]... arrays)</code>
- */
- public static int[] concatenate(int[]... arrays) {
- int len = 0;
- for (int[] array : arrays) {
- len += array.length;
- }
- if (len == 0) {
- return EMPTY_INT_ARRAY;
- }
- int[] result = new int[len];
- int current = 0;
- for (int[] array : arrays) {
- int arrayLength = array.length;
- if (arrayLength != 0) {
- System.arraycopy(array, 0, result, current, arrayLength);
- current += arrayLength;
- }
- }
- return result;
- }
-
-
- // ********** contains **********
-
- /**
- * Return whether the specified array contains the
- * specified element.
- * <p>
- * <code>Arrays.contains(Object[] array, Object o)</code>
- */
- public static boolean contains(Object[] array, Object value) {
- return contains(array, value, array.length);
- }
-
- /**
- * check array length
- */
- private static boolean contains(Object[] array, Object value, int arrayLength) {
- return (arrayLength == 0) ? false : contains_(array, value, arrayLength);
- }
-
- /**
- * assume array length > 0
- */
- public static boolean contains_(Object[] array, Object value, int arrayLength) {
- if (value == null) {
- for (int i = arrayLength; i-- > 0; ) {
- if (array[i] == null) {
- return true;
- }
- }
- } else {
- for (int i = arrayLength; i-- > 0; ) {
- if (value.equals(array[i])) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified array contains the
- * specified element.
- * <p>
- * <code>Arrays.contains(char[] array, char value)</code>
- */
- public static boolean contains(char[] array, char value) {
- return contains(array, value, array.length);
- }
-
- /**
- * check array length
- */
- private static boolean contains(char[] array, char value, int arrayLength) {
- return (arrayLength == 0) ? false : contains_(array, value, arrayLength);
- }
-
- /**
- * assume array length > 0
- */
- private static boolean contains_(char[] array, char value, int arrayLength) {
- for (int i = arrayLength; i-- > 0; ) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified array contains the
- * specified element.
- * <p>
- * <code>Arrays.contains(int[] array, int value)</code>
- */
- public static boolean contains(int[] array, int value) {
- return contains(array, value, array.length);
- }
-
- /**
- * check array length
- */
- private static boolean contains(int[] array, int value, int arrayLength) {
- return (arrayLength == 0) ? false : contains_(array, value, arrayLength);
- }
-
- /**
- * assume array length > 0
- */
- private static boolean contains_(int[] array, int value, int arrayLength) {
- for (int i = arrayLength; i-- > 0; ) {
- if (array[i] == value) {
- return true;
- }
- }
- return false;
- }
-
-
- // ********** contains all **********
-
- /**
- * Return whether the specified array contains all of the
- * elements in the specified collection.
- * <p>
- * <code>Arrays.containsAll(Object[] array, Collection collection)</code>
- */
- public static boolean containsAll(Object[] array, Collection<?> collection) {
- return containsAll(array, collection.iterator());
- }
-
- /**
- * Return whether the specified array contains all of the
- * elements in the specified iterable.
- * <p>
- * <code>Arrays.containsAll(Object[] array, Iterable iterable)</code>
- */
- public static boolean containsAll(Object[] array, Iterable<?> iterable) {
- return containsAll(array, iterable.iterator());
- }
-
- /**
- * Return whether the specified array contains all of the
- * elements in the specified iterator.
- * <p>
- * <code>Arrays.containsAll(Object[] array, Iterator iterator)</code>
- */
- public static boolean containsAll(Object[] array, Iterator<?> iterator) {
- // use hashed lookup
- HashSet<Object> set = CollectionTools.set(array);
- while (iterator.hasNext()) {
- if ( ! set.contains(iterator.next())) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified array 1 contains all of the
- * elements in the specified array 2.
- * <p>
- * <code>Arrays.containsAll(Object[] array1, Object[] array2)</code>
- */
- public static boolean containsAll(Object[] array1, Object... array2) {
- // use hashed lookup
- HashSet<Object> set = CollectionTools.set(array1);
- for (int i = array2.length; i-- > 0; ) {
- if ( ! set.contains(array2[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified array 1 contains all of the
- * elements in the specified array 2.
- * <p>
- * <code>Arrays.containsAll(char[] array1, char[] array2)</code>
- */
- public static boolean containsAll(char[] array1, char... array2) {
- for (int i = array2.length; i-- > 0; ) {
- if ( ! contains(array1, array2[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified array 1 contains all of the
- * elements in the specified array 2.
- * <p>
- * <code>Arrays.containsAll(int[] array1, int[] array2)</code>
- */
- public static boolean containsAll(int[] array1, int... array2) {
- for (int i = array2.length; i-- > 0; ) {
- if ( ! contains(array1, array2[i])) {
- return false;
- }
- }
- return true;
- }
-
-
- // ********** diff **********
-
- /**
- * Return the index of the first elements in the specified
- * arrays that are different, beginning at the end.
- * If the arrays are identical, return -1.
- * If the arrays are different sizes, return the index of the
- * last element in the longer array.
- * Use the elements' {@link Object#equals(Object)} method to compare the
- * elements.
- */
- public static int diffEnd(Object[] array1, Object[] array2) {
- int len1 = array1.length;
- int len2 = array2.length;
- if (len1 != len2) {
- return Math.max(len1, len2) - 1;
- }
- for (int i = len1 - 1; i > -1; i--) {
- Object o = array1[i];
- if (o == null) {
- if (array2[i] != null) {
- return i;
- }
- } else {
- if ( ! o.equals(array2[i])) {
- return i;
- }
- }
- }
- return -1;
- }
-
- /**
- * Return the range of elements in the specified
- * arrays that are different.
- * If the arrays are identical, return [size, -1].
- * Use the elements' {@link Object#equals(Object)} method to compare the
- * elements.
- * @see #diffStart(Object[], Object[])
- * @see #diffEnd(Object[], Object[])
- */
- public static Range diffRange(Object[] array1, Object[] array2) {
- int end = diffEnd(array1, array2);
- if (end == -1) {
- // the lists are identical, the start is the size of the two lists
- return new Range(array1.length, end);
- }
- // the lists are different, calculate the start of the range
- return new Range(diffStart(array1, array2), end);
- }
-
- /**
- * Return the index of the first elements in the specified
- * arrays that are different. If the arrays are identical, return
- * the size of the two arrays (i.e. one past the last index).
- * If the arrays are different sizes and all the elements in
- * the shorter array match their corresponding elements in
- * the longer array, return the size of the shorter array
- * (i.e. one past the last index of the shorter array).
- * Use the elements' {@link Object#equals(Object)} method to compare the
- * elements.
- */
- public static int diffStart(Object[] array1, Object[] array2) {
- int end = Math.min(array1.length, array2.length);
- for (int i = 0; i < end; i++) {
- Object o = array1[i];
- if (o == null) {
- if (array2[i] != null) {
- return i;
- }
- } else {
- if ( ! o.equals(array2[i])) {
- return i;
- }
- }
- }
- return end;
- }
-
-
- // ********** identity diff **********
-
- /**
- * Return the index of the first elements in the specified
- * arrays that are different, beginning at the end.
- * If the arrays are identical, return -1.
- * If the arrays are different sizes, return the index of the
- * last element in the longer array.
- * Use object identity to compare the elements.
- */
- public static int identityDiffEnd(Object[] array1, Object[] array2) {
- int len1 = array1.length;
- int len2 = array2.length;
- if (len1 != len2) {
- return Math.max(len1, len2) - 1;
- }
- for (int i = len1 - 1; i > -1; i--) {
- if (array1[i] != array2[i]) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Return the range of elements in the specified
- * arrays that are different.
- * If the arrays are identical, return [size, -1].
- * Use object identity to compare the elements.
- * @see #identityDiffStart(Object[], Object[])
- * @see #identityDiffEnd(Object[], Object[])
- */
- public static Range identityDiffRange(Object[] array1, Object[] array2) {
- int end = identityDiffEnd(array1, array2);
- if (end == -1) {
- // the lists are identical, the start is the size of the two lists
- return new Range(array1.length, end);
- }
- // the lists are different, calculate the start of the range
- return new Range(identityDiffStart(array1, array2), end);
- }
-
- /**
- * Return the index of the first elements in the specified
- * arrays that are different. If the arrays are identical, return
- * the size of the two arrays (i.e. one past the last index).
- * If the arrays are different sizes and all the elements in
- * the shorter array match their corresponding elements in
- * the longer array, return the size of the shorter array
- * (i.e. one past the last index of the shorter array).
- * Use object identity to compare the elements.
- */
- public static int identityDiffStart(Object[] array1, Object[] array2) {
- int end = Math.min(array1.length, array2.length);
- for (int i = 0; i < end; i++) {
- if (array1[i] != array2[i]) {
- return i;
- }
- }
- return end;
- }
-
-
- // ********** elements are identical **********
-
- /**
- * Return whether the specified arrays contain the same elements.
- * <p>
- * <code>Arrays.identical(Object[] array1, Object[] array2)</code>
- */
- public static boolean elementsAreIdentical(Object[] array1, Object[] array2) {
- if (array1 == array2) {
- return true;
- }
- if (array1 == null || array2 == null) {
- return false;
- }
- int length = array1.length;
- if (array2.length != length) {
- return false;
- }
- for (int i = length; i-- > 0; ) {
- if (array1[i] != array2[i]) {
- return false;
- }
- }
- return true;
- }
-
-
- // ********** index of **********
-
- /**
- * Return the index of the first occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * <p>
- * <code>Arrays.indexOf(Object[] array, Object o)</code>
- */
- public static int indexOf(Object[] array, Object value) {
- int len = array.length;
- if (value == null) {
- for (int i = 0; i < len; i++) {
- if (array[i] == null) {
- return i;
- }
- }
- } else {
- for (int i = 0; i < len; i++) {
- if (value.equals(array[i])) {
- return i;
- }
- }
- }
- return -1;
- }
-
- /**
- * Return the index of the first occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * <p>
- * <code>Arrays.identityIndexOf(Object[] array, Object o)</code>
- */
- public static int identityIndexOf(Object[] array, Object value) {
- int len = array.length;
- for (int i = 0; i < len; i++) {
- if (array[i] == value) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Return the index of the first occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * <p>
- * <code>Arrays.indexOf(char[] array, char value)</code>
- */
- public static int indexOf(char[] array, char value) {
- int len = array.length;
- for (int i = 0; i < len; i++) {
- if (array[i] == value) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Return the index of the first occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * <p>
- * <code>Arrays.indexOf(int[] array, int value)</code>
- */
- public static int indexOf(int[] array, int value) {
- int len = array.length;
- for (int i = 0; i < len; i++) {
- if (array[i] == value) {
- return i;
- }
- }
- return -1;
- }
-
-
- // ********** insertion index of **********
-
- /**
- * Return the maximum index of where the specified comparable object
- * should be inserted into the specified sorted array and still keep
- * the array sorted.
- */
- public static <E extends Comparable<? super E>> int insertionIndexOf(E[] sortedArray, Comparable<E> value) {
- int len = sortedArray.length;
- for (int i = 0; i < len; i++) {
- if (value.compareTo(sortedArray[i]) < 0) {
- return i;
- }
- }
- return len;
- }
-
- /**
- * Return the maximum index of where the specified comparable object
- * should be inserted into the specified sorted array and still keep
- * the array sorted.
- */
- public static <E> int insertionIndexOf(E[] sortedArray, E value, Comparator<? super E> comparator) {
- int len = sortedArray.length;
- for (int i = 0; i < len; i++) {
- if (comparator.compare(value, sortedArray[i]) < 0) {
- return i;
- }
- }
- return len;
- }
-
-
- // ********** last index of **********
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified array;
- * return -1 if there is no such index.
- * <p>
- * <code>Arrays.lastIndexOf(Object[] array, Object o)</code>
- */
- public static int lastIndexOf(Object[] array, Object value) {
- int len = array.length;
- if (value == null) {
- for (int i = len; i-- > 0; ) {
- if (array[i] == null) {
- return i;
- }
- }
- } else {
- for (int i = len; i-- > 0; ) {
- if (value.equals(array[i])) {
- return i;
- }
- }
- }
- return -1;
- }
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * <p>
- * <code>Arrays.lastIndexOf(char[] array, char value)</code>
- */
- public static int lastIndexOf(char[] array, char value) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == value) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified array,
- * or return -1 if there is no such index.
- * <p>
- * <code>Arrays.lastIndexOf(int[] array, int value)</code>
- */
- public static int lastIndexOf(int[] array, int value) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == value) {
- return i;
- }
- }
- return -1;
- }
-
-
- // ********** min/max **********
-
- /**
- * Return the character from the specified array with the minimum value.
- * <p>
- * <code>Arrays.min(char[] array)</code>
- */
- public static char min(char... array) {
- int len = array.length;
- if (len == 0) {
- throw new IndexOutOfBoundsException();
- }
- int last = len - 1;
- char min = array[last];
- for (int i = last; i-- > 0; ) {
- char c = array[i];
- if (c < min) {
- min = c;
- }
- }
- return min;
- }
-
- /**
- * Return the integer from the specified array with the minimum value.
- * <p>
- * <code>Arrays.min(int[] array)</code>
- */
- public static int min(int... array) {
- int len = array.length;
- if (len == 0) {
- throw new IndexOutOfBoundsException();
- }
- int last = len - 1;
- int min = array[last];
- for (int i = last; i-- > 0; ) {
- int x = array[i];
- if (x < min) {
- min = x;
- }
- }
- return min;
- }
-
- /**
- * Return the character from the specified array with the maximum value.
- * <p>
- * <code>Arrays.max(char[] array)</code>
- */
- public static char max(char... array) {
- int len = array.length;
- if (len == 0) {
- throw new IndexOutOfBoundsException();
- }
- int last = len - 1;
- char max = array[last];
- for (int i = last; i-- > 0; ) {
- char c = array[i];
- if (c > max) {
- max = c;
- }
- }
- return max;
- }
-
- /**
- * Return the integer from the specified array with the maximum value.
- * <p>
- * <code>Arrays.max(int[] array)</code>
- */
- public static int max(int... array) {
- int len = array.length;
- if (len == 0) {
- throw new IndexOutOfBoundsException();
- }
- int last = len - 1;
- int max = array[last];
- for (int i = last; i-- > 0; ) {
- int x = array[i];
- if (x > max) {
- max = x;
- }
- }
- return max;
- }
-
-
- // ********** move **********
-
- /**
- * Move an element from the specified source index to the specified target
- * index. Return the altered array.
- * <p>
- * <code>Arrays.move(Object[] array, int targetIndex, int sourceIndex)</code>
- */
- public static <E> E[] move(E[] array, int targetIndex, int sourceIndex) {
- return (targetIndex == sourceIndex) ? array : move_(array, targetIndex, sourceIndex);
- }
-
- /**
- * assume target index != source index
- */
- private static <E> E[] move_(E[] array, int targetIndex, int sourceIndex) {
- E temp = array[sourceIndex];
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + 1, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + 1, array, sourceIndex, targetIndex - sourceIndex);
- }
- array[targetIndex] = temp;
- return array;
- }
-
- /**
- * Move elements from the specified source index to the specified target
- * index. Return the altered array.
- * <p>
- * <code>Arrays.move(Object[] array, int targetIndex, int sourceIndex, int length)</code>
- */
- public static <E> E[] move(E[] array, int targetIndex, int sourceIndex, int length) {
- if ((targetIndex == sourceIndex) || (length == 0)) {
- return array;
- }
- if (length == 1) {
- return move_(array, targetIndex, sourceIndex);
- }
- E[] temp = newArray(array, length);
- System.arraycopy(array, sourceIndex, temp, 0, length);
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + length, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + length, array, sourceIndex, targetIndex - sourceIndex);
- }
- System.arraycopy(temp, 0, array, targetIndex, length);
- return array;
- }
-
- /**
- * Move an element from the specified source index to the specified target
- * index. Return the altered array.
- * <p>
- * <code>Arrays.move(int[] array, int targetIndex, int sourceIndex)</code>
- */
- public static int[] move(int[] array, int targetIndex, int sourceIndex) {
- return (targetIndex == sourceIndex) ? array : move_(array, targetIndex, sourceIndex);
- }
-
- /**
- * assume targetIndex != sourceIndex
- */
- private static int[] move_(int[] array, int targetIndex, int sourceIndex) {
- int temp = array[sourceIndex];
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + 1, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + 1, array, sourceIndex, targetIndex - sourceIndex);
- }
- array[targetIndex] = temp;
- return array;
- }
-
- /**
- * Move elements from the specified source index to the specified target
- * index. Return the altered array.
- * <p>
- * <code>Arrays.move(int[] array, int targetIndex, int sourceIndex, int length)</code>
- */
- public static int[] move(int[] array, int targetIndex, int sourceIndex, int length) {
- if ((targetIndex == sourceIndex) || (length == 0)) {
- return array;
- }
- if (length == 1) {
- return move_(array, targetIndex, sourceIndex);
- }
- int[] temp = new int[length];
- System.arraycopy(array, sourceIndex, temp, 0, length);
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + length, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + length, array, sourceIndex, targetIndex - sourceIndex);
- }
- System.arraycopy(temp, 0, array, targetIndex, length);
- return array;
- }
-
- /**
- * Move an element from the specified source index to the specified target
- * index. Return the altered array.
- * <p>
- * <code>Arrays.move(char[] array, int targetIndex, int sourceIndex)</code>
- */
- public static char[] move(char[] array, int targetIndex, int sourceIndex) {
- return (targetIndex == sourceIndex) ? array : move_(array, targetIndex, sourceIndex);
- }
-
- /**
- * assume targetIndex != sourceIndex
- */
- private static char[] move_(char[] array, int targetIndex, int sourceIndex) {
- char temp = array[sourceIndex];
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + 1, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + 1, array, sourceIndex, targetIndex - sourceIndex);
- }
- array[targetIndex] = temp;
- return array;
- }
-
- /**
- * Move elements from the specified source index to the specified target
- * index. Return the altered array.
- * <p>
- * <code>Arrays.move(char[] array, int targetIndex, int sourceIndex, int length)</code>
- */
- public static char[] move(char[] array, int targetIndex, int sourceIndex, int length) {
- if ((targetIndex == sourceIndex) || (length == 0)) {
- return array;
- }
- if (length == 1) {
- return move_(array, targetIndex, sourceIndex);
- }
- char[] temp = new char[length];
- System.arraycopy(array, sourceIndex, temp, 0, length);
- if (targetIndex < sourceIndex) {
- System.arraycopy(array, targetIndex, array, targetIndex + length, sourceIndex - targetIndex);
- } else {
- System.arraycopy(array, sourceIndex + length, array, sourceIndex, targetIndex - sourceIndex);
- }
- System.arraycopy(temp, 0, array, targetIndex, length);
- return array;
- }
-
-
- // ********** remove **********
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * <p>
- * <code>Arrays.remove(Object[] array, Object value)</code>
- */
- public static <E> E[] remove(E[] array, Object value) {
- return removeElementAtIndex(array, indexOf(array, value));
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * <p>
- * <code>Arrays.remove(char[] array, char value)</code>
- */
- public static char[] remove(char[] array, char value) {
- return removeElementAtIndex(array, indexOf(array, value));
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * <p>
- * <code>Arrays.remove(int[] array, int value)</code>
- */
- public static int[] remove(int[] array, int value) {
- return removeElementAtIndex(array, indexOf(array, value));
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the first element removed.
- * <p>
- * <code>Arrays.removeFirst(Object[] array)</code>
- */
- public static <E> E[] removeFirst(E[] array) {
- return removeElementAtIndex(array, 0);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the first element removed.
- * <p>
- * <code>Arrays.removeFirst(char[] array)</code>
- */
- public static char[] removeFirst(char[] array) {
- return removeElementAtIndex(array, 0);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the first element removed.
- * <p>
- * <code>Arrays.removeFirst(int[] array)</code>
- */
- public static int[] removeFirst(int[] array) {
- return removeElementAtIndex(array, 0);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the last element removed.
- * <p>
- * <code>Arrays.removeLast(Object[] array)</code>
- */
- public static <E> E[] removeLast(E[] array) {
- return removeElementAtIndex(array, array.length - 1);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the last element removed.
- * <p>
- * <code>Arrays.removeLast(char[] array)</code>
- */
- public static char[] removeLast(char[] array) {
- return removeElementAtIndex(array, array.length - 1);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the last element removed.
- * <p>
- * <code>Arrays.removeLast(int[] array)</code>
- */
- public static int[] removeLast(int[] array) {
- return removeElementAtIndex(array, array.length - 1);
- }
-
-
- // ********** remove all **********
-
- /**
- * Remove from the specified array all the elements in
- * the specified iterable and return the result.
- * <p>
- * <code>Arrays.removeAll(Object[] array, Iterable iterable)</code>
- */
- public static <E> E[] removeAll(E[] array, Iterable<?> iterable) {
- return removeAll(array, iterable.iterator());
- }
-
- /**
- * Remove from the specified array all the elements in
- * the specified iterable and return the result.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Arrays.removeAll(Object[] array, Iterable iterable)</code>
- */
- public static <E> E[] removeAll(E[] array, Iterable<?> iterable, int iterableSize) {
- return removeAll(array, iterable.iterator(), iterableSize);
- }
-
- /**
- * Remove from the specified array all the elements in
- * the specified iterator and return the result.
- * <p>
- * <code>Arrays.removeAll(Object[] array, Iterator iterator)</code>
- */
- public static <E> E[] removeAll(E[] array, Iterator<?> iterator) {
- // convert to a set to take advantage of hashed look-up
- return iterator.hasNext() ? removeAll_(array, CollectionTools.set(iterator)) : array;
- }
-
- /**
- * Remove from the specified array all the elements in
- * the specified iterator and return the result.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Arrays.removeAll(Object[] array, Iterator iterator)</code>
- */
- public static <E> E[] removeAll(E[] array, Iterator<?> iterator, int iteratorSize) {
- // convert to a set to take advantage of hashed look-up
- return iterator.hasNext() ? removeAll_(array, CollectionTools.set(iterator, iteratorSize)) : array;
- }
-
- /**
- * Remove from the specified array all the elements in
- * the specified collection and return the result.
- * <p>
- * <code>Arrays.removeAll(Object[] array, Collection collection)</code>
- */
- public static <E> E[] removeAll(E[] array, Collection<?> collection) {
- return collection.isEmpty() ? array : removeAll_(array, collection);
- }
-
- /**
- * assume collection is non-empty
- */
- private static <E> E[] removeAll_(E[] array, Collection<?> collection) {
- return removeAll(array, collection, array.length);
- }
-
- /**
- * assume collection is non-empty; check array length
- */
- private static <E> E[] removeAll(E[] array, Collection<?> collection, int arrayLength) {
- return (arrayLength == 0) ? array : removeAll_(array, collection, arrayLength);
- }
-
- /**
- * assume collection is non-empty and array length > 0
- */
- private static <E> E[] removeAll_(E[] array, Collection<?> collection, int arrayLength) {
- // build the indices of the elements that are to remain
- int[] indices = new int[arrayLength];
- int j = 0;
- for (int i = 0; i < arrayLength; i++) {
- if ( ! collection.contains(array[i])) {
- indices[j++] = i;
- }
- }
- if (j == arrayLength) {
- return array; // nothing was removed
- }
- E[] result = newArray(array, j);
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * <p>
- * <code>Arrays.removeAll(Object[] array1, Object[] array2)</code>
- */
- public static <E> E[] removeAll(E[] array1, Object... array2) {
- // convert to a set to take advantage of hashed look-up
- return (array2.length == 0) ? array1 : removeAll_(array1, CollectionTools.set(array2));
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * <p>
- * <code>Arrays#removeAll(char[] array1, char[] array2)</code>
- */
- public static char[] removeAll(char[] array1, char... array2) {
- if (array2.length == 0) {
- return array1;
- }
- int array1Length = array1.length;
- if (array1Length == 0) {
- return array1;
- }
- int[] indices = new int[array1Length];
- int j = 0;
- for (int i = 0; i < array1Length; i++) {
- if ( ! contains(array2, array1[i])) {
- indices[j++] = i;
- }
- }
- if (j == array1Length) {
- return array1; // nothing was removed
- }
- char[] result = new char[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array1[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * <p>
- * <code>Arrays#removeAll(int[] array1, int[] array2)</code>
- */
- public static int[] removeAll(int[] array1, int... array2) {
- if (array2.length == 0) {
- return array1;
- }
- int array1Length = array1.length;
- if (array1Length == 0) {
- return array1;
- }
- int[] indices = new int[array1Length];
- int j = 0;
- for (int i = 0; i < array1Length; i++) {
- if ( ! contains(array2, array1[i])) {
- indices[j++] = i;
- }
- }
- if (j == array1Length) {
- return array1; // nothing was removed
- }
- int[] result = new int[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array1[indices[i]];
- }
- return result;
- }
-
-
- // ********** remove all occurrences **********
-
- /**
- * Remove from the specified array all occurrences of
- * the specified element and return the result.
- * <p>
- * <code>Arrays.removeAllOccurrences(Object[] array, Object value)</code>
- */
- public static <E> E[] removeAllOccurrences(E[] array, Object value) {
- int arrayLength = array.length;
- if (arrayLength == 0) {
- return array;
- }
- int[] indices = new int[arrayLength];
- int j = 0;
- if (value == null) {
- for (int i = arrayLength; i-- > 0; ) {
- if (array[i] != null) {
- indices[j++] = i;
- }
- }
- } else {
- for (int i = array.length; i-- > 0; ) {
- if ( ! value.equals(array[i])) {
- indices[j++] = i;
- }
- }
- }
- if (j == arrayLength) {
- return array; // nothing was removed
- }
- E[] result = newArray(array, j);
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the specified array all occurrences of
- * the specified element and return the result.
- * <p>
- * <code>Arrays.removeAllOccurrences(char[] array, char value)</code>
- */
- public static char[] removeAllOccurrences(char[] array, char value) {
- int arrayLength = array.length;
- if (arrayLength == 0) {
- return array;
- }
- int[] indices = new int[arrayLength];
- int j = 0;
- for (int i = arrayLength; i-- > 0; ) {
- if (array[i] != value) {
- indices[j++] = i;
- }
- }
- if (j == arrayLength) {
- return array; // nothing was removed
- }
- char[] result = new char[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the specified array all occurrences of
- * the specified element and return the result.
- * <p>
- * <code>Arrays.removeAllOccurrences(int[] array, int value)</code>
- */
- public static int[] removeAllOccurrences(int[] array, int value) {
- int arrayLength = array.length;
- if (arrayLength == 0) {
- return array;
- }
- int[] indices = new int[arrayLength];
- int j = 0;
- for (int i = arrayLength; i-- > 0; ) {
- if (array[i] != value) {
- indices[j++] = i;
- }
- }
- if (j == arrayLength) {
- return array; // nothing was removed
- }
- int[] result = new int[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array[indices[i]];
- }
- return result;
- }
-
-
- // ********** remove duplicate elements **********
-
- /**
- * Remove any duplicate elements from the specified array,
- * while maintaining the order.
- */
- public static <E> E[] removeDuplicateElements(E... array) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- ArrayList<E> temp = CollectionTools.list(array);
- return CollectionTools.removeDuplicateElements(temp, len) ?
- temp.toArray(newArray(array, temp.size())) :
- array;
- }
-
-
- // ********** remove element at index **********
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * <p>
- * <code>Arrays.removeElementAtIndex(Object[] array, int index)</code>
- */
- public static <E> E[] removeElementAtIndex(E[] array, int index) {
- return removeElementsAtIndex(array, index, 1);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * <p>
- * <code>Arrays.removeElementAtIndex(char[] array, int index)</code>
- */
- public static char[] removeElementAtIndex(char[] array, int index) {
- return removeElementsAtIndex(array, index, 1);
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified element removed.
- * <p>
- * <code>Arrays.removeElementAtIndex(int[] array, int index)</code>
- */
- public static int[] removeElementAtIndex(int[] array, int index) {
- return removeElementsAtIndex(array, index, 1);
- }
-
-
- // ********** remove elements at index **********
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified elements removed.
- * <p>
- * <code>Arrays.removeElementsAtIndex(Object[] array, int index, int length)</code>
- */
- public static <E> E[] removeElementsAtIndex(E[] array, int index, int length) {
- if (length == 0) {
- return array;
- }
- int arrayLength = array.length;
- int newLength = arrayLength - length;
- E[] result = newArray(array, newLength);
- if ((newLength == 0) && (index == 0)) {
- return result; // performance tweak
- }
- if (index != 0) {
- System.arraycopy(array, 0, result, 0, index);
- }
- int length2 = newLength - index;
- if (length2 != 0) {
- System.arraycopy(array, index + length, result, index, length2);
- }
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified elements removed.
- * <p>
- * <code>Arrays.removeElementsAtIndex(char[] array, int index, int length)
- */
- public static char[] removeElementsAtIndex(char[] array, int index, int length) {
- if (length == 0) {
- return array;
- }
- int arrayLength = array.length;
- int newLength = arrayLength - length;
- if ((newLength == 0) && (index == 0)) {
- return EMPTY_CHAR_ARRAY; // performance tweak
- }
- char[] result = new char[newLength];
- if (index != 0) {
- System.arraycopy(array, 0, result, 0, index);
- }
- int length2 = newLength - index;
- if (length2 != 0) {
- System.arraycopy(array, index + length, result, index, length2);
- }
- return result;
- }
-
- /**
- * Return a new array that contains the elements in the
- * specified array with the specified elements removed.
- * <p>
- * <code>Arrays.removeElementsAtIndex(int[] array, int index, int length)
- */
- public static int[] removeElementsAtIndex(int[] array, int index, int length) {
- if (length == 0) {
- return array;
- }
- int arrayLength = array.length;
- int newLength = arrayLength - length;
- if ((newLength == 0) && (index == 0)) {
- return EMPTY_INT_ARRAY; // performance tweak
- }
- int[] result = new int[newLength];
- if (index != 0) {
- System.arraycopy(array, 0, result, 0, index);
- }
- int length2 = newLength - index;
- if (length2 != 0) {
- System.arraycopy(array, index + length, result, index, length2);
- }
- return result;
- }
-
-
- // ********** replace all **********
-
- /**
- * Replace all occurrences of the specified old value with
- * the specified new value. Return the altered array.
- * <p>
- * <code>Arrays.replaceAll(Object[] array, Object oldValue, Object newValue)</code>
- */
- public static <E> E[] replaceAll(E[] array, Object oldValue, E newValue) {
- if (oldValue == null) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == null) {
- array[i] = newValue;
- }
- }
- } else {
- for (int i = array.length; i-- > 0; ) {
- if (oldValue.equals(array[i])) {
- array[i] = newValue;
- }
- }
- }
- return array;
- }
-
- /**
- * Replace all occurrences of the specified old value with
- * the specified new value. Return the altered array.
- *<p>
- * <code> Arrays.replaceAll(int[] array, int oldValue, int newValue)</code>
- */
- public static int[] replaceAll(int[] array, int oldValue, int newValue) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == oldValue) {
- array[i] = newValue;
- }
- }
- return array;
- }
-
- /**
- * Replace all occurrences of the specified old value with
- * the specified new value. Return the altered array.
- * <p>
- * <code>Arrays.replaceAll(char[] array, char oldValue, char newValue)</code>
- */
- public static char[] replaceAll(char[] array, char oldValue, char newValue) {
- for (int i = array.length; i-- > 0; ) {
- if (array[i] == oldValue) {
- array[i] = newValue;
- }
- }
- return array;
- }
-
-
- // ********** retain all **********
-
- /**
- * Retain in the specified array all the elements in
- * the specified iterable and return the result.
- * <p>
- * <code>Arrays.retainAll(Object[] array, Iterable iterable)</code>
- */
- public static <E> E[] retainAll(E[] array, Iterable<?> iterable) {
- int arrayLength = array.length;
- return (arrayLength == 0) ? array : retainAll(array, arrayLength, iterable.iterator());
- }
-
- /**
- * Retain in the specified array all the elements in
- * the specified iterable and return the result.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Arrays.retainAll(Object[] array, Iterable iterable)</code>
- */
- public static <E> E[] retainAll(E[] array, Iterable<?> iterable, int iterableSize) {
- int arrayLength = array.length;
- return (arrayLength == 0) ? array : retainAll(array, arrayLength, iterable.iterator(), iterableSize);
- }
-
- /**
- * Retain in the specified array all the elements in
- * the specified iterator and return the result.
- * <p>
- * <code>Arrays.retainAll(Object[] array, Iterator iterator)</code>
- */
- public static <E> E[] retainAll(E[] array, Iterator<?> iterator) {
- int arrayLength = array.length;
- return (arrayLength == 0) ? array : retainAll(array, arrayLength, iterator);
- }
-
- /**
- * Retain in the specified array all the elements in
- * the specified iterator and return the result.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Arrays.retainAll(Object[] array, Iterator iterator)</code>
- */
- public static <E> E[] retainAll(E[] array, Iterator<?> iterator, int iteratorSize) {
- int arrayLength = array.length;
- return (arrayLength == 0) ? array : retainAll(array, arrayLength, iterator, iteratorSize);
- }
-
- /**
- * assume array length > 0
- */
- private static <E> E[] retainAll(E[] array, int arrayLength, Iterator<?> iterator) {
- return iterator.hasNext() ?
- retainAll_(array, CollectionTools.set(iterator), arrayLength) :
- newArray(array, 0);
- }
-
- /**
- * assume array length > 0
- */
- private static <E> E[] retainAll(E[] array, int arrayLength, Iterator<?> iterator, int iteratorSize) {
- return iterator.hasNext() ?
- retainAll_(array, CollectionTools.set(iterator, iteratorSize), arrayLength) :
- newArray(array, 0);
- }
-
- /**
- * Retain in the specified array all the elements in
- * the specified collection and return the result.
- * <p>
- * <code>Arrays.retainAll(Object[] array, Collection collection)</code>
- */
- public static <E> E[] retainAll(E[] array, Collection<?> collection) {
- int arrayLength = array.length;
- return (arrayLength == 0) ? array : retainAll(array, collection, arrayLength);
- }
-
- /**
- * assume array length > 0
- */
- private static <E> E[] retainAll(E[] array, Collection<?> collection, int arrayLength) {
- return collection.isEmpty() ?
- newArray(array, 0) :
- retainAll_(array, collection, arrayLength);
- }
-
- /**
- * assume collection is non-empty and array length > 0
- */
- private static <E> E[] retainAll_(E[] array, Collection<?> collection, int arrayLength) {
- int[] indices = new int[arrayLength];
- int j = 0;
- for (int i = 0; i < arrayLength; i++) {
- if (collection.contains(array[i])) {
- indices[j++] = i;
- }
- }
- if (j == arrayLength) {
- return array; // everything was retained
- }
- E[] result = newArray(array, j);
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * <p>
- * <code>Arrays.retainAll(Object[] array1, Object[] array2)</code>
- */
- public static <E> E[] retainAll(E[] array1, Object[] array2) {
- int array1Length = array1.length;
- return (array1Length == 0) ?
- array1 :
- (array2.length == 0) ?
- newArray(array1, 0) :
- retainAll(array1, CollectionTools.set(array2), array1Length);
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * <p>
- * <code>Arrays.retainAll(char[] array1, char[] array2)</code>
- */
- public static char[] retainAll(char[] array1, char... array2) {
- int array1Length = array1.length;
- return (array1Length == 0) ? array1 : retainAll(array1, array2, array1Length);
- }
-
- /**
- * assume array 1 length > 0
- */
- private static char[] retainAll(char[] array1, char[] array2, int array1Length) {
- int array2Length = array2.length;
- return (array2Length == 0) ? EMPTY_CHAR_ARRAY : retainAll(array1, array2, array1Length, array2Length);
- }
-
- /**
- * assume both array lengths > 0
- */
- private static char[] retainAll(char[] array1, char[] array2, int array1Length, int array2Length) {
- int[] indices = new int[array1Length];
- int j = 0;
- for (int i = 0; i < array1Length; i++) {
- if (contains_(array2, array1[i], array2Length)) {
- indices[j++] = i;
- }
- }
- if (j == array1Length) {
- return array1; // everything was retained
- }
- char[] result = new char[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array1[indices[i]];
- }
- return result;
- }
-
- /**
- * Remove from the first specified array all the elements in
- * the second specified array and return the result.
- * <p>
- * <code>Arrays.retainAll(int[] array1, int[] array2)</code>
- */
- public static int[] retainAll(int[] array1, int... array2) {
- int array1Length = array1.length;
- return (array1Length == 0) ? array1 : retainAll(array1, array2, array1Length);
- }
-
- /**
- * assume array 1 length > 0
- */
- private static int[] retainAll(int[] array1, int[] array2, int array1Length) {
- int array2Length = array2.length;
- return (array2Length == 0) ? EMPTY_INT_ARRAY : retainAll(array1, array2, array1Length, array2Length);
- }
-
- /**
- * assume both array lengths > 0
- */
- private static int[] retainAll(int[] array1, int[] array2, int array1Length, int array2Length) {
- int[] indices = new int[array1Length];
- int j = 0;
- for (int i = 0; i < array1Length; i++) {
- if (contains_(array2, array1[i], array2Length)) {
- indices[j++] = i;
- }
- }
- if (j == array1Length) {
- return array1; // everything was retained
- }
- int[] result = new int[j];
- int resultLength = result.length;
- for (int i = 0; i < resultLength; i++) {
- result[i] = array1[indices[i]];
- }
- return result;
- }
-
-
- // ********** reverse **********
-
- /**
- * Return the array, reversed.
- * <p>
- * <code>Arrays.reverse(Object... array)</code>
- */
- public static <E> E[] reverse(E... array) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- for (int i = 0, mid = len >> 1, j = len - 1; i < mid; i++, j--) {
- swap(array, i, j);
- }
- return array;
- }
-
- /**
- * Return the array, reversed.
- * <p>
- * <code>Arrays.reverse(char... array)</code>
- */
- public static char[] reverse(char... array) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- for (int i = 0, mid = len >> 1, j = len - 1; i < mid; i++, j--) {
- swap(array, i, j);
- }
- return array;
- }
-
- /**
- * Return the array, reversed.
- * <p>
- * <code>Arrays.reverse(int... array)</code>
- */
- public static int[] reverse(int... array) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- for (int i = 0, mid = len >> 1, j = len - 1; i < mid; i++, j--) {
- swap(array, i, j);
- }
- return array;
- }
-
-
- // ********** rotate **********
-
- /**
- * Return the rotated array after rotating it one position.
- * <p>
- * <code>Arrays.rotate(Object[] array)</code>
- */
- public static <E> E[] rotate(E... array) {
- return rotate(array, 1);
- }
-
- /**
- * Return the rotated array after rotating it the specified distance.
- * <p>
- * <code>Arrays.rotate(Object[] array, int distance)</code>
- */
- public static <E> E[] rotate(E[] array, int distance) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- distance = distance % len;
- if (distance < 0) {
- distance += len;
- }
- if (distance == 0) {
- return array;
- }
- for (int cycleStart = 0, nMoved = 0; nMoved != len; cycleStart++) {
- E displaced = array[cycleStart];
- int i = cycleStart;
- do {
- i += distance;
- if (i >= len) {
- i -= len;
- }
- E temp = array[i];
- array[i] = displaced;
- displaced = temp;
- nMoved ++;
- } while (i != cycleStart);
- }
- return array;
- }
-
- /**
- * Return the rotated array after rotating it one position.
- * <p>
- * <code>Arrays.rotate(char[] array)</code>
- */
- public static char[] rotate(char... array) {
- return rotate(array, 1);
- }
-
- /**
- * Return the rotated array after rotating it the specified distance.
- * <p>
- * <code>Arrays.rotate(char[] array, int distance)</code>
- */
- public static char[] rotate(char[] array, int distance) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- distance = distance % len;
- if (distance < 0) {
- distance += len;
- }
- if (distance == 0) {
- return array;
- }
- for (int cycleStart = 0, nMoved = 0; nMoved != len; cycleStart++) {
- char displaced = array[cycleStart];
- int i = cycleStart;
- do {
- i += distance;
- if (i >= len) {
- i -= len;
- }
- char temp = array[i];
- array[i] = displaced;
- displaced = temp;
- nMoved ++;
- } while (i != cycleStart);
- }
- return array;
- }
-
- /**
- * Return the rotated array after rotating it one position.
- * <p>
- * <code>Arrays.rotate(int[] array)</code>
- */
- public static int[] rotate(int... array) {
- return rotate(array, 1);
- }
-
- /**
- * Return the rotated array after rotating it the specified distance.
- * <p>
- * <code>Arrays.rotate(int[] array, int distance)</code>
- */
- public static int[] rotate(int[] array, int distance) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- distance = distance % len;
- if (distance < 0) {
- distance += len;
- }
- if (distance == 0) {
- return array;
- }
- for (int cycleStart = 0, nMoved = 0; nMoved != len; cycleStart++) {
- int displaced = array[cycleStart];
- int i = cycleStart;
- do {
- i += distance;
- if (i >= len) {
- i -= len;
- }
- int temp = array[i];
- array[i] = displaced;
- displaced = temp;
- nMoved ++;
- } while (i != cycleStart);
- }
- return array;
- }
-
-
- // ********** shuffle **********
-
- private static final Random RANDOM = new Random();
-
- /**
- * Return the array after "shuffling" it.
- * <p>
- * <code>Arrays.shuffle(Object... array)</code>
- */
- public static <E> E[] shuffle(E... array) {
- return shuffle(array, RANDOM);
- }
-
- /**
- * Return the array after "shuffling" it.
- * <p>
- * <code>Arrays.shuffle(Object[] array, Random r)</code>
- */
- public static <E> E[] shuffle(E[] array, Random random) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- for (int i = len; i-- > 0; ) {
- swap(array, i, random.nextInt(len));
- }
- return array;
- }
-
- /**
- * Return the array after "shuffling" it.
- * <p>
- * <code>Arrays.shuffle(char... array)</code>
- */
- public static char[] shuffle(char... array) {
- return shuffle(array, RANDOM);
- }
-
- /**
- * Return the array after "shuffling" it.
- * <p>
- * <code>Arrays.shuffle(char[] array, Random r)</code>
- */
- public static char[] shuffle(char[] array, Random random) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- for (int i = len; i-- > 0; ) {
- swap(array, i, random.nextInt(len));
- }
- return array;
- }
-
- /**
- * Return the array after "shuffling" it.
- * <p>
- * <code>Arrays.shuffle(int... array)</code>
- */
- public static int[] shuffle(int... array) {
- return shuffle(array, RANDOM);
- }
-
- /**
- * Return the array after "shuffling" it.
- * <p>
- * <code>Arrays.shuffle(int[] array, Random r)</code>
- */
- public static int[] shuffle(int[] array, Random random) {
- int len = array.length;
- if ((len == 0) || (len == 1)) {
- return array;
- }
- for (int i = len; i-- > 0; ) {
- swap(array, i, random.nextInt(len));
- }
- return array;
- }
-
-
- // ********** sub-array **********
-
- /**
- * Return a sub-array of the specified array with elements copied from
- * the specified range. The "from" index is inclusive; the "to" index is exclusive.
- * <p>
- * <code>Arrays.subArray(E[] array, int fromIndex, int toIndex)</code>
- */
- public static <E> E[] subArray(E[] array, int fromIndex, int toIndex) {
- int len = toIndex - fromIndex;
- E[] result = newArray(array, len);
- if (len > 0) {
- System.arraycopy(array, fromIndex, result, 0, len);
- }
- return result;
- }
-
- /**
- * Return a sub-array of the specified array with elements copied from
- * the specified range. The "from" index is inclusive; the "to" index is exclusive.
- * <p>
- * <code>Arrays.subArray(int[] array, int fromIndex, int toIndex)</code>
- */
- public static int[] subArray(int[] array, int fromIndex, int toIndex) {
- int len = toIndex - fromIndex;
- if (len == 0) {
- return EMPTY_INT_ARRAY;
- }
- int[] result = new int[len];
- System.arraycopy(array, fromIndex, result, 0, len);
- return result;
- }
-
- /**
- * Return a sub-array of the specified array with elements copied from
- * the specified range. The "from" index is inclusive; the "to" index is exclusive.
- * <p>
- * <code>
- * Arrays.subArray(char[] array, int fromIndex, int toIndex)</code>
- * </code>
- */
- public static char[] subArray(char[] array, int fromIndex, int toIndex) {
- int len = toIndex - fromIndex;
- if (len == 0) {
- return EMPTY_CHAR_ARRAY;
- }
- char[] result = new char[len];
- System.arraycopy(array, fromIndex, result, 0, len);
- return result;
- }
-
-
- // ********** swap **********
-
- /**
- * Return the array after the specified elements have been "swapped".
- * <p>
- * <code>Arrays.swap(Object[] array, int i, int j)</code>
- */
- public static <E> E[] swap(E[] array, int i, int j) {
- return (i == j) ? array : swap_(array, i, j);
- }
-
- /**
- * assume the indices are different
- */
- private static <E> E[] swap_(E[] array, int i, int j) {
- E temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- return array;
- }
-
- /**
- * Return the array after the specified elements have been "swapped".
- * <p>
- * <code>Arrays.swap(char[] array, int i, int j)</code>
- */
- public static char[] swap(char[] array, int i, int j) {
- return (i == j) ? array : swap_(array, i, j);
- }
-
- /**
- * assume the indices are different
- */
- private static char[] swap_(char[] array, int i, int j) {
- char temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- return array;
- }
-
- /**
- * Return the array after the specified elements have been "swapped".
- * <p>
- * <code>Arrays.swap(int[] array, int i, int j)</code>
- */
- public static int[] swap(int[] array, int i, int j) {
- return (i == j) ? array : swap_(array, i, j);
- }
-
- /**
- * assume the indices are different
- */
- private static int[] swap_(int[] array, int i, int j) {
- int temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- return array;
- }
-
-
- // ********** Arrays enhancements **********
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(boolean[], boolean)
- */
- public static boolean[] fill(boolean[] array, boolean value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(boolean[], int, int, boolean)
- */
- public static boolean[] fill(boolean[] array, int fromIndex, int toIndex, boolean value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(byte[], byte)
- */
- public static byte[] fill(byte[] array, byte value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(byte[], int, int, byte)
- */
- public static byte[] fill(byte[] array, int fromIndex, int toIndex, byte value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(char[], char)
- */
- public static char[] fill(char[] array, char value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(char[], int, int, char)
- */
- public static char[] fill(char[] array, int fromIndex, int toIndex, char value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(double[], double)
- */
- public static double[] fill(double[] array, double value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(double[], int, int, double)
- */
- public static double[] fill(double[] array, int fromIndex, int toIndex, double value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(float[], float)
- */
- public static float[] fill(float[] array, float value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(float[], int, int, float)
- */
- public static float[] fill(float[] array, int fromIndex, int toIndex, float value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(int[], int)
- */
- public static int[] fill(int[] array, int value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(int[], int, int, int)
- */
- public static int[] fill(int[] array, int fromIndex, int toIndex, int value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(Object[], Object)
- */
- public static <E> E[] fill(E[] array, E value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(Object[], int, int, Object)
- */
- public static <E> E[] fill(E[] array, int fromIndex, int toIndex, E value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(long[], long)
- */
- public static long[] fill(long[] array, long value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(long[], int, int, long)
- */
- public static long[] fill(long[] array, int fromIndex, int toIndex, long value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(short[], short)
- */
- public static short[] fill(short[] array, short value) {
- Arrays.fill(array, value);
- return array;
- }
-
- /**
- * Return the array after it has been "filled".
- * @see Arrays#fill(short[], int, int, short)
- */
- public static short[] fill(short[] array, int fromIndex, int toIndex, short value) {
- Arrays.fill(array, fromIndex, toIndex, value);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(byte[])
- */
- public static byte[] sort(byte... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(byte[], int, int)
- */
- public static byte[] sort(byte[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(char[])
- */
- public static char[] sort(char... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(char[], int, int)
- */
- public static char[] sort(char[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(double[])
- */
- public static double[] sort(double... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(double[], int, int)
- */
- public static double[] sort(double[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(float[])
- */
- public static float[] sort(float... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(float[], int, int)
- */
- public static float[] sort(float[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(int[])
- */
- public static int[] sort(int... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(int[], int, int)
- */
- public static int[] sort(int[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(Object[])
- */
- public static <E> E[] sort(E... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(Object[], Comparator)
- */
- public static <E> E[] sort(E[] array, Comparator<? super E> comparator) {
- Arrays.sort(array, comparator);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(Object[], int, int)
- */
- public static <E> E[] sort(E[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(Object[], int, int, Comparator)
- */
- public static <E> E[] sort(E[] array, int fromIndex, int toIndex, Comparator<? super E> comparator) {
- Arrays.sort(array, fromIndex, toIndex, comparator);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(long[])
- */
- public static long[] sort(long... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(long[], int, int)
- */
- public static long[] sort(long[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(short[])
- */
- public static short[] sort(short... array) {
- Arrays.sort(array);
- return array;
- }
-
- /**
- * Return the array after it has been "sorted".
- * @see Arrays#sort(short[], int, int)
- */
- public static short[] sort(short[] array, int fromIndex, int toIndex) {
- Arrays.sort(array, fromIndex, toIndex);
- return array;
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private ArrayTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Association.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Association.java
deleted file mode 100644
index 02226b4333..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Association.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Straightforward definition of an object pairing.
- * The key is immutable.
- */
-public interface Association<K, V> {
-
- /**
- * Return the association's key.
- */
- K getKey();
-
- /**
- * Return the association's value.
- */
- V getValue();
-
- /**
- * Set the association's value.
- * Return the previous value.
- */
- V setValue(V value);
-
- /**
- * Return true if the associations' keys and values
- * are equal.
- */
- boolean equals(Object o);
-
- /**
- * Return a hash code based on the association's
- * key and value.
- */
- int hashCode();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Bag.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Bag.java
deleted file mode 100644
index 0cecf9718c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Bag.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.AbstractCollection;
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-
-/**
- * A collection that allows duplicate elements.
- * <p>
- * The <code>Bag</code> interface places additional stipulations,
- * beyond those inherited from the {@link java.util.Collection} interface,
- * on the contracts of the {@link #equals(Object)} and {@link #hashCode()} methods.
- *
- * @see HashBag
- */
-
-public interface Bag<E> extends java.util.Collection<E> {
-
- /**
- * Compares the specified object with this bag for equality. Returns
- * <code>true</code> if the specified object is also a bag, the two bags
- * have the same size, and every member of the specified bag is
- * contained in this bag with the same number of occurrences (or equivalently,
- * every member of this bag is contained in the specified bag with the same
- * number of occurrences). This definition ensures that the
- * equals method works properly across different implementations of the
- * bag interface.
- */
- boolean equals(Object o);
-
- /**
- * Returns the hash code value for this bag. The hash code of a bag is
- * defined to be the sum of the hash codes of the elements in the bag,
- * where the hashcode of a <code>null</code> element is defined to be zero.
- * This ensures that <code>b1.equals(b2)</code> implies that
- * <code>b1.hashCode() == b2.hashCode()</code> for any two bags
- * <code>b1</code> and <code>b2</code>, as required by the general
- * contract of the {@link Object#hashCode()} method.
- */
- int hashCode();
-
- /**
- * Return the number of times the specified object occurs in the bag.
- */
- int count(Object o);
-
- /**
- * Add the specified object the specified number of times to the bag.
- * Return whether the bag changed.
- */
- boolean add(E o, int count);
-
- /**
- * Remove the specified number of occurrences of the specified object
- * from the bag. Return whether the bag changed.
- */
- boolean remove(Object o, int count);
-
- /**
- * Return an iterator that returns each item in the bag
- * once and only once, irrespective of how many times
- * the item was added to the bag.
- */
- java.util.Iterator<E> uniqueIterator();
-
- /**
- * Return the number of unique items in the bag.
- */
- int uniqueCount();
-
- /**
- * Return an iterator that returns an entry for each item in the bag
- * once and only once, irrespective of how many times
- * the item was added to the bag. The entry will indicate the item's
- * count.
- */
- java.util.Iterator<Entry<E>> entries();
-
-
- /**
- * A bag entry (element-count pair).
- * The {@link Bag#entries()} method returns an iterator whose
- * elements are of this class. The <em>only</em> way to obtain a reference
- * to a bag entry is from the iterator returned by this method. These
- * <code>Bag.Entry</code> objects are valid <em>only</em> for the duration
- * of the iteration; more formally, the behavior of a bag entry is
- * undefined if the backing bag has been modified after the entry was
- * returned by the iterator, except through the {@link #setCount(int)}
- * operation on the bag entry.
- */
- interface Entry<E> {
-
- /**
- * Return the entry's element.
- */
- E getElement();
-
- /**
- * Return entry's count; i.e. the number of times the entry's element
- * occurs in the bag.
- * @see Bag#count(Object)
- */
- int getCount();
-
- /**
- * Set the entry's count; i.e. the number of times the entry's element
- * occurs in the bag. The new count must be a positive number.
- * Return the previous count of the entry's element.
- * NB: Use {@link Iterator#remove()} to set the
- * count to zero.
- */
- int setCount(int count);
-
- /**
- * Return whether the entry is equal to the specified object;
- * i.e. the specified object is a <code>Bag.Entry</code> and its
- * element and count are the same as the entry's.
- */
- boolean equals(Object obj);
-
- /**
- * Return the entry's hash code.
- */
- int hashCode();
-
- }
-
-
- final class Empty<E> extends AbstractCollection<E> implements Bag<E>, Serializable {
- @SuppressWarnings("rawtypes")
- public static final Bag INSTANCE = new Empty();
- @SuppressWarnings("unchecked")
- public static <T> Bag<T> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Empty() {
- super();
- }
- @Override
- public Iterator<E> iterator() {
- return EmptyIterator.instance();
- }
- @Override
- public int size() {
- return 0;
- }
- public Iterator<E> uniqueIterator() {
- return EmptyIterator.instance();
- }
- public int uniqueCount() {
- return 0;
- }
- public int count(Object o) {
- return 0;
- }
- public Iterator<Bag.Entry<E>> entries() {
- return EmptyIterator.instance();
- }
- public boolean remove(Object o, int count) {
- return false;
- }
- public boolean add(E o, int count) {
- throw new UnsupportedOperationException();
- }
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if ( ! (o instanceof Bag<?>)) {
- return false;
- }
- return ((Bag<?>) o).size() == 0;
- }
- @Override
- public int hashCode() {
- return 0;
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiFilter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiFilter.java
deleted file mode 100644
index 015dc8fecc..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiFilter.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-import org.eclipse.jpt.common.utility.Filter;
-
-/**
- * Used by various "pluggable" classes to filter objects
- * in both directions.
- *
- * If anyone can come up with a better class name
- * and/or method name, I would love to hear it. ~bjv
- */
-public interface BidiFilter<T>
- extends Filter<T>
-{
- /**
- * Return whether the specified object is "accepted" by the
- * "reverse" filter. What that means is determined by the client.
- */
- boolean reverseAccept(T o);
-
-
- final class Null<S>
- implements BidiFilter<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final BidiFilter INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R> BidiFilter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // nothing is filtered - everything is accepted
- public boolean accept(S o) {
- return true;
- }
- // nothing is "reverse-filtered" - everything is accepted
- public boolean reverseAccept(S o) {
- return true;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- final class Opaque<S>
- implements BidiFilter<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final BidiFilter INSTANCE = new Opaque();
- @SuppressWarnings("unchecked")
- public static <R> BidiFilter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Opaque() {
- super();
- }
- // everything is filtered - nothing is accepted
- public boolean accept(S o) {
- return false;
- }
- // everything is "reverse-filtered" - nothing is accepted
- public boolean reverseAccept(S o) {
- return false;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- final class Disabled<S>
- implements BidiFilter<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final BidiFilter INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> BidiFilter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public boolean accept(S o) {
- throw new UnsupportedOperationException();
- }
- // throw an exception
- public boolean reverseAccept(S o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiStringConverter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiStringConverter.java
deleted file mode 100644
index 8c7ebda6d3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiStringConverter.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * Used by various "pluggable" classes to transform objects
- * into strings and vice versa.
- *
- * If anyone can come up with a better class name
- * and/or method name, I would love to hear it. ~bjv
- */
-public interface BidiStringConverter<T>
- extends StringConverter<T>
-{
- /**
- * Convert the specified string into an object.
- * The semantics of "convert to object" is determined by the
- * contract between the client and the server.
- * Typically, if the string is null, null is returned.
- */
- T convertToObject(String s);
-
-
- final class Default<S>
- implements BidiStringConverter<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final BidiStringConverter INSTANCE = new Default();
- @SuppressWarnings("unchecked")
- public static <R> BidiStringConverter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- // simply return the object's #toString() result
- public String convertToString(S o) {
- return (o == null) ? null : o.toString();
- }
- // simply return the string
- @SuppressWarnings("unchecked")
- public S convertToObject(String s) {
- return (S) s;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- final class Disabled<S>
- implements BidiStringConverter<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final BidiStringConverter INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> BidiStringConverter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public String convertToString(S o) {
- throw new UnsupportedOperationException();
- }
- // throw an exception
- public S convertToObject(String s) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- final class BooleanConverter
- implements BidiStringConverter<Boolean>, Serializable
- {
- public static final BidiStringConverter<Boolean> INSTANCE = new BooleanConverter();
- public static BidiStringConverter<Boolean> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private BooleanConverter() {
- super();
- }
- /** Return "true" if the Boolean is true, otherwise return "false". */
- public String convertToString(Boolean b) {
- return (b == null) ? null : b.toString();
- }
- /** Return Boolean.TRUE if the string is "true" (case-insensitive), otherwise return Boolean.FALSE. */
- public Boolean convertToObject(String s) {
- return (s == null) ? null : Boolean.valueOf(s);
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- final class IntegerConverter
- implements BidiStringConverter<Integer>, Serializable
- {
- public static final BidiStringConverter<Integer> INSTANCE = new IntegerConverter();
- public static BidiStringConverter<Integer> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private IntegerConverter() {
- super();
- }
- /** Integer's #toString() works well. */
- public String convertToString(Integer integer) {
- return (integer == null) ? null : integer.toString();
- }
- /** Convert the string to an Integer, if possible. */
- public Integer convertToObject(String s) {
- return (s == null) ? null : Integer.valueOf(s);
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiTransformer.java
deleted file mode 100644
index 3916af450c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BidiTransformer.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * Used by various "pluggable" classes to transform objects
- * in both directions.
- *
- * If anyone can come up with a better class name
- * and/or method name, I would love to hear it. ~bjv
- */
-public interface BidiTransformer<T1, T2>
- extends Transformer<T1, T2>
-{
- /**
- * Return the "reverse-transformed" object.
- * The semantics of "reverse-transform" is determined by the
- * contract between the client and the server.
- */
- T1 reverseTransform(T2 o);
-
-
- final class Null<S1, S2>
- implements BidiTransformer<S1, S2>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final BidiTransformer INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R1, R2> BidiTransformer<R1, R2> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // simply return the object, unchanged
- @SuppressWarnings("unchecked")
- public S2 transform(S1 o) {
- return (S2) o;
- }
- // simply return the object, unchanged
- @SuppressWarnings("unchecked")
- public S1 reverseTransform(S2 o) {
- return (S1) o;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- final class Disabled<S1, S2>
- implements BidiTransformer<S1, S2>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final BidiTransformer INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R1, R2> BidiTransformer<R1, R2> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public S2 transform(S1 o) {
- throw new UnsupportedOperationException();
- }
- // throw an exception
- public S1 reverseTransform(S2 o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BitTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BitTools.java
deleted file mode 100644
index 20cbf7c9f0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BitTools.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Assorted bit tools
- */
-public final class BitTools {
-
- /**
- * Return whether the specified 'flags' has the specified
- * 'flagToCheck' set.
- */
- public static boolean flagIsSet(int flags, int flagToCheck) {
- return allFlagsAreSet(flags, flagToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has the specified
- * 'flagToCheck' turned off.
- */
- public static boolean flagIsOff(int flags, int flagToCheck) {
- return allFlagsAreOff(flags, flagToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagToCheck' set.
- */
- public static boolean onlyFlagIsSet(int flags, int flagToCheck) {
- return onlyFlagsAreSet(flags, flagToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagToCheck' turned off.
- */
- public static boolean onlyFlagIsOff(int flags, int flagToCheck) {
- return onlyFlagsAreOff(flags, flagToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has all the specified
- * 'flagsToCheck' set.
- */
- public static boolean allFlagsAreSet(int flags, int flagsToCheck) {
- return (flags & flagsToCheck) == flagsToCheck;
- }
-
- /**
- * Return whether the specified 'flags' has all the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean allFlagsAreOff(int flags, int flagsToCheck) {
- return (flags & flagsToCheck) == 0;
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagsToCheck' set.
- */
- public static boolean onlyFlagsAreSet(int flags, int flagsToCheck) {
- return allFlagsAreSet(flags, flagsToCheck) && allFlagsAreOff(flags, ~flagsToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean onlyFlagsAreOff(int flags, int flagsToCheck) {
- return allFlagsAreOff(flags, flagsToCheck) && allFlagsAreSet(flags, ~flagsToCheck);
- }
-
- /**
- * Return whether the specified 'flags' has any one of the specified
- * 'flagsToCheck' set.
- */
- public static boolean anyFlagsAreSet(int flags, int flagsToCheck) {
- return (flags & flagsToCheck) != 0;
- }
-
- /**
- * Return whether the specified 'flags' has any one of the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean anyFlagsAreOff(int flags, int flagsToCheck) {
- return (flags & flagsToCheck) != flagsToCheck;
- }
-
- /**
- * Return whether the specified 'flags' has all the specified
- * 'flagsToCheck' set.
- */
- public static boolean allFlagsAreSet(int flags, int... flagsToCheck) {
- for (int i = flagsToCheck.length; i-- > 0; ) {
- if ( ! allFlagsAreSet(flags, flagsToCheck[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified 'flags' has all the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean allFlagsAreOff(int flags, int... flagsToCheck) {
- for (int i = flagsToCheck.length; i-- > 0; ) {
- if ( ! allFlagsAreOff(flags, flagsToCheck[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagsToCheck' set.
- */
- public static boolean onlyFlagsAreSet(int flags, int... flagsToCheck) {
- int combinedFlags = orFlags(flagsToCheck);
- return allFlagsAreSet(flags, combinedFlags) && allFlagsAreOff(flags, ~combinedFlags);
- }
-
- /**
- * Return whether the specified 'flags' has ONLY the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean onlyFlagsAreOff(int flags, int... flagsToCheck) {
- int combinedFlags = orFlags(flagsToCheck);
- return allFlagsAreOff(flags, combinedFlags) && allFlagsAreSet(flags, ~combinedFlags);
- }
-
- /**
- * Return whether the specified 'flags' has any one of the specified
- * 'flagsToCheck' set.
- */
- public static boolean anyFlagsAreSet(int flags, int... flagsToCheck) {
- for (int i = flagsToCheck.length; i-- > 0; ) {
- if (anyFlagsAreSet(flags, flagsToCheck[i])) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified 'flags' has any one of the specified
- * 'flagsToCheck' turned off.
- */
- public static boolean anyFlagsAreOff(int flags, int... flagsToCheck) {
- for (int i = flagsToCheck.length; i-- > 0; ) {
- if (anyFlagsAreOff(flags, flagsToCheck[i])) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * OR all the specified 'flags' together and return the result.
- */
- public static int orFlags(int... flags) {
- int last = flags.length - 1;
- int result = flags[last];
- for (int i = last; i-- > 0; ) {
- result |= flags[i];
- }
- return result;
- }
-
- /**
- * AND all the specified 'flags' together and return the result.
- */
- public static int andFlags(int... flags) {
- int last = flags.length - 1;
- int result = flags[last];
- for (int i = last; i-- > 0; ) {
- result &= flags[i];
- }
- return result;
- }
-
- /**
- * XOR all the specified 'flags' together and return the result.
- */
- public static int xorFlags(int... flags) {
- int last = flags.length - 1;
- int result = flags[last];
- for (int i = last; i-- > 0; ) {
- result ^= flags[i];
- }
- return result;
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private BitTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BooleanTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BooleanTools.java
deleted file mode 100644
index 783c0f1299..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/BooleanTools.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Assorted "Capital-B Boolean" operations.
- */
- // commented code is just playing around with building *everything* from NAND
-public final class BooleanTools {
-
- /**
- * Return the NOT of the specified Boolean.
- * Boolean#not()
- */
- public static Boolean not(Boolean b) {
- return Boolean.valueOf( ! b.booleanValue());
-// return nand(b, b);
- }
-
- /**
- * Return the AND of the specified Booleans.
- * Boolean#and(Boolean)
- */
- public static Boolean and(Boolean b1, Boolean b2) {
- return Boolean.valueOf(b1.booleanValue() && b2.booleanValue());
-// Boolean nand = nand(b1, b2);
-// return nand(nand, nand);
- }
-
- /**
- * Return the OR of the specified Booleans.
- * Boolean#or(Boolean)
- */
- public static Boolean or(Boolean b1, Boolean b2) {
- return Boolean.valueOf(b1.booleanValue() || b2.booleanValue());
-// Boolean nand = nand(b1, b2);
-// Boolean xor = nand(nand(b1, nand), nand(b2, nand));
-// Boolean and = nand(nand, nand);
-// Boolean nand2 = nand(xor, and);
-// return nand(nand(xor, nand2), nand(and, nand2));
- }
-
- /**
- * Return the XOR of the specified Booleans.
- * Boolean#xor(Boolean)
- */
- public static Boolean xor(Boolean b1, Boolean b2) {
- return and(or(b1, b2), nand(b1, b2));
-// Boolean nand = nand(b1, b2);
-// return nand(nand(b1, nand), nand(b2, nand));
- }
-
- /**
- * Return the NAND of the specified Booleans.
- * Boolean#nand(Boolean)
- */
- public static Boolean nand(Boolean b1, Boolean b2) {
- return not(and(b1, b2));
-// return Boolean.valueOf( ! (b1.booleanValue() && b2.booleanValue()));
- }
-
- /**
- * Return the NOR of the specified Booleans.
- * Boolean#nor(Boolean)
- */
- public static Boolean nor(Boolean b1, Boolean b2) {
- return not(or(b1, b2));
-// Boolean nand = nand(b1, b2);
-// Boolean xor = nand(nand(b1, nand), nand(b2, nand));
-// Boolean and = nand(nand, nand);
-// Boolean nand2 = nand(xor, and);
-// Boolean nand3 = nand(nand(xor, nand2), nand(and, nand2));
-// return nand(nand3, nand3);
- }
-
- /**
- * Return the XNOR of the specified Booleans.
- * Boolean#xnor(Boolean)
- */
- public static Boolean xnor(Boolean b1, Boolean b2) {
- return not(xor(b1, b2));
-// Boolean nand = nand(b1, b2);
-// Boolean xor = nand(nand(b1, nand), nand(b2, nand));
-// return nand(xor, xor);
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private BooleanTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ClassName.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ClassName.java
deleted file mode 100644
index aaf4be351c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ClassName.java
+++ /dev/null
@@ -1,431 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Convenience methods related to Java class names as returned by
- * {@link java.lang.Class#getName()}.
- */
-public final class ClassName {
-
- public static final String VOID_CLASS_NAME = ReflectionTools.VOID_CLASS.getName();
- public static final String VOID_WRAPPER_CLASS_NAME = ReflectionTools.VOID_WRAPPER_CLASS.getName();
-
- public static final char REFERENCE_CLASS_CODE = 'L';
- public static final char REFERENCE_CLASS_NAME_DELIMITER = ';';
-
- /**
- * Return whether the specified class is an array type.
- * @see java.lang.Class#getName()
- */
- public static boolean isArray(String className) {
- return className.charAt(0) == '[';
- }
-
- /**
- * Return the "element type" of the specified class.
- * The element type is the base type held by an array type.
- * Non-array types simply return themselves.
- * @see java.lang.Class#getName()
- */
- public static String getElementTypeName(String className) {
- int depth = getArrayDepth(className);
- if (depth == 0) {
- // the name is in the form: "java.lang.Object" or "int"
- return className;
- }
- return getElementTypeName_(className, depth);
- }
-
- /**
- * pre-condition: array depth is not zero
- */
- private static String getElementTypeName_(String className, int arrayDepth) {
- int last = className.length() - 1;
- if (className.charAt(arrayDepth) == REFERENCE_CLASS_CODE) {
- // the name is in the form: "[[[Ljava.lang.Object;"
- return className.substring(arrayDepth + 1, last); // drop the trailing ';'
- }
- // the name is in the form: "[[[I"
- return forCode(className.charAt(last));
- }
-
- /**
- * Return the "array depth" of the specified class.
- * The depth is the number of dimensions for an array type.
- * Non-array types have a depth of zero.
- * @see java.lang.Class#getName()
- */
- public static int getArrayDepth(String className) {
- int depth = 0;
- while (className.charAt(depth) == '[') {
- depth++;
- }
- return depth;
- }
-
- /**
- * Return the specified class's component type.
- * Return <code>null</code> if the specified class is not an array type.
- * @see java.lang.Class#getName()
- */
- public static String getComponentTypeName(String className) {
- switch (getArrayDepth(className)) {
- case 0:
- return null;
- case 1:
- return getElementTypeName_(className, 1);
- default:
- return className.substring(1);
- }
- }
-
- /**
- * Return the specified class's simple name.
- * Return an empty string if the specified class is anonymous.
- * <p>
- * The simple name of an array type is the simple name of the
- * component type with <code>"[]"</code> appended. In particular,
- * the simple name of an array type whose component type is
- * anonymous is simply <code>"[]"</code>.
- * @see java.lang.Class#getSimpleName()
- */
- public static String getSimpleName(String className) {
- return isArray(className) ?
- getSimpleName(getComponentTypeName(className)) + "[]" : //$NON-NLS-1$
- getSimpleName_(className);
- }
-
- /**
- * pre-condition: specified class is not an array type
- */
- private static String getSimpleName_(String className) {
- int index = className.lastIndexOf('$');
- if (index == -1) { // "top-level" class - strip package name
- return className.substring(className.lastIndexOf('.') + 1);
- }
-
- int len = className.length();
- for (int i = ++index; i < len; i++) {
- if ( ! charIsAsciiDigit(className.charAt(i))) {
- return className.substring(i); // "member" or "local" class
- }
- }
- // all the characters past the '$' are ASCII digits ("anonymous" class)
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Return the specified class's package name (e.g.
- * <code>"java.lang.Object"</code> returns
- * <code>"java.lang"</code>).
- * Return an empty string if the specified class is:<ul>
- * <li>in the "default" package
- * <li>an array class
- * <li>a primtive class
- * </ul>
- * @see java.lang.Class#getPackage()
- * @see java.lang.Package#getName()
- */
- public static String getPackageName(String className) {
- if (isArray(className)) {
- return ""; //$NON-NLS-1$
- }
- int lastPeriod = className.lastIndexOf('.');
- return (lastPeriod == -1) ? "" : className.substring(0, lastPeriod); //$NON-NLS-1$
- }
-
- /**
- * Return whether the specified class is a "top-level" class,
- * as opposed to a "member", "local", or "anonymous" class,
- * using the standard JDK naming conventions (i.e. the class
- * name does NOT contain a <code>'$'</code>).
- * A "top-level" class can be either the "primary" (public) class defined
- * in a file/compilation unit (i.e. the class with the same name as its
- * file's simple base name) or a "non-primary" (package visible) class
- * (i.e. the other top-level classes defined in a file).
- * A "top-level" class can contain any of the other types of classes.
- * @see java.lang.Class#getName()
- */
- public static boolean isTopLevel(String className) {
- if (isArray(className)) {
- return false;
- }
- return className.lastIndexOf('$') == -1;
- }
-
- /**
- * Return whether the specified class is a "member" class,
- * as opposed to a "top-level", "local", or "anonymous" class,
- * using the standard JDK naming convention (i.e. the class
- * name ends with a <code>'$'</code> followed by a legal class name; e.g.
- * <code>"TopLevelClass$1LocalClass$MemberClass"</code>).
- * A "member" class can be either "nested" (static) or "inner";
- * but there is no way to determine which from the class's name.
- * A "member" class can contain "local", "anonymous", or other
- * "member" classes; and vice-versa.
- * @see java.lang.Class#getName()
- */
- public static boolean isMember(String className) {
- if (isArray(className)) {
- return false;
- }
- int index = className.lastIndexOf('$');
- if (index == -1) {
- return false; // "top-level" class
- }
- // the character immediately after the dollar sign cannot be an ASCII digit
- return ! charIsAsciiDigit(className.charAt(++index));
- }
-
- /**
- * Return whether the specified class is a "local" class,
- * as opposed to a "top-level", "member", or "anonymous" class,
- * using the standard JDK naming convention (i.e. the class name
- * ends with <code>"$nnnXXX"</code>,
- * where the <code>'$'</code> is
- * followed by a series of numeric digits which are followed by the
- * local class name; e.g. <code>"TopLevelClass$1LocalClass"</code>).
- * A "local" class can contain "member", "anonymous", or other
- * "local" classes; and vice-versa.
- * @see java.lang.Class#getName()
- */
- public static boolean isLocal(String className) {
- if (isArray(className)) {
- return false;
- }
- int index = className.lastIndexOf('$');
- if (index == -1) {
- return false; // "top-level" class
- }
- if ( ! charIsAsciiDigit(className.charAt(++index))) {
- return false; // "member" class
- }
- int len = className.length();
- for (int i = ++index; i < len; i++) {
- if ( ! charIsAsciiDigit(className.charAt(i))) {
- return true;
- }
- }
- // all the characters past the '$' are ASCII digits ("anonymous" class)
- return false;
- }
-
- /**
- * Return whether the specified class is an "anonymous" class,
- * as opposed to a "top-level", "member", or "local" class,
- * using the standard JDK naming convention (i.e. the class
- * name ends with <code>"$nnn"</code> where all the characters past the
- * last <code>'$'</code> are ASCII numeric digits;
- * e.g. <code>"TopLevelClass$1"</code>).
- * An "anonymous" class can contain "member", "local", or other
- * "anonymous" classes; and vice-versa.
- * @see java.lang.Class#getName()
- */
- public static boolean isAnonymous(String className) {
- if (isArray(className)) {
- return false;
- }
- int index = className.lastIndexOf('$');
- if (index == -1) {
- return false; // "top-level" class
- }
- if ( ! charIsAsciiDigit(className.charAt(++index))) {
- return false; // "member" class
- }
- int len = className.length();
- for (int i = ++index; i < len; i++) {
- if ( ! charIsAsciiDigit(className.charAt(i))) {
- return false; // "local" class
- }
- }
- // all the characters past the '$' are ASCII digits ("anonymous" class)
- return true;
- }
-
- /**
- * {@link Character#isDigit(char)} returns <code>true</code> for some non-ASCII
- * digits. This method does not.
- */
- private static boolean charIsAsciiDigit(char c) {
- return ('0' <= c) && (c <= '9');
- }
-
- /**
- * Return whether the specified class is a "reference"
- * class (i.e. neither <code>void</code> nor one of the primitive variable classes,
- * <code>boolean</code>, <code>int</code>, <code>float</code>, etc.).
- * <p>
- * <strong>NB:</strong> <code>void.class.isPrimitive() == true</code>
- */
- public static boolean isReference(String className) {
- return ! isPrimitive(className);
- }
-
- /**
- * Return whether the specified class is a primitive
- * class (i.e. <code>void</code> or one of the primitive variable classes,
- * <code>boolean</code>, <code>int</code>, <code>float</code>, etc.).
- * <p>
- * <strong>NB:</strong> <code>void.class.isPrimitive() == true</code>
- */
- public static boolean isPrimitive(String className) {
- if (isArray(className) || (className.length() > ReflectionTools.MAX_PRIMITIVE_CLASS_NAME_LENGTH)) {
- return false; // performance tweak
- }
- for (ReflectionTools.Primitive primitive : ReflectionTools.PRIMITIVES) {
- if (className.equals(primitive.javaClass.getName())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified class is a primitive wrapper
- * class (i.e. <code>java.lang.Void</code> or one of the primitive
- * variable wrapper classes, <code>java.lang.Boolean</code>,
- * <code>java.lang.Integer</code>, <code>java.lang.Float</code>, etc.).
- * <p>
- * <strong>NB:</strong> <code>void.class.isPrimitive() == true</code>
- */
- public static boolean isPrimitiveWrapper(String className) {
- if (isArray(className) || (className.length() > ReflectionTools.MAX_PRIMITIVE_WRAPPER_CLASS_NAME_LENGTH)) {
- return false; // performance tweak
- }
- for (ReflectionTools.Primitive primitive : ReflectionTools.PRIMITIVES) {
- if (className.equals(primitive.wrapperClass.getName())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified class is a "variable" primitive
- * class (i.e. <code>boolean</code>, <code>int</code>, <code>float</code>, etc.,
- * but not <code>void</code>).
- * <p>
- * <strong>NB:</strong> <code>void.class.isPrimitive() == true</code>
- */
- public static boolean isVariablePrimitive(String className) {
- return isPrimitive(className)
- && ( ! className.equals(VOID_CLASS_NAME));
- }
-
- /**
- * Return whether the specified class is a "variable" primitive wrapper
- * class (i.e. <code>java.lang.Boolean</code>,
- * <code>java.lang.Integer</code>, <code>java.lang.Float</code>, etc.,
- * but not <code>java.lang.Void</code>).
- * <p>
- * <strong>NB:</strong> <code>void.class.isPrimitive() == true</code>
- */
- public static boolean isVariablePrimitiveWrapper(String className) {
- return isPrimitiveWrapper(className)
- && ( ! className.equals(VOID_WRAPPER_CLASS_NAME));
- }
-
- /**
- * Return the name of the primitive wrapper class corresponding to the specified
- * primitive class. Return <code>null</code> if the specified class is not a primitive.
- */
- public static String getWrapperClassName(String primitiveClassName) {
- for (ReflectionTools.Primitive primitive : ReflectionTools.PRIMITIVES) {
- if (primitive.javaClass.getName().equals(primitiveClassName)) {
- return primitive.wrapperClass.getName();
- }
- }
- return null;
- }
-
- /**
- * Return the name of the primitive class corresponding to the specified
- * primitive wrapper class. Return <code>null</code> if the specified class
- * is not a primitive wrapper.
- */
- public static String getPrimitiveClassName(String primitiveWrapperClassName) {
- for (ReflectionTools.Primitive primitive : ReflectionTools.PRIMITIVES) {
- if (primitive.wrapperClass.getName().equals(primitiveWrapperClassName)) {
- return primitive.javaClass.getName();
- }
- }
- return null;
- }
-
- /**
- * Return whether the two class names are equivalent, given autoboxing.
- * (e.g. "java.lang.Integer" and "int" should be equivalent)
- */
- public static boolean areAutoboxEquivalents(String className1, String className2) {
- return Tools.valuesAreEqual(className1, className2)
- || Tools.valuesAreEqual(getPrimitiveClassName(className1), className2)
- || Tools.valuesAreEqual(getWrapperClassName(className1), className2);
- }
-
-
- // ********** primitive codes **********
-
- /**
- * Return the primitive class name for the specified primitive class code.
- * Return <code>null</code> if the specified code
- * is not a primitive class code.
- * @see java.lang.Class#getName()
- */
- public static String forCode(int classCode) {
- return forCode((char) classCode);
- }
-
- /**
- * Return the primitive class name for the specified primitive class code.
- * Return <code>null</code> if the specified code
- * is not a primitive class code.
- * @see java.lang.Class#getName()
- */
- public static String forCode(char classCode) {
- Class<?> primitiveClass = ReflectionTools.getClassForCode(classCode);
- return (primitiveClass == null) ? null : primitiveClass.getName();
- }
-
- /**
- * Return the class code for the specified primitive class.
- * Return <code>0</code> if the specified class
- * is not a primitive class.
- * @see java.lang.Class#getName()
- */
- public static char getCodeForClassName(String primitiveClassName) {
- if (( ! isArray(primitiveClassName)) && (primitiveClassName.length() <= ReflectionTools.MAX_PRIMITIVE_CLASS_NAME_LENGTH)) {
- for (ReflectionTools.Primitive primitive : ReflectionTools.PRIMITIVES) {
- if (primitive.javaClass.getName().equals(primitiveClassName)) {
- return primitive.code;
- }
- }
- }
- return 0;
- }
-
- static void append(String className, StringBuilder sb) {
- sb.append(REFERENCE_CLASS_CODE);
- sb.append(className);
- sb.append(REFERENCE_CLASS_NAME_DELIMITER);
- }
-
-
- // ********** suppressed constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private ClassName() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Classpath.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Classpath.java
deleted file mode 100644
index 33657d5e41..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Classpath.java
+++ /dev/null
@@ -1,939 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-
-/**
- * <code>Classpath</code> models a Java classpath, which consists of a list of
- * {@link Entry}s, each of which contain Java classes. The classpath can return
- * the names of classes found in it etc. There are a number of static
- * convenience methods that can be use to construct <code>Classpath</code>s
- * corresponding to the Java classpath etc.
- */
-public class Classpath
- implements Serializable
-{
- /** The entries in the classpath */
- private final Entry[] entries;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** static methods **********
-
- // ***** factory methods for "standard" classpaths *****
-
- /**
- * Return the Java "boot" classpath. This includes <code>rt.jar</code>.
- */
- public static Classpath bootClasspath() {
- return new Classpath(System.getProperty("sun.boot.class.path")); //$NON-NLS-1$
- }
-
- /**
- * Return a "virtual classpath" that contains all the jars
- * that would be used by the Java Extension Mechanism.
- */
- public static Classpath javaExtensionClasspath() {
- File[] dirs = javaExtensionDirectories();
- List<String> jarFileNames = new ArrayList<String>();
- for (File dir : dirs) {
- if (dir.isDirectory()) {
- addJarFileNamesTo(dir, jarFileNames);
- }
- }
- return new Classpath(jarFileNames);
- }
-
- /**
- * Return the Java "system" classpath.
- */
- public static Classpath javaClasspath() {
- return new Classpath(System.getProperty("java.class.path")); //$NON-NLS-1$
- }
-
- /**
- * Return the unretouched "complete" classpath.
- * This includes the boot classpath, the Java Extension
- * Mechanism classpath, and the normal "system" classpath.
- */
- public static Classpath completeClasspath() {
- return new Classpath(new Classpath[] {
- bootClasspath(),
- javaExtensionClasspath(),
- javaClasspath()
- });
- }
-
- /**
- * Return a classpath that contains the location of the specified class.
- */
- public static Classpath classpathFor(Class<?> javaClass) {
- return new Classpath(locationFor(javaClass));
- }
-
-
- // ***** file => class *****
-
- /**
- * Convert a relative file name to a class name; this will work for
- * any file that has a single extension beyond the base
- * class name:<ul>
- * <li><code>"java/lang/String.class"</code> is converted to <code>"java.lang.String"</code>
- * <li><code>"java/lang/String.java"</code> is converted to <code>"java.lang.String"</code>
- * </ul>
- */
- public static String convertToClassName(String classFileName) {
- String className = FileTools.stripExtension(classFileName);
- // do this for archive entry names
- className = className.replace('/', '.');
- // do this for O/S-specific file names
- if (File.separatorChar != '/') {
- className = className.replace(File.separatorChar, '.');
- }
- return className;
- }
-
- /**
- * Convert a file to a class name;
- * e.g. <code>File(java/lang/String.class)</code> is converted to
- * <code>"java.lang.String"</code>.
- */
- public static String convertToClassName(File classFile) {
- return convertToClassName(classFile.getPath());
- }
-
- /**
- * Convert a relative file name to a class;
- * e.g. <code>"java/lang/String.class"</code> is converted to
- * <code>java.lang.String.class</code>.
- */
- public static Class<?> convertToClass(String classFileName) throws ClassNotFoundException {
- return Class.forName(convertToClassName(classFileName));
- }
-
- /**
- * Convert a relative file to a class;
- * e.g. <code>File(java/lang/String.class)</code> is converted to
- * <code>java.lang.String.class</code>.
- */
- public static Class<?> convertToClass(File classFile) throws ClassNotFoundException {
- return convertToClass(classFile.getPath());
- }
-
-
- // ***** class => JAR entry *****
-
- /**
- * Convert a class name to an archive entry name base;
- * e.g. <code>"java.lang.String"</code> is converted to
- * <code>"java/lang/String"</code>.
- */
- public static String convertToArchiveEntryNameBase(String className) {
- return className.replace('.', '/');
- }
-
- /**
- * Convert a class to an archive entry name base;
- * e.g. <code>java.lang.String.class</code> is converted to
- * <code>"java/lang/String"</code>.
- */
- public static String convertToArchiveEntryNameBase(Class<?> javaClass) {
- return convertToArchiveEntryNameBase(javaClass.getName());
- }
-
- /**
- * Convert a class name to an archive class file entry name;
- * e.g. <code>"java.lang.String"</code> is converted to
- * <code>"java/lang/String.class"</code>.
- */
- public static String convertToArchiveClassFileEntryName(String className) {
- return convertToArchiveEntryNameBase(className) + ".class"; //$NON-NLS-1$
- }
-
- /**
- * Convert a class to an archive class file entry name;
- * e.g. <code>java.lang.String.class</code> is converted to
- * <code>"java/lang/String.class"</code>.
- */
- public static String convertToArchiveClassFileEntryName(Class<?> javaClass) {
- return convertToArchiveClassFileEntryName(javaClass.getName());
- }
-
-
- // ***** class => file (.class or .java) *****
-
- /**
- * Convert a class name to a file name base for the current O/S;
- * e.g. <code>"java.lang.String"</code> is converted to
- * <code>"java/lang/String"</code> on Unix and
- * <code>"java\\lang\\String"</code> on Windows.
- */
- public static String convertToFileNameBase(String className) {
- return className.replace('.', File.separatorChar);
- }
-
- /**
- * Convert a class to a file name base for the current O/S;
- * e.g. <code>java.lang.String.class</code> is converted to
- * <code>"java/lang/String"</code> on Unix and
- * <code>"java\\lang\\String"</code> on Windows.
- */
- public static String convertToFileNameBase(Class<?> javaClass) {
- return convertToFileNameBase(javaClass.getName());
- }
-
- /**
- * Convert a class name to a class file name for the current O/S;
- * e.g. <code>"java.lang.String"</code> is converted to
- * <code>"java/lang/String.class"</code> on Unix and
- * <code>"java\\lang\\String.class"</code> on Windows.
- */
- public static String convertToClassFileName(String className) {
- return convertToFileNameBase(className) + ".class"; //$NON-NLS-1$
- }
-
- /**
- * Convert a class to a class file name for the current O/S;
- * e.g. <code>java.lang.String.class</code> is converted to
- * <code>"java/lang/String.class"</code> on Unix and
- * <code>"java\\lang\\String.class"</code> on Windows.
- */
- public static String convertToClassFileName(Class<?> javaClass) {
- return convertToClassFileName(javaClass.getName());
- }
-
- /**
- * Convert a class name to a class file for the current O/S;
- * e.g. <code>"java.lang.String"</code> is converted to
- * <code>File(java/lang/String.class)</code>.
- */
- public static File convertToClassFile(String className) {
- return new File(convertToClassFileName(className));
- }
-
- /**
- * Convert a class to a class file for the current O/S;
- * e.g. <code>java.lang.String.class</code> is converted to
- * <code>File(java/lang/String.class)</code>.
- */
- public static File convertToClassFile(Class<?> javaClass) {
- return convertToClassFile(javaClass.getName());
- }
-
- /**
- * Convert a class name to a java file name for the current O/S;
- * e.g. <code>"java.lang.String"</code> is converted to
- * <code>"java/lang/String.java"</code> on Unixl and
- * <code>"java\\lang\\String.java"</code> on Windows.
- */
- public static String convertToJavaFileName(String className) {
- return convertToFileNameBase(className) + ".java"; //$NON-NLS-1$
- }
-
- /**
- * Convert a class to a java file name for the current O/S;
- * e.g. <code>java.lang.String.class</code> is converted to
- * <code>"java/lang/String.java"</code> on Unix and
- * <code>"java\\lang\\String.java"</code> on Windows.
- */
- public static String convertToJavaFileName(Class<?> javaClass) {
- return convertToJavaFileName(javaClass.getName());
- }
-
- /**
- * Convert a class name to a java file for the current O/S;
- * e.g. <code>"java.lang.String"</code> is converted to
- * <code>File(java/lang/String.java)</code>.
- */
- public static File convertToJavaFile(String className) {
- return new File(convertToJavaFileName(className));
- }
-
- /**
- * Convert a class to a java file for the current O/S;
- * e.g. <code>java.lang.String.class</code> is converted to
- * <code>File(java/lang/String.java)</code>.
- */
- public static File convertToJavaFile(Class<?> javaClass) {
- return convertToJavaFile(javaClass.getName());
- }
-
-
- // ***** class => resource *****
-
- /**
- * Convert a class to a resource name;
- * e.g. <code>java.lang.String.class</code> is converted to
- * <code>"/java/lang/String.class"</code>.
- */
- public static String convertToResourceName(Class<?> javaClass) {
- return '/' + convertToArchiveClassFileEntryName(javaClass);
- }
-
- /**
- * Convert a class to a resource;
- * e.g. <code>java.lang.String.class</code> is converted to
- * <code>URL(jar:file:/C:/jdk/1.4.2_04/jre/lib/rt.jar!/java/lang/String.class)</code>.
- */
- public static URL convertToResource(Class<?> javaClass) {
- return javaClass.getResource(convertToResourceName(javaClass));
- }
-
-
- // ***** utilities *****
-
- /**
- * Return whether the specified file is an archive file;
- * i.e. its name ends with <code>".zip"</code> or <code>".jar"</code>.
- */
- public static boolean fileNameIsArchive(String fileName) {
- String ext = FileTools.extension(fileName).toLowerCase();
- return ext.equals(".jar") || ext.equals(".zip"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Return whether the specified file is an archive file;
- * i.e. its name ends with <code>".zip"</code> or <code>".jar"</code>.
- */
- public static boolean fileIsArchive(File file) {
- return fileNameIsArchive(file.getName());
- }
-
- /**
- * Return what should be the fully-qualified file name
- * for the JRE runtime JAR;
- * e.g. <code>"C:\jdk1.4.2_04\jre\lib\rt.jar"</code>.
- */
- public static String rtJarName() {
- return locationFor(java.lang.Object.class);
- }
-
- /**
- * Return the location from where the specified class was loaded.
- */
- public static String locationFor(Class<?> javaClass) {
- URL url = convertToResource(javaClass);
- String path;
- try {
- path = FileTools.buildFile(url).getPath();
- } catch (URISyntaxException ex) {
- throw new RuntimeException(ex);
- }
- String protocol = url.getProtocol().toLowerCase();
- if (protocol.equals("jar")) { //$NON-NLS-1$
- // if the class is in a JAR, the URL will look something like this:
- // jar:file:/C:/jdk/1.4.2_04/jre/lib/rt.jar!/java/lang/String.class
- return path.substring(0, path.indexOf('!'));
- } else if (protocol.equals("file")) { //$NON-NLS-1$
- // if the class is in a directory, the URL will look something like this:
- // file:/C:/dev/main/mwdev/class/org/eclipse/dali/utility/Classpath.class
- return path.substring(0, path.length() - convertToClassFileName(javaClass).length() - 1);
- } else if (protocol.equals("bundleresource")) { //$NON-NLS-1$
- // if the class is in a bundle resource (Eclipse?), the URL will look something like this:
- // bundleresource://43/org/eclipse/dali/utility/Classpath.class
- return path.substring(0, path.length() - convertToClassFileName(javaClass).length() - 1);
- }
-
- throw new IllegalStateException(url.toString());
- }
-
- /**
- * Return the directories used by the Java Extension Mechanism.
- */
- public static File[] javaExtensionDirectories() {
- return convertToFiles(javaExtensionDirectoryNames());
- }
-
- /**
- * Return the directory names used by the Java Extension Mechanism.
- */
- public static String[] javaExtensionDirectoryNames() {
- return System.getProperty("java.ext.dirs").split(File.pathSeparator); //$NON-NLS-1$
- }
-
-
- // ***** internal *****
-
- private static File[] convertToFiles(String[] fileNames) {
- File[] files = new File[fileNames.length];
- for (int i = fileNames.length; i-- > 0; ) {
- files[i] = new File(fileNames[i]);
- }
- return files;
- }
-
- private static void addJarFileNamesTo(File dir, List<String> jarFileNames) {
- File[] jarFiles = jarFilesIn(dir);
- for (File jarFile : jarFiles) {
- jarFileNames.add(FileTools.canonicalFile(jarFile).getPath());
- }
- }
-
- private static File[] jarFilesIn(File directory) {
- return directory.listFiles(jarFileFilter());
- }
-
- private static FileFilter jarFileFilter() {
- return new FileFilter() {
- public boolean accept(File file) {
- return FileTools.extension(file.getName()).toLowerCase().equals(".jar"); //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** constructors **********
-
- /**
- * Construct a classpath with the specified entries.
- */
- private Classpath(Entry[] entries) {
- super();
- this.entries = entries;
- }
-
- /**
- * Construct a classpath with the specified entries.
- */
- public Classpath(String... fileNames) {
- this(buildEntries(fileNames));
- }
-
- /**
- * Skip empty file names because they will end up expanding to the current
- * working directory, which is not what we want. Empty file names actually
- * occur with some frequency; such as when the classpath has been built up
- * dynamically with too many separators. For example:<pre>
- * "C:\dev\foo.jar;;C:\dev\bar.jar"
- * </pre>will be parsed into three file names:<pre>
- * { "C:\dev\foo.jar", "", "C:\dev\bar.jar" }
- * </pre>
- */
- private static Entry[] buildEntries(String[] fileNames) {
- List<Entry> entries = new ArrayList<Entry>();
- for (String fileName : fileNames) {
- if ((fileName != null) && (fileName.length() != 0)) {
- entries.add(new Entry(fileName));
- }
- }
- return entries.toArray(new Entry[entries.size()]);
- }
-
- /**
- * Construct a classpath with the specified path.
- */
- public Classpath(String path) {
- this(path.split(File.pathSeparator));
- }
-
- /**
- * Construct a classpath with the specified entries.
- */
- public Classpath(Iterable<String> fileNames) {
- this(ArrayTools.array(fileNames, StringTools.EMPTY_STRING_ARRAY));
- }
-
- /**
- * Consolidate the specified classpaths into a single classpath.
- */
- public Classpath(Classpath... classpaths) {
- this(consolidateEntries(classpaths));
- }
-
- private static Entry[] consolidateEntries(Classpath[] classpaths) {
- List<Entry> entries = new ArrayList<Entry>();
- for (Classpath classpath : classpaths) {
- CollectionTools.addAll(entries, classpath.getEntries());
- }
- return entries.toArray(new Entry[entries.size()]);
- }
-
-
- // ********** public API **********
-
- /**
- * Return the classpath's entries.
- */
- public Iterable<Entry> getEntries() {
- return new ArrayIterable<Entry>(this.entries);
- }
-
- /**
- * Return the classpath's path.
- */
- public String getPath() {
- int max = this.entries.length - 1;
- if (max == -1) {
- return ""; //$NON-NLS-1$
- }
- StringBuilder sb = new StringBuilder(2000);
- // stop one short of the end of the array
- for (int i = 0; i < max; i++) {
- sb.append(this.entries[i].getFileName());
- sb.append(File.pathSeparatorChar);
- }
- sb.append(this.entries[max].getFileName());
- return sb.toString();
- }
-
- /**
- * Search the classpath for the specified (unqualified) file
- * and return its entry. Return null if an entry is not found.
- * For example, you could use this method to find the entry
- * for <code>"rt.jar"</code> or <code>"toplink.jar"</code>.
- */
- public Entry getEntryForFileNamed(String shortFileName) {
- for (Entry entry : this.entries) {
- if (entry.getFile().getName().equals(shortFileName)) {
- return entry;
- }
- }
- return null;
- }
-
- /**
- * Return the first entry file in the classpath
- * that contains the specified class.
- * Return null if an entry is not found.
- */
- public Entry getEntryForClassNamed(String className) {
- String relativeClassFileName = convertToClassFileName(className);
- String archiveEntryName = convertToArchiveClassFileEntryName(className);
- for (Entry entry : this.entries) {
- if (entry.contains(relativeClassFileName, archiveEntryName)) {
- return entry;
- }
- }
- return null;
- }
-
- /**
- * Return the names of all the classes discovered on the classpath,
- * with duplicates removed.
- * @see #classNames()
- */
- public Iterable<String> getClassNames() {
- return this.getClassNames(Filter.Transparent.<String>instance());
- }
-
- /**
- * Return the names of all the classes discovered on the classpath
- * and accepted by the specified filter, with duplicates removed.
- * @see #classNames(Filter)
- */
- public Iterable<String> getClassNames(Filter<String> filter) {
- Collection<String> classNames = new HashSet<String>(10000);
- this.addClassNamesTo(classNames, filter);
- return classNames;
- }
-
- /**
- * Add the names of all the classes discovered on the classpath
- * to the specified collection.
- */
- public void addClassNamesTo(Collection<String> classNames) {
- this.addClassNamesTo(classNames, Filter.Transparent.<String>instance());
- }
-
- /**
- * Add the names of all the classes discovered on the classpath
- * and accepted by the specified filter to the specified collection.
- */
- public void addClassNamesTo(Collection<String> classNames, Filter<String> filter) {
- for (Entry entry : this.entries) {
- entry.addClassNamesTo(classNames, filter);
- }
- }
-
- /**
- * Return the names of all the classes discovered on the classpath.
- * Just a bit more performant than {@link #getClassNames()}.
- */
- public Iterator<String> classNames() {
- return this.classNames(Filter.Transparent.<String>instance());
- }
-
- /**
- * Return the names of all the classes discovered on the classpath
- * that are accepted by the specified filter.
- * Just a bit more performant than {@link #getClassNames(Filter)}.
- */
- public Iterator<String> classNames(Filter<String> filter) {
- return new CompositeIterator<String>(this.entryClassNamesIterators(filter));
- }
-
- private Iterator<Iterator<String>> entryClassNamesIterators(final Filter<String> filter) {
- return new TransformationIterator<Entry, Iterator<String>>(new ArrayIterator<Entry>(this.entries)) {
- @Override
- protected Iterator<String> transform(Entry entry) {
- return entry.classNames(filter);
- }
- };
- }
-
- /**
- * Return a "compressed" version of the classpath with its
- * duplicate entries eliminated.
- */
- public Classpath compressed() {
- return new Classpath(ArrayTools.removeDuplicateElements(this.entries));
- }
-
- /**
- * Convert the classpath to an array of URLs
- * (that can be used to instantiate a {@link java.net.URLClassLoader}).
- */
- public Iterable<URL> getURLs() {
- int len = this.entries.length;
- URL[] urls = new URL[len];
- for (int i = 0; i < len; i++) {
- urls[i] = this.entries[i].getURL();
- }
- return new ArrayIterable<URL>(urls);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.getPath());
- }
-
-
- // ********** classpath entry **********
-
- /**
- * <code>Entry</code> models a Java classpath entry, which can be either a
- * directory containing <code>.class</code> files or a JAR file (or,
- * similarly, a <code>.zip</code> file). The entry can return the names of
- * classes found in it etc.
- */
- public static class Entry
- implements Serializable
- {
- private final String fileName;
- private final File file;
- private final File canonicalFile;
-
- private static final long serialVersionUID = 1L;
-
- Entry(String fileName) {
- super();
- if ((fileName == null) || (fileName.length() == 0)) {
- throw new IllegalArgumentException("'fileName' must be non-empty"); //$NON-NLS-1$
- }
- this.fileName = fileName;
- this.file = new File(fileName);
- this.canonicalFile = FileTools.canonicalFile(this.file);
- }
-
- public String getFileName() {
- return this.fileName;
- }
-
- public File getFile() {
- return this.file;
- }
-
- public File getCanonicalFile() {
- return this.canonicalFile;
- }
-
- public String getCanonicalFileName() {
- return this.canonicalFile.getAbsolutePath();
- }
-
- @Override
- public boolean equals(Object o) {
- if ( ! (o instanceof Entry)) {
- return false;
- }
- return ((Entry) o).canonicalFile.equals(this.canonicalFile);
- }
-
- @Override
- public int hashCode() {
- return this.canonicalFile.hashCode();
- }
-
- /**
- * Return the entry's "canonical" URL.
- */
- public URL getURL() {
- try {
- return this.canonicalFile.toURI().toURL();
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * Return whether the entry contains the specified class.
- */
- public boolean contains(Class<?> javaClass) {
- return this.contains(javaClass.getName());
- }
-
- /**
- * Return whether the entry contains the specified class.
- */
- public boolean contains(String className) {
- return this.contains(convertToClassFileName(className), convertToArchiveClassFileEntryName(className));
- }
-
- /**
- * Return whether the entry contains either the specified relative
- * class file or the specified archive entry.
- * Not the prettiest signature, but it's internal....
- */
- boolean contains(String relativeClassFileName, String archiveEntryName) {
- if ( ! this.canonicalFile.exists()) {
- return false;
- }
- if (this.canonicalFile.isDirectory() && (new File(this.canonicalFile, relativeClassFileName)).exists()) {
- return true;
- }
- return (fileIsArchive(this.canonicalFile) && this.archiveContainsEntry(archiveEntryName));
- }
-
- /**
- * Return whether the entry's archive contains the specified entry.
- */
- private boolean archiveContainsEntry(String zipEntryName) {
- ZipFile zipFile = null;
- ZipEntry zipEntry = null;
- try {
- zipFile = new ZipFile(this.canonicalFile);
- zipEntry = zipFile.getEntry(zipEntryName);
- } catch (IOException ex) {
- // something is wrong, leave the entry null
- } finally {
- try {
- if (zipFile != null) {
- zipFile.close();
- }
- } catch (IOException ex) {
- zipEntry = null; // something is wrong, clear out the entry
- }
- }
- return zipEntry != null;
- }
-
- /**
- * Return the names of all the classes discovered in the entry.
- * @see #classNames()
- */
- public Iterable<String> getClassNames() {
- return this.getClassNames(Filter.Transparent.<String>instance());
- }
-
- /**
- * Return the names of all the classes discovered in the entry
- * and accepted by the specified filter.
- * @see #classNames(Filter)
- */
- public Iterable<String> getClassNames(Filter<String> filter) {
- Collection<String> classNames = new ArrayList<String>(2000);
- this.addClassNamesTo(classNames, filter);
- return classNames;
- }
-
- /**
- * Add the names of all the classes discovered in the entry
- * to the specified collection.
- */
- public void addClassNamesTo(Collection<String> classNames) {
- this.addClassNamesTo(classNames, Filter.Transparent.<String>instance());
- }
-
- /**
- * Add the names of all the classes discovered in the entry
- * and accepted by the specified filter to the specified collection.
- */
- public void addClassNamesTo(Collection<String> classNames, Filter<String> filter) {
- if (this.canonicalFile.exists()) {
- if (this.canonicalFile.isDirectory()) {
- this.addClassNamesForDirectoryTo(classNames, filter);
- } else if (fileIsArchive(this.canonicalFile)) {
- this.addClassNamesForArchiveTo(classNames, filter);
- }
- }
- }
-
- /**
- * Add the names of all the classes discovered
- * under the entry's directory and accepted by
- * the specified filter to the specified collection.
- */
- private void addClassNamesForDirectoryTo(Collection<String> classNames, Filter<String> filter) {
- int start = this.canonicalFile.getAbsolutePath().length() + 1;
- for (Iterator<File> stream = this.classFilesForDirectory(); stream.hasNext(); ) {
- String className = convertToClassName(stream.next().getAbsolutePath().substring(start));
- if (filter.accept(className)) {
- classNames.add(className);
- }
- }
- }
-
- /**
- * Return an iterator on all the class files discovered
- * under the entry's directory.
- */
- private Iterator<File> classFilesForDirectory() {
- return new FilteringIterator<File>(FileTools.filesInTree(this.canonicalFile)) {
- @Override
- protected boolean accept(File next) {
- return Entry.this.fileNameMightBeForClassFile(next.getName());
- }
- };
- }
-
- /**
- * Add the names of all the classes discovered
- * in the entry's archive file and accepted by the
- * specified filter to the specified collection.
- */
- private void addClassNamesForArchiveTo(Collection<String> classNames, Filter<String> filter) {
- ZipFile zipFile = null;
- try {
- zipFile = new ZipFile(this.canonicalFile);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- for (Enumeration<? extends ZipEntry> stream = zipFile.entries(); stream.hasMoreElements(); ) {
- ZipEntry zipEntry = stream.nextElement();
- String zipEntryName = zipEntry.getName();
- if (this.fileNameMightBeForClassFile(zipEntryName)) {
- String className = convertToClassName(zipEntryName);
- if (filter.accept(className)) {
- classNames.add(className);
- }
- }
- }
- try {
- zipFile.close();
- } catch (IOException ex) {
- return;
- }
- }
-
- /**
- * Return whether the specified file might be a Java class file.
- * The file name must at least end with <code>".class"</code> and contain no spaces.
- * (Neither class names nor package names may contain spaces.)
- * Whether it actually is a class file will need to be determined by
- * a class loader.
- */
- boolean fileNameMightBeForClassFile(String name) {
- return FileTools.extension(name).toLowerCase().equals(".class") //$NON-NLS-1$
- && (name.indexOf(' ') == -1);
- }
-
- /**
- * Return the names of all the classes discovered on the classpath.
- * Just a bit more performant than {@link #getClassNames()}.
- */
- public Iterator<String> classNames() {
- return this.classNames(Filter.Transparent.<String>instance());
- }
-
- /**
- * Return the names of all the classes discovered on the classpath
- * that are accepted by the specified filter.
- * Just a bit more performant than {@link #getClassNames(Filter)}.
- */
- public Iterator<String> classNames(Filter<String> filter) {
- if (this.canonicalFile.exists()) {
- if (this.canonicalFile.isDirectory()) {
- return this.classNamesForDirectory(filter);
- }
- if (fileIsArchive(this.canonicalFile)) {
- return this.classNamesForArchive(filter);
- }
- }
- return EmptyIterator.instance();
- }
-
- /**
- * Return the names of all the classes discovered
- * under the entry's directory and accepted by
- * the specified filter.
- */
- private Iterator<String> classNamesForDirectory(Filter<String> filter) {
- return new FilteringIterator<String>(this.classNamesForDirectory(), filter);
- }
-
- /**
- * Transform the class files to class names.
- */
- private Iterator<String> classNamesForDirectory() {
- final int start = this.canonicalFile.getAbsolutePath().length() + 1;
- return new TransformationIterator<File, String>(this.classFilesForDirectory()) {
- @Override
- protected String transform(File f) {
- return convertToClassName(f.getAbsolutePath().substring(start));
- }
- };
- }
-
- /**
- * Return the names of all the classes discovered
- * in the entry's archive file and accepted by the
- * specified filter.
- */
- private Iterator<String> classNamesForArchive(Filter<String> filter) {
- // we can't simply wrap iterators here because we need to close the archive file...
- ZipFile zipFile = null;
- try {
- zipFile = new ZipFile(this.canonicalFile);
- } catch (IOException ex) {
- return EmptyIterator.instance();
- }
- Collection<String> classNames = new HashSet<String>(zipFile.size());
- for (Enumeration<? extends ZipEntry> stream = zipFile.entries(); stream.hasMoreElements(); ) {
- ZipEntry zipEntry = stream.nextElement();
- String zipEntryName = zipEntry.getName();
- if (this.fileNameMightBeForClassFile(zipEntryName)) {
- String className = convertToClassName(zipEntryName);
- if (filter.accept(className)) {
- classNames.add(className);
- }
- }
- }
- try {
- zipFile.close();
- } catch (IOException ex) {
- return EmptyIterator.instance();
- }
- return classNames.iterator();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CollectingExceptionHandler.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CollectingExceptionHandler.java
deleted file mode 100644
index 55f90eb25c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CollectingExceptionHandler.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.util.Vector;
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.internal.iterables.SnapshotCloneIterable;
-
-/**
- * An exception handler that collects and hold the exceptions handed to it.
- * They can be retrieved at a later time via calls to {@link #getExceptions()}
- * and {{@link #clearExceptions()}.
- */
-public class CollectingExceptionHandler
- implements ExceptionHandler
-{
- private final Vector<Throwable> exceptions = new Vector<Throwable>();
-
- public void handleException(Throwable t) {
- this.exceptions.add(t);
- }
-
- /**
- * Return the current list of exceptions handled by the handler so far.
- */
- public Iterable<Throwable> getExceptions() {
- return new SnapshotCloneIterable<Throwable>(this.exceptions);
- }
-
- /**
- * Clear and return the current list of exceptions handled by the handler
- * so far.
- */
- public Iterable<Throwable> clearExceptions() {
- synchronized (this.exceptions) {
- Iterable<Throwable> result = new SnapshotCloneIterable<Throwable>(this.exceptions);
- this.exceptions.clear();
- return result;
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.exceptions);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CollectionTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CollectionTools.java
deleted file mode 100644
index da0c1d1e8b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CollectionTools.java
+++ /dev/null
@@ -1,1977 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Random;
-import java.util.RandomAccess;
-import java.util.TreeSet;
-import java.util.Vector;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.SuperIteratorWrapper;
-
-/**
- * {@link Collection}-related utility methods.
- */
-public final class CollectionTools {
-
- // ********** add all **********
-
- /**
- * Add all the elements returned by the specified iterable
- * to the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.addAll(Iterable iterable)</code>
- */
- public static <E> boolean addAll(Collection<? super E> collection, Iterable<? extends E> iterable) {
- return addAll(collection, iterable.iterator());
- }
-
- /**
- * Add all the elements returned by the specified iterable
- * to the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.addAll(Iterable iterable)</code>
- */
- public static <E> boolean addAll(Collection<? super E> collection, Iterable<? extends E> iterable, int size) {
- return addAll(collection, iterable.iterator(), size);
- }
-
- /**
- * Add all the elements returned by the specified iterator
- * to the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.addAll(Iterator iterator)</code>
- */
- public static <E> boolean addAll(Collection<? super E> collection, Iterator<? extends E> iterator) {
- return iterator.hasNext() ? addAll_(collection, iterator) : false;
- }
-
- /**
- * assume the iterator is not empty
- */
- private static <E> boolean addAll_(Collection<? super E> collection, Iterator<? extends E> iterator) {
- boolean modified = false;
- while (iterator.hasNext()) {
- modified |= collection.add(iterator.next());
- }
- return modified;
- }
-
- /**
- * Add all the elements returned by the specified iterator
- * to the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.addAll(Iterator iterator)</code>
- */
- public static <E> boolean addAll(Collection<? super E> collection, Iterator<? extends E> iterator, int size) {
- return iterator.hasNext() ? collection.addAll(list(iterator, size)) : false;
- }
-
- /**
- * Add all the elements in the specified array
- * to the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.addAll(Object[] array)</code>
- */
- public static <E> boolean addAll(Collection<? super E> collection, E... array) {
- return (array.length == 0) ? false : addAll_(collection, array);
- }
-
- /**
- * assume the array is not empty
- */
- private static <E> boolean addAll_(Collection<? super E> collection, E... array) {
- boolean modified = false;
- for (E element : array) {
- modified |= collection.add(element);
- }
- return modified;
- }
-
- /**
- * Add all the elements returned by the specified iterable
- * to the specified list at the specified index.
- * Return whether the list changed as a result.
- * <p>
- * <code>List.addAll(Iterable iterable)</code>
- */
- public static <E> boolean addAll(List<? super E> list, int index, Iterable<E> iterable) {
- return addAll(list, index, iterable.iterator());
- }
-
- /**
- * Add all the elements returned by the specified iterable
- * to the specified list at the specified index.
- * Return whether the list changed as a result.
- * <p>
- * <code>List.addAll(Iterable iterable)</code>
- */
- public static <E> boolean addAll(List<? super E> list, int index, Iterable<E> iterable, int size) {
- return addAll(list, index, iterable.iterator(), size);
- }
-
- /**
- * Add all the elements returned by the specified iterator
- * to the specified list at the specified index.
- * Return whether the list changed as a result.
- * <p>
- * <code>List.addAll(Iterator iterator)</code>
- */
- public static <E> boolean addAll(List<? super E> list, int index, Iterator<? extends E> iterator) {
- return iterator.hasNext() ? list.addAll(index, list(iterator)) : false;
- }
-
- /**
- * Add all the elements returned by the specified iterator
- * to the specified list at the specified index.
- * Return whether the list changed as a result.
- * <p>
- * <code>List.addAll(Iterator iterator)</code>
- */
- public static <E> boolean addAll(List<? super E> list, int index, Iterator<? extends E> iterator, int size) {
- return iterator.hasNext() ? list.addAll(index, list(iterator, size)) : false;
- }
-
- /**
- * Add all the elements in the specified array
- * to the specified list at the specified index.
- * Return whether the list changed as a result.
- * <p>
- * <code>List.addAll(Object[] array)</code>
- */
- public static <E> boolean addAll(List<? super E> list, int index, E... array) {
- return (array.length == 0) ? false : list.addAll(index, Arrays.asList(array));
- }
-
-
- // ********** bag **********
-
- /**
- * Return a bag corresponding to the specified enumeration.
- * <p>
- * <code>HashBag(Enumeration enumeration)</code>
- */
- public static <E> HashBag<E> bag(Enumeration<? extends E> enumeration) {
- return bag(enumeration, new HashBag<E>());
- }
-
- /**
- * Return a bag corresponding to the specified enumeration.
- * The specified enumeration size is a performance hint.
- * <p>
- * <code>HashBag(Enumeration enumeration)</code>
- */
- public static <E> HashBag<E> bag(Enumeration<? extends E> enumeration, int enumerationSize) {
- return bag(enumeration, new HashBag<E>(enumerationSize));
- }
-
- private static <E> HashBag<E> bag(Enumeration<? extends E> enumeration, HashBag<E> bag) {
- while (enumeration.hasMoreElements()) {
- bag.add(enumeration.nextElement());
- }
- return bag;
- }
-
- /**
- * Return a bag corresponding to the specified iterable.
- * <p>
- * <code>HashBag(Iterable iterable)</code>
- */
- public static <E> HashBag<E> bag(Iterable<? extends E> iterable) {
- return bag(iterable.iterator());
- }
-
- /**
- * Return a bag corresponding to the specified iterable.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>HashBag(Iterable iterable)</code>
- */
- public static <E> HashBag<E> bag(Iterable<? extends E> iterable, int iterableSize) {
- return bag(iterable.iterator(), iterableSize);
- }
-
- /**
- * Return a bag corresponding to the specified iterator.
- * <p>
- * <code>HashBag(Iterator iterator)</code>
- */
- public static <E> HashBag<E> bag(Iterator<? extends E> iterator) {
- return bag(iterator, new HashBag<E>());
- }
-
- /**
- * Return a bag corresponding to the specified iterator.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>HashBag(Iterator iterator)</code>
- */
- public static <E> HashBag<E> bag(Iterator<? extends E> iterator, int iteratorSize) {
- return bag(iterator, new HashBag<E>(iteratorSize));
- }
-
- private static <E> HashBag<E> bag(Iterator<? extends E> iterator, HashBag<E> bag) {
- while (iterator.hasNext()) {
- bag.add(iterator.next());
- }
- return bag;
- }
-
- /**
- * Return a bag corresponding to the specified array.
- * <p>
- * <code>HashBag(Object[] array)</code>
- */
- public static <E> HashBag<E> bag(E... array) {
- int len = array.length;
- HashBag<E> bag = new HashBag<E>(len);
- for (E item : array) {
- bag.add(item);
- }
- return bag;
- }
-
-
- // ********** collection **********
-
- /**
- * Return a collection corresponding to the specified enumeration.
- */
- public static <E> HashBag<E> collection(Enumeration<? extends E> enumeration) {
- return bag(enumeration);
- }
-
- /**
- * Return a collection corresponding to the specified enumeration.
- * The specified enumeration size is a performance hint.
- */
- public static <E> HashBag<E> collection(Enumeration<? extends E> enumeration, int enumerationSize) {
- return bag(enumeration, enumerationSize);
- }
-
- /**
- * Return a collection corresponding to the specified iterable.
- */
- public static <E> HashBag<E> collection(Iterable<? extends E> iterable) {
- return collection(iterable.iterator());
- }
-
- /**
- * Return a collection corresponding to the specified iterable.
- * The specified iterable size is a performance hint.
- */
- public static <E> HashBag<E> collection(Iterable<? extends E> iterable, int iterableSize) {
- return collection(iterable.iterator(), iterableSize);
- }
-
- /**
- * Return a collection corresponding to the specified iterator.
- */
- public static <E> HashBag<E> collection(Iterator<? extends E> iterator) {
- return bag(iterator);
- }
-
- /**
- * Return a collection corresponding to the specified iterator.
- * The specified iterator size is a performance hint.
- */
- public static <E> HashBag<E> collection(Iterator<? extends E> iterator, int iteratorSize) {
- return bag(iterator, iteratorSize);
- }
-
- /**
- * Return a collection corresponding to the specified array.
- */
- public static <E> HashBag<E> collection(E... array) {
- return bag(array);
- }
-
-
- // ********** contains **********
-
- /**
- * Return whether the specified enumeration contains the
- * specified element.
- * <p>
- * <code>Enumeration.contains(Object o)</code>
- */
- public static boolean contains(Enumeration<?> enumeration, Object value) {
- if (value == null) {
- while (enumeration.hasMoreElements()) {
- if (enumeration.nextElement() == null) {
- return true;
- }
- }
- } else {
- while (enumeration.hasMoreElements()) {
- if (value.equals(enumeration.nextElement())) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified iterable contains the
- * specified element.
- * <p>
- * <code>Iterable.contains(Object o)</code>
- */
- public static boolean contains(Iterable<?> iterable, Object value) {
- return contains(iterable.iterator(), value);
- }
-
- /**
- * Return whether the specified iterator contains the
- * specified element.
- * <p>
- * <code>Iterator.contains(Object o)</code>
- */
- public static boolean contains(Iterator<?> iterator, Object value) {
- if (value == null) {
- while (iterator.hasNext()) {
- if (iterator.next() == null) {
- return true;
- }
- }
- } else {
- while (iterator.hasNext()) {
- if (value.equals(iterator.next())) {
- return true;
- }
- }
- }
- return false;
- }
-
-
- // ********** contains all **********
-
- /**
- * Return whether the specified collection contains all of the
- * elements in the specified iterable.
- * <p>
- * <code>Collection.containsAll(Iterable iterable)</code>
- */
- public static boolean containsAll(Collection<?> collection, Iterable<?> iterable) {
- return containsAll(collection, iterable.iterator());
- }
-
- /**
- * Return whether the specified collection contains all of the
- * elements in the specified iterator.
- * <p>
- * <code>Collection.containsAll(Iterator iterator)</code>
- */
- public static boolean containsAll(Collection<?> collection, Iterator<?> iterator) {
- while (iterator.hasNext()) {
- if ( ! collection.contains(iterator.next())) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified collection contains all of the
- * elements in the specified array.
- * <p>
- * <code>Collection.containsAll(Object[] array)</code>
- */
- public static boolean containsAll(Collection<?> collection, Object... array) {
- for (int i = array.length; i-- > 0; ) {
- if ( ! collection.contains(array[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified collection.
- * <p>
- * <code>Iterable.containsAll(Collection collection)</code>
- */
- public static boolean containsAll(Iterable<?> iterable, Collection<?> collection) {
- return containsAll(iterable.iterator(), collection);
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified collection.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Iterable.containsAll(Collection collection)</code>
- */
- public static boolean containsAll(Iterable<?> iterable, int iterableSize, Collection<?> collection) {
- return containsAll(iterable.iterator(), iterableSize, collection);
- }
-
- /**
- * Return whether the specified iterable 1 contains all of the
- * elements in the specified iterable 2.
- * <p>
- * <code>Iterable.containsAll(Iterable iterable)</code>
- */
- public static boolean containsAll(Iterable<?> iterable1, Iterable<?> iterable2) {
- return containsAll(iterable1.iterator(), iterable2.iterator());
- }
-
- /**
- * Return whether the specified iterable 1 contains all of the
- * elements in the specified iterable 2.
- * The specified iterable 1 size is a performance hint.
- * <p>
- * <code>Iterable.containsAll(Iterable iterable)</code>
- */
- public static boolean containsAll(Iterable<?> iterable1, int iterable1Size, Iterable<?> iterable2) {
- return containsAll(iterable1.iterator(), iterable1Size, iterable2.iterator());
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified iterator.
- * <p>
- * <code>Iterable.containsAll(Iterator iterator)</code>
- */
- public static boolean containsAll(Iterable<?> iterable, Iterator<?> iterator) {
- return containsAll(iterable.iterator(), iterator);
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified iterator.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Iterable.containsAll(Iterator iterator)</code>
- */
- public static boolean containsAll(Iterable<?> iterable, int iterableSize, Iterator<?> iterator) {
- return containsAll(iterable.iterator(), iterableSize, iterator);
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified array.
- * <p>
- * <code>Iterable.containsAll(Object[] array)</code>
- */
- public static boolean containsAll(Iterable<?> iterable, Object... array) {
- return containsAll(iterable.iterator(), array);
- }
-
- /**
- * Return whether the specified iterable contains all of the
- * elements in the specified array.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Iterable.containsAll(Object[] array)</code>
- */
- public static boolean containsAll(Iterable<?> iterable, int iterableSize, Object... array) {
- return containsAll(iterable.iterator(), iterableSize, array);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified collection.
- * <p>
- * <code>Iterator.containsAll(Collection collection)</code>
- */
- public static boolean containsAll(Iterator<?> iterator, Collection<?> collection) {
- return set(iterator).containsAll(collection);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified collection.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Iterator.containsAll(Collection collection)</code>
- */
- public static boolean containsAll(Iterator<?> iterator, int iteratorSize, Collection<?> collection) {
- return set(iterator, iteratorSize).containsAll(collection);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified iterable.
- * <p>
- * <code>Iterator.containsAll(Iterable iterable)</code>
- */
- public static boolean containsAll(Iterator<?> iterator, Iterable<?> iterable) {
- return containsAll(set(iterator), iterable);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified iterable.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Iterator.containsAll(Iterable iterable)</code>
- */
- public static boolean containsAll(Iterator<?> iterator, int iteratorSize, Iterable<?> iterable) {
- return containsAll(set(iterator, iteratorSize), iterable);
- }
-
- /**
- * Return whether the specified iterator 1 contains all of the
- * elements in the specified iterator 2.
- * <p>
- * <code>Iterator.containsAll(Iterator iterator)</code>
- */
- public static boolean containsAll(Iterator<?> iterator1, Iterator<?> iterator2) {
- return containsAll(set(iterator1), iterator2);
- }
-
- /**
- * Return whether the specified iterator 1 contains all of the
- * elements in the specified iterator 2.
- * The specified iterator 1 size is a performance hint.
- * <p>
- * <code>Iterator.containsAll(Iterator iterator)</code>
- */
- public static boolean containsAll(Iterator<?> iterator1, int iterator1Size, Iterator<?> iterator2) {
- return containsAll(set(iterator1, iterator1Size), iterator2);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified array.
- * <p>
- * <code>Iterator.containsAll(Object[] array)</code>
- */
- public static boolean containsAll(Iterator<?> iterator, Object... array) {
- return containsAll(set(iterator), array);
- }
-
- /**
- * Return whether the specified iterator contains all of the
- * elements in the specified array.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Iterator.containsAll(Object[] array)</code>
- */
- public static boolean containsAll(Iterator<?> iterator, int iteratorSize, Object... array) {
- return containsAll(set(iterator, iteratorSize), array);
- }
-
-
- // ********** diff **********
-
- /**
- * Return the index of the first elements in the specified
- * lists that are different, beginning at the end.
- * If the lists are identical, return -1.
- * If the lists are different sizes, return the index of the
- * last element in the longer list.
- * Use the elements' {@link Object#equals(Object)} method to compare the
- * elements.
- * <p>
- * <code>Collections.diffEnd(List list1, List list2)</code>
- */
- public static int diffEnd(List<?> list1, List<?> list2) {
- return ArrayTools.diffEnd(list1.toArray(), list2.toArray());
- }
-
- /**
- * Return the range of elements in the specified
- * arrays that are different.
- * If the arrays are identical, return [size, -1].
- * Use the elements' {@link Object#equals(Object)} method to compare the
- * elements.
- * <p>
- * <code>Collections.diffRange(List list1, List list2)</code>
- * @see #diffStart(List, List)
- * @see #diffEnd(List, List)
- */
- public static Range diffRange(List<?> list1, List<?> list2) {
- return ArrayTools.diffRange(list1.toArray(), list2.toArray());
- }
-
- /**
- * Return the index of the first elements in the specified
- * lists that are different. If the lists are identical, return
- * the size of the two lists (i.e. one past the last index).
- * If the lists are different sizes and all the elements in
- * the shorter list match their corresponding elements in
- * the longer list, return the size of the shorter list
- * (i.e. one past the last index of the shorter list).
- * Use the elements' {@link Object#equals(Object)} method to compare the
- * elements.
- * <p>
- * <code>Collections.diffStart(List list1, List list2)</code>
- */
- public static int diffStart(List<?> list1, List<?> list2) {
- return ArrayTools.diffStart(list1.toArray(), list2.toArray());
- }
-
-
- // ********** identity diff **********
-
- /**
- * Return the index of the first elements in the specified
- * lists that are different, beginning at the end.
- * If the lists are identical, return -1.
- * If the lists are different sizes, return the index of the
- * last element in the longer list.
- * Use object identity to compare the elements.
- * <p>
- * <code>Collections.identityDiffEnd(List list1, List list2)</code>
- */
- public static int identityDiffEnd(List<?> list1, List<?> list2) {
- return ArrayTools.identityDiffEnd(list1.toArray(), list2.toArray());
- }
-
- /**
- * Return the range of elements in the specified
- * arrays that are different.
- * If the arrays are identical, return [size, -1].
- * Use object identity to compare the elements.
- * <p>
- * <code>Collections.identityDiffStart(List list1, List list2)</code>
- * @see #identityDiffStart(List, List)
- * @see #identityDiffEnd(List, List)
- */
- public static Range identityDiffRange(List<?> list1, List<?> list2) {
- return ArrayTools.identityDiffRange(list1.toArray(), list2.toArray());
- }
-
- /**
- * Return the index of the first elements in the specified
- * lists that are different. If the lists are identical, return
- * the size of the two lists (i.e. one past the last index).
- * If the lists are different sizes and all the elements in
- * the shorter list match their corresponding elements in
- * the longer list, return the size of the shorter list
- * (i.e. one past the last index of the shorter list).
- * Use object identity to compare the elements.
- * <p>
- * <code>Collections.identityDiffStart(List list1, List list2)</code>
- */
- public static int identityDiffStart(List<?> list1, List<?> list2) {
- return ArrayTools.identityDiffStart(list1.toArray(), list2.toArray());
- }
-
-
- // ********** elements are equal **********
-
- /**
- * Return whether the specified iterables do not return the same elements
- * in the same order.
- */
- public static boolean elementsAreDifferent(Iterable<?> iterable1, Iterable<?> iterable2) {
- return elementsAreDifferent(iterable1.iterator(), iterable2.iterator());
- }
-
- /**
- * Return whether the specified iterators do not return the same elements
- * in the same order.
- */
- public static boolean elementsAreDifferent(Iterator<?> iterator1, Iterator<?> iterator2) {
- return ! elementsAreEqual(iterator1, iterator2);
- }
-
- /**
- * Return whether the specified iterables return equal elements
- * in the same order.
- * <p>
- * <code>Iterable.elementsAreEqual(Iterable iterable)</code>
- */
- public static boolean elementsAreEqual(Iterable<?> iterable1, Iterable<?> iterable2) {
- return elementsAreEqual(iterable1.iterator(), iterable2.iterator());
- }
-
- /**
- * Return whether the specified iterators return equal elements
- * in the same order.
- * <p>
- * <code>Iterator.elementsAreEqual(Iterator iterator)</code>
- */
- public static boolean elementsAreEqual(Iterator<?> iterator1, Iterator<?> iterator2) {
- while (iterator1.hasNext() && iterator2.hasNext()) {
- if (Tools.valuesAreDifferent(iterator1.next(), iterator2.next())) {
- return false;
- }
- }
- return ! (iterator1.hasNext() || iterator2.hasNext());
- }
-
-
- // ********** elements are identical **********
-
- /**
- * Return whether the specified iterables return the same elements.
- * <p>
- * <code>Iterable.identical(Iterable iterable)</code>
- */
- public static boolean elementsAreIdentical(Iterable<?> iterable1, Iterable<?> iterable2) {
- return elementsAreIdentical(iterable1.iterator(), iterable2.iterator());
- }
-
- /**
- * Return whether the specified iterators return the same elements.
- * <p>
- * <code>Iterator.identical(Iterator iterator)</code>
- */
- public static boolean elementsAreIdentical(Iterator<?> iterator1, Iterator<?> iterator2) {
- while (iterator1.hasNext() && iterator2.hasNext()) {
- if (iterator1.next() != iterator2.next()) {
- return false;
- }
- }
- return ! (iterator1.hasNext() || iterator2.hasNext());
- }
-
- /**
- * Return whether the specified iterables do <em>not</em> return the same
- * elements.
- * <p>
- * <code>Iterable.notIdentical(Iterable iterable)</code>
- */
- public static boolean elementsAreNotIdentical(Iterable<?> iterable1, Iterable<?> iterable2) {
- return elementsAreNotIdentical(iterable1.iterator(), iterable2.iterator());
- }
-
- /**
- * Return whether the specified iterators do <em>not</em> return the same
- * elements.
- * <p>
- * <code>Iterator.notIdentical(Iterator iterator)</code>
- */
- public static boolean elementsAreNotIdentical(Iterator<?> iterator1, Iterator<?> iterator2) {
- return ! elementsAreIdentical(iterator1, iterator2);
- }
-
-
- // ********** get **********
-
- /**
- * Return the element corresponding to the specified index
- * in the specified iterable.
- * <p>
- * <code>Iterable.get(int index)</code>
- */
- public static <E> E get(Iterable<? extends E> iterable, int index) {
- return get(iterable.iterator(), index);
- }
-
- /**
- * Return the element corresponding to the specified index
- * in the specified iterator.
- * <p>
- * <code>Iterator.get(int index)</code>
- */
- public static <E> E get(Iterator<? extends E> iterator, int index) {
- int i = 0;
- while (iterator.hasNext()) {
- E next = iterator.next();
- if (i++ == index) {
- return next;
- }
- }
- throw new IndexOutOfBoundsException(String.valueOf(index) + ':' + String.valueOf(i));
- }
-
-
- // ********** hash code **********
-
- public static int hashCode(Iterable<?> iterable) {
- if (iterable == null) {
- return 0;
- }
- int hash = 1;
- for (Object element : iterable) {
- hash = 31 * hash + (element == null ? 0 : element.hashCode());
- }
- return hash;
- }
-
-
- // ********** index of **********
-
- /**
- * Return the index of the first occurrence of the
- * specified element in the specified iterable;
- * return -1 if there is no such index.
- * <p>
- * <code>Iterable.indexOf(Object o)</code>
- */
- public static int indexOf(Iterable<?> iterable, Object value) {
- return indexOf(iterable.iterator(), value);
- }
-
- /**
- * Return the index of the first occurrence of the
- * specified element in the specified iterator;
- * return -1 if there is no such index.
- * <p>
- * <code>Iterator.indexOf(Object o)</code>
- */
- public static int indexOf(Iterator<?> iterator, Object value) {
- if (value == null) {
- for (int i = 0; iterator.hasNext(); i++) {
- if (iterator.next() == null) {
- return i;
- }
- }
- } else {
- for (int i = 0; iterator.hasNext(); i++) {
- if (value.equals(iterator.next())) {
- return i;
- }
- }
- }
- return -1;
- }
-
-
- // ********** insertion index of **********
-
- /**
- * Return an index of where the specified comparable object
- * can be inserted into the specified sorted list and still keep
- * the list sorted. If the specified sorted list is an instance of
- * {@link RandomAccess} return the <em>maximum</em> insertion index;
- * otherwise return the <em>minimum</em> insertion index.
- */
- public static <E extends Comparable<? super E>> int insertionIndexOf(List<E> sortedList, Comparable<E> value) {
- if (sortedList instanceof RandomAccess) {
- for (int i = sortedList.size(); i-- > 0; ) {
- if (value.compareTo(sortedList.get(i)) >= 0) {
- return i + 1;
- }
- }
- return 0;
- }
- int i = 0;
- for (E element : sortedList) {
- if (value.compareTo(element) <= 0) {
- return i;
- }
- i++;
- }
- return i;
- }
-
- /**
- * Return an index of where the specified comparable object
- * can be inserted into the specified sorted list and still keep
- * the list sorted. If the specified sorted list is an instance of
- * {@link RandomAccess} return the <em>maximum</em> insertion index;
- * otherwise return the <em>minimum</em> insertion index.
- */
- public static <E> int insertionIndexOf(List<E> sortedList, E value, Comparator<? super E> comparator) {
- if (sortedList instanceof RandomAccess) {
- for (int i = sortedList.size(); i-- > 0; ) {
- if (comparator.compare(value, sortedList.get(i)) >= 0) {
- return i + 1;
- }
- }
- return 0;
- }
- int i = 0;
- for (E element : sortedList) {
- if (comparator.compare(value, element) <= 0) {
- return i;
- }
- i++;
- }
- return i;
- }
-
-
- // ********** iterable/iterator **********
-
- /**
- * Return an iterable on the elements in the specified array.
- * <p>
- * <code>Arrays.iterable(Object[] array)</code>
- */
- public static <E> Iterable<E> iterable(E... array) {
- return new ArrayIterable<E>(array);
- }
-
- /**
- * Return an iterator on the elements in the specified array.
- * <p>
- * <code>Arrays.iterator(Object[] array)</code>
- */
- public static <E> Iterator<E> iterator(E... array) {
- return new ArrayIterator<E>(array);
- }
-
-
- // ********** last **********
-
- /**
- * Return the specified iterable's last element.
- * <p>
- * <code>Iterable.last()</code>
- *
- * @exception java.util.NoSuchElementException iterable is empty.
- */
- public static <E> E last(Iterable<E> iterable) {
- return last(iterable.iterator());
- }
-
- /**
- * Return the specified iterator's last element.
- * <p>
- * <code>Iterator.last()</code>
- *
- * @exception java.util.NoSuchElementException iterator is empty.
- */
- public static <E> E last(Iterator<E> iterator) {
- E last;
- do {
- last = iterator.next();
- } while (iterator.hasNext());
- return last;
- }
-
-
- // ********** last index of **********
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified iterable;
- * return -1 if there is no such index.
- * <p>
- * <code>Iterable.lastIndexOf(Object o)
- */
- public static int lastIndexOf(Iterable<?> iterable, Object value) {
- return lastIndexOf(iterable.iterator(), value);
- }
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified iterable;
- * return -1 if there is no such index.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Iterable.lastIndexOf(Object o)
- */
- public static int lastIndexOf(Iterable<?> iterable, int iterableSize, Object value) {
- return lastIndexOf(iterable.iterator(), iterableSize, value);
- }
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified iterator;
- * return -1 if there is no such index.
- * <p>
- * <code>Iterator.lastIndexOf(Object o)
- */
- public static int lastIndexOf(Iterator<?> iterator, Object value) {
- return iterator.hasNext() ? list(iterator).lastIndexOf(value) : -1;
- }
-
- /**
- * Return the index of the last occurrence of the
- * specified element in the specified iterator;
- * return -1 if there is no such index.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Iterator.lastIndexOf(Object o)
- */
- public static int lastIndexOf(Iterator<?> iterator, int iteratorSize, Object value) {
- return iterator.hasNext() ? list(iterator, iteratorSize).lastIndexOf(value) : -1;
- }
-
-
- // ********** list **********
-
- /**
- * Return a list corresponding to the specified iterable.
- * <p>
- * <code>Iterable.toList()</code>
- */
- public static <E> ArrayList<E> list(Iterable<? extends E> iterable) {
- return list(iterable.iterator());
- }
-
- /**
- * Return a list corresponding to the specified iterable.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Iterable.toList()</code>
- */
- public static <E> ArrayList<E> list(Iterable<? extends E> iterable, int iterableSize) {
- return list(iterable.iterator(), iterableSize);
- }
-
- /**
- * Return a list corresponding to the specified iterator.
- * <p>
- * <code>Iterator.toList()</code>
- */
- public static <E> ArrayList<E> list(Iterator<? extends E> iterator) {
- return list(iterator, new ArrayList<E>());
- }
-
- /**
- * Return a list corresponding to the specified iterator.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Iterator.toList()</code>
- */
- public static <E> ArrayList<E> list(Iterator<? extends E> iterator, int iteratorSize) {
- return list(iterator, new ArrayList<E>(iteratorSize));
- }
-
- private static <E> ArrayList<E> list(Iterator<? extends E> iterator, ArrayList<E> list) {
- while (iterator.hasNext()) {
- list.add(iterator.next());
- }
- return list;
- }
-
- /**
- * Return a list corresponding to the specified array.
- * Unlike {@link Arrays#asList(Object[])}, the list
- * is modifiable and is not backed by the array.
- */
- public static <E> ArrayList<E> list(E... array) {
- return new ArrayList<E>(Arrays.asList(array));
- }
-
- /**
- * Return a list iterator for the specified array.
- * <p>
- * <code>Arrays.listIterator(Object[] array)</code>
- */
- public static <E> ListIterator<E> listIterator(E... array) {
- return listIterator(array, 0);
- }
-
- /**
- * Return a list iterator for the specified array
- * starting at the specified position in the array.
- * <p>
- * <code>Arrays.listIterator(Object[] array, int index)</code>
- */
- public static <E> ListIterator<E> listIterator(E[] array, int start) {
- return listIterator(array, start, array.length - start);
- }
-
- /**
- * Return a list iterator for the specified array
- * starting at the specified position in the array.
- * <p>
- * <code>Arrays.listIterator(Object[] array, int index, int length)</code>
- */
- public static <E> ListIterator<E> listIterator(E[] array, int start, int length) {
- return new ArrayListIterator<E>(array, start, length);
- }
-
-
- // ********** move **********
-
- /**
- * Move an element from the specified source index to the specified target
- * index. Return the altered list.
- * <p>
- * <code>List.move(int targetIndex, int sourceIndex)</code>
- */
- public static <E> List<E> move(List<E> list, int targetIndex, int sourceIndex) {
- return (targetIndex == sourceIndex) ? list : move_(list, targetIndex, sourceIndex);
- }
-
- /**
- * assume targetIndex != sourceIndex
- */
- private static <E> List<E> move_(List<E> list, int targetIndex, int sourceIndex) {
- if (list instanceof RandomAccess) {
- // move elements, leaving the list in place
- E temp = list.get(sourceIndex);
- if (targetIndex < sourceIndex) {
- for (int i = sourceIndex; i-- > targetIndex; ) {
- list.set(i + 1, list.get(i));
- }
- } else {
- for (int i = sourceIndex; i < targetIndex; i++) {
- list.set(i, list.get(i + 1));
- }
- }
- list.set(targetIndex, temp);
- } else {
- // remove the element and re-add it at the target index
- list.add(targetIndex, list.remove(sourceIndex));
- }
- return list;
- }
-
- /**
- * Move elements from the specified source index to the specified target
- * index. Return the altered list.
- * <p>
- * <code>List.move(int targetIndex, int sourceIndex, int length)</code>
- */
- public static <E> List<E> move(List<E> list, int targetIndex, int sourceIndex, int length) {
- if ((targetIndex == sourceIndex) || (length == 0)) {
- return list;
- }
- if (length == 1) {
- return move_(list, targetIndex, sourceIndex);
- }
- if (list instanceof RandomAccess) {
- // move elements, leaving the list in place
- ArrayList<E> temp = new ArrayList<E>(list.subList(sourceIndex, sourceIndex + length));
- if (targetIndex < sourceIndex) {
- for (int i = sourceIndex; i-- > targetIndex; ) {
- list.set(i + length, list.get(i));
- }
- } else {
- for (int i = sourceIndex; i < targetIndex; i++) {
- list.set(i, list.get(i + length));
- }
- }
- for (int i = 0; i < length; i++) {
- list.set(targetIndex + i, temp.get(i));
- }
- } else {
- // remove the elements and re-add them at the target index
- list.addAll(targetIndex, removeElementsAtIndex(list, sourceIndex, length));
- }
- return list;
- }
-
-
- // ********** remove all **********
-
- /**
- * Remove all the elements returned by the specified iterable
- * from the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.removeAll(Iterable iterable)</code>
- */
- public static boolean removeAll(Collection<?> collection, Iterable<?> iterable) {
- return removeAll(collection, iterable.iterator());
- }
-
- /**
- * Remove all the elements returned by the specified iterable
- * from the specified collection.
- * Return whether the collection changed as a result.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Collection.removeAll(Iterable iterable)</code>
- */
- public static boolean removeAll(Collection<?> collection, Iterable<?> iterable, int iterableSize) {
- return removeAll(collection, iterable.iterator(), iterableSize);
- }
-
- /**
- * Remove all the elements returned by the specified iterator
- * from the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.removeAll(Iterator iterator)</code>
- */
- public static boolean removeAll(Collection<?> collection, Iterator<?> iterator) {
- return iterator.hasNext() ? collection.removeAll(set(iterator)) : false;
- }
-
- /**
- * Remove all the elements returned by the specified iterator
- * from the specified collection.
- * Return whether the collection changed as a result.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Collection.removeAll(Iterator iterator)</code>
- */
- public static boolean removeAll(Collection<?> collection, Iterator<?> iterator, int iteratorSize) {
- return iterator.hasNext() ? collection.removeAll(set(iterator, iteratorSize)) : false;
- }
-
- /**
- * Remove all the elements in the specified array
- * from the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.removeAll(Object[] array)</code>
- */
- public static boolean removeAll(Collection<?> collection, Object... array) {
- return (array.length == 0) ? false : collection.removeAll(set(array));
- }
-
-
- // ********** remove all occurrences **********
-
- /**
- * Remove all occurrences of the specified element
- * from the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.removeAllOccurrences(Object value)</code>
- */
- public static boolean removeAllOccurrences(Collection<?> collection, Object value) {
- boolean modified = false;
- Iterator<?> stream = collection.iterator();
- if (value == null) {
- while (stream.hasNext()) {
- if (stream.next() == null) {
- stream.remove();
- modified = true;
- }
- }
- } else {
- while (stream.hasNext()) {
- if (value.equals(stream.next())) {
- stream.remove();
- modified = true;
- }
- }
- }
- return modified;
- }
-
-
- // ********** remove elements at index **********
-
- /**
- * Remove the elements at the specified index.
- * Return the removed elements.
- * <p>
- * <code>List.remove(int index, int length)</code>
- */
- public static <E> ArrayList<E> removeElementsAtIndex(List<E> list, int index, int length) {
- List<E> subList = list.subList(index, index + length);
- ArrayList<E> result = new ArrayList<E>(subList);
- subList.clear();
- return result;
- }
-
-
- // ********** remove duplicate elements **********
-
- /**
- * Remove any duplicate elements from the specified list,
- * while maintaining the order.
- * Return whether the list changed as a result.
- */
- public static <E> boolean removeDuplicateElements(List<E> list) {
- int size = list.size();
- if ((size == 0) || (size == 1)) {
- return false;
- }
- return removeDuplicateElements(list, size);
- }
-
- /**
- * assume list is non-empty
- */
- static <E> boolean removeDuplicateElements(List<E> list, int size) {
- LinkedHashSet<E> temp = new LinkedHashSet<E>(size); // take advantage of hashed look-up
- boolean modified = false;
- for (E item : list) {
- if ( ! temp.add(item)) {
- modified = true; // duplicate item
- }
- }
- if (modified) {
- int i = 0;
- for (E e : temp) {
- list.set(i, e);
- i++;
- }
- int tempSize = temp.size();
- for (i = list.size(); i-- > tempSize; ) {
- list.remove(i); // pull off the end
- }
- }
- return modified;
- }
-
-
- // ********** retain all **********
-
- /**
- * Retain only the elements in the specified iterable
- * in the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.retainAll(Iterable iterable)</code>
- */
- public static boolean retainAll(Collection<?> collection, Iterable<?> iterable) {
- return retainAll(collection, iterable.iterator());
- }
-
- /**
- * Retain only the elements in the specified iterable
- * in the specified collection.
- * Return whether the collection changed as a result.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Collection.retainAll(Iterable iterable)</code>
- */
- public static boolean retainAll(Collection<?> collection, Iterable<?> iterable, int iterableSize) {
- return retainAll(collection, iterable.iterator(), iterableSize);
- }
-
- /**
- * Retain only the elements in the specified iterator
- * in the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.retainAll(Iterator iterator)</code>
- */
- public static boolean retainAll(Collection<?> collection, Iterator<?> iterator) {
- if (iterator.hasNext()) {
- return collection.retainAll(set(iterator));
- }
- if (collection.isEmpty()) {
- return false;
- }
- collection.clear();
- return true;
- }
-
- /**
- * Retain only the elements in the specified iterator
- * in the specified collection.
- * Return whether the collection changed as a result.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Collection.retainAll(Iterator iterator)</code>
- */
- public static boolean retainAll(Collection<?> collection, Iterator<?> iterator, int iteratorSize) {
- if (iterator.hasNext()) {
- return collection.retainAll(set(iterator, iteratorSize));
- }
- if (collection.isEmpty()) {
- return false;
- }
- collection.clear();
- return true;
- }
-
- /**
- * Retain only the elements in the specified array
- * in the specified collection.
- * Return whether the collection changed as a result.
- * <p>
- * <code>Collection.retainAll(Object[] array)</code>
- */
- public static boolean retainAll(Collection<?> collection, Object... array) {
- if (array.length > 0) {
- return collection.retainAll(set(array));
- }
- if (collection.isEmpty()) {
- return false;
- }
- collection.clear();
- return true;
- }
-
-
- // ********** reverse list **********
-
- /**
- * Return a list with entries in reverse order from those
- * returned by the specified iterable.
- * <p>
- * <code>Iterable.reverseList()</code>
- */
- public static <E> ArrayList<E> reverseList(Iterable<? extends E> iterable) {
- return reverseList(iterable.iterator());
- }
-
- /**
- * Return a list with entries in reverse order from those
- * returned by the specified iterable.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Iterable.reverseList()</code>
- */
- public static <E> ArrayList<E> reverseList(Iterable<? extends E> iterable, int iterableSize) {
- return reverseList(iterable.iterator(), iterableSize);
- }
-
- /**
- * Return a list with entries in reverse order from those
- * returned by the specified iterator.
- * <p>
- * <code>Iterator.reverseList()</code>
- */
- public static <E> ArrayList<E> reverseList(Iterator<? extends E> iterator) {
- return (ArrayList<E>) reverse(list(iterator));
- }
-
- /**
- * Return a list with entries in reverse order from those
- * returned by the specified iterator.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Iterator.reverseList()</code>
- */
- public static <E> ArrayList<E> reverseList(Iterator<? extends E> iterator, int size) {
- return (ArrayList<E>) reverse(list(iterator, size));
- }
-
-
- // ********** rotate **********
-
- /**
- * Return the list after it has been "rotated" by one position.
- * <p>
- * <code>List.rotate()</code>
- */
- public static <E> List<E> rotate(List<E> list) {
- return rotate(list, 1);
- }
-
-
- // ********** set **********
-
- /**
- * Return a set corresponding to the specified iterable.
- * <p>
- * <code>HashSet(Iterable iterable)</code>
- */
- public static <E> HashSet<E> set(Iterable<? extends E> iterable) {
- return set(iterable.iterator());
- }
-
- /**
- * Return a set corresponding to the specified iterable.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>HashSet(Iterable iterable)</code>
- */
- public static <E> HashSet<E> set(Iterable<? extends E> iterable, int iterableSize) {
- return set(iterable.iterator(), iterableSize);
- }
-
- /**
- * Return a set corresponding to the specified iterator.
- * <p>
- * <code>HashSet(Iterator iterator)</code>
- */
- public static <E> HashSet<E> set(Iterator<? extends E> iterator) {
- return set(iterator, new HashSet<E>());
- }
-
- /**
- * Return a set corresponding to the specified iterator.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>HashSet(Iterator iterator)</code>
- */
- public static <E> HashSet<E> set(Iterator<? extends E> iterator, int iteratorSize) {
- return set(iterator, new HashSet<E>(iteratorSize));
- }
-
- private static <E> HashSet<E> set(Iterator<? extends E> iterator, HashSet<E> set) {
- while (iterator.hasNext()) {
- set.add(iterator.next());
- }
- return set;
- }
-
- /**
- * Return a set corresponding to the specified array.
- * <p>
- * <code>HashSet(Object[] array)</code>
- */
- public static <E> HashSet<E> set(E... array) {
- HashSet<E> set = new HashSet<E>(array.length);
- for (int i = array.length; i-- > 0;) {
- set.add(array[i]);
- }
- return set;
- }
-
-
- // ********** singleton iterator **********
-
- /**
- * Return an iterator that returns only the single,
- * specified object.
- * <p>
- * <code>Object.toIterator()</code>
- */
- public static <E> Iterator<E> singletonIterator(E value) {
- return new SingleElementIterator<E>(value);
- }
-
- /**
- * Return a list iterator that returns only the single,
- * specified object.
- * <p>
- * <code>Object.toListIterator()</code>
- */
- public static <E> ListIterator<E> singletonListIterator(E value) {
- return new SingleElementListIterator<E>(value);
- }
-
-
- // ********** size **********
-
- /**
- * Return the number of elements returned by the specified iterable.
- * <p>
- * <code>Iterable.size()</code>
- */
- public static int size(Iterable<?> iterable) {
- return size(iterable.iterator());
- }
-
- /**
- * Return the number of elements returned by the specified iterator.
- * <p>
- * <code>Iterator.size()</code>
- */
- public static int size(Iterator<?> iterator) {
- int size = 0;
- while (iterator.hasNext()) {
- iterator.next();
- size++;
- }
- return size;
- }
-
- /**
- * Return whether the specified iterable is empty
- * (Shortcuts the iterator rather than calculating the entire size)
- */
- public static boolean isEmpty(Iterable<?> iterable) {
- return isEmpty(iterable.iterator());
- }
-
- /**
- * Return whether the specified iterator is empty
- * (Shortcuts the iterator rather than calculating the entire size)
- */
- public static boolean isEmpty(Iterator<?> iterator) {
- return ! iterator.hasNext();
- }
-
-
- // ********** sort **********
-
- /**
- * Return an iterable containing the sorted elements of the specified iterable.
- * <p>
- * <code>Iterable.sort()</code>
- */
- public static <E extends Comparable<? super E>> Iterable<E> sort(Iterable<E> iterable) {
- return sort(iterable, null);
- }
-
- /**
- * Return an iterable containing the sorted elements of the specified iterable.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Iterable.sort()</code>
- */
- public static <E extends Comparable<? super E>> Iterable<E> sort(Iterable<E> iterable, int iterableSize) {
- return sort(iterable, null, iterableSize);
- }
-
- /**
- * Return an iterable containing the sorted elements of the specified iterable.
- * <p>
- * <code>Iterable.sort(Comparator comparator)</code>
- */
- public static <E> Iterable<E> sort(Iterable<E> iterable, Comparator<? super E> comparator) {
- return sort(list(iterable), comparator);
- }
-
- /**
- * Return an iterable containing the sorted elements of the specified iterable.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>Iterable.sort(Comparator comparator)</code>
- */
- public static <E> Iterable<E> sort(Iterable<E> iterable, Comparator<? super E> comparator, int iterableSize) {
- return sort(list(iterable, iterableSize), comparator);
- }
-
- /**
- * Return the iterator after it has been "sorted".
- * <p>
- * <code>Iterator.sort()</code>
- */
- public static <E extends Comparable<? super E>> ListIterator<E> sort(Iterator<? extends E> iterator) {
- return sort(iterator, null);
- }
-
- /**
- * Return the iterator after it has been "sorted".
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Iterator.sort()</code>
- */
- public static <E extends Comparable<? super E>> ListIterator<E> sort(Iterator<? extends E> iterator, int iteratorSize) {
- return sort(iterator, null, iteratorSize);
- }
-
- /**
- * Return the iterator after it has been "sorted".
- * <p>
- * <code>Iterator.sort(Comparator comparator)</code>
- */
- public static <E> ListIterator<E> sort(Iterator<? extends E> iterator, Comparator<? super E> comparator) {
- return sort(list(iterator), comparator).listIterator();
- }
-
- /**
- * Return the iterator after it has been "sorted".
- * The specified iterator size is a performance hint.
- * <p>
- * <code>Iterator.sort(Comparator comparator)</code>
- */
- public static <E> ListIterator<E> sort(Iterator<? extends E> iterator, Comparator<? super E> comparator, int iteratorSize) {
- return sort(list(iterator, iteratorSize), comparator).listIterator();
- }
-
-
- // ********** sorted set **********
-
- /**
- * Return a sorted set corresponding to the specified iterable.
- * <p>
- * <code>TreeSet(Iterable iterable)</code>
- */
- public static <E extends Comparable<? super E>> TreeSet<E> sortedSet(Iterable<? extends E> iterable) {
- return sortedSet(iterable.iterator());
- }
-
- /**
- * Return a sorted set corresponding to the specified iterable.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>TreeSet(Iterable iterable)</code>
- */
- public static <E extends Comparable<? super E>> TreeSet<E> sortedSet(Iterable<? extends E> iterable, int iterableSize) {
- return sortedSet(iterable.iterator(), iterableSize);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterable
- * and comparator.
- * <p>
- * <code>TreeSet(Iterable iterable, Comparator c)</code>
- */
- public static <E> TreeSet<E> sortedSet(Iterable<? extends E> iterable, Comparator<? super E> comparator) {
- return sortedSet(iterable.iterator(), comparator);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterable
- * and comparator.
- * The specified iterable size is a performance hint.
- * <p>
- * <code>TreeSet(Iterable iterable, Comparator c)</code>
- */
- public static <E> TreeSet<E> sortedSet(Iterable<? extends E> iterable, Comparator<? super E> comparator, int iterableSize) {
- return sortedSet(iterable.iterator(), comparator, iterableSize);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterator.
- * <p>
- * <code>TreeSet(Iterator iterator)</code>
- */
- public static <E extends Comparable<? super E>> TreeSet<E> sortedSet(Iterator<? extends E> iterator) {
- return sortedSet(iterator, null);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterator.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>TreeSet(Iterator iterator)</code>
- */
- public static <E extends Comparable<? super E>> TreeSet<E> sortedSet(Iterator<? extends E> iterator, int iteratorSize) {
- return sortedSet(iterator, null, iteratorSize);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterator
- * and comparator.
- * <p>
- * <code>TreeSet(Iterator iterator, Comparator c)</code>
- */
- public static <E> TreeSet<E> sortedSet(Iterator<? extends E> iterator, Comparator<? super E> comparator) {
- return sortedSet(list(iterator), comparator);
- }
-
- /**
- * Return a sorted set corresponding to the specified iterator
- * and comparator.
- * The specified iterator size is a performance hint.
- * <p>
- * <code>TreeSet(Iterator iterator, Comparator c)</code>
- */
- public static <E> TreeSet<E> sortedSet(Iterator<? extends E> iterator, Comparator<? super E> comparator, int iteratorSize) {
- return sortedSet(list(iterator, iteratorSize), comparator);
- }
-
- private static <E> TreeSet<E> sortedSet(List<E> list, Comparator<? super E> comparator) {
- TreeSet<E> sortedSet = new TreeSet<E>(comparator);
- sortedSet.addAll(list);
- return sortedSet;
- }
-
- /**
- * Return a sorted set corresponding to the specified array.
- * <p>
- * <code>TreeSet(Object[] array)</code>
- */
- public static <E extends Comparable<? super E>> TreeSet<E> sortedSet(E... array) {
- return sortedSet(array, null);
- }
-
- /**
- * Return a sorted set corresponding to the specified array
- * and comparator.
- * <p>
- * <code>TreeSet(Object[] array, Comparator c)</code>
- */
- public static <E> TreeSet<E> sortedSet(E[] array, Comparator<? super E> comparator) {
- TreeSet<E> sortedSet = new TreeSet<E>(comparator);
- sortedSet.addAll(Arrays.asList(array));
- return sortedSet;
- }
-
-
- // ********** Old School Vector **********
-
- /**
- * Return a vector corresponding to the specified iterable.
- * This is useful for legacy code that requires a {@link Vector}.
- * <p>
- * <code>Vector(Iterable iterable)</code>
- */
- public static <E> Vector<E> vector(Iterable<? extends E> iterable) {
- return vector(iterable.iterator());
- }
-
- /**
- * Return a vector corresponding to the specified iterable.
- * This is useful for legacy code that requires a {@link Vector}.
- * <p>
- * <code>Vector(Iterable iterable, int size)</code>
- */
- public static <E> Vector<E> vector(Iterable<? extends E> iterable, int size) {
- return vector(iterable.iterator(), size);
- }
-
- /**
- * Return a vector corresponding to the specified iterator.
- * This is useful for legacy code that requires a {@link Vector}.
- * <p>
- * <code>Vector(Iterator iterator)</code>
- */
- public static <E> Vector<E> vector(Iterator<? extends E> iterator) {
- return vector(iterator, new Vector<E>());
- }
-
- /**
- * Return a vector corresponding to the specified iterator.
- * This is useful for legacy code that requires a {@link Vector}.
- * <p>
- * <code>Vector(Iterator iterator, int size)</code>
- */
- public static <E> Vector<E> vector(Iterator<? extends E> iterator, int size) {
- return vector(iterator, new Vector<E>(size));
- }
-
- private static <E> Vector<E> vector(Iterator<? extends E> iterator, Vector<E> v) {
- while (iterator.hasNext()) {
- v.addElement(iterator.next());
- }
- return v;
- }
-
- /**
- * Return a vector corresponding to the specified array.
- * This is useful for legacy code that requires a {@link Vector}.
- * <p>
- * <code>Vector(Object... array)</code>
- */
- public static <E> Vector<E> vector(E... array) {
- Vector<E> v = new Vector<E>(array.length);
- for (E item : array) {
- v.addElement(item);
- }
- return v;
- }
-
-
- // ********** single-use Iterable **********
-
- /**
- * Return a one-use {@link Iterable} for the specified {@link Iterator}.
- * Throw an {@link IllegalStateException} if {@link Iterable#iterator()}
- * is called more than once.
- * As such, this utility should only be used in one-use situations, such as
- * a foreach loop.
- */
- public static <E> Iterable<E> iterable(Iterator<? extends E> iterator) {
- return new SingleUseIterable<E>(iterator);
- }
-
- /**
- * This is a one-time use iterable that can return a single iterator.
- * Once the iterator is returned the iterable is no longer valid.
- * As such, this utility should only be used in one-time use situations,
- * such as a 'for-each' loop.
- */
- public static class SingleUseIterable<E> implements Iterable<E> {
- private Iterator<E> iterator;
-
- public SingleUseIterable(Iterator<? extends E> iterator) {
- super();
- if (iterator == null) {
- throw new NullPointerException();
- }
- this.iterator = new SuperIteratorWrapper<E>(iterator);
- }
-
- public Iterator<E> iterator() {
- if (this.iterator == null) {
- throw new IllegalStateException("This method has already been called."); //$NON-NLS-1$
- }
- Iterator<E> result = this.iterator;
- this.iterator = null;
- return result;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterator);
- }
-
- }
-
-
- // ********** java.util.Collections enhancements **********
-
- /**
- * Return the destination list after the source list has been copied into it.
- * @see Collections#copy(List, List)
- */
- public static <E> List<E> copy(List<E> dest, List<? extends E> src) {
- Collections.copy(dest, src);
- return dest;
- }
-
- /**
- * Return the list after it has been "filled".
- * @see Collections#fill(List, Object)
- */
- public static <E> List<E> fill(List<E> list, E value) {
- Collections.fill(list, value);
- return list;
- }
-
- /**
- * Return the list after it has been "reversed".
- * @see Collections#reverse(List)
- */
- public static <E> List<E> reverse(List<E> list) {
- Collections.reverse(list);
- return list;
- }
-
- /**
- * Return the list after it has been "rotated".
- * @see Collections#rotate(List, int)
- */
- public static <E> List<E> rotate(List<E> list, int distance) {
- Collections.rotate(list, distance);
- return list;
- }
-
- /**
- * Return the list after it has been "shuffled".
- * @see Collections#shuffle(List)
- */
- public static <E> List<E> shuffle(List<E> list) {
- Collections.shuffle(list);
- return list;
- }
-
- /**
- * Return the list after it has been "shuffled".
- * @see Collections#shuffle(List, Random)
- */
- public static <E> List<E> shuffle(List<E> list, Random random) {
- Collections.shuffle(list, random);
- return list;
- }
-
- /**
- * Return the list after it has been "sorted".
- * NB: The list is sorted in place as a side-effect.
- * @see Collections#sort(List)
- */
- public static <E extends Comparable<? super E>> List<E> sort(List<E> list) {
- Collections.sort(list);
- return list;
- }
-
- /**
- * Return the list after it has been "sorted".
- * NB: The list is sorted in place as a side-effect.
- * @see Collections#sort(List, Comparator)
- */
- public static <E> List<E> sort(List<E> list, Comparator<? super E> comparator) {
- Collections.sort(list, comparator);
- return list;
- }
-
- /**
- * Return the list after the specified elements have been "swapped".
- * @see Collections#swap(List, int, int)
- */
- public static <E> List<E> swap(List<E> list, int i, int j) {
- Collections.swap(list, i, j);
- return list;
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private CollectionTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CompositeException.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CompositeException.java
deleted file mode 100644
index dcb51283cd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/CompositeException.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.util.Collection;
-
-/**
- * Provide a way for multiple exceptions to be packaged and reported.
- */
-public class CompositeException
- extends RuntimeException
-{
- private final Throwable[] exceptions;
- private static final long serialVersionUID = 1L;
-
-
- /**
- * The specified exceptions list must not be empty.
- */
- public CompositeException(Collection<Throwable> exceptions) {
- this(exceptions.toArray(new Throwable[exceptions.size()]));
- }
-
- /**
- * The specified exceptions list must not be empty.
- */
- public CompositeException(Throwable[] exceptions) {
- // provide a list of the nested exceptions and
- // grab the first exception and make it the "cause"
- super(buildMessage(exceptions));
- this.exceptions = exceptions;
- }
-
- public Throwable[] getExceptions() {
- return this.exceptions;
- }
-
- private static String buildMessage(Throwable[] exceptions) {
- StringBuilder sb = new StringBuilder();
- sb.append(exceptions.length);
- sb.append(" exceptions: "); //$NON-NLS-1$
- sb.append('[');
- for (Throwable ex : exceptions) {
- sb.append(ex.getClass().getSimpleName());
- sb.append(", "); //$NON-NLS-1$
- }
- sb.setLength(sb.length() - 2); // chop off trailing comma
- sb.append(']');
- return sb.toString();
- }
-
- @Override
- public void printStackTrace(PrintStream s) {
- synchronized (s) {
- s.println(this);
- for (StackTraceElement element : this.getStackTrace()) {
- s.print("\tat "); //$NON-NLS-1$
- s.println(element);
- }
- int i = 1;
- for (Throwable ex : this.exceptions) {
- s.print("Nested exception "); //$NON-NLS-1$
- s.print(i++);
- s.print(": "); //$NON-NLS-1$
- ex.printStackTrace(s);
- }
- }
- }
-
- @Override
- public void printStackTrace(PrintWriter s) {
- synchronized (s) {
- s.println(this);
- for (StackTraceElement element : this.getStackTrace()) {
- s.print("\tat "); //$NON-NLS-1$
- s.println(element);
- }
- int i = 1;
- for (Throwable ex : this.exceptions) {
- s.print("Nested exception "); //$NON-NLS-1$
- s.print(i++);
- s.print(": "); //$NON-NLS-1$
- ex.printStackTrace(s);
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ConsumerThreadCoordinator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ConsumerThreadCoordinator.java
deleted file mode 100644
index 25dfbf438a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ConsumerThreadCoordinator.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.util.concurrent.ThreadFactory;
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-
-/**
- * A <code>ConsumerThreadCoordinator</code> controls the creation,
- * starting, and stopping of a general purpose "consumer" thread. Construct
- * the coordinator with a {@link Consumer} that both waits for the producer
- * to "produce" something to "consume" and, once the wait is over,
- * "consumes" whatever is available.
- */
-public class ConsumerThreadCoordinator {
- /**
- * The runnable passed to the consumer thread each time it is built.
- */
- private final Runnable runnable;
-
- /**
- * Client-supplied thread factory. Defaults to a straightforward
- * implementation.
- */
- private final ThreadFactory threadFactory;
-
- /**
- * Optional, client-supplied name for the consumer thread.
- * If null, the JDK assigns a name.
- */
- private final String threadName;
-
- /**
- * The consumer is executed on this thread. A new thread is built
- * for every start/stop cycle (since a thread cannot be started more than
- * once).
- */
- private volatile Thread thread;
-
- /**
- * This handles the exceptions thrown by the consumer.
- */
- /* CU private */ final ExceptionHandler exceptionHandler;
-
-
- // ********** construction **********
-
- /**
- * Construct a consumer thread coordinator for the specified consumer.
- * Use simple JDK thread(s) for the consumer thread(s).
- * Allow the consumer thread(s) to be assigned JDK-generated names.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public ConsumerThreadCoordinator(Consumer consumer, ExceptionHandler exceptionHandler) {
- this(consumer, null, exceptionHandler);
- }
-
- /**
- * Construct a consumer thread coordinator for the specified consumer.
- * Assign the consumer thread(s) the specified name.
- * Use simple JDK thread(s) for the consumer thread(s).
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public ConsumerThreadCoordinator(Consumer consumer, String threadName, ExceptionHandler exceptionHandler) {
- this(consumer, SimpleThreadFactory.instance(), threadName, exceptionHandler);
- }
-
- /**
- * Construct a consumer thread coordinator for the specified consumer.
- * Use the specified thread factory to construct the consumer thread(s).
- * Assign the consumer thread(s) the specified name.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public ConsumerThreadCoordinator(Consumer consumer, ThreadFactory threadFactory, String threadName, ExceptionHandler exceptionHandler) {
- super();
- this.runnable = this.buildRunnable(consumer);
- if ((threadFactory == null) || ((exceptionHandler == null))) {
- throw new NullPointerException();
- }
- this.threadFactory = threadFactory;
- this.threadName = threadName;
- this.exceptionHandler = exceptionHandler;
- }
-
- private Runnable buildRunnable(Consumer consumer) {
- return new RunnableConsumer(consumer);
- }
-
-
- // ********** lifecycle support **********
-
- /**
- * Build and start the consumer thread.
- *
- * @exception IllegalStateException if the coordinator has already been started
- */
- public synchronized void start() {
- if (this.thread != null) {
- throw new IllegalStateException("Not stopped."); //$NON-NLS-1$
- }
- this.thread = this.buildThread();
- this.thread.start();
- }
-
- private Thread buildThread() {
- Thread t = this.threadFactory.newThread(this.runnable);
- if (this.threadName != null) {
- t.setName(this.threadName);
- }
- return t;
- }
-
- /**
- * Interrupt the consumer thread so that it stops executing at the
- * end of its current iteration. Suspend the current thread until
- * the consumer thread is finished executing. If any uncaught
- * exceptions were thrown while the consumer thread was executing,
- * wrap them in a composite exception and throw the composite exception.
- *
- * @exception IllegalStateException if the coordinator has not been started
- */
- public synchronized void stop() throws InterruptedException {
- if (this.thread == null) {
- throw new IllegalStateException("Not started."); //$NON-NLS-1$
- }
- this.thread.interrupt();
- this.thread.join();
- this.thread = null;
- }
-
-
- // ********** misc **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.thread);
- }
-
-
- // ********** consumer thread runnable **********
-
- /**
- * This implementation of {@link Runnable} is a long-running consumer that
- * will repeatedly execute the consumer {@link Consumer#consume()} method.
- * With each iteration, the consumer thread will wait
- * until the other consumer method, {@link Consumer#waitForProducer()}, allows the
- * consumer thread to proceed (i.e. there is something for the consumer to
- * consume). Once {@link Consumer#consume()} is finished, the thread will quiesce
- * until {@link Consumer#waitForProducer()} returns again.
- * Stop the thread by calling {@link Thread#interrupt()}.
- */
- private class RunnableConsumer
- implements Runnable
- {
- /**
- * Client-supplied consumer that controls waiting for something to consume
- * and the consuming itself.
- */
- private final Consumer consumer;
-
- RunnableConsumer(Consumer consumer) {
- super();
- if (consumer == null) {
- throw new NullPointerException();
- }
- this.consumer = consumer;
- }
-
- /**
- * Loop while this thread has not been interrupted by another thread.
- * In each loop: Pause execution until {@link Consumer#waitForProducer()}
- * allows us to proceed.
- * <p>
- * If this thread is interrupted <em>during</em> {@link Consumer#consume()},
- * the call to {@link Thread#isInterrupted()} will stop the loop. If this thread is
- * interrupted during the call to {@link Consumer#waitForProducer()},
- * we will catch the {@link InterruptedException} and stop the loop also.
- *
- * @see ConsumerThreadCoordinator#stop()
- */
- public void run() {
- while ( ! Thread.currentThread().isInterrupted()) {
- try {
- this.consumer.waitForProducer();
- } catch (InterruptedException ex) {
- // we were interrupted while waiting, must be Quittin' Time
- Thread.currentThread().interrupt(); // set the Thread's interrupt status
- return;
- } catch (RuntimeException ex) {
- ConsumerThreadCoordinator.this.exceptionHandler.handleException(ex);
- return; // hmmm... kill the thread?
- }
- this.consume();
- }
- }
-
- /**
- * Delegate to the consumer {@link Consumer#consume()} method.
- * Do not allow any unhandled exceptions to kill the thread.
- * Pass them to the exception handler.
- * @see ConsumerThreadCoordinator#stop()
- */
- private void consume() {
- try {
- this.consumer.consume();
- } catch (RuntimeException ex) {
- ConsumerThreadCoordinator.this.exceptionHandler.handleException(ex);
- }
- }
- }
-
-
- // ********** consumer interface **********
-
- /**
- * Interface implemented by clients that controls:<ul>
- * <li>when the consumer thread suspends, waiting for something to consume
- * <li>the consuming of whatever is being produced
- * </ul>
- */
- public interface Consumer {
- /**
- * Wait for something to consume.
- * Throw an {@link InterruptedException} if the thread is interrupted.
- */
- void waitForProducer() throws InterruptedException;
-
- /**
- * Consume whatever is currently available.
- */
- void consume();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FileTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FileTools.java
deleted file mode 100644
index cfe93a64b7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FileTools.java
+++ /dev/null
@@ -1,1002 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.channels.FileChannel;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-
-/**
- * Assorted file tools:
- * - delete entire trees of directories and files
- * - build iterators on entire trees of directories and files
- * - build a temporary directory
- * - "canonize" files
- */
-public final class FileTools {
-
- public static final String USER_HOME_DIRECTORY_NAME = System.getProperty("user.home"); //$NON-NLS-1$
- public static final String USER_TEMPORARY_DIRECTORY_NAME = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
- public static String DEFAULT_TEMPORARY_DIRECTORY_NAME = "tmpdir"; //$NON-NLS-1$
- public static final String CURRENT_WORKING_DIRECTORY_NAME = System.getProperty("user.dir"); //$NON-NLS-1$
-
- /** A list of some invalid file name characters.
- : is the filename separator in MacOS and the drive indicator in DOS
- * is a DOS wildcard character
- | is a DOS redirection character
- & is our own escape character
- / is the filename separator in Unix and the command option tag in DOS
- \ is the filename separator in DOS/Windows and the escape character in Unix
- ; is ???
- ? is a DOS wildcard character
- [ is ???
- ] is ???
- = is ???
- + is ???
- < is a DOS redirection character
- > is a DOS redirection character
- " is used by DOS to delimit file names with spaces
- , is ???
- */
- public static final char[] INVALID_FILENAME_CHARACTERS = { ':', '*', '|', '&', '/', '\\', ';', '?', '[', ']', '=', '+', '<', '>', '"', ',' };
-
- /** This encoder will convert strings into valid file names. */
- public static final XMLStringEncoder FILE_NAME_ENCODER = new XMLStringEncoder(INVALID_FILENAME_CHARACTERS);
-
- /** Windows files that are redirected to devices etc. */
- @SuppressWarnings("nls")
- private static final String[] WINDOWS_RESERVED_FILE_NAMES = {
- "con",
- "aux",
- "com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8", "com9",
- "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9",
- "prn",
- "nul"
- };
-
- /** The default length of a shortened file name. */
- public static final int MAXIMUM_SHORTENED_FILE_NAME_LENGTH = 60;
-
-
- // ********** deleting directories **********
-
- /**
- * Delete the specified directory and all of its contents.
- * <em>USE WITH CARE.</em>
- * File#deleteAll()?
- */
- public static void deleteDirectory(String directoryName) {
- deleteDirectory(new File(directoryName));
- }
-
- /**
- * Delete the specified directory and all of its contents.
- * <em>USE WITH CARE.</em>
- * File#deleteAll()?
- */
- public static void deleteDirectory(File directory) {
- deleteDirectoryContents(directory);
- if ( ! directory.delete()) {
- throw new RuntimeException("unable to delete directory: " + directory.getAbsolutePath()); //$NON-NLS-1$
- }
- }
-
- /**
- * Delete the contents of the specified directory
- * (but not the directory itself).
- * <em>USE WITH CARE.</em>
- * File#deleteFiles()
- */
- public static void deleteDirectoryContents(String directoryName) {
- deleteDirectoryContents(new File(directoryName));
- }
-
- /**
- * Delete the contents of the specified directory
- * (but not the directory itself).
- * <em>USE WITH CARE.</em>
- * File#deleteFiles()
- */
- public static void deleteDirectoryContents(File directory) {
- for (File file : directory.listFiles()) {
- if (file.isDirectory()) {
- deleteDirectory(file); // recurse through subdirectories
- } else {
- if ( ! file.delete()) {
- throw new RuntimeException("unable to delete file: " + file.getAbsolutePath()); //$NON-NLS-1$
- }
- }
- }
- }
-
-
- // ********** copying files **********
-
- /**
- * Copies the content of the source file to the destination file.
- * File#copy(File destinationFile)
- */
- public static void copyToFile(File sourceFile, File destinationFile)
- throws IOException
- {
- FileChannel sourceChannel = new FileInputStream(sourceFile).getChannel();
- FileChannel destinationChannel = new FileOutputStream(destinationFile).getChannel();
- try {
- destinationChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
- } finally {
- sourceChannel.close();
- destinationChannel.close();
- }
- }
-
- /**
- * Copies the content of the source file to a file by
- * the same name in the destination directory.
- * File#copyToDirectory(File destinationDirectory)
- */
- public static void copyToDirectory(File sourceFile, File destinationDirectory)
- throws IOException
- {
- File destinationFile = new File(destinationDirectory, sourceFile.getName());
- if ( ! destinationFile.exists() && ! destinationFile.createNewFile()) {
- throw new RuntimeException("createNewFile() failed: " + destinationFile); //$NON-NLS-1$
- }
- copyToFile(sourceFile, destinationFile);
- }
-
-
- // ********** iteratoring over files and directories **********
-
- /**
- * Return an iterator on all the files in the specified directory.
- * The iterator will skip over subdirectories.
- * File#files()
- */
- public static Iterator<File> filesIn(String directoryName) {
- return filesIn(new File(directoryName));
- }
-
- /**
- * Return an iterator on all the files in the specified directory.
- * The iterator will skip over subdirectories.
- * File#files()
- */
- public static Iterator<File> filesIn(File directory) {
- return filesIn(directory.listFiles());
- }
-
- private static Iterator<File> filesIn(File[] files) {
- return new FilteringIterator<File>(new ArrayIterator<File>(files)) {
- @Override
- protected boolean accept(File next) {
- return next.isFile();
- }
- };
- }
-
- /**
- * Return an iterator on all the subdirectories
- * in the specified directory.
- * File#subDirectories()
- */
- public static Iterator<File> directoriesIn(String directoryName) {
- return directoriesIn(new File(directoryName));
- }
-
- /**
- * Return an iterator on all the subdirectories
- * in the specified directory.
- * File#subDirectories()
- */
- public static Iterator<File> directoriesIn(File directory) {
- return directoriesIn(directory.listFiles());
- }
-
- private static Iterator<File> directoriesIn(File[] files) {
- return new FilteringIterator<File>(new ArrayIterator<File>(files)) {
- @Override
- protected boolean accept(File next) {
- return next.isDirectory();
- }
- };
- }
-
- /**
- * Return an iterator on all the files under the specified
- * directory, recursing into subdirectories.
- * The iterator will skip over the subdirectories themselves.
- * File#filesRecurse()
- */
- public static Iterator<File> filesInTree(String directoryName) {
- return filesInTree(new File(directoryName));
- }
-
- /**
- * Return an iterator on all the files under the specified
- * directory, recursing into subdirectories.
- * The iterator will skip over the subdirectories themselves.
- * File#filesRecurse()
- */
- public static Iterator<File> filesInTree(File directory) {
- return filesInTreeAsSet(directory).iterator();
- }
-
- private static Set<File> filesInTreeAsSet(File directory) {
- Set<File> files = new HashSet<File>(10000);
- addFilesInTreeTo(directory, files);
- return files;
- }
-
- private static void addFilesInTreeTo(File directory, Collection<File> allFiles) {
- for (File file : directory.listFiles()) {
- if (file.isFile()) {
- allFiles.add(file);
- } else if (file.isDirectory()) {
- addFilesInTreeTo(file, allFiles);
- }
- }
- }
-
- /**
- * Return an iterator on all the directories under the specified
- * directory, recursing into subdirectories.
- * File#subDirectoriesRecurse()
- */
- public static Iterator<File> directoriesInTree(String directoryName) {
- return directoriesInTree(new File(directoryName));
- }
-
- /**
- * Return an iterator on all the directories under the specified
- * directory, recursing into subdirectories.
- * File#subDirectoriesRecurse()
- */
- @SuppressWarnings("unchecked")
- public static Iterator<File> directoriesInTree(File directory) {
- File[] files = directory.listFiles();
- return new CompositeIterator<File>(directoriesIn(files), directoriesInTrees(directoriesIn(files)));
- }
-
- private static Iterator<File> directoriesInTrees(Iterator<File> directories) {
- return new CompositeIterator<File>(
- new TransformationIterator<File, Iterator<File>>(directories) {
- @Override
- protected Iterator<File> transform(File next) {
- return FileTools.directoriesInTree(next);
- }
- }
- );
- }
-
-
- // ********** short file name manipulation **********
-
- /**
- * Strip the extension from the specified file name
- * and return the result. If the file name has no
- * extension, it is returned unchanged
- * File#basePath()
- */
- public static String stripExtension(String fileName) {
- int index = fileName.lastIndexOf('.');
- if (index == -1) {
- return fileName;
- }
- return fileName.substring(0, index);
- }
-
- /**
- * Strip the extension from the specified file's name
- * and return the result. If the file's name has no
- * extension, it is returned unchanged
- * File#basePath()
- */
- public static String stripExtension(File file) {
- return stripExtension(file.getPath());
- }
-
- /**
- * Return the extension, including the dot, of the specified file name.
- * If the file name has no extension, return an empty string.
- * File#extension()
- */
- public static String extension(String fileName) {
- int index = fileName.lastIndexOf('.');
- if (index == -1) {
- return ""; //$NON-NLS-1$
- }
- return fileName.substring(index);
- }
-
- /**
- * Return the extension, including the dot, of the specified file's name.
- * If the file's name has no extension, return an empty string.
- * File#extension()
- */
- public static String extension(File file) {
- return extension(file.getPath());
- }
-
-
- // ********** temporary directories **********
-
- /**
- * Build and return an empty temporary directory with the specified
- * name. If the directory already exists, it will be cleared out.
- * This directory will be a subdirectory of the Java temporary directory,
- * as indicated by the System property "java.io.tmpdir".
- */
- public static File emptyTemporaryDirectory(String name) {
- File dir = new File(userTemporaryDirectory(), name);
- if (dir.exists()) {
- deleteDirectoryContents(dir);
- } else {
- mkdirs(dir);
- }
- return dir;
- }
-
- private static void mkdirs(File dir) {
- if ( ! dir.mkdirs()) {
- throw new RuntimeException("mkdirs() failed: " + dir); //$NON-NLS-1$
- }
- }
-
- /**
- * Build and return an empty temporary directory with a
- * name of "tmpdir". If the directory already exists, it will be cleared out.
- * This directory will be a subdirectory of the Java temporary directory,
- * as indicated by the System property "java.io.tmpdir".
- */
- public static File emptyTemporaryDirectory() {
- return emptyTemporaryDirectory(DEFAULT_TEMPORARY_DIRECTORY_NAME);
- }
-
- /**
- * Build and return a temporary directory with the specified
- * name. If the directory already exists, it will be left unchanged;
- * if it does not already exist, it will be created.
- * This directory will be a subdirectory of the Java temporary directory,
- * as indicated by the System property "java.io.tmpdir".
- */
- public static File temporaryDirectory(String name) {
- File dir = new File(userTemporaryDirectory(), name);
- if ( ! dir.exists()) {
- mkdirs(dir);
- }
- return dir;
- }
-
- /**
- * Build and return a temporary directory with a name of
- * "tmpdir". If the directory already exists, it will be left unchanged;
- * if it does not already exist, it will be created.
- * This directory will be a subdirectory of the Java temporary directory,
- * as indicated by the System property "java.io.tmpdir".
- */
- public static File temporaryDirectory() {
- return temporaryDirectory(DEFAULT_TEMPORARY_DIRECTORY_NAME);
- }
-
- /**
- * Build and return a *new* temporary directory with the specified
- * prefix. The prefix will be appended with a number that
- * is incremented, starting with 1, until a non-pre-existing directory
- * is found and successfully created. This directory will be a
- * subdirectory of the Java temporary directory, as indicated by
- * the System property "java.io.tmpdir".
- */
- public static File newTemporaryDirectory(String prefix) {
- if ( ! prefix.endsWith(".")) { //$NON-NLS-1$
- prefix = prefix + '.';
- }
- File dir;
- int i = 0;
- do {
- i++;
- dir = new File(userTemporaryDirectory(), prefix + i);
- } while ( ! dir.mkdirs());
- return dir;
- }
-
- /**
- * Build and return a *new* temporary directory with a
- * prefix of "tmpdir". This prefix will be appended with a number that
- * is incremented, starting with 1, until a non-pre-existing directory
- * is found and successfully created. This directory will be a
- * subdirectory of the Java temporary directory, as indicated by
- * the System property "java.io.tmpdir".
- */
- public static File newTemporaryDirectory() {
- return newTemporaryDirectory(DEFAULT_TEMPORARY_DIRECTORY_NAME);
- }
-
-
- // ********** resource files **********
-
- /**
- * Build and return a file for the specified resource.
- * The resource name must be fully-qualified, i.e. it cannot be relative
- * to the package name/directory.
- * NB: There is a bug in jdk1.4.x the prevents us from getting
- * a resource that has spaces (or other special characters) in
- * its name.... (see Sun's Java bug 4466485)
- */
- public static File resourceFile(String resourceName) throws URISyntaxException {
- if ( ! resourceName.startsWith("/")) { //$NON-NLS-1$
- throw new IllegalArgumentException(resourceName);
- }
- return resourceFile(resourceName, FileTools.class);
- }
-
- /**
- * Build and return a file for the specified resource.
- * NB: There is a bug in jdk1.4.x the prevents us from getting
- * a resource that has spaces (or other special characters) in
- * its name.... (see Sun's Java bug 4466485)
- */
- public static File resourceFile(String resourceName, Class<?> javaClass) throws URISyntaxException {
- URL url = javaClass.getResource(resourceName);
- return buildFile(url);
- }
-
- /**
- * Build and return a file for the specified URL.
- * NB: There is a bug in jdk1.4.x the prevents us from getting
- * a resource that has spaces (or other special characters) in
- * its name.... (see Sun's Java bug 4466485)
- */
- public static File buildFile(URL url) throws URISyntaxException {
- return buildFile(url.getFile());
- }
-
- /**
- * Build and return a file for the specified file name.
- * NB: There is a bug in jdk1.4.x the prevents us from getting
- * a resource that has spaces (or other special characters) in
- * its name.... (see Sun's Java bug 4466485)
- */
- public static File buildFile(String fileName) throws URISyntaxException {
- URI uri = new URI(fileName);
- File file = new File(uri.getPath());
- return file;
- }
-
-
- // ********** "canonical" files **********
-
- /**
- * Convert the specified file into a "canonical" file.
- */
- public static File canonicalFile(File file) {
- try {
- return file.getCanonicalFile();
- } catch (IOException ioexception) {
- // settle for the absolute file
- return file.getAbsoluteFile();
- }
- }
-
- /**
- * Build an iterator that will convert the specified files
- * into "canonical" files.
- */
- public static Iterator<File> canonicalFiles(Iterator<File> files) {
- return new TransformationIterator<File, File>(files) {
- @Override
- protected File transform(File next) {
- return canonicalFile(next);
- }
- };
- }
-
- /**
- * Build an iterator that will convert the specified files
- * into "canonical" files.
- */
- public static Iterator<File> canonicalFiles(Collection<File> files) {
- return canonicalFiles(files.iterator());
- }
-
- /**
- * Convert the specified file name into a "canonical" file name.
- */
- public static String canonicalFileName(String fileName) {
- return canonicalFile(new File(fileName)).getAbsolutePath();
- }
-
- /**
- * Build an iterator that will convert the specified file names
- * into "canonical" file names.
- */
- public static Iterator<String> canonicalFileNames(Iterator<String> fileNames) {
- return new TransformationIterator<String, String>(fileNames) {
- @Override
- protected String transform(String next) {
- return canonicalFileName(next);
- }
- };
- }
-
- /**
- * Build an iterator that will convert the specified file names
- * into "canonical" file names.
- */
- public static Iterator<String> canonicalFileNames(Collection<String> fileNames) {
- return canonicalFileNames(fileNames.iterator());
- }
-
-
- // ********** file name validation **********
-
- /**
- * Return whether the specified file name is invalid.
- */
- public static boolean fileNameIsInvalid(String filename) {
- return ! fileNameIsValid(filename);
- }
-
- /**
- * Return whether the specified file name is valid.
- */
- public static boolean fileNameIsValid(String filename) {
- int len = filename.length();
- for (int i = 0; i < len; i++) {
- char filenameChar = filename.charAt(i);
- if (ArrayTools.contains(INVALID_FILENAME_CHARACTERS, filenameChar)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Convert the illegal characters in the specified file name to
- * the specified character and return the result.
- */
- public static String convertToValidFileName(String filename, char replacementChar) {
- int len = filename.length();
- StringBuilder sb = new StringBuilder(len);
- for (int i = 0; i < len; i++) {
- char filenameChar = filename.charAt(i);
- if (ArrayTools.contains(INVALID_FILENAME_CHARACTERS, filenameChar)) {
- sb.append(replacementChar);
- } else {
- sb.append(filenameChar);
- }
- }
- return sb.toString();
- }
-
- /**
- * Convert the illegal characters in the specified file name to
- * periods ('.') and return the result.
- */
- public static String convertToValidFileName(String filename) {
- return convertToValidFileName(filename, '.');
- }
-
- /**
- * Return whether the specified file name is "reserved"
- * (i.e. it cannot be used for "user" files). Windows reserves
- * a number of file names (e.g. CON, AUX, PRN).
- */
- public static boolean fileNameIsReserved(String fileName) {
- // Unix/Linux does not have any "reserved" file names (I think...)
- return Tools.osIsWindows() && ArrayTools.contains(WINDOWS_RESERVED_FILE_NAMES, fileName.toLowerCase());
- }
-
- /**
- * Return whether the specified file contains any "reserved"
- * components.
- * Windows reserves a number of file names (e.g. CON, AUX, PRN);
- * and these file names cannot be used for either the names of
- * files or directories.
- */
- public static boolean fileHasAnyReservedComponents(File file) {
- File temp = file;
- while (temp != null) {
- if (fileNameIsReserved(temp.getName())) {
- return true;
- }
- temp = temp.getParentFile();
- }
- return false;
- }
-
-
- // ********** shortened file names **********
-
- /**
- * Return a shorter version of the absolute file name for the specified file.
- * The shorter version will not be longer than the maximum length.
- * The first directory (usually the drive letter) and the file name or the
- * last directory will always be added to the generated string regardless of
- * the maximum length allowed.
- */
- public static String shortenFileName(URL url) {
- return shortenFileName(url, MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- /**
- * Return a shorter version of the absolute file name for the specified file.
- * The shorter version will not be longer than the maximum length.
- * The first directory (usually the drive letter) and the file name or the
- * last directory will always be added to the generated string regardless of
- * the maximum length allowed.
- */
- public static String shortenFileName(URL url, int maxLength) {
- File file;
- try {
- file = buildFile(url);
- } catch (URISyntaxException e) {
- file = new File(url.getFile());
- }
- return shortenFileName(file, maxLength);
- }
-
- /**
- * Return a shorter version of the absolute file name for the specified file.
- * The shorter version will not be longer than the maximum length.
- * The first directory (usually the drive letter) and the file name or the
- * last directory will always be added to the generated string regardless of
- * the maximum length allowed.
- */
- public static String shortenFileName(File file) {
- return shortenFileName(file, MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- /**
- * Return a shorter version of the absolute file name for the specified file.
- * The shorter version will not be longer than the maximum length.
- * The first directory (usually the drive letter) and the file name or the
- * last directory will always be added to the generated string regardless of
- * the maximum length allowed.
- */
- public static String shortenFileName(File file, int maxLength) {
- String absoluteFileName = canonicalFile(file).getAbsolutePath();
- if (absoluteFileName.length() <= maxLength) {
- // no need to shorten
- return absoluteFileName;
- }
-
- // break down the path into its components
- String fs = File.separator;
- String[] paths = absoluteFileName.split('\\' + fs);
-
- if (paths.length <= 1) {
- // e.g. "C:\"
- return paths[0];
- }
-
- if (paths.length == 2) {
- // e.g. "C:\MyReallyLongFileName.ext" or "C:\MyReallyLongDirectoryName"
- // return the complete file name since this is a minimum requirement,
- // regardless of the maximum length allowed
- return absoluteFileName;
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append(paths[0]); // always add the first directory, which is usually the drive letter
-
- // Keep the index of insertion into the string buffer
- int insertIndex = sb.length();
-
- sb.append(fs);
- sb.append(paths[paths.length - 1]); // append the file name or the last directory
-
- maxLength -= 4; // -4 for "/..."
-
- int currentLength = sb.length() - 4; // -4 for "/..."
- int leftIndex = 1; // 1 to skip the root directory
- int rightIndex = paths.length - 2; // -1 for the file name or the last directory
-
- boolean canAddFromLeft = true;
- boolean canAddFromRight = true;
-
- // Add each directory, the insertion is going in both direction: left and
- // right, once a side can't be added, the other side is still continuing
- // until both can't add anymore
- while (true) {
- if (!canAddFromLeft && !canAddFromRight)
- break;
-
- if (canAddFromRight) {
- String rightDirectory = paths[rightIndex];
- int rightLength = rightDirectory.length();
-
- // Add the directory on the right side of the loop
- if (currentLength + rightLength + 1 <= maxLength) {
- sb.insert(insertIndex, fs);
- sb.insert(insertIndex + 1, rightDirectory);
-
- currentLength += rightLength + 1;
- rightIndex--;
-
- // The right side is now overlapping the left side, that means
- // we can't add from the right side anymore
- if (leftIndex >= rightIndex) {
- canAddFromRight = false;
- }
- } else {
- canAddFromRight = false;
- }
- }
-
- if (canAddFromLeft) {
- String leftDirectory = paths[leftIndex];
- int leftLength = leftDirectory.length();
-
- // Add the directory on the left side of the loop
- if (currentLength + leftLength + 1 <= maxLength) {
- sb.insert(insertIndex, fs);
- sb.insert(insertIndex + 1, leftDirectory);
-
- insertIndex += leftLength + 1;
- currentLength += leftLength + 1;
- leftIndex++;
-
- // The left side is now overlapping the right side, that means
- // we can't add from the left side anymore
- if (leftIndex >= rightIndex) {
- canAddFromLeft = false;
- }
- } else {
- canAddFromLeft = false;
- }
- }
- }
-
- if (leftIndex <= rightIndex) {
- sb.insert(insertIndex, fs);
- sb.insert(insertIndex + 1, "..."); //$NON-NLS-1$
- }
-
- return sb.toString();
- }
-
-
- // ********** system properties **********
-
- /**
- * Return a file representing the user's home directory.
- */
- public static File userHomeDirectory() {
- return new File(USER_HOME_DIRECTORY_NAME);
- }
-
- /**
- * Return a file representing the user's temporary directory.
- */
- public static File userTemporaryDirectory() {
- return new File(USER_TEMPORARY_DIRECTORY_NAME);
- }
-
- /**
- * Return a file representing the current working directory.
- */
- public static File currentWorkingDirectory() {
- return new File(CURRENT_WORKING_DIRECTORY_NAME);
- }
-
-
- // ********** miscellaneous **********
-
- /**
- * Return only the files that fit the filter.
- * File#files(FileFilter fileFilter)
- */
- public static Iterator<File> filter(Iterator<File> files, final FileFilter fileFilter) {
- return new FilteringIterator<File>(files) {
- @Override
- protected boolean accept(File next) {
- return fileFilter.accept(next);
- }
- };
- }
-
- /**
- * Return a file that is a re-specification of the specified
- * file, relative to the specified directory.
- * Linux/Unix/Mac:
- * convertToRelativeFile(/foo/bar/baz.java, /foo)
- * => bar/baz.java
- * Windows:
- * convertToRelativeFile(C:\foo\bar\baz.java, C:\foo)
- * => bar/baz.java
- * The file can be either a file or a directory; the directory
- * *should* be a directory.
- * If the file is already relative or it cannot be made relative
- * to the directory, it will be returned unchanged.
- *
- * NB: This method has been tested on Windows and Linux,
- * but not Mac (but the Mac is Unix-based these days, so
- * it shouldn't be a problem...).
- */
- public static File convertToRelativeFile(final File file, final File dir) {
- // check whether the file is already relative
- if ( ! file.isAbsolute()) {
- return file; // return unchanged
- }
-
- File cFile = canonicalFile(file);
- File cDir = canonicalFile(dir);
-
- // the two are the same directory
- if (cFile.equals(cDir)) {
- return new File("."); //$NON-NLS-1$
- }
-
- File[] filePathFiles = pathFiles(cFile);
- File[] dirPathFiles = pathFiles(cDir);
-
- // Windows only (?): the roots are different - e.g. D:\ vs. C:\
- if ( ! dirPathFiles[0].equals(filePathFiles[0])) {
- return file; // return unchanged
- }
-
- // at this point we know the root is the same, now find how much is in common
- int i = 0; // this will point at the first miscompare
- while ((i < dirPathFiles.length) && (i < filePathFiles.length)) {
- if (dirPathFiles[i].equals(filePathFiles[i])) {
- i++;
- } else {
- break;
- }
- }
- // save our current position
- int firstMismatch = i;
-
- // check whether the file is ABOVE the directory: ../..
- if (firstMismatch == filePathFiles.length) {
- return relativeParentFile(dirPathFiles.length - firstMismatch);
- }
-
- // build a new file from the path beyond the matching portions
- File diff = new File(filePathFiles[i].getName());
- while (++i < filePathFiles.length) {
- diff = new File(diff, filePathFiles[i].getName());
- }
-
- // check whether the file is BELOW the directory: subdir1/subdir2/file.ext
- if (firstMismatch == dirPathFiles.length) {
- return diff;
- }
-
- // the file must be a PEER of the directory: ../../subdir1/subdir2/file.ext
- return new File(relativeParentFile(dirPathFiles.length - firstMismatch), diff.getPath());
- }
-
- /**
- * Return a file that is a re-specification of the specified
- * file, relative to the current working directory.
- * Linux/Unix/Mac (CWD = /foo):
- * convertToRelativeFile(/foo/bar/baz.java)
- * => bar/baz.java
- * Windows (CWD = C:\foo):
- * convertToRelativeFile(C:\foo\bar\baz.java)
- * => bar/baz.java
- * The file can be either a file or a directory.
- * If the file is already relative or it cannot be made relative
- * to the directory, it will be returned unchanged.
- *
- * NB: This method has been tested on Windows and Linux,
- * but not Mac (but the Mac is Unix-based these days, so
- * it shouldn't be a problem...).
- */
- public static File convertToRelativeFile(final File file) {
- return convertToRelativeFile(file, currentWorkingDirectory());
- }
-
- /**
- * Return an array of files representing the path to the specified
- * file. For example:
- * C:/foo/bar/baz.txt =>
- * { C:/, C:/foo, C:/foo/bar, C:/foo/bar/baz.txt }
- */
- private static File[] pathFiles(File file) {
- List<File> path = new ArrayList<File>();
- for (File f = file; f != null; f = f.getParentFile()) {
- path.add(f);
- }
- Collections.reverse(path);
- return path.toArray(new File[path.size()]);
- }
-
- /**
- * Return a file with the specified (non-zero) number of relative
- * file names, e.g. xxx(3) => ../../..
- */
- private static File relativeParentFile(int len) {
- if (len <= 0) {
- throw new IllegalArgumentException("length must be greater than zero: " + len); //$NON-NLS-1$
- }
- File result = new File(".."); //$NON-NLS-1$
- for (int i = len - 1; i-- > 0; ) {
- result = new File(result, ".."); //$NON-NLS-1$
- }
- return result;
- }
-
- /**
- * Return a file that is a re-specification of the specified
- * file, absolute to the specified directory.
- * Linux/Unix/Mac:
- * convertToAbsoluteFile(bar/baz.java, /foo)
- * => /foo/bar/baz.java
- * Windows:
- * convertToAbsoluteFile(bar/baz.java, C:\foo)
- * => C:\foo\bar\baz.java
- * The file can be either a file or a directory; the directory
- * *should* be a directory.
- * If the file is already absolute, it will be returned unchanged.
- *
- * NB: This method has been tested on Windows and Linux,
- * but not Mac (but the Mac is Unix-based these days, so
- * it shouldn't be a problem...).
- */
- public static File convertToAbsoluteFile(final File file, final File dir) {
- // check whether the file is already absolute
- if (file.isAbsolute()) {
- return file; // return unchanged
- }
- return canonicalFile(new File(dir, file.getPath()));
- }
-
- /**
- * Return a file that is a re-specification of the specified
- * file, absolute to the current working directory.
- * Linux/Unix/Mac (CWD = /foo):
- * convertToAbsoluteFile(bar/baz.java)
- * => /foo/bar/baz.java
- * Windows (CWD = C:\foo):
- * convertToAbsoluteFile(bar/baz.java)
- * => C:\foo\bar\baz.java
- * The file can be either a file or a directory.
- * If the file is already absolute, it will be returned unchanged.
- *
- * NB: This method has been tested on Windows and Linux,
- * but not Mac (but the Mac is Unix-based these days, so
- * it shouldn't be a problem...).
- */
- public static File convertToAbsoluteFile(final File file) {
- return convertToAbsoluteFile(file, currentWorkingDirectory());
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private FileTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FilterAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FilterAdapter.java
deleted file mode 100644
index 204515d5ca..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FilterAdapter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import org.eclipse.jpt.common.utility.Filter;
-
-/**
- * Convenience filter implementation that accepts everything.
- *
- * @see org.eclipse.jpt.common.utility.Filter.Transparent
- */
-public class FilterAdapter<T>
- implements Filter<T>
-{
- public boolean accept(T o) {
- return true;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FlaggedObjectReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FlaggedObjectReference.java
deleted file mode 100644
index 84d06c6552..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/FlaggedObjectReference.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Provide a container for passing an object that can be changed by the
- * recipient. If the value is set at any time after construction of the
- * reference, the reference is marked "set". This allows the client to
- * detect whether the server/recipient ever set the value, even if it remains
- * unchanged. This is particularly useful when the value can be set to
- * <code>null</code>.
- * <p>
- * The reference can be set multiple times, but it can
- * never be "unset" once it is "set".
- */
-public class FlaggedObjectReference<V>
- extends SimpleObjectReference<V>
-{
- private volatile boolean set = false;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Create an object reference with the specified initial value.
- */
- public FlaggedObjectReference(V value) {
- super(value);
- }
-
- /**
- * Create an object reference with an initial value of
- * <code>null</code>.
- */
- public FlaggedObjectReference() {
- super();
- }
-
-
- // ********** set **********
-
- public boolean isSet() {
- return this.set;
- }
-
-
- // ********** overrides **********
-
- @Override
- public V setValue(V value) {
- this.set = true;
- return super.setValue(value);
- }
-
- @Override
- public String toString() {
- String s = super.toString();
- return (this.set) ? '*' + s : s;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/HashBag.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/HashBag.java
deleted file mode 100644
index 36892ba597..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/HashBag.java
+++ /dev/null
@@ -1,882 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.AbstractCollection;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * This class implements the {@link Bag} interface, backed by a
- * hash table. It makes no guarantees as to the iteration order of
- * the bag's elements; in particular, it does not guarantee the order
- * will remain constant over time. This class permits the <code>null</code>
- * element.
- * <p>
- * This class offers constant time performance for the basic operations
- * (<code>add</code>, <code>remove</code>, <code>contains</code> and
- * <code>size</code>), assuming the hash function disperses the elements
- * properly among the buckets. Iterating over this bag requires time
- * proportional to the sum of the bag's size (the number of elements) plus the
- * "capacity" of the backing hash table (the number of buckets). Thus, it is
- * important not to set the initial capacity too high (or the load factor too
- * low) if iteration performance is important.
- * <p>
- * <strong>Note that this implementation is not synchronized.</strong> If multiple
- * threads access a bag concurrently, and at least one of the threads modifies
- * the bag, it <em>must</em> be synchronized externally. This is typically
- * accomplished by synchronizing on some object that naturally encapsulates
- * the bag. If no such object exists, the bag should be "wrapped" using the
- * <code>Collections.synchronizedCollection</code> method. This is
- * best done at creation time, to prevent accidental unsynchronized access
- * to the bag:
- * <pre>
- * Collection c = Collections.synchronizedCollection(new HashBag(...));
- * </pre>
- * <p>
- * The iterators returned by this class's <code>iterator</code> method are
- * <em>fail-fast</em>: if the bag is modified at any time after the iterator is
- * created, in any way except through the iterator's own <code>remove</code>
- * method, the iterator throws a {@link ConcurrentModificationException}.
- * Thus, in the face of concurrent modification, the iterator fails quickly
- * and cleanly, rather than risking arbitrary, non-deterministic behavior at
- * an undetermined time in the future.
- * <p>
- * Note that the fail-fast behavior of an iterator cannot be guaranteed
- * as it is, generally speaking, impossible to make any hard guarantees in the
- * presence of unsynchronized concurrent modification. Fail-fast iterators
- * throw <code>ConcurrentModificationException</code> on a best-effort basis.
- * Therefore, it would be wrong to write a program that depended on this
- * exception for its correctness: <em>the fail-fast behavior of iterators
- * should be used only to detect bugs.</em>
- *
- * @param <E> the type of elements maintained by the bag
- *
- * @see Collection
- * @see Bag
- * @see SynchronizedBag
- * @see java.util.Collections#synchronizedCollection(Collection)
- * @see IdentityHashBag
- */
-public class HashBag<E>
- extends AbstractCollection<E>
- implements Bag<E>, Cloneable, Serializable
-{
- /** The hash table. Resized as necessary. Length MUST Always be a power of two. */
- transient Entry<E>[] table;
-
- /** The total number of entries in the bag. */
- transient int size = 0;
-
- /** The number of UNIQUE entries in the bag. */
- transient int uniqueCount = 0;
-
- /**
- * The hash table is rehashed when its size exceeds this threshold. (The
- * value of this field is <code>(int) (capacity * loadFactor)</code>.)
- *
- * @serial size threshold
- */
- private int threshold;
-
- /**
- * The load factor for the hash table.
- *
- * @serial load factor
- */
- private final float loadFactor;
-
- /**
- * The number of times this bag has been structurally modified.
- * Structural modifications are those that change the number of entries in
- * the bag or otherwise modify its internal structure (e.g. rehash).
- * This field is used to make iterators on this bag fail-fast.
- *
- * @see java.util.ConcurrentModificationException
- */
- transient int modCount = 0;
-
- /**
- * The default initial capacity - MUST be a power of two.
- */
- private static final int DEFAULT_INITIAL_CAPACITY = 16;
-
- /**
- * The maximum capacity, used if a higher value is implicitly specified
- * by either of the constructors with arguments.
- * MUST be a power of two <= (1 << 30).
- */
- private static final int MAXIMUM_CAPACITY = 1 << 30;
-
- /**
- * The load factor used when none specified in constructor.
- */
- private static final float DEFAULT_LOAD_FACTOR = 0.75f;
-
- /**
- * Construct a new, empty bag with the
- * default capacity, which is 16, and load factor, which is 0.75.
- */
- public HashBag() {
- this(DEFAULT_INITIAL_CAPACITY);
- }
-
- /**
- * Construct a new, empty bag with the specified initial capacity
- * and the default load factor, which is 0.75.
- *
- * @param initialCapacity the initial capacity
- * @exception IllegalArgumentException if the initial capacity is less
- * than zero
- */
- public HashBag(int initialCapacity) {
- this(initialCapacity, DEFAULT_LOAD_FACTOR, false); // false = do not validate parms
- }
-
- /**
- * Construct a new, empty bag with
- * the specified initial capacity and load factor.
- *
- * @param initialCapacity the initial capacity
- * @param loadFactor the load factor
- * @exception IllegalArgumentException if the initial capacity is less
- * than zero or if the load factor is non-positive
- */
- public HashBag(int initialCapacity, float loadFactor) {
- this(initialCapacity, loadFactor, true); // true = validate parms
- }
-
- private HashBag(int initialCapacity, float loadFactor, boolean validateParms) {
- super();
- int capacity = initialCapacity;
- if (validateParms) {
- if (capacity < 0) {
- throw new IllegalArgumentException("Illegal Initial Capacity: " + capacity); //$NON-NLS-1$
- }
- if (capacity > MAXIMUM_CAPACITY) {
- capacity = MAXIMUM_CAPACITY;
- }
- if (loadFactor <= 0 || Float.isNaN(loadFactor)) {
- throw new IllegalArgumentException("Illegal Load factor: " + loadFactor); //$NON-NLS-1$
- }
-
- // find a power of 2 >= 'initialCapacity'
- capacity = 1;
- while (capacity < initialCapacity) {
- capacity <<= 1;
- }
- }
-
- this.loadFactor = loadFactor;
- this.table = this.buildTable(capacity);
- this.threshold = (int) (capacity * loadFactor);
- }
-
- /**
- * Construct a new bag containing the elements in the specified
- * collection. The bag's load factor will be the default, which is 0.75,
- * and its initial capacity will be sufficient to hold all the elements in
- * the specified collection.
- *
- * @param c the collection whose elements are to be placed into this bag.
- */
- public HashBag(Collection<? extends E> c) {
- this(Math.max((int) (c.size() / DEFAULT_LOAD_FACTOR) + 1, DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR);
- this.addAll_(c);
- }
-
- /**
- * Return a hash for the specified object.
- */
- private int hash(Object o) {
- return (o == null) ? 0 : this.tweakHash(o.hashCode());
- }
-
- /**
- * Tweak the specified hash, to defend against poor implementations
- * of {@link Object#hashCode()}.
- */
- private int tweakHash(int h) {
- h ^= (h >>> 20) ^ (h >>> 12);
- return h ^ (h >>> 7) ^ (h >>> 4);
- }
-
- /**
- * Return the index for the specified hash.
- */
- private int index(int hash) {
- return this.index(hash, this.table.length);
- }
-
- /**
- * Return the index for the specified hash
- * within a table with the specified length.
- */
- int index(int hash, int length) {
- return hash & (length - 1);
- }
-
- /**
- * Internal {@link #addAll(Collection)} for construction and cloning.
- * (No check for re-hash; no change to mod count; no return value.)
- */
- private void addAll_(Iterable<? extends E> c) {
- for (E e : c) {
- this.add_(e);
- }
- }
-
- /**
- * Internal {@link #add(Object)} for construction and cloning.
- * (No check for re-hash; no change to mod count; no return value.)
- */
- private void add_(E o) {
- this.add_(o, 1);
- }
-
- /**
- * Internal {@link #add(Object, int)} for construction, cloning, and serialization.
- * (No check for re-hash; no change to mod count; no return value.)
- */
- private void add_(E o, int cnt) {
- int hash = this.hash(o);
- int index = this.index(hash);
- for (Entry<E> e = this.table[index]; e != null; e = e.next) {
- Object eo;
- if ((e.hash == hash) && (((eo = e.object) == o) || ((o != null) && o.equals(eo)))) {
- e.count += cnt;
- this.size += cnt;
- return;
- }
- }
-
- // create the new entry and put it in the table
- Entry<E> e = this.buildEntry(hash, o, cnt, this.table[index]);
- this.table[index] = e;
- this.size += cnt;
- this.uniqueCount++;
- }
-
- /**
- * This implementation simply returns the maintained size.
- */
- @Override
- public int size() {
- return this.size;
- }
-
- /**
- * This implementation simply compares the maintained size to zero.
- */
- @Override
- public boolean isEmpty() {
- return this.size == 0;
- }
-
- /**
- * Search for the object's entry in the hash table by calculating
- * the object's hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- private Entry<E> getEntry(Object o) {
- int hash = this.hash(o);
- for (Entry<E> e = this.table[this.index(hash)]; e != null; e = e.next) {
- Object eo;
- if ((e.hash == hash) && (((eo = e.object) == o) || ((o != null) && o.equals(eo)))) {
- return e;
- }
- }
- return null;
- }
-
- @Override
- public boolean contains(Object o) {
- return this.getEntry(o) != null;
- }
-
- public int count(Object o) {
- Entry<E> e = this.getEntry(o);
- return (e == null) ? 0 : e.count;
- }
-
- /**
- * Rehash the contents of the bag into a new hash table
- * with a larger capacity. This method is called when the
- * number of different elements in the bag exceeds its
- * capacity and load factor.
- */
- private void rehash() {
- Entry<E>[] oldTable = this.table;
- int oldCapacity = oldTable.length;
-
- if (oldCapacity == MAXIMUM_CAPACITY) {
- this.threshold = Integer.MAX_VALUE;
- return;
- }
-
- int newCapacity = 2 * oldCapacity;
- Entry<E>[] newTable = this.buildTable(newCapacity);
-
- for (int i = oldCapacity; i-- > 0; ) {
- for (Entry<E> old = oldTable[i]; old != null; ) {
- Entry<E> e = old;
- old = old.next;
-
- int index = this.index(e.hash, newCapacity);
- e.next = newTable[index];
- newTable[index] = e;
- }
- }
-
- this.table = newTable;
- this.threshold = (int) (newCapacity * this.loadFactor);
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private Entry<E>[] buildTable(int capacity) {
- return new Entry[capacity];
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- @Override
- public boolean add(E o) {
- return this.add(o, 1);
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- public boolean add(E o, int cnt) {
- if (cnt <= 0) {
- return false;
- }
- this.modCount++;
- int hash = this.hash(o);
- int index = this.index(hash);
-
- // if the object is already in the bag, simply bump its count
- for (Entry<E> e = this.table[index]; e != null; e = e.next) {
- Object eo;
- if ((e.hash == hash) && (((eo = e.object) == o) || ((o != null) && o.equals(eo)))) {
- e.count += cnt;
- this.size += cnt;
- return true;
- }
- }
-
- // rehash the table if we are going to exceed the threshold
- if (this.uniqueCount >= this.threshold) {
- this.rehash();
- index = this.index(hash); // need to re-calculate the index
- }
-
- // create the new entry and put it in the table
- Entry<E> e = this.buildEntry(hash, o, cnt, this.table[index]);
- this.table[index] = e;
- this.size += cnt;
- this.uniqueCount++;
- return true;
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings({ "rawtypes", "unchecked" } )
- private Entry<E> buildEntry(int hash, Object o, int cnt, Entry next) {
- return new Entry<E>(hash, (E) o, cnt, (Entry<E>) next);
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- @Override
- public boolean remove(Object o) {
- return this.remove(o, 1);
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- public boolean remove(Object o, int cnt) {
- if (cnt <= 0) {
- return false;
- }
- int hash = this.hash(o);
- int index = this.index(hash);
-
- for (Entry<E> e = this.table[index], prev = null; e != null; prev = e, e = e.next) {
- Object eo;
- if ((e.hash == hash) && (((eo = e.object) == o) || ((o != null) && o.equals(eo)))) {
- this.modCount++;
- cnt = (cnt < e.count) ? cnt : e.count;
- e.count -= cnt;
- // if we are removing the last element(s), remove the entry from the table
- if (e.count == 0) {
- if (prev == null) {
- this.table[index] = e.next;
- } else {
- prev.next = e.next;
- }
- this.uniqueCount--;
- }
- this.size -= cnt;
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * This implementation simply clears out all of the hash table buckets.
- */
- @Override
- public void clear() {
- Entry<E>[] tab = this.table;
- this.modCount++;
- for (int i = tab.length; i-- > 0; ) {
- tab[i] = null;
- }
- this.size = 0;
- this.uniqueCount = 0;
- }
-
- /**
- * Returns a shallow copy of this bag: the elements
- * themselves are not cloned.
- *
- * @return a shallow copy of this bag.
- */
- @Override
- public HashBag<E> clone() {
- try {
- @SuppressWarnings("unchecked")
- HashBag<E> clone = (HashBag<E>) super.clone();
- clone.table = this.buildTable(this.table.length);
- clone.size = 0;
- clone.uniqueCount = 0;
- clone.modCount = 0;
- clone.addAll_(this);
- return clone;
- } catch (CloneNotSupportedException e) {
- throw new InternalError();
- }
- }
-
-
- /**
- * Hash table collision list entry.
- */
- private static class Entry<E>
- implements Bag.Entry<E>
- {
- final int hash;
- final E object;
- int count;
- Entry<E> next;
-
- Entry(int hash, E object, int count, Entry<E> next) {
- this.hash = hash;
- this.object = object;
- this.count = count;
- this.next = next;
- }
-
- // ***** Bag.Entry implementation
- public E getElement() {
- return this.object;
- }
-
- public int getCount() {
- return this.count;
- }
-
- public int setCount(int count) {
- if (count <= 0) {
- throw new IllegalArgumentException("count must be greater than zero: " + count); //$NON-NLS-1$
- }
- int old = this.count;
- this.count = count;
- return old;
- }
-
- @Override
- public boolean equals(Object o) {
- if ( ! (o instanceof Bag.Entry<?>)) {
- return false;
- }
- @SuppressWarnings("rawtypes")
- Bag.Entry e = (Bag.Entry) o;
- return (this.count == e.getCount()) &&
- Tools.valuesAreEqual(this.object, e.getElement());
- }
-
- @Override
- public int hashCode() {
- E o = this.object;
- return (o == null) ? 0 : (this.count * o.hashCode());
- }
-
- @Override
- public String toString() {
- return this.object + "=>" + this.count; //$NON-NLS-1$
- }
- }
-
-
- @Override
- @SuppressWarnings("unchecked")
- public Iterator<E> iterator() {
- return (this.size == 0) ? EMPTY_ITERATOR : new HashIterator();
- }
-
- @SuppressWarnings("unchecked")
- public Iterator<E> uniqueIterator() {
- return (this.size == 0) ? EMPTY_ITERATOR : new UniqueIterator();
- }
-
- public int uniqueCount() {
- return this.uniqueCount;
- }
-
- @SuppressWarnings("unchecked")
- public Iterator<Bag.Entry<E>> entries() {
- return (this.size == 0) ? EMPTY_ITERATOR : new EntryIterator();
- }
-
-
- /**
- * Empty iterator that does just about nothing.
- */
- @SuppressWarnings("rawtypes")
- private static final Iterator EMPTY_ITERATOR = new EmptyIterator();
-
- @SuppressWarnings("rawtypes")
- private static class EmptyIterator
- implements Iterator
- {
- EmptyIterator() {
- super();
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public Object next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new IllegalStateException();
- }
- }
-
-
- private class HashIterator
- implements Iterator<E>
- {
- private int index = HashBag.this.table.length; // start at the end of the table
- private Entry<E> nextEntry = null;
- private int nextEntryCount = 0;
- private Entry<E> lastReturnedEntry = null;
-
- /**
- * The modCount value that the iterator believes that the backing
- * bag should have. If this expectation is violated, the iterator
- * has detected a concurrent modification.
- */
- private int expectedModCount = HashBag.this.modCount;
-
- HashIterator() {
- super();
- }
-
- public boolean hasNext() {
- Entry<E> e = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = HashBag.this.table;
- // Use locals for faster loop iteration
- while ((e == null) && (i > 0)) {
- e = tab[--i]; // move backwards through the table
- }
- this.nextEntry = e;
- this.index = i;
- return e != null;
- }
-
- public E next() {
- if (HashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E> et = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = HashBag.this.table;
- // Use locals for faster loop iteration
- while ((et == null) && (i > 0)) {
- et = tab[--i]; // move backwards through the table
- }
- this.nextEntry = et;
- this.index = i;
- if (et == null) {
- throw new NoSuchElementException();
- }
- Entry<E> e = this.lastReturnedEntry = this.nextEntry;
- this.nextEntryCount++;
- if (this.nextEntryCount == e.count) {
- this.nextEntry = e.next;
- this.nextEntryCount = 0;
- }
- return e.object;
- }
-
- public void remove() {
- if (this.lastReturnedEntry == null) {
- throw new IllegalStateException();
- }
- if (HashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- int slot = HashBag.this.index(this.lastReturnedEntry.hash, HashBag.this.table.length);
- for (Entry<E> e = HashBag.this.table[slot], prev = null; e != null; prev = e, e = e.next) {
- if (e == this.lastReturnedEntry) {
- HashBag.this.modCount++;
- this.expectedModCount++;
- e.count--;
- if (e.count == 0) {
- // if we are removing the last one, remove the entry from the table
- if (prev == null) {
- HashBag.this.table[slot] = e.next;
- } else {
- prev.next = e.next;
- }
- HashBag.this.uniqueCount--;
- } else {
- // slide back the count to account for the just-removed element
- this.nextEntryCount--;
- }
- HashBag.this.size--;
- this.lastReturnedEntry = null; // it cannot be removed again
- return;
- }
- }
- throw new ConcurrentModificationException();
- }
- }
-
-
- private class EntryIterator
- implements Iterator<Entry<E>>
- {
- private int index = HashBag.this.table.length; // start at the end of the table
- private Entry<E> nextEntry = null;
- private Entry<E> lastReturnedEntry = null;
-
- /**
- * The modCount value that the iterator believes that the backing
- * bag should have. If this expectation is violated, the iterator
- * has detected a concurrent modification.
- */
- private int expectedModCount = HashBag.this.modCount;
-
- EntryIterator() {
- super();
- }
-
- public boolean hasNext() {
- Entry<E> e = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = HashBag.this.table;
- // Use locals for faster loop iteration
- while ((e == null) && (i > 0)) {
- e = tab[--i]; // move backwards through the table
- }
- this.nextEntry = e;
- this.index = i;
- return e != null;
- }
-
- public Entry<E> next() {
- if (HashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E> et = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = HashBag.this.table;
- // Use locals for faster loop iteration
- while ((et == null) && (i > 0)) {
- et = tab[--i]; // move backwards through the table
- }
- this.nextEntry = et;
- this.index = i;
- if (et == null) {
- throw new NoSuchElementException();
- }
- Entry<E> e = this.lastReturnedEntry = this.nextEntry;
- this.nextEntry = e.next;
- return e;
- }
-
- public void remove() {
- if (this.lastReturnedEntry == null) {
- throw new IllegalStateException();
- }
- if (HashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- int slot = HashBag.this.index(this.lastReturnedEntry.hash, HashBag.this.table.length);
- for (Entry<E> e = HashBag.this.table[slot], prev = null; e != null; prev = e, e = e.next) {
- if (e == this.lastReturnedEntry) {
- HashBag.this.modCount++;
- this.expectedModCount++;
- // remove the entry from the table
- if (prev == null) {
- HashBag.this.table[slot] = e.next;
- } else {
- prev.next = e.next;
- }
- HashBag.this.uniqueCount--;
- HashBag.this.size -= this.lastReturnedEntry.count;
- this.lastReturnedEntry = null; // it cannot be removed again
- return;
- }
- }
- throw new ConcurrentModificationException();
- }
- }
-
-
- private class UniqueIterator
- implements Iterator<E>
- {
- private EntryIterator entryIterator = new EntryIterator();
-
- UniqueIterator() {
- super();
- }
-
- public boolean hasNext() {
- return this.entryIterator.hasNext();
- }
-
- public E next() {
- return this.entryIterator.next().object;
- }
-
- public void remove() {
- this.entryIterator.remove();
- }
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if ( ! (o instanceof Bag<?>)) {
- return false;
- }
- @SuppressWarnings("unchecked")
- Bag<E> b = (Bag<E>) o;
- if (b.size() != this.size()) {
- return false;
- }
- if (b.uniqueCount() != this.uniqueCount()) {
- return false;
- }
- for (Iterator<Bag.Entry<E>> stream = b.entries(); stream.hasNext(); ) {
- Bag.Entry<E> entry = stream.next();
- if (entry.getCount() != this.count(entry.getElement())) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- int h = 0;
- for (E o : this) {
- if (o != null) {
- h += o.hashCode();
- }
- }
- return h;
- }
-
- /**
- * Save the state of this bag to a stream (i.e. serialize it).
- *
- * @serialData Emit the capacity of the bag (int),
- * followed by the number of unique elements in the bag (int),
- * followed by all of the bag's elements (each an Object) and
- * their counts (each an int), in no particular order.
- */
- private void writeObject(java.io.ObjectOutputStream s)
- throws java.io.IOException {
- // write out the threshold, load factor, and any hidden stuff
- s.defaultWriteObject();
-
- // write out number of buckets
- s.writeInt(this.table.length);
-
- // write out number of unique elements
- s.writeInt(this.uniqueCount);
-
- // write out elements and counts (alternating)
- if (this.uniqueCount > 0) {
- for (Entry<E> entry : this.table) {
- while (entry != null) {
- s.writeObject(entry.object);
- s.writeInt(entry.count);
- entry = entry.next;
- }
- }
- }
- }
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Reconstitute the bag from a stream (i.e. deserialize it).
- */
- private void readObject(java.io.ObjectInputStream s)
- throws java.io.IOException, ClassNotFoundException {
- // read in the threshold, loadfactor, and any hidden stuff
- s.defaultReadObject();
-
- // read in number of buckets and allocate the bucket array
- this.table = this.buildTable(s.readInt());
-
- // read in number of unique elements
- int unique = s.readInt();
-
- // read the elements and counts, and put the elements in the bag
- for (int i = 0; i < unique; i++) {
- @SuppressWarnings("unchecked")
- E element = (E) s.readObject();
- int elementCount = s.readInt();
- this.add_(element, elementCount);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/IdentityHashBag.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/IdentityHashBag.java
deleted file mode 100644
index b00a55c3c9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/IdentityHashBag.java
+++ /dev/null
@@ -1,924 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.AbstractCollection;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * This class implements the {@link Bag} interface with a
- * hash table, using object-identity in place of object-equality when
- * comparing elements. In other words, in an <code>IdentityHashBag</code>,
- * two objects <code>o1</code> and <code>o2</code> are considered
- * equal if and only if <code>(o1 == o2)</code>. (In normal {@link Bag}
- * implementations (like {@link HashBag}) two objects <code>o1</code>
- * and <code>o2</code> are considered equal if and only if
- * <code>(o1 == null ? o2 == null : o1.equals(o2))</code>.)
- * <p>
- * <strong>
- * This class is <em>not</em> a general-purpose {@link Bag}
- * implementation! While this class implements the {@link Bag} interface, it
- * intentionally violates {@link Bag}'s general contract, which mandates the
- * use of the <code>equals</code> method when comparing objects. This class is
- * designed for use only in the rare cases wherein object-identity
- * semantics are required.
- * </strong>
- * <p>
- * This class makes no guarantees as to the iteration order of
- * the bag's elements; in particular, it does not guarantee that the order
- * will remain constant over time. This class permits the <code>null</code>
- * element.
- * <p>
- * This class offers constant time performance for the basic operations
- * (<code>add</code>, <code>remove</code>, <code>contains</code> and
- * <code>size</code>), assuming the system identity hash function
- * ({@link System#identityHashCode(Object)}) disperses elements properly
- * among the buckets. Iterating over this bag requires time
- * proportional to the sum of the bag's size (the number of elements) plus the
- * "capacity" of the backing hash table (the number of buckets). Thus, it is
- * important not to set the initial capacity too high (or the load factor too
- * low) if iteration performance is important.
- * <p>
- * <strong>Note that this implementation is not synchronized.</strong> If multiple
- * threads access a bag concurrently, and at least one of the threads modifies
- * the bag, it <em>must</em> be synchronized externally. This is typically
- * accomplished by synchronizing on some object that naturally encapsulates
- * the bag. If no such object exists, the bag should be "wrapped" using the
- * <code>Collections.synchronizedCollection</code> method. This is
- * best done at creation time, to prevent accidental unsynchronized access
- * to the bag:
- * <pre>
- * Collection c = Collections.synchronizedCollection(new IdentityHashBag(...));
- * </pre>
- * <p>
- * The iterators returned by this class's <code>iterator</code> method are
- * <em>fail-fast</em>: if the bag is modified at any time after the iterator is
- * created, in any way except through the iterator's own <code>remove</code>
- * method, the iterator throws a {@link ConcurrentModificationException}.
- * Thus, in the face of concurrent modification, the iterator fails quickly
- * and cleanly, rather than risking arbitrary, non-deterministic behavior at
- * an undetermined time in the future.
- * <p>
- * Note that the fail-fast behavior of an iterator cannot be guaranteed
- * as it is, generally speaking, impossible to make any hard guarantees in the
- * presence of unsynchronized concurrent modification. Fail-fast iterators
- * throw <code>ConcurrentModificationException</code> on a best-effort basis.
- * Therefore, it would be wrong to write a program that depended on this
- * exception for its correctness: <em>the fail-fast behavior of iterators
- * should be used only to detect bugs.</em>
- *
- * @param <E> the type of elements maintained by the bag
- *
- * @see Collection
- * @see Bag
- * @see SynchronizedBag
- * @see java.util.Collections#synchronizedCollection(Collection)
- * @see HashBag
- */
-public class IdentityHashBag<E>
- extends AbstractCollection<E>
- implements Bag<E>, Cloneable, Serializable
-{
- /** The hash table. Resized as necessary. Length MUST Always be a power of two. */
- transient Entry<E>[] table;
-
- /** The total number of entries in the bag. */
- transient int size = 0;
-
- /** The number of UNIQUE entries in the bag. */
- transient int uniqueCount = 0;
-
- /**
- * The hash table is rehashed when its size exceeds this threshold. (The
- * value of this field is <code>(int) (capacity * loadFactor)</code>.)
- *
- * @serial size threshold
- */
- private int threshold;
-
- /**
- * The load factor for the hash table.
- *
- * @serial load factor
- */
- private final float loadFactor;
-
- /**
- * The number of times this bag has been structurally modified.
- * Structural modifications are those that change the number of entries in
- * the bag or otherwise modify its internal structure (e.g. rehash).
- * This field is used to make iterators on this bag fail-fast.
- *
- * @see java.util.ConcurrentModificationException
- */
- transient int modCount = 0;
-
- /**
- * The default initial capacity - MUST be a power of two.
- */
- private static final int DEFAULT_INITIAL_CAPACITY = 16;
-
- /**
- * The maximum capacity, used if a higher value is implicitly specified
- * by either of the constructors with arguments.
- * MUST be a power of two <= (1 << 30).
- */
- private static final int MAXIMUM_CAPACITY = 1 << 30;
-
- /**
- * The load factor used when none specified in constructor.
- */
- private static final float DEFAULT_LOAD_FACTOR = 0.75f;
-
- /**
- * Construct a new, empty bag with the
- * default capacity, which is 16, and load factor, which is 0.75.
- */
- public IdentityHashBag() {
- this(DEFAULT_INITIAL_CAPACITY);
- }
-
- /**
- * Construct a new, empty bag with the specified initial capacity
- * and the default load factor, which is 0.75.
- *
- * @param initialCapacity the initial capacity
- * @throws IllegalArgumentException if the initial capacity is less
- * than zero
- */
- public IdentityHashBag(int initialCapacity) {
- this(initialCapacity, DEFAULT_LOAD_FACTOR, false); // false = do not validate parms
- }
-
- /**
- * Construct a new, empty bag with
- * the specified initial capacity and load factor.
- *
- * @param initialCapacity the initial capacity
- * @param loadFactor the load factor
- * @throws IllegalArgumentException if the initial capacity is less
- * than zero or if the load factor is non-positive
- */
- public IdentityHashBag(int initialCapacity, float loadFactor) {
- this(initialCapacity, loadFactor, true); // true = validate parms
- }
-
- private IdentityHashBag(int initialCapacity, float loadFactor, boolean validateParms) {
- super();
- int capacity = initialCapacity;
- if (validateParms) {
- if (capacity < 0) {
- throw new IllegalArgumentException("Illegal Initial Capacity: " + capacity); //$NON-NLS-1$
- }
- if (capacity > MAXIMUM_CAPACITY) {
- capacity = MAXIMUM_CAPACITY;
- }
- if (loadFactor <= 0 || Float.isNaN(loadFactor)) {
- throw new IllegalArgumentException("Illegal Load factor: " + loadFactor); //$NON-NLS-1$
- }
-
- // find a power of 2 >= 'initialCapacity'
- capacity = 1;
- while (capacity < initialCapacity) {
- capacity <<= 1;
- }
- }
-
- this.loadFactor = loadFactor;
- this.table = this.buildTable(capacity);
- this.threshold = (int) (capacity * loadFactor);
- }
-
- /**
- * Construct a new bag containing the elements in the specified
- * collection. The bag's load factor will be the default, which is 0.75,
- * and its initial capacity will be sufficient to hold all the elements in
- * the specified collection.
- *
- * @param c the collection whose elements are to be placed into this bag.
- */
- public IdentityHashBag(Collection<? extends E> c) {
- this(Math.max((int) (c.size() / DEFAULT_LOAD_FACTOR) + 1, DEFAULT_INITIAL_CAPACITY), DEFAULT_LOAD_FACTOR);
- this.addAll_(c);
- }
-
- /**
- * Return a index for the specified object.
- */
- private int index(Object o) {
- return this.index(this.hash(o));
- }
-
- /**
- * Return a hash for the specified object.
- */
- private int hash(Object o) {
- return (o == null) ? 0 : this.tweakHash(System.identityHashCode(o));
- }
-
- /**
- * Tweak the specified hash.
- */
- private int tweakHash(int h) {
- return h;
-// h ^= (h >>> 20) ^ (h >>> 12);
-// return h ^ (h >>> 7) ^ (h >>> 4);
- }
-
- /**
- * Return the index for the specified hash.
- */
- private int index(int hash) {
- return this.index(hash, this.table.length);
- }
-
- /**
- * Return the index for the specified hash
- * within a table with the specified length.
- */
- int index(int hash, int length) {
- return hash & (length - 1);
- }
-
- /**
- * Internal {@link #addAll(Collection)} for construction and cloning.
- * (No check for re-hash; no change to mod count; no return value.)
- */
- private void addAll_(Iterable<? extends E> c) {
- for (E e : c) {
- this.add_(e);
- }
- }
-
- /**
- * Internal {@link #add(Object)} for construction and cloning.
- * (No check for re-hash; no change to mod count; no return value.)
- */
- private void add_(E o) {
- this.add_(o, 1);
- }
-
- /**
- * Internal {@link #add(Object, int)} for construction, cloning, and serialization.
- * (No check for re-hash; no change to mod count; no return value.)
- */
- private void add_(E o, int cnt) {
- int hash = this.hash(o);
- int index = this.index(hash);
- for (Entry<E> e = this.table[index]; e != null; e = e.next) {
- if (e.object == o) {
- e.count += cnt;
- this.size += cnt;
- return;
- }
- }
-
- // create the new entry and put it in the table
- Entry<E> e = this.buildEntry(hash, o, cnt, this.table[index]);
- this.table[index] = e;
- this.size += cnt;
- this.uniqueCount++;
- }
-
- /**
- * This implementation simply returns the maintained size.
- */
- @Override
- public int size() {
- return this.size;
- }
-
- /**
- * This implementation simply compares the maintained size to zero.
- */
- @Override
- public boolean isEmpty() {
- return this.size == 0;
- }
-
- /**
- * Search for the object's entry in the hash table by calculating
- * the object's identity hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- private Entry<E> getEntry(Object o) {
- for (Entry<E> e = this.table[this.index(o)]; e != null; e = e.next) {
- if (e.object == o) {
- return e;
- }
- }
- return null;
- }
-
- @Override
- public boolean contains(Object o) {
- return this.getEntry(o) != null;
- }
-
- public int count(Object o) {
- Entry<E> e = this.getEntry(o);
- return (e == null) ? 0 : e.count;
- }
-
- /**
- * Rehash the contents of the bag into a new hash table
- * with a larger capacity. This method is called when the
- * number of different elements in the bag exceeds its
- * capacity and load factor.
- */
- private void rehash() {
- Entry<E>[] oldTable = this.table;
- int oldCapacity = oldTable.length;
-
- if (oldCapacity == MAXIMUM_CAPACITY) {
- this.threshold = Integer.MAX_VALUE;
- return;
- }
-
- int newCapacity = 2 * oldCapacity;
- Entry<E>[] newTable = this.buildTable(newCapacity);
-
- for (int i = oldCapacity; i-- > 0; ) {
- for (Entry<E> old = oldTable[i]; old != null; ) {
- Entry<E> e = old;
- old = old.next;
-
- int index = this.index(e.hash, newCapacity);
- e.next = newTable[index];
- newTable[index] = e;
- }
- }
-
- this.table = newTable;
- this.threshold = (int) (newCapacity * this.loadFactor);
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private Entry<E>[] buildTable(int capacity) {
- return new Entry[capacity];
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's identity hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- @Override
- public boolean add(E o) {
- return this.add(o, 1);
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's identity hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- public boolean add(E o, int cnt) {
- if (cnt <= 0) {
- return false;
- }
- this.modCount++;
- int hash = this.hash(o);
- int index = this.index(hash);
-
- // if the object is already in the bag, simply bump its count
- for (Entry<E> e = this.table[index]; e != null; e = e.next) {
- if (e.object == o) {
- e.count += cnt;
- this.size += cnt;
- return true;
- }
- }
-
- // rehash the table if we are going to exceed the threshold
- if (this.uniqueCount >= this.threshold) {
- this.rehash();
- index = this.index(hash); // need to re-calculate the index
- }
-
- // create the new entry and put it in the table
- Entry<E> e = this.buildEntry(hash, o, cnt, this.table[index]);
- this.table[index] = e;
- this.size += cnt;
- this.uniqueCount++;
- return true;
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings({ "unchecked", "rawtypes" })
- private Entry<E> buildEntry(int hash, Object o, int cnt, Entry next) {
- return new Entry<E>(hash, (E) o, cnt, (Entry<E>) next);
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's identity hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- @Override
- public boolean remove(Object o) {
- return this.remove(o, 1);
- }
-
- /**
- * This implementation searches for the object in the hash table by calculating
- * the object's identity hash code and examining the entries in the corresponding hash
- * table bucket.
- */
- public boolean remove(Object o, int cnt) {
- if (cnt <= 0) {
- return false;
- }
- int index = this.index(o);
-
- for (Entry<E> e = this.table[index], prev = null; e != null; prev = e, e = e.next) {
- if (e.object == o) {
- this.modCount++;
- cnt = (cnt < e.count) ? cnt : e.count;
- e.count -= cnt;
- // if we are removing the last element(s), remove the entry from the table
- if (e.count == 0) {
- if (prev == null) {
- this.table[index] = e.next;
- } else {
- prev.next = e.next;
- }
- this.uniqueCount--;
- }
- this.size -= cnt;
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * This implementation uses object-identity to determine whether the
- * specified collection contains a particular element.
- */
- @Override
- public boolean removeAll(Collection<?> c) {
- return super.removeAll(new IdentityHashBag<Object>(c));
- }
-
- /**
- * This implementation uses object-identity to determine whether the
- * specified collection contains a particular element.
- */
- @Override
- public boolean retainAll(Collection<?> c) {
- return super.retainAll(new IdentityHashBag<Object>(c));
- }
-
- /**
- * This implementation simply clears out all of the hash table buckets.
- */
- @Override
- public void clear() {
- Entry<E>[] tab = this.table;
- this.modCount++;
- for (int i = tab.length; i-- > 0; ) {
- tab[i] = null;
- }
- this.size = 0;
- this.uniqueCount = 0;
- }
-
- /**
- * Returns a shallow copy of this bag: the elements
- * themselves are not cloned.
- *
- * @return a shallow copy of this bag.
- */
- @Override
- public IdentityHashBag<E> clone() {
- try {
- @SuppressWarnings("unchecked")
- IdentityHashBag<E> clone = (IdentityHashBag<E>) super.clone();
- clone.table = this.buildTable(this.table.length);
- clone.size = 0;
- clone.uniqueCount = 0;
- clone.modCount = 0;
- clone.addAll_(this);
- return clone;
- } catch (CloneNotSupportedException e) {
- throw new InternalError();
- }
- }
-
-
- /**
- * Hash table collision list entry.
- */
- private static class Entry<E> implements Bag.Entry<E> {
- final int hash; // cache the hash for re-hashes
- final E object;
- int count;
- Entry<E> next;
-
- Entry(int hash, E object, int count, Entry<E> next) {
- this.hash = hash;
- this.object = object;
- this.count = count;
- this.next = next;
- }
-
- // ***** Bag.Entry implementation
- public E getElement() {
- return this.object;
- }
-
- public int getCount() {
- return this.count;
- }
-
- public int setCount(int count) {
- if (count <= 0) {
- throw new IllegalArgumentException("count must be greater than zero: " + count); //$NON-NLS-1$
- }
- int old = this.count;
- this.count = count;
- return old;
- }
-
- @Override
- public boolean equals(Object o) {
- if ( ! (o instanceof Bag.Entry<?>)) {
- return false;
- }
- @SuppressWarnings("rawtypes")
- Bag.Entry e = (Bag.Entry) o;
- return (this.object == e.getElement())
- && (this.count == e.getCount());
- }
-
- @Override
- public int hashCode() {
- E o = this.object;
- return (o == null) ? 0 : (this.count * o.hashCode());
- }
-
- @Override
- public String toString() {
- return this.object + "=>" + this.count; //$NON-NLS-1$
- }
- }
-
-
- @Override
- @SuppressWarnings("unchecked")
- public Iterator<E> iterator() {
- return (this.size == 0) ? EMPTY_ITERATOR : new HashIterator();
- }
-
- @SuppressWarnings("unchecked")
- public Iterator<E> uniqueIterator() {
- return (this.size == 0) ? EMPTY_ITERATOR : new UniqueIterator();
- }
-
- public int uniqueCount() {
- return this.uniqueCount;
- }
-
- @SuppressWarnings("unchecked")
- public Iterator<Bag.Entry<E>> entries() {
- return (this.size == 0) ? EMPTY_ITERATOR : new EntryIterator();
- }
-
-
- /**
- * Empty iterator that does just about nothing.
- */
- @SuppressWarnings("rawtypes")
- private static final Iterator EMPTY_ITERATOR = new EmptyIterator();
-
- @SuppressWarnings("rawtypes")
- private static class EmptyIterator implements Iterator {
-
- EmptyIterator() {
- super();
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public Object next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new IllegalStateException();
- }
- }
-
-
- private class HashIterator implements Iterator<E> {
- private int index = IdentityHashBag.this.table.length; // start at the end of the table
- private Entry<E> nextEntry = null;
- private int nextEntryCount = 0;
- private Entry<E> lastReturnedEntry = null;
-
- /**
- * The modCount value that the iterator believes that the backing
- * bag should have. If this expectation is violated, the iterator
- * has detected a concurrent modification.
- */
- private int expectedModCount = IdentityHashBag.this.modCount;
-
- HashIterator() {
- super();
- }
-
- public boolean hasNext() {
- Entry<E> e = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = IdentityHashBag.this.table;
- // Use locals for faster loop iteration
- while ((e == null) && (i > 0)) {
- e = tab[--i]; // move backwards through the table
- }
- this.nextEntry = e;
- this.index = i;
- return e != null;
- }
-
- public E next() {
- if (IdentityHashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E> et = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = IdentityHashBag.this.table;
- // Use locals for faster loop iteration
- while ((et == null) && (i > 0)) {
- et = tab[--i]; // move backwards through the table
- }
- this.nextEntry = et;
- this.index = i;
- if (et == null) {
- throw new NoSuchElementException();
- }
- Entry<E> e = this.lastReturnedEntry = this.nextEntry;
- this.nextEntryCount++;
- if (this.nextEntryCount == e.count) {
- this.nextEntry = e.next;
- this.nextEntryCount = 0;
- }
- return e.object;
- }
-
- public void remove() {
- if (this.lastReturnedEntry == null) {
- throw new IllegalStateException();
- }
- if (IdentityHashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- int slot = IdentityHashBag.this.index(this.lastReturnedEntry.hash, IdentityHashBag.this.table.length);
- for (Entry<E> e = IdentityHashBag.this.table[slot], prev = null; e != null; prev = e, e = e.next) {
- if (e == this.lastReturnedEntry) {
- IdentityHashBag.this.modCount++;
- this.expectedModCount++;
- e.count--;
- if (e.count == 0) {
- // if we are removing the last one, remove the entry from the table
- if (prev == null) {
- IdentityHashBag.this.table[slot] = e.next;
- } else {
- prev.next = e.next;
- }
- IdentityHashBag.this.uniqueCount--;
- } else {
- // slide back the count to account for the just-removed element
- this.nextEntryCount--;
- }
- IdentityHashBag.this.size--;
- this.lastReturnedEntry = null; // it cannot be removed again
- return;
- }
- }
- throw new ConcurrentModificationException();
- }
-
- }
-
-
- private class EntryIterator implements Iterator<Entry<E>> {
- private int index = IdentityHashBag.this.table.length; // start at the end of the table
- private Entry<E> nextEntry = null;
- private Entry<E> lastReturnedEntry = null;
-
- /**
- * The modCount value that the iterator believes that the backing
- * bag should have. If this expectation is violated, the iterator
- * has detected a concurrent modification.
- */
- private int expectedModCount = IdentityHashBag.this.modCount;
-
- EntryIterator() {
- super();
- }
-
- public boolean hasNext() {
- Entry<E> e = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = IdentityHashBag.this.table;
- // Use locals for faster loop iteration
- while ((e == null) && (i > 0)) {
- e = tab[--i]; // move backwards through the table
- }
- this.nextEntry = e;
- this.index = i;
- return e != null;
- }
-
- public Entry<E> next() {
- if (IdentityHashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- Entry<E> et = this.nextEntry;
- int i = this.index;
- Entry<E>[] tab = IdentityHashBag.this.table;
- // Use locals for faster loop iteration
- while ((et == null) && (i > 0)) {
- et = tab[--i]; // move backwards through the table
- }
- this.nextEntry = et;
- this.index = i;
- if (et == null) {
- throw new NoSuchElementException();
- }
- Entry<E> e = this.lastReturnedEntry = this.nextEntry;
- this.nextEntry = e.next;
- return e;
- }
-
- public void remove() {
- if (this.lastReturnedEntry == null) {
- throw new IllegalStateException();
- }
- if (IdentityHashBag.this.modCount != this.expectedModCount) {
- throw new ConcurrentModificationException();
- }
- int slot = IdentityHashBag.this.index(this.lastReturnedEntry.hash, IdentityHashBag.this.table.length);
- for (Entry<E> e = IdentityHashBag.this.table[slot], prev = null; e != null; prev = e, e = e.next) {
- if (e == this.lastReturnedEntry) {
- IdentityHashBag.this.modCount++;
- this.expectedModCount++;
- // remove the entry from the table
- if (prev == null) {
- IdentityHashBag.this.table[slot] = e.next;
- } else {
- prev.next = e.next;
- }
- IdentityHashBag.this.uniqueCount--;
- IdentityHashBag.this.size -= this.lastReturnedEntry.count;
- this.lastReturnedEntry = null; // it cannot be removed again
- return;
- }
- }
- throw new ConcurrentModificationException();
- }
-
- }
-
-
- private class UniqueIterator implements Iterator<E> {
- private EntryIterator entryIterator = new EntryIterator();
-
- UniqueIterator() {
- super();
- }
-
- public boolean hasNext() {
- return this.entryIterator.hasNext();
- }
-
- public E next() {
- return this.entryIterator.next().object;
- }
-
- public void remove() {
- this.entryIterator.remove();
- }
-
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- } else if (o instanceof IdentityHashBag<?>) {
- @SuppressWarnings("unchecked")
- IdentityHashBag<E> b = (IdentityHashBag<E>) o;
- if (b.size() != this.size()) {
- return false;
- }
- if (b.uniqueCount() != this.uniqueCount()) {
- return false;
- }
- for (Iterator<Bag.Entry<E>> stream = b.entries(); stream.hasNext(); ) {
- Bag.Entry<E> entry = stream.next();
- if (entry.getCount() != this.count(entry.getElement())) {
- return false;
- }
- }
- return true;
- } else {
- return this.equals_(o);
- }
-// } else if (o instanceof Bag<?>) {
-// // hmmm...
-// return new HashBag<Object>(this).equals(o);
-// } else {
-// return false;
-// }
- }
-
- private boolean equals_(Object o) {
- // hmmm...
- return (o instanceof Bag<?>) &&
- new HashBag<Object>(this).equals(o);
- }
-
- @Override
- public int hashCode() {
- int h = 0;
- for (E o : this) {
- h += System.identityHashCode(o);
- }
- return h;
- }
-
- /**
- * Save the state of this bag to a stream (i.e. serialize it).
- *
- * @serialData Emit the capacity of the bag (int),
- * followed by the number of unique elements in the bag (int),
- * followed by all of the bag's elements (each an Object) and
- * their counts (each an int), in no particular order.
- */
- private void writeObject(java.io.ObjectOutputStream s)
- throws java.io.IOException {
- // write out the threshold, load factor, and any hidden stuff
- s.defaultWriteObject();
-
- // write out number of buckets
- s.writeInt(this.table.length);
-
- // write out number of unique elements
- s.writeInt(this.uniqueCount);
-
- // write out elements and counts (alternating)
- if (this.uniqueCount > 0) {
- for (Entry<E> entry : this.table) {
- while (entry != null) {
- s.writeObject(entry.object);
- s.writeInt(entry.count);
- entry = entry.next;
- }
- }
- }
- }
-
- private static final long serialVersionUID = 1L;
-
- /**
- * Reconstitute the bag from a stream (i.e. deserialize it).
- */
- private void readObject(java.io.ObjectInputStream s)
- throws java.io.IOException, ClassNotFoundException {
- // read in the threshold, loadfactor, and any hidden stuff
- s.defaultReadObject();
-
- // read in number of buckets and allocate the bucket array
- this.table = this.buildTable(s.readInt());
-
- // read in number of unique elements
- int unique = s.readInt();
-
- // read the elements and counts, and put the elements in the bag
- for (int i = 0; i < unique; i++) {
- @SuppressWarnings("unchecked")
- E element = (E) s.readObject();
- int elementCount = s.readInt();
- this.add_(element, elementCount);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/IntReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/IntReference.java
deleted file mode 100644
index a790457d0b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/IntReference.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Interface for a container for holding an <code>int</code> that cannot be
- * changed by clients.
- */
-public interface IntReference
- extends Comparable<IntReference>
-{
- /**
- * Return the current <code>int</code> value.
- */
- int getValue();
-
- /**
- * Return whether the current <code>int</code> value is equal to the
- * specified value.
- */
- boolean equals(int v);
-
- /**
- * Return whether the current <code>int</code> value is not equal to
- * the specified value.
- */
- boolean notEqual(int v);
-
- /**
- * Return whether the current <code>int</code> value is zero.
- */
- boolean isZero();
-
- /**
- * Return whether the current <code>int</code> value is not zero.
- */
- boolean isNotZero();
-
- /**
- * Return whether the current <code>int</code> value is greater than
- * the specified value.
- */
- boolean isGreaterThan(int v);
-
- /**
- * Return whether the current <code>int</code> value is greater than
- * or equal to the specified value.
- */
- boolean isGreaterThanOrEqual(int v);
-
- /**
- * Return whether the current <code>int</code> value is less than
- * the specified value.
- */
- boolean isLessThan(int v);
-
- /**
- * Return whether the current <code>int</code> value is less than
- * or equal to the specified value.
- */
- boolean isLessThanOrEqual(int v);
-
- /**
- * Return whether the current <code>int</code> value is positive.
- */
- boolean isPositive();
-
- /**
- * Return whether the current <code>int</code> value is not positive
- * (i.e. negative or zero).
- */
- boolean isNotPositive();
-
- /**
- * Return whether the current <code>int</code> value is negative.
- */
- boolean isNegative();
-
- /**
- * Return whether the current <code>int</code> value is not negative
- * (i.e. zero or positive).
- */
- boolean isNotNegative();
-
- /**
- * Return the absolute value of the current <code>int</code> value.
- */
- int abs();
-
- /**
- * Return the negative value of the current <code>int</code> value.
- */
- int neg();
-
- /**
- * Return the current <code>int</code> value plus the specified value.
- */
- int add(int v);
-
- /**
- * Return current <code>int</code> value minus the specified value.
- */
- int subtract(int v);
-
- /**
- * Return current <code>int</code> value multiplied by the specified value.
- */
- int multiply(int v);
-
- /**
- * Return current <code>int</code> value divided by the specified value.
- */
- int divide(int v);
-
- /**
- * Return the remainder of the current <code>int</code> value divided by
- * the specified value.
- */
- int remainder(int v);
-
- /**
- * Return the minimum of the current <code>int</code> value and
- * the specified value.
- */
- int min(int v);
-
- /**
- * Return the maximum of the current <code>int</code> value and
- * the specified value.
- */
- int max(int v);
-
- /**
- * Return the current <code>int</code> value raised to the power
- * of the specified value.
- */
- double pow(int v);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/JDBCTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/JDBCTools.java
deleted file mode 100644
index 1663a8e493..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/JDBCTools.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.sql.Types;
-import java.util.HashMap;
-import org.eclipse.jpt.common.utility.JavaType;
-
-/**
- * Helper methods for dealing with the JDBC API.
- */
-public final class JDBCTools {
-
-
- /**
- * Return the JDBC type corresponding to the specified class.
- * @see java.sql.Types
- */
- public static JDBCType jdbcTypeForClassNamed(String className) {
- JavaToJDBCTypeMapping mapping = javaToJDBCTypeMapping(className);
- return (mapping == null) ? DEFAULT_JDBC_TYPE : mapping.getJDBCType();
- }
-
- /**
- * Return the JDBC type corresponding to the specified class.
- * @see java.sql.Types
- */
- public static JDBCType jdbcTypeFor(Class<?> javaClass) {
- return jdbcTypeForClassNamed(javaClass.getName());
- }
-
- /**
- * Return the JDBC type corresponding to the specified class.
- * @see java.sql.Types
- */
- public static JDBCType jdbcTypeFor(JavaType javaType) {
- return jdbcTypeForClassNamed(javaType.getJavaClassName());
- }
-
- /**
- * Return the Java type corresponding to the specified JDBC type.
- * @see java.sql.Types
- */
- public static JavaType javaTypeForJDBCTypeNamed(String jdbcTypeName) {
- JDBCToJavaTypeMapping mapping = jdbcToJavaTypeMapping(jdbcTypeName);
- return (mapping == null) ? DEFAULT_JAVA_TYPE : mapping.getJavaType();
- }
-
- /**
- * Return the Java type corresponding to the specified JDBC type.
- * @see java.sql.Types
- */
- public static JavaType javaTypeFor(JDBCType jdbcType) {
- return javaTypeForJDBCTypeNamed(jdbcType.name());
- }
-
- /**
- * Return the Java type corresponding to the specified JDBC type.
- * @see java.sql.Types
- */
- public static JavaType javaTypeForJDBCTypeCode(int jdbcTypeCode) {
- return javaTypeFor(JDBCType.type(jdbcTypeCode));
- }
-
-
- // ********** internal stuff **********
-
-
- // ********** JDBC => Java **********
-
- /**
- * JDBC => Java type mappings, keyed by JDBC type name (e.g. "VARCHAR")
- */
- private static HashMap<String, JDBCToJavaTypeMapping> JDBC_TO_JAVA_TYPE_MAPPINGS; // pseudo 'final' - lazy-initialized
- private static final JavaType DEFAULT_JAVA_TYPE = new SimpleJavaType(java.lang.Object.class); // TODO Object is the default?
-
-
- private static JDBCToJavaTypeMapping jdbcToJavaTypeMapping(String jdbcTypeName) {
- return jdbcToJavaTypeMappings().get(jdbcTypeName);
- }
-
- private static synchronized HashMap<String, JDBCToJavaTypeMapping> jdbcToJavaTypeMappings() {
- if (JDBC_TO_JAVA_TYPE_MAPPINGS == null) {
- JDBC_TO_JAVA_TYPE_MAPPINGS = buildJDBCToJavaTypeMappings();
- }
- return JDBC_TO_JAVA_TYPE_MAPPINGS;
- }
-
- private static HashMap<String, JDBCToJavaTypeMapping> buildJDBCToJavaTypeMappings() {
- HashMap<String, JDBCToJavaTypeMapping> mappings = new HashMap<String, JDBCToJavaTypeMapping>();
- addJDBCToJavaTypeMappingsTo(mappings);
- return mappings;
- }
-
- /**
- * hard code the default mappings from the JDBC types to the
- * appropriate Java types
- * @see java.sql.Types
- * see "JDBC 3.0 Specification" Appendix B
- */
- private static void addJDBCToJavaTypeMappingsTo(HashMap<String, JDBCToJavaTypeMapping> mappings) {
- addJDBCToJavaTypeMappingTo(Types.ARRAY, java.sql.Array.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.BIGINT, long.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.BINARY, byte[].class, mappings);
- addJDBCToJavaTypeMappingTo(Types.BIT, boolean.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.BLOB, java.sql.Blob.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.BOOLEAN, boolean.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.CHAR, java.lang.String.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.CLOB, java.sql.Clob.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.DATALINK, java.net.URL.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.DATE, java.sql.Date.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.DECIMAL, java.math.BigDecimal.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.DISTINCT, java.lang.Object.class, mappings); // ???
- addJDBCToJavaTypeMappingTo(Types.DOUBLE, double.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.FLOAT, double.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.INTEGER, int.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.JAVA_OBJECT, java.lang.Object.class, mappings); // ???
- addJDBCToJavaTypeMappingTo(Types.LONGVARBINARY, byte[].class, mappings);
- addJDBCToJavaTypeMappingTo(Types.LONGVARCHAR, java.lang.String.class, mappings);
- // not sure why this is defined in java.sql.Types
-// addJDBCToJavaTypeMappingTo(Types.NULL, java.lang.Object.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.NUMERIC, java.math.BigDecimal.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.OTHER, java.lang.Object.class, mappings); // ???
- addJDBCToJavaTypeMappingTo(Types.REAL, float.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.REF, java.sql.Ref.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.SMALLINT, short.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.STRUCT, java.sql.Struct.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.TIME, java.sql.Time.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.TIMESTAMP, java.sql.Timestamp.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.TINYINT, byte.class, mappings);
- addJDBCToJavaTypeMappingTo(Types.VARBINARY, byte[].class, mappings);
- addJDBCToJavaTypeMappingTo(Types.VARCHAR, java.lang.String.class, mappings);
- }
-
- private static void addJDBCToJavaTypeMappingTo(int jdbcTypeCode, Class<?> javaClass, HashMap<String, JDBCToJavaTypeMapping> mappings) {
- // check for duplicates
- JDBCType jdbcType = JDBCType.type(jdbcTypeCode);
- Object prev = mappings.put(jdbcType.name(), buildJDBCToJavaTypeMapping(jdbcType, javaClass));
- if (prev != null) {
- throw new IllegalArgumentException("duplicate JDBC type: " + jdbcType.name()); //$NON-NLS-1$
- }
- }
-
- private static JDBCToJavaTypeMapping buildJDBCToJavaTypeMapping(JDBCType jdbcType, Class<?> javaClass) {
- return new JDBCToJavaTypeMapping(jdbcType, new SimpleJavaType(javaClass));
- }
-
-
- // ********** Java => JDBC **********
-
- /**
- * Java => JDBC type mappings, keyed by Java class name (e.g. "java.lang.Object")
- */
- private static HashMap<String, JavaToJDBCTypeMapping> JAVA_TO_JDBC_TYPE_MAPPINGS; // pseudo 'final' - lazy-initialized
- private static final JDBCType DEFAULT_JDBC_TYPE = JDBCType.type(Types.VARCHAR); // TODO VARCHAR is the default?
-
-
- private static JavaToJDBCTypeMapping javaToJDBCTypeMapping(String className) {
- return javaToJDBCTypeMappings().get(className);
- }
-
- private static synchronized HashMap<String, JavaToJDBCTypeMapping> javaToJDBCTypeMappings() {
- if (JAVA_TO_JDBC_TYPE_MAPPINGS == null) {
- JAVA_TO_JDBC_TYPE_MAPPINGS = buildJavaToJDBCTypeMappings();
- }
- return JAVA_TO_JDBC_TYPE_MAPPINGS;
- }
-
- private static HashMap<String, JavaToJDBCTypeMapping> buildJavaToJDBCTypeMappings() {
- HashMap<String, JavaToJDBCTypeMapping> mappings = new HashMap<String, JavaToJDBCTypeMapping>();
- addJavaToJDBCTypeMappingsTo(mappings);
- return mappings;
- }
-
- /**
- * hard code the default mappings from the Java types to the
- * appropriate JDBC types
- * @see java.sql.Types
- * see "JDBC 3.0 Specification" Appendix B
- */
- private static void addJavaToJDBCTypeMappingsTo(HashMap<String, JavaToJDBCTypeMapping> mappings) {
- // primitives
- addJavaToJDBCTypeMappingTo(boolean.class, Types.BIT, mappings);
- addJavaToJDBCTypeMappingTo(byte.class, Types.TINYINT, mappings);
- addJavaToJDBCTypeMappingTo(double.class, Types.DOUBLE, mappings);
- addJavaToJDBCTypeMappingTo(float.class, Types.REAL, mappings);
- addJavaToJDBCTypeMappingTo(int.class, Types.INTEGER, mappings);
- addJavaToJDBCTypeMappingTo(long.class, Types.BIGINT, mappings);
- addJavaToJDBCTypeMappingTo(short.class, Types.SMALLINT, mappings);
-
- // reference classes
- addJavaToJDBCTypeMappingTo(java.lang.Boolean.class, Types.BIT, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Byte.class, Types.TINYINT, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Double.class, Types.DOUBLE, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Float.class, Types.REAL, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Integer.class, Types.INTEGER, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Long.class, Types.BIGINT, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Short.class, Types.SMALLINT, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.String.class, Types.VARCHAR, mappings);
- addJavaToJDBCTypeMappingTo(java.math.BigDecimal.class, Types.NUMERIC, mappings);
- addJavaToJDBCTypeMappingTo(java.net.URL.class, Types.DATALINK, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Array.class, Types.ARRAY, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Blob.class, Types.BLOB, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Clob.class, Types.CLOB, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Date.class, Types.DATE, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Ref.class, Types.REF, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Struct.class, Types.STRUCT, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Time.class, Types.TIME, mappings);
- addJavaToJDBCTypeMappingTo(java.sql.Timestamp.class, Types.TIMESTAMP, mappings);
-
- // arrays
- addJavaToJDBCTypeMappingTo(byte[].class, Types.VARBINARY, mappings);
- addJavaToJDBCTypeMappingTo(java.lang.Byte[].class, Types.VARBINARY, mappings);
- }
-
- private static void addJavaToJDBCTypeMappingTo(Class<?> javaClass, int jdbcTypeCode, HashMap<String, JavaToJDBCTypeMapping> mappings) {
- // check for duplicates
- Object prev = mappings.put(javaClass.getName(), buildJavaToJDBCTypeMapping(javaClass, jdbcTypeCode));
- if (prev != null) {
- throw new IllegalArgumentException("duplicate Java class: " + ((JavaToJDBCTypeMapping) prev).getJavaType().declaration()); //$NON-NLS-1$
- }
- }
-
- private static JavaToJDBCTypeMapping buildJavaToJDBCTypeMapping(Class<?> javaClass, int jdbcTypeCode) {
- return new JavaToJDBCTypeMapping(new SimpleJavaType(javaClass), JDBCType.type(jdbcTypeCode));
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private JDBCTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-
- // ********** member classes **********
-
- /**
- * JDBC => Java
- */
- static class JDBCToJavaTypeMapping {
- private final JDBCType jdbcType;
- private final JavaType javaType;
-
- JDBCToJavaTypeMapping(JDBCType jdbcType, JavaType javaType) {
- super();
- this.jdbcType = jdbcType;
- this.javaType = javaType;
- }
-
- public JDBCType getJDBCType() {
- return this.jdbcType;
- }
-
- public JavaType getJavaType() {
- return this.javaType;
- }
-
- public boolean maps(int jdbcTypeCode) {
- return this.jdbcType.code() == jdbcTypeCode;
- }
-
- public boolean maps(String jdbcTypeName) {
- return this.jdbcType.name().equals(jdbcTypeName);
- }
-
- public boolean maps(JDBCType type) {
- return this.jdbcType == type;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- this.appendTo(sb);
- return sb.toString();
- }
-
- public void appendTo(StringBuilder sb) {
- this.jdbcType.appendTo(sb);
- sb.append(" => "); //$NON-NLS-1$
- this.javaType.appendDeclarationTo(sb);
- }
-
- }
-
- /**
- * Java => JDBC
- */
- static class JavaToJDBCTypeMapping {
- private final JavaType javaType;
- private final JDBCType jdbcType;
-
- JavaToJDBCTypeMapping(JavaType javaType, JDBCType jdbcType) {
- super();
- this.javaType = javaType;
- this.jdbcType = jdbcType;
- }
-
- public JavaType getJavaType() {
- return this.javaType;
- }
-
- public JDBCType getJDBCType() {
- return this.jdbcType;
- }
-
- public boolean maps(JavaType jt) {
- return this.javaType.equals(jt);
- }
-
- public boolean maps(String elementTypeName, int arrayDepth) {
- return this.javaType.equals(elementTypeName, arrayDepth);
- }
-
- public boolean maps(String javaClassName) {
- return this.javaType.describes(javaClassName);
- }
-
- public boolean maps(Class<?> javaClass) {
- return this.javaType.describes(javaClass);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- this.appendTo(sb);
- return sb.toString();
- }
-
- public void appendTo(StringBuilder sb) {
- this.javaType.appendDeclarationTo(sb);
- sb.append(" => "); //$NON-NLS-1$
- this.jdbcType.appendTo(sb);
- }
-
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/JDBCType.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/JDBCType.java
deleted file mode 100644
index 96fd283a7d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/JDBCType.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.sql.Types;
-
-/**
- * Associate the Java constant and the JDBC type name.
- * These are derived from java.sql.Types.
- *
- * @see java.sql.Types
- */
-public final class JDBCType
- implements Cloneable, Serializable
-{
-
- /**
- * the constant name (e.g. VARCHAR)
- */
- private final String name;
-
- /**
- * the JDBC code used by JDBC drivers
- */
- private final int code;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a JDBC type with the specified name and type code.
- * This is private because all the possible JDBC types are built and
- * stored in the static array TYPES.
- * @see #types()
- */
- private JDBCType(String name, int code) {
- super();
- this.name = name;
- this.code = code;
- }
-
-
- // ********** accessors **********
-
- /**
- * Return the name of the type, as defined in java.sql.Types.
- */
- public String name() {
- return this.name;
- }
-
-
- /**
- * Return the type code, as defined in java.sql.Types.
- */
- public int code() {
- return this.code;
- }
-
-
- // ********** printing and displaying **********
-
- public void appendTo(StringBuilder sb) {
- sb.append(this.name);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(this.getClass().getSimpleName());
- sb.append('(');
- this.appendTo(sb);
- sb.append(')');
- return sb.toString();
- }
-
- @Override
- public JDBCType clone() {
- try {
- return (JDBCType) super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
-
- // ********** static stuff **********
-
- /**
- * all the JDBC type defined in java.sql.Types
- */
- private static JDBCType[] TYPES; // pseudo 'final' - lazy-initialized
-
-
- public synchronized static JDBCType[] types() {
- if (TYPES == null) {
- TYPES = buildTypes();
- }
- return TYPES;
- }
-
- /**
- * Return the JDBC type for the specified type code (e.g. Types.VARCHAR).
- * @see java.sql.Types
- */
- public static JDBCType type(int code) {
- JDBCType[] types = types();
- for (int i = types.length; i-- > 0; ) {
- if (types[i].code() == code) {
- return types[i];
- }
- }
- throw new IllegalArgumentException("invalid JDBC type code: " + code); //$NON-NLS-1$
- }
-
- /**
- * Return the JDBC type for the specified type name (e.g. "VARCHAR").
- * @see java.sql.Types
- */
- public static JDBCType type(String name) {
- JDBCType[] types = types();
- for (int i = types.length; i-- > 0; ) {
- if (types[i].name().equals(name)) {
- return types[i];
- }
- }
- throw new IllegalArgumentException("invalid JDBC type name: " + name); //$NON-NLS-1$
- }
-
- /**
- * build up the JDBC types via reflection
- * @see java.sql.Types
- */
- private static JDBCType[] buildTypes() {
- Field[] fields = Types.class.getDeclaredFields();
- int len = fields.length;
- JDBCType[] types = new JDBCType[len];
- for (int i = len; i-- > 0; ) {
- String name = fields[i].getName();
- int code;
- try {
- code = ((Integer) fields[i].get(null)).intValue();
- } catch (IllegalAccessException ex) {
- throw new RuntimeException(ex); // shouldn't happen...
- }
- types[i] = new JDBCType(name, code);
- }
- return types;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/KeyedSet.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/KeyedSet.java
deleted file mode 100644
index cf471f4bb8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/KeyedSet.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * This class maintains a {@link Set} of items, and a {@link Map} of keys to those items.
- * An item may have multiple keys, but an item may have no keys and remain in the set. Once an
- * item's last key is removed, the item is also removed.
- */
-public class KeyedSet<K, V> {
-
- private final Set<V> itemSet;
- private final Set<V> unmodifiableItemSet;
- private final Map<K,V> map;
-
-
- public KeyedSet() {
- this.itemSet = new HashSet<V>();
- this.unmodifiableItemSet = Collections.unmodifiableSet(this.itemSet);
- this.map = new HashMap<K,V>();
- }
-
- /**
- * Return an unmodifiable representation of the set of items.
- */
- public Set<V> getItemSet() {
- return this.unmodifiableItemSet;
- }
-
- /**
- * Return the item stored under the given key.
- */
- public V getItem(K key) {
- return this.map.get(key);
- }
-
- /**
- * Return whether an item is stored under the given key.
- */
- public boolean containsKey(K key) {
- return this.map.containsKey(key);
- }
-
- /**
- * Return whether the item is stored under *any* key.
- */
- public boolean containsItem(V item) {
- return this.itemSet.contains(item);
- }
-
- /**
- * Add an item to be stored under the given key.
- * The item must not already be stored.
- */
- public void addItem(K key, V item) {
- addItem(item);
- addKey(key, item);
- }
-
- private void addItem(V item) {
- if (item == null) {
- throw new IllegalArgumentException();
- }
- this.itemSet.add(item);
- }
-
- /**
- * Add an additional key to an item already stored under an alternate key.
- */
- public void addKey(K key, V item) {
- if (key == null || item == null) {
- throw new IllegalArgumentException();
- }
- if (! this.itemSet.contains(item)) {
- throw new IllegalArgumentException();
- }
- this.map.put(key, item);
- }
-
- /**
- * Remove the given item and remove any key-to-item mapping it may have.
- */
- public boolean removeItem(V item) {
- if (this.itemSet.remove(item)) {
- for (Map.Entry<K,V> entry : CollectionTools.collection(this.map.entrySet())) {
- if (entry.getValue() == item) {
- map.remove(entry.getKey());
- }
- }
- return true;
- }
- return false;
- }
-
- /**
- * Remove the key-to-item mapping for the given key.
- * If it is the last key to the item, also remove the item.
- */
- public boolean removeKey(K key) {
- final V item = this.map.get(key);
- if (item != null) {
- this.map.remove(key);
- boolean otherKey = false;
- for (Map.Entry<K,V> entry : CollectionTools.collection(this.map.entrySet())) {
- if (otherKey | entry.getValue() == item) {
- otherKey = true;
- }
- }
- if (! otherKey) {
- removeItem(item);
- }
- return true;
- }
- return false;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/LazyObjectReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/LazyObjectReference.java
deleted file mode 100644
index 454a6e1cf0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/LazyObjectReference.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.ObjectReference;
-
-/**
- * Provide a thread-safe, reasonably performing container for holding an
- * object that will be "lazy-initialized" upon its first reference. This is
- * also useful for preventing direct references (accidental or otherwise) to
- * lazy-initialized state.
- * <p>
- * There are some penalties:<ul>
- * <li>The reference's use of generics will require casting (and the requisite
- * VM testing) with every access
- * <li>If the value calculated during lazy initialization is <code>null</code>,
- * access will be <code>synchronized</code> <em>every</em> time.
- * </ul>
- * @see SimpleObjectReference
- * @see SynchronizedObject
- */
-public abstract class LazyObjectReference<V>
- implements ObjectReference<V>, Cloneable, Serializable
-{
- /** Backing value. */
- private volatile V value = null;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Create a lazy object reference.
- */
- protected LazyObjectReference() {
- super();
- }
-
-
- // ********** value **********
-
- /**
- * In JDK 5 and later, this "double-checked locking" idiom works as long
- * as the instance variable is marked <code>volatile</code>.
- */
- public V getValue() {
- V result = this.value;
- if (result == null) {
- synchronized (this) {
- result = this.value;
- if (result == null) {
- this.value = result = this.buildValue();
- }
- }
- }
- return result;
- }
-
- protected abstract V buildValue();
-
- public boolean valueEquals(Object object) {
- return Tools.valuesAreEqual(this.getValue(), object);
- }
-
- public boolean valueNotEqual(Object object) {
- return Tools.valuesAreDifferent(this.getValue(), object);
- }
-
- public boolean isNull() {
- return this.getValue() == null;
- }
-
- public boolean isNotNull() {
- return this.getValue() != null;
- }
-
-
- // ********** standard methods **********
-
- @Override
- public LazyObjectReference<V> clone() {
- try {
- @SuppressWarnings("unchecked")
- LazyObjectReference<V> clone = (LazyObjectReference<V>) super.clone();
- return clone;
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- /**
- * This method will <em>not</em> trigger the "lazy-initialization".
- */
- @Override
- public String toString() {
- return '[' + String.valueOf(this.value) + ']';
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ListenerList.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ListenerList.java
deleted file mode 100644
index 6161fb00c9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ListenerList.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.lang.reflect.Array;
-import java.util.Arrays;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-
-/**
- * Maintain a thread-safe list of listeners that does not allow adding
- * duplicate listeners or removing non-listeners.
- *
- * @parm <L> the type of listeners held by the list
- */
-public class ListenerList<L>
- implements Serializable
-{
- /**
- * We can mark this <code>volatile</code> and not synchronize the read
- * methods because we never change the <em>contents</em> of the array.
- */
- private transient volatile L[] listeners;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a listener list for listeners of the specified type.
- */
- public ListenerList(Class<L> listenerClass) {
- super();
- this.listeners = this.buildListenerArray(listenerClass, 0);
- }
-
- /**
- * Construct a listener list for listeners of the specified type.
- * Add the specified listener to the list.
- */
- public ListenerList(Class<L> listenerClass, L listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listeners = this.buildListenerArray(listenerClass, 1);
- this.listeners[0] = listener;
- }
-
- @SuppressWarnings("unchecked")
- private L[] buildListenerArray(Class<L> listenerClass, int length) {
- return (L[]) Array.newInstance(listenerClass, length);
- }
-
- /**
- * Return the listeners.
- */
- public Iterable<L> getListeners() {
- return new ArrayIterable<L>(this.listeners);
- }
-
- /**
- * Return the number of listeners.
- */
- public int size() {
- return this.listeners.length;
- }
-
- /**
- * Return whether the listener list has no listeners.
- */
- public boolean isEmpty() {
- return this.listeners.length == 0;
- }
-
- /**
- * Add the specified listener to the listener list.
- * Duplicate listeners are not allowed.
- */
- public synchronized void add(L listener) {
- if (listener == null) {
- throw new NullPointerException();
- }
- if (ArrayTools.contains(this.listeners, listener)) {
- throw new IllegalArgumentException("duplicate listener: " + listener); //$NON-NLS-1$
- }
- this.listeners = ArrayTools.add(this.listeners, listener);
- }
-
- /**
- * Remove the specified listener from the listener list.
- * Removing a listener that is not on the list is not allowed.
- */
- public synchronized void remove(L listener) {
- if (listener == null) {
- throw new NullPointerException();
- }
- int index = ArrayTools.indexOf(this.listeners, listener);
- if (index == -1) {
- throw new IllegalArgumentException("unregistered listener: " + listener); //$NON-NLS-1$
- }
- this.listeners = ArrayTools.removeElementAtIndex(this.listeners, index);
- }
-
- /**
- * Clear the listener list.
- */
- public synchronized void clear() {
- this.listeners = ArrayTools.clear(this.listeners);
- }
-
- /**
- * Return the type of listeners held by the listener list.
- */
- @SuppressWarnings("unchecked")
- public Class<L> getListenerType() {
- return (Class<L>) this.listeners.getClass().getComponentType();
- }
-
- @Override
- public String toString() {
- return Arrays.toString(this.listeners);
- }
-
-
- // ********** serialization **********
-
- /**
- * Silently drop any non-serializable listeners.
- */
- private synchronized void writeObject(ObjectOutputStream s) throws IOException {
- // write out any hidden stuff
- s.defaultWriteObject();
-
- @SuppressWarnings("unchecked")
- Class<L> listenerClass = (Class<L>) this.listeners.getClass().getComponentType();
- s.writeObject(listenerClass);
-
- // only write out serializable listeners
- for (L listener : this.listeners) {
- if (listener instanceof Serializable) {
- s.writeObject(listener);
- }
- }
-
- s.writeObject(null);
- }
-
- @SuppressWarnings("unchecked")
- private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
- // read in any hidden stuff
- s.defaultReadObject();
-
- Class<L> listenerClass = (Class<L>) s.readObject();
- this.listeners = this.buildListenerArray(listenerClass, 0);
- Object o;
- while ((o = s.readObject()) != null) {
- this.listeners = ArrayTools.add(this.listeners, (L) o);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ModifiableBooleanReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ModifiableBooleanReference.java
deleted file mode 100644
index c22849ae58..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ModifiableBooleanReference.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import org.eclipse.jpt.common.utility.BooleanReference;
-
-/**
- * Interface for a container for passing a flag that can be changed by
- * the recipient.
- */
-public interface ModifiableBooleanReference
- extends BooleanReference
-{
- /**
- * Set the <code>boolean</code> value.
- * Return the previous value.
- */
- boolean setValue(boolean value);
-
- /**
- * Set the <code>boolean</code> value to the NOT of its current value.
- * Return the new value.
- */
- boolean flip();
-
- /**
- * Set the <code>boolean</code> value to the NOT of the specified value.
- * Return the previous value.
- */
- boolean setNot(boolean v);
-
- /**
- * Set the <code>boolean</code> value to <code>true</code>.
- * Return the previous value.
- */
- boolean setTrue();
-
- /**
- * Set the <code>boolean</code> value to <code>false</code>.
- * Return the previous value.
- */
- boolean setFalse();
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ModifiableIntReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ModifiableIntReference.java
deleted file mode 100644
index 135b86068a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ModifiableIntReference.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Interface for a container for passing an integer that can be changed by
- * the recipient.
- */
-public interface ModifiableIntReference
- extends IntReference
-{
- /**
- * Set the <code>int</code> value.
- * Return the previous value.
- */
- int setValue(int value);
-
- /**
- * Set the <code>int</code> value to zero.
- * Return the previous value.
- */
- int setZero();
-
- /**
- * Increment and return the <code>int</code> value.
- */
- int increment();
-
- /**
- * Decrement and return the <code>int</code> value.
- */
- int decrement();
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NameTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NameTools.java
deleted file mode 100644
index 11cf1ea5e3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NameTools.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.beans.Introspector;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.SortedSet;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-
-/**
- * Various helper methods for generating names.
- */
-public final class NameTools {
-
- /**
- * Given a "root" name and a set of existing names, generate a unique
- * name that is either the "root" name or some variation on the "root"
- * name (e.g. "root2", "root3",...). The names are case-sensitive
- * (i.e. "Root" and "root" are both allowed).
- */
- public static String uniqueNameFor(String rootName, Iterator<String> existingNames) {
- return uniqueNameFor(rootName, CollectionTools.set(existingNames));
- }
-
- /**
- * Given a "root" name and a set of existing names, generate a unique
- * name that is either the "root" name or some variation on the "root"
- * name (e.g. "root2", "root3",...). The names are case-sensitive
- * (i.e. "Root" and "root" are both allowed).
- */
- public static String uniqueNameFor(String rootName, Collection<String> existingNames) {
- return uniqueNameFor(rootName, existingNames, rootName);
- }
-
- /**
- * Given a "root" name and a set of existing names, generate a unique
- * name that is either the "root" name or some variation on the "root"
- * name (e.g. "root2", "root3",...). The names are NOT case-sensitive
- * (i.e. "Root" and "root" are NOT both allowed).
- */
- public static String uniqueNameForIgnoreCase(String rootName, Iterator<String> existingNames) {
- return uniqueNameForIgnoreCase(rootName, CollectionTools.set(existingNames));
- }
-
- /**
- * Given a "root" name and a set of existing names, generate a unique
- * name that is either the "root" name or some variation on the "root"
- * name (e.g. "root2", "root3",...). The names are NOT case-sensitive
- * (i.e. "Root" and "root" are NOT both allowed).
- */
- public static String uniqueNameForIgnoreCase(String rootName, Collection<String> existingNames) {
- return uniqueNameFor(rootName, convertToLowerCase(existingNames), rootName.toLowerCase());
- }
-
- /**
- * use the suffixed "template" name to perform the comparisons, but RETURN
- * the suffixed "root" name; this allows case-insensitive comparisons
- * (i.e. the "template" name has been morphed to the same case as
- * the "existing" names, while the "root" name has not, but the "root" name
- * is what the client wants morphed to be unique)
- */
- private static String uniqueNameFor(String rootName, Collection<String> existingNames, String templateName) {
- if ( ! existingNames.contains(templateName)) {
- return rootName;
- }
- String uniqueName = templateName;
- for (int suffix = 2; true; suffix++) {
- if ( ! existingNames.contains(uniqueName + suffix)) {
- return rootName.concat(String.valueOf(suffix));
- }
- }
- }
-
- /**
- * Convert the specified collection of strings to a collection of the same
- * strings converted to lower case.
- */
- private static HashSet<String> convertToLowerCase(Collection<String> strings) {
- HashSet<String> result = new HashSet<String>(strings.size());
- for (String string : strings) {
- result.add(string.toLowerCase());
- }
- return result;
- }
-
- /**
- * Build a fully-qualified name for the specified database object.
- * Variations:
- * catalog.schema.name
- * catalog..name
- * schema.name
- * name
- */
- public static String buildQualifiedDatabaseObjectName(String catalog, String schema, String name) {
- if (name == null) {
- return null;
- }
- if ((catalog == null) && (schema == null)) {
- return name;
- }
-
- StringBuilder sb = new StringBuilder(100);
- if (catalog != null) {
- sb.append(catalog);
- sb.append('.');
- }
- if (schema != null) {
- sb.append(schema);
- }
- sb.append('.');
- sb.append(name);
- return sb.toString();
- }
-
- /**
- * The set of reserved words in the Java programming language.
- * These words cannot be used as identifiers (i.e. names).
- * http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
- */
- @SuppressWarnings("nls")
- public static final String[] JAVA_RESERVED_WORDS = new String[] {
- "abstract",
- "assert", // jdk 1.4
- "boolean",
- "break",
- "byte",
- "case",
- "catch",
- "char",
- "class",
- "const", // unused
- "continue",
- "default",
- "do",
- "double",
- "else",
- "enum", // jdk 1.5
- "extends",
- "false",
- "final",
- "finally",
- "float",
- "for",
- "goto", // unused
- "if",
- "implements",
- "import",
- "instanceof",
- "int",
- "interface",
- "long",
- "native",
- "new",
- "null",
- "package",
- "private",
- "protected",
- "public",
- "return",
- "short",
- "static",
- "strictfp", // jdk 1.2
- "super",
- "switch",
- "synchronized",
- "this",
- "throw",
- "throws",
- "transient",
- "true",
- "try",
- "void",
- "volatile",
- "while"
- };
-
- /**
- * The set of reserved words in the Java programming language.
- * These words cannot be used as identifiers (i.e. names).
- * http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
- */
- public static final SortedSet<String> JAVA_RESERVED_WORDS_SET =
- Collections.unmodifiableSortedSet(CollectionTools.sortedSet(JAVA_RESERVED_WORDS));
-
- /**
- * Return the set of Java programming language reserved words.
- * These words cannot be used as identifiers (i.e. names).
- * http://java.sun.com/docs/books/tutorial/java/nutsandbolts/_keywords.html
- */
- public static Iterator<String> javaReservedWords() {
- return new ArrayIterator<String>(JAVA_RESERVED_WORDS);
- }
-
- /**
- * Return whether the specified string consists of Java identifier
- * characters (but may be a reserved word).
- */
- public static boolean stringConsistsOfJavaIdentifierCharacters(String string) {
- if (string.length() == 0) {
- return false;
- }
- return stringConsistsOfJavaIdentifierCharacters_(string.toCharArray());
- }
-
- /**
- * Return whether the specified string consists of Java identifier
- * characters (but may be a reserved word).
- */
- public static boolean stringConsistsOfJavaIdentifierCharacters(char[] string) {
- if (string.length == 0) {
- return false;
- }
- return stringConsistsOfJavaIdentifierCharacters_(string);
- }
-
- /**
- * The specified string must not be empty.
- */
- private static boolean stringConsistsOfJavaIdentifierCharacters_(char[] string) {
- if ( ! Character.isJavaIdentifierStart(string[0])) {
- return false;
- }
- for (int i = string.length; i-- > 1; ) { // NB: end with 1
- if ( ! Character.isJavaIdentifierPart(string[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified string is a valid Java identifier.
- */
- public static boolean stringIsLegalJavaIdentifier(String string) {
- return stringConsistsOfJavaIdentifierCharacters(string)
- && ! JAVA_RESERVED_WORDS_SET.contains(string);
- }
-
- /**
- * Return whether the specified string is a valid Java identifier.
- */
- public static boolean stringIsLegalJavaIdentifier(char[] string) {
- return stringConsistsOfJavaIdentifierCharacters(string)
- && ! JAVA_RESERVED_WORDS_SET.contains(new String(string));
- }
-
- /**
- * Convert the specified string to a valid Java identifier
- * by substituting an underscore '_' for any invalid characters
- * in the string and appending an underscore '_' to the string if
- * it is a Java reserved word.
- */
- public static String convertToJavaIdentifier(String string) {
- return convertToJavaIdentifier(string, '_');
- }
-
- /**
- * Convert the specified string to a valid Java identifier
- * by substituting the specified character for any invalid characters
- * in the string and, if necessary, appending the specified character
- * to the string until it is not a Java reserved word.
- */
- public static String convertToJavaIdentifier(String string, char c) {
- if (string.length() == 0) {
- return string;
- }
- if (JAVA_RESERVED_WORDS_SET.contains(string)) {
- // a reserved word is a valid identifier, we just need to tweak it a bit
- checkCharIsJavaIdentifierPart(c);
- return convertToJavaIdentifier(string + c, c);
- }
- char[] array = string.toCharArray();
- return convertToJavaIdentifier_(array, c) ? new String(array) : string;
- }
-
- /**
- * Convert the specified string to a valid Java identifier
- * by substituting an underscore '_' for any invalid characters
- * in the string and appending an underscore '_' to the string if
- * it is a Java reserved word.
- */
- public static char[] convertToJavaIdentifier(char[] string) {
- return convertToJavaIdentifier(string, '_');
- }
-
- /**
- * Convert the specified string to a valid Java identifier
- * by substituting the specified character for any invalid characters
- * in the string and, if necessary, appending the specified character
- * to the string until it is not a Java reserved word.
- */
- public static char[] convertToJavaIdentifier(char[] string, char c) {
- if (string.length == 0) {
- return string;
- }
- if (JAVA_RESERVED_WORDS_SET.contains(new String(string))) {
- // a reserved word is a valid identifier, we just need to tweak it a bit
- checkCharIsJavaIdentifierPart(c);
- return convertToJavaIdentifier(ArrayTools.add(string, c), c);
- }
- convertToJavaIdentifier_(string, c);
- return string;
- }
-
- /**
- * The specified string must not be empty.
- * Return whether the string was modified.
- */
- private static boolean convertToJavaIdentifier_(char[] string, char c) {
- boolean mod = false;
- if ( ! Character.isJavaIdentifierStart(string[0])) {
- checkCharIsJavaIdentifierStart(c);
- string[0] = c;
- mod = true;
- }
- checkCharIsJavaIdentifierPart(c);
- for (int i = string.length; i-- > 1; ) { // NB: end with 1
- if ( ! Character.isJavaIdentifierPart(string[i])) {
- string[i] = c;
- mod = true;
- }
- }
- return mod;
- }
-
- private static void checkCharIsJavaIdentifierStart(char c) {
- if ( ! Character.isJavaIdentifierStart(c)) {
- throw new IllegalArgumentException("invalid Java identifier start char: '" + c + '\''); //$NON-NLS-1$
- }
- }
-
- private static void checkCharIsJavaIdentifierPart(char c) {
- if ( ! Character.isJavaIdentifierPart(c)) {
- throw new IllegalArgumentException("invalid Java identifier part char: '" + c + '\''); //$NON-NLS-1$
- }
- }
-
- /**
- * Convert the specified method name to a property name.
- * @see Introspector#decapitalize(String)
- */
- public static String convertGetterSetterMethodNameToPropertyName(String methodName) {
- int beginIndex = 0;
- if (methodName.startsWith("get")) { //$NON-NLS-1$
- beginIndex = 3;
- } else if (methodName.startsWith("set")) { //$NON-NLS-1$
- beginIndex = 3;
- } else if (methodName.startsWith("is")) { //$NON-NLS-1$
- beginIndex = 2;
- } else {
- return methodName; // return method name unchanged?
- }
- return Introspector.decapitalize(methodName.substring(beginIndex));
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private NameTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NonEmptyStringFilter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NonEmptyStringFilter.java
deleted file mode 100644
index cc1c4bc77f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NonEmptyStringFilter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-import org.eclipse.jpt.common.utility.Filter;
-
-/**
- * This filter accepts only non-<code>null</code>, non-empty,
- * non-whitespace-only strings.
- */
-public class NonEmptyStringFilter
- implements Filter<String>, Serializable
-{
- public static final Filter<String> INSTANCE = new NonEmptyStringFilter();
-
- public static Filter<String> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private NonEmptyStringFilter() {
- super();
- }
-
- // accept only non-null objects
- public boolean accept(String string) {
- return StringTools.stringIsNotEmpty(string);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NonNullBooleanTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NonNullBooleanTransformer.java
deleted file mode 100644
index 0c9749fcd3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NonNullBooleanTransformer.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * A <code>NonNullBooleanTransformer</code> will transform a possibly-null
- * {@link Boolean} to a non-null {@link Boolean}:<ul>
- * <li>When the original {@link Boolean} is <em>not</em> <code>null</code>,
- * the transformer will return it unchanged.
- * <li>When the original {@link Boolean} is <code>null</code>,
- * the transformer will return its client-specified "null value"
- * ({@link Boolean#TRUE} or {@link Boolean#FALSE}).
- * </ul>
- */
-public final class NonNullBooleanTransformer
- implements Transformer<Boolean, Boolean>
-{
- // not null
- private final Boolean nullValue;
-
- /**
- * A {@link Transformer} that will return the original {@link Boolean} when
- * it is non-<code>null</code>; otherwise the {@link Transformer} will return
- * {@link Boolean#TRUE}.
- */
- public static final Transformer<Boolean, Boolean> TRUE = new NonNullBooleanTransformer(Boolean.TRUE);
-
- /**
- * A {@link Transformer} that will return the original {@link Boolean} when
- * it is non-<code>null</code>; otherwise the {@link Transformer} will return
- * {@link Boolean#FALSE}.
- */
- public static final Transformer<Boolean, Boolean> FALSE = new NonNullBooleanTransformer(Boolean.FALSE);
-
- /**
- * Return a transformer that will return the specified value if the original
- * value is <code>null</code>. Throw a {@link NullPointerException} if the
- * specified value is <code>null</code>.
- */
- public Transformer<Boolean, Boolean> valueOf(Boolean b) {
- return valueOf(b.booleanValue());
- }
-
- /**
- * Return a transformer that will return the {@link Boolean} corresponding
- * to the specified value if the original value is <code>null</code>.
- */
- public Transformer<Boolean, Boolean> valueOf(boolean b) {
- return b ? TRUE : FALSE;
- }
-
- /**
- * Ensure only 2 constant versions.
- */
- private NonNullBooleanTransformer(Boolean nullValue) {
- super();
- if (nullValue == null) {
- throw new NullPointerException();
- }
- this.nullValue = nullValue;
- }
-
- public Boolean transform(Boolean b) {
- return (b != null) ? b : this.nullValue;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.nullValue);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NotBooleanTransformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NotBooleanTransformer.java
deleted file mode 100644
index 9fee6aa2d9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NotBooleanTransformer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * A <code>NotBooleanTransformer</code> will transform a
- * {@link Boolean} to its NOT value:<ul>
- * <li>If the original {@link Boolean} is {@link Boolean#TRUE},
- * the transformer will return {@link Boolean#FALSE}.
- * <li>If the original {@link Boolean} is {@link Boolean#FALSE},
- * the transformer will return {@link Boolean#TRUE}.
- * <li>If the original {@link Boolean} is <code>null</code>,
- * the transformer will return <code>null</code>.
- * </ul>
- */
-public class NotBooleanTransformer
- implements BidiTransformer<Boolean, Boolean>, Serializable
-{
- public static final BidiTransformer<Boolean, Boolean> INSTANCE = new NotBooleanTransformer();
-
- public static BidiTransformer<Boolean, Boolean> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private NotBooleanTransformer() {
- super();
- }
-
- public Boolean transform(Boolean b) {
- return (b == null) ? null : BooleanTools.not(b);
- }
-
- public Boolean reverseTransform(Boolean b) {
- return (b == null) ? null : BooleanTools.not(b);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NotNullFilter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NotNullFilter.java
deleted file mode 100644
index c1e27e45b9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NotNullFilter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-import org.eclipse.jpt.common.utility.Filter;
-
-/**
- * This filter accepts only non-null objects.
- */
-public final class NotNullFilter<T>
- implements Filter<T>, Serializable
-{
- @SuppressWarnings("rawtypes")
- public static final Filter INSTANCE = new NotNullFilter();
-
- @SuppressWarnings("unchecked")
- public static <R> Filter<R> instance() {
- return INSTANCE;
- }
-
- // ensure single instance
- private NotNullFilter() {
- super();
- }
-
- // accept only non-null objects
- public boolean accept(T o) {
- return o != null;
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NullList.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NullList.java
deleted file mode 100644
index 826593db6b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/NullList.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
-
-/**
- * A "null" list is a bit different from an "empty" list: it allows clients to
- * add/remove elements to/from it but never changes. This is useful
- * for passing to methods that require a "collecting parameter" but the
- * client will ignore the resulting "collection".
- */
-public final class NullList<E>
- implements List<E>, Serializable
-{
- // singleton
- @SuppressWarnings("rawtypes")
- private static final NullList INSTANCE = new NullList();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <E> List<E> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private NullList() {
- super();
- }
-
- public boolean add(E o) {
- return false; // the list did not change
- }
-
- public void add(int index, E element) {
- // ignore
- }
-
- public boolean addAll(Collection<? extends E> c) {
- return false; // the list did not change
- }
-
- public boolean addAll(int index, Collection<? extends E> c) {
- return false; // the list did not change
- }
-
- public void clear() {
- // ignore
- }
-
- public boolean contains(Object o) {
- return false;
- }
-
- public boolean containsAll(Collection<?> c) {
- return c.isEmpty();
- }
-
- public E get(int index) {
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: 0"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public int indexOf(Object o) {
- return -1;
- }
-
- public boolean isEmpty() {
- return true;
- }
-
- public Iterator<E> iterator() {
- return EmptyIterator.instance();
- }
-
- public int lastIndexOf(Object o) {
- return -1;
- }
-
- public ListIterator<E> listIterator() {
- return EmptyListIterator.instance();
- }
-
- public ListIterator<E> listIterator(int index) {
- return EmptyListIterator.instance();
- }
-
- public boolean remove(Object o) {
- return false; // the list did not change
- }
-
- public E remove(int index) {
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: 0"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public boolean removeAll(Collection<?> c) {
- return false; // the list did not change
- }
-
- public boolean retainAll(Collection<?> c) {
- return false; // the list did not change
- }
-
- public E set(int index, E element) {
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: 0"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public int size() {
- return 0;
- }
-
- public List<E> subList(int fromIndex, int toIndex) {
- return this;
- }
-
- private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
- public Object[] toArray() {
- return EMPTY_OBJECT_ARRAY;
- }
-
- public <T> T[] toArray(T[] a) {
- return a;
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Queue.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Queue.java
deleted file mode 100644
index 4f46bbb4c4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Queue.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.NoSuchElementException;
-
-/**
- * Interface defining the classic queue behavior,
- * without the backdoors allowed by {@link java.util.Queue}.
- *
- * @param <E> the type of elements contained by the queue
- */
-public interface Queue<E> {
-
- /**
- * "Enqueue" the specified item to the tail of the queue.
- */
- void enqueue(E o);
-
- /**
- * "Dequeue" an item from the head of the queue.
- */
- E dequeue();
-
- /**
- * Return the item on the head of the queue
- * without removing it from the queue.
- */
- E peek();
-
- /**
- * Return whether the queue is empty.
- */
- boolean isEmpty();
-
-
- final class Empty<E>
- implements Queue<E>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Queue INSTANCE = new Empty();
- @SuppressWarnings("unchecked")
- public static <T> Queue<T> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Empty() {
- super();
- }
- public void enqueue(E o) {
- throw new UnsupportedOperationException();
- }
- public E dequeue() {
- throw new NoSuchElementException();
- }
- public E peek() {
- throw new NoSuchElementException();
- }
- public boolean isEmpty() {
- return true;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Range.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Range.java
deleted file mode 100644
index bc66046c0a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Range.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * This simple container class simply puts a bit of semantics
- * around a pair of numbers.
- */
-public class Range
- implements Cloneable, Serializable
-{
- /** The starting index of the range. */
- public final int start;
-
- /** The ending index of the range. */
- public final int end;
-
- /**
- * The size can be negative if the ending index
- * is less than the starting index.
- */
- public final int size;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct with the specified start and end,
- * both of which are immutable.
- */
- public Range(int start, int end) {
- super();
- this.start = start;
- this.end = end;
- this.size = end - start + 1;
- }
-
- /**
- * Return whether the range includes the specified
- * index.
- */
- public boolean includes(int index) {
- return (this.start <= index) && (index <= this.end);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if ( ! (o instanceof Range)) {
- return false;
- }
- Range otherRange = (Range) o;
- return (this.start == otherRange.start)
- && (this.end == otherRange.end);
- }
-
- @Override
- public int hashCode() {
- return this.start ^ this.end;
- }
-
- @Override
- public Range clone() {
- try {
- return (Range) super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public String toString() {
- return '[' + this.start + ", " + this.end + ']'; //$NON-NLS-1$
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ReflectionTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ReflectionTools.java
deleted file mode 100644
index d3617b9795..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ReflectionTools.java
+++ /dev/null
@@ -1,1544 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-
-/**
- * Convenience methods related to the <code>java.lang.reflect</code> package.
- * These methods provide shortcuts for manipulating objects via
- * reflection; particularly when dealing with fields and/or methods that
- * are not publicly accessible or are inherited.
- * <p>
- * In most cases, all exceptions are handled and wrapped in
- * {@link java.lang.RuntimeException}s; so these methods should
- * be used when there should be no problems using reflection (i.e.
- * the referenced members are presumably present etc.).
- * <p>
- * There are also a number of methods whose names
- * end with an underscore. These methods declare the expected checked
- * exceptions (e.g. {@link NoSuchMethodException}, {@link NoSuchFieldException}).
- * These methods can be used to probe
- * for methods, fields, etc. that should be present but might not be.
- */
-public final class ReflectionTools {
-
- public static final Class<?>[] ZERO_PARAMETER_TYPES = new Class[0];
- public static final Object[] ZERO_ARGUMENTS = new Object[0];
- private static final String CR = StringTools.CR;
-
- public static final Class<?> VOID_CLASS = void.class;
- public static final Class<java.lang.Void> VOID_WRAPPER_CLASS = java.lang.Void.class;
-
-
- // ********** fields **********
-
- /**
- * Get a field value, given the containing object and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * <p>
- * <code>Object.getFieldValue(String fieldName)</code>
- */
- public static Object getFieldValue(Object object, String fieldName) {
- try {
- return getFieldValue_(object, fieldName);
- } catch (NoSuchFieldException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedFieldName(object, fieldName), ex);
- } catch (IllegalAccessException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedFieldName(object, fieldName), ex);
- }
- }
-
- /**
- * Get a field value, given the containing object and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * <p>
- * <code>Object.getFieldValue(String fieldName)</code>
- */
- public static Object getFieldValue_(Object object, String fieldName)
- throws NoSuchFieldException, IllegalAccessException
- {
- return getField_(object, fieldName).get(object);
- }
-
- /**
- * Get a static field value, given the containing class and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * <p>
- * <code>Class.getStaticFieldValue(String fieldName)</code>
- */
- public static Object getStaticFieldValue(Class<?> javaClass, String fieldName) {
- try {
- return getStaticFieldValue_(javaClass, fieldName);
- } catch (NoSuchFieldException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedFieldName(javaClass, fieldName), ex);
- } catch (IllegalAccessException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedFieldName(javaClass, fieldName), ex);
- }
- }
-
- /**
- * Get a static field value, given the containing class and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * <p>
- * <code>Class.getStaticFieldValue(String fieldName)</code>
- */
- public static Object getStaticFieldValue_(Class<?> javaClass, String fieldName)
- throws NoSuchFieldException, IllegalAccessException
- {
- return getField_(javaClass, fieldName).get(null);
- }
-
- /**
- * Set a field value, given the containing object, field name, and new value.
- * Useful for accessing private, package, or protected fields.
- * <p>
- * <code>Object.setFieldValue(String fieldName, Object value)</code>
- */
- public static void setFieldValue(Object object, String fieldName, Object value) {
- try {
- setFieldValue_(object, fieldName, value);
- } catch (NoSuchFieldException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedFieldName(object, fieldName), ex);
- } catch (IllegalAccessException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedFieldName(object, fieldName), ex);
- }
- }
-
- /**
- * Set a field value, given the containing object, field name, and new value.
- * Useful for accessing private, package, or protected fields.
- * <p>
- * <code>Object.setFieldValue(String fieldName, Object value)</code>
- */
- public static void setFieldValue_(Object object, String fieldName, Object value)
- throws NoSuchFieldException, IllegalAccessException
- {
- getField_(object, fieldName).set(object, value);
- }
-
- /**
- * Set a static field value, given the containing class, field name, and new value.
- * Useful for accessing private, package, or protected fields.
- * <p>
- * <code>Class.setStaticFieldValue(String fieldName, Object value)</code>
- */
- public static void setStaticFieldValue(Class<?> javaClass, String fieldName, Object value) {
- try {
- setStaticFieldValue_(javaClass, fieldName, value);
- } catch (NoSuchFieldException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedFieldName(javaClass, fieldName), ex);
- } catch (IllegalAccessException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedFieldName(javaClass, fieldName), ex);
- }
- }
-
- /**
- * Set a static field value, given the containing class, field name, and new value.
- * Useful for accessing private, package, or protected fields.
- * <p>
- * <code>Class.setStaticFieldValue(String fieldName, Object value)</code>
- */
- public static void setStaticFieldValue_(Class<?> javaClass, String fieldName, Object value)
- throws NoSuchFieldException, IllegalAccessException
- {
- getField_(javaClass, fieldName).set(null, value);
- }
-
- /**
- * Convenience method.
- * Return a field for the specified object and field name.
- * If the object's class does not directly
- * define the field, look for it in the class's superclasses.
- * Make any private/package/protected field accessible.
- * <p>
- * <code>Object.getField(String fieldName)</code>
- */
- public static Field getField(Object object, String fieldName) {
- try {
- return getField_(object, fieldName);
- } catch (NoSuchFieldException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedFieldName(object, fieldName), ex);
- }
- }
-
- /**
- * Convenience method.
- * Return a field for the specified object and field name.
- * If the object's class does not directly
- * define the field, look for it in the class's superclasses.
- * Make any private/package/protected field accessible.
- * <p>
- * <code>Object.getField(String fieldName)</code>
- */
- public static Field getField_(Object object, String fieldName)
- throws NoSuchFieldException
- {
- return getField_(object.getClass(), fieldName);
- }
-
- /**
- * Return a field for the specified class and field name.
- * If the class does not directly
- * define the field, look for it in the class's superclasses.
- * Make any private/package/protected field accessible.
- */
- public static Field getField(Class<?> javaClass, String fieldName) {
- try {
- return getField_(javaClass, fieldName);
- } catch (NoSuchFieldException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedFieldName(javaClass, fieldName), ex);
- }
- }
-
- /**
- * Return a field for the specified class and field name.
- * If the class does not directly
- * define the field, look for it in the class's superclasses.
- * Make any private/package/protected field accessible.
- */
- public static Field getField_(Class<?> javaClass, String fieldName)
- throws NoSuchFieldException
- {
- Field field = null;
- try {
- field = javaClass.getDeclaredField(fieldName);
- } catch (NoSuchFieldException ex) {
- Class<?> superclass = javaClass.getSuperclass();
- if (superclass == null) {
- throw ex;
- }
- return getField_(superclass, fieldName); // recurse
- }
- field.setAccessible(true);
- return field;
- }
-
- /**
- * Return all the fields for the
- * specified class, including inherited fields.
- * Make any private/package/protected fields accessible.
- * <p>
- * <code>Class.getAllFields()</code>
- */
- public static Iterable<Field> getAllFields(Class<?> javaClass) {
- ArrayList<Field> fields = new ArrayList<Field>();
- for (Class<?> tempClass = javaClass; tempClass != null; tempClass = tempClass.getSuperclass()) {
- addDeclaredFieldsTo(tempClass, fields);
- }
- return fields;
- }
-
- /*
- * Add the declared fields for the specified class
- * to the specified list.
- */
- private static void addDeclaredFieldsTo(Class<?> javaClass, ArrayList<Field> fields) {
- for (Field field : getDeclaredFields(javaClass)) {
- fields.add(field);
- }
- }
-
- /**
- * Return the declared fields for the specified class.
- * Make any private/package/protected fields accessible.
- * <p>
- * <code>Class.getAccessibleDeclaredFields()</code>
- */
- public static Iterable<Field> getDeclaredFields(Class<?> javaClass) {
- Field[] fields = javaClass.getDeclaredFields();
- for (Field field : fields) {
- field.setAccessible(true);
- }
- return new ArrayIterable<Field>(fields);
- }
-
-
- // ********** methods **********
-
- /**
- * Convenience method.
- * Execute a zero-argument method, given the receiver and method name.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Object.execute(String methodName)</code>
- */
- public static Object executeMethod(Object receiver, String methodName) {
- return executeMethod(receiver, methodName, ZERO_PARAMETER_TYPES, ZERO_ARGUMENTS);
- }
-
- /**
- * Convenience method.
- * Execute a one-argument method, given the receiver,
- * method name, parameter type, and argument.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Object.execute(String methodName, Class<?> parameterType, Object argument)</code>
- */
- public static Object executeMethod(Object receiver, String methodName, Class<?> parameterType, Object argument) {
- return executeMethod(receiver, methodName, new Class[] {parameterType}, new Object[] {argument});
- }
-
- /**
- * Execute a method, given the receiver,
- * method name, parameter types, and arguments.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Object.execute(String methodName, Class<?>[] parameterTypes, Object[] arguments)</code>
- */
- public static Object executeMethod(Object receiver, String methodName, Class<?>[] parameterTypes, Object[] arguments) {
- return executeMethod(getMethod(receiver, methodName, parameterTypes), receiver, arguments);
- }
-
- /**
- * Execute the specified method, given the receiver and arguments.
- * Return its result.
- * Useful for invoking cached methods.
- */
- public static Object executeMethod(Method method, Object receiver, Object[] arguments) {
- try {
- return method.invoke(receiver, arguments);
- } catch (IllegalAccessException ex) {
- throw new RuntimeException(ex + CR + method, ex);
- } catch (InvocationTargetException ex) {
- throw new RuntimeException(method + CR + ex.getTargetException(), ex);
- }
- }
-
- /**
- * Convenience method.
- * Execute a zero-argument method,
- * given the receiver and method name.
- * Return its result.
- * Throw an exception if the method is not defined.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Object.execute(String methodName)</code>
- */
- public static Object executeMethod_(Object receiver, String methodName)
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
- {
- return executeMethod_(receiver, methodName, ZERO_PARAMETER_TYPES, ZERO_ARGUMENTS);
- }
-
- /**
- * Convenience method.
- * Execute a method, given the receiver,
- * method name, parameter type, and argument.
- * Return its result.
- * Throw an exception if the method is not defined.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Object.execute(String methodName, Class<?> parameterType, Object argument)</code>
- */
- public static Object executeMethod_(Object receiver, String methodName, Class<?> parameterType, Object argument)
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
- {
- return executeMethod_(receiver, methodName, new Class[] {parameterType}, new Object[] {argument});
- }
-
- /**
- * Execute a method, given the receiver,
- * method name, parameter types, and arguments.
- * Return its result.
- * Throw an exception if the method is not defined.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Object.execute(String methodName, Class<?>[] parameterTypes, Object[] arguments)</code>
- */
- public static Object executeMethod_(Object receiver, String methodName, Class<?>[] parameterTypes, Object[] arguments)
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
- {
- return getMethod_(receiver, methodName, parameterTypes).invoke(receiver, arguments);
- }
-
- /**
- * Convenience method.
- * Execute a zero-argument static method,
- * given the class and method name.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Class.executeStaticMethod(String methodName)</code>
- */
- public static Object executeStaticMethod(Class<?> javaClass, String methodName) {
- return executeStaticMethod(javaClass, methodName, ZERO_PARAMETER_TYPES, ZERO_ARGUMENTS);
- }
-
- /**
- * Convenience method.
- * Execute a static method, given the class,
- * method name, parameter type, and argument.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Class.executeStaticMethod(String methodName, Class<?> parameterType, Object argument)</code>
- */
- public static Object executeStaticMethod(Class<?> javaClass, String methodName, Class<?> parameterType, Object argument) {
- return executeStaticMethod(javaClass, methodName, new Class[] {parameterType}, new Object[] {argument});
- }
-
- /**
- * Execute a static method, given the class,
- * method name, parameter types, and arguments.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Class.executeStaticMethod(String methodName, Class<?>[] parameterTypes, Object[] arguments)</code>
- */
- public static Object executeStaticMethod(Class<?> javaClass, String methodName, Class<?>[] parameterTypes, Object[] arguments) {
- try {
- return executeStaticMethod_(javaClass, methodName, parameterTypes, arguments);
- } catch (NoSuchMethodException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedMethodSignature(javaClass, methodName, parameterTypes), ex);
- } catch (IllegalAccessException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedMethodSignature(javaClass, methodName, parameterTypes), ex);
- } catch (InvocationTargetException ex) {
- throw new RuntimeException(buildFullyQualifiedMethodSignature(javaClass, methodName, parameterTypes) + CR + ex.getTargetException(), ex);
- }
- }
-
- /**
- * Convenience method.
- * Execute a zero-argument static method,
- * given the class and method name.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Class.executeStaticMethod(String methodName)</code>
- */
- public static Object executeStaticMethod_(Class<?> javaClass, String methodName)
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
- {
- return executeStaticMethod_(javaClass, methodName, ZERO_PARAMETER_TYPES, ZERO_ARGUMENTS);
- }
-
- /**
- * Convenience method.
- * Execute a static method, given the class,
- * method name, parameter type, and argument.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Class.executeStaticMethod(String methodName, Class<?> parameterType, Object argument)</code>
- */
- public static Object executeStaticMethod_(Class<?> javaClass, String methodName, Class<?> parameterType, Object argument)
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
- {
- return executeStaticMethod_(javaClass, methodName, new Class[] {parameterType}, new Object[] {argument});
- }
-
- /**
- * Execute a static method, given the class,
- * method name, parameter types, and arguments.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * <p>
- * <code>Class.executeStaticMethod(String methodName, Class<?>[] parameterTypes, Object[] arguments)</code>
- */
- public static Object executeStaticMethod_(Class<?> javaClass, String methodName, Class<?>[] parameterTypes, Object[] arguments)
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
- {
- return getStaticMethod_(javaClass, methodName, parameterTypes).invoke(null, arguments);
- }
-
- /**
- * Convenience method.
- * Return a zero-argument method for the specified class
- * and method name. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod(Class<?> javaClass, String methodName) {
- return getMethod(javaClass, methodName, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Convenience method.
- * Return a zero-argument method for the specified class
- * and method name. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod_(Class<?> javaClass, String methodName)
- throws NoSuchMethodException
- {
- return getMethod_(javaClass, methodName, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Convenience method.
- * Return a method for the specified class, method name,
- * and formal parameter type. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod(Class<?> javaClass, String methodName, Class<?> parameterType) {
- return getMethod(javaClass, methodName, new Class[] {parameterType});
- }
-
- /**
- * Convenience method.
- * Return a method for the specified class, method name,
- * and formal parameter type. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod_(Class<?> javaClass, String methodName, Class<?> parameterType)
- throws NoSuchMethodException
- {
- return getMethod_(javaClass, methodName, new Class[] {parameterType});
- }
-
- /**
- * Return a method for the specified class, method name,
- * and formal parameter types. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod(Class<?> javaClass, String methodName, Class<?>[] parameterTypes) {
- try {
- return getMethod_(javaClass, methodName, parameterTypes);
- } catch (NoSuchMethodException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedMethodSignature(javaClass, methodName, parameterTypes), ex);
- }
- }
-
- /**
- * Return a method for the specified class, method name,
- * and formal parameter types. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod_(Class<?> javaClass, String methodName, Class<?>[] parameterTypes)
- throws NoSuchMethodException
- {
- Method method = null;
- try {
- method = javaClass.getDeclaredMethod(methodName, parameterTypes);
- } catch (NoSuchMethodException ex) {
- Class<?> superclass = javaClass.getSuperclass();
- if (superclass == null) {
- throw ex;
- }
- // recurse
- return getMethod_(superclass, methodName, parameterTypes);
- }
- method.setAccessible(true);
- return method;
- }
-
- /**
- * Convenience method.
- * Return a zero-argument method for the specified object
- * and method name. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod(Object object, String methodName) {
- return getMethod(object.getClass(), methodName);
- }
-
- /**
- * Convenience method.
- * Return a zero-argument method for the specified object
- * and method name. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod_(Object object, String methodName)
- throws NoSuchMethodException
- {
- return getMethod_(object.getClass(), methodName);
- }
-
- /**
- * Convenience method.
- * Return a method for the specified object, method name,
- * and formal parameter types. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod(Object object, String methodName, Class<?>[] parameterTypes) {
- return getMethod(object.getClass(), methodName, parameterTypes);
- }
-
- /**
- * Convenience method.
- * Return a method for the specified object, method name,
- * and formal parameter types. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod_(Object object, String methodName, Class<?>[] parameterTypes)
- throws NoSuchMethodException
- {
- return getMethod_(object.getClass(), methodName, parameterTypes);
- }
-
- /**
- * Convenience method.
- * Return a method for the specified object, method name,
- * and formal parameter type. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod(Object object, String methodName, Class<?> parameterType) {
- return getMethod(object.getClass(), methodName, parameterType);
- }
-
- /**
- * Convenience method.
- * Return a method for the specified object, method name,
- * and formal parameter type. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getMethod_(Object object, String methodName, Class<?> parameterType)
- throws NoSuchMethodException
- {
- return getMethod_(object.getClass(), methodName, parameterType);
- }
-
- /**
- * Convenience method.
- * Return a zero-argument static method for the specified class
- * and method name. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getStaticMethod(Class<?> javaClass, String methodName) {
- return getStaticMethod(javaClass, methodName, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Convenience method.
- * Return a static method for the specified class, method name,
- * and formal parameter type. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getStaticMethod(Class<?> javaClass, String methodName, Class<?> parameterTypes) {
- return getStaticMethod(javaClass, methodName, new Class[] {parameterTypes});
- }
-
- /**
- * Return a static method for the specified class, method name,
- * and formal parameter types. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getStaticMethod(Class<?> javaClass, String methodName, Class<?>[] parameterTypes) {
- try {
- return getStaticMethod_(javaClass, methodName, parameterTypes);
- } catch (NoSuchMethodException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedMethodSignature(javaClass, methodName, parameterTypes), ex);
- }
- }
-
- /**
- * Convenience method.
- * Return a zero-argument static method for the specified class
- * and method name. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getStaticMethod_(Class<?> javaClass, String methodName)
- throws NoSuchMethodException
- {
- return getStaticMethod_(javaClass, methodName, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Convenience method.
- * Return a static method for the specified class, method name,
- * and formal parameter type. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getStaticMethod_(Class<?> javaClass, String methodName, Class<?> parameterTypes)
- throws NoSuchMethodException
- {
- return getStaticMethod_(javaClass, methodName, new Class[] {parameterTypes});
- }
-
- /**
- * Return a static method for the specified class, method name,
- * and formal parameter types. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Make any private/package/protected method accessible.
- */
- public static Method getStaticMethod_(Class<?> javaClass, String methodName, Class<?>[] parameterTypes)
- throws NoSuchMethodException
- {
- Method method = getMethod_(javaClass, methodName, parameterTypes);
- if (Modifier.isStatic(method.getModifiers())) {
- return method;
- }
- throw new NoSuchMethodException(buildFullyQualifiedMethodSignature(javaClass, methodName, parameterTypes));
- }
-
- /**
- * Return all the methods for the
- * specified class, including inherited methods.
- * Make any private/package/protected methods accessible.
- * <p>
- * <code>Class.getAllMethods()</code>
- */
- public static Iterable<Method> getAllMethods(Class<?> javaClass) {
- ArrayList<Method> methods = new ArrayList<Method>();
- for (Class<?> tempClass = javaClass; tempClass != null; tempClass = tempClass.getSuperclass()) {
- addDeclaredMethodsTo(tempClass, methods);
- }
- return methods;
- }
-
- /*
- * Add the declared methods for the specified class
- * to the specified list.
- */
- private static void addDeclaredMethodsTo(Class<?> javaClass, ArrayList<Method> methods) {
- for (Method method : getDeclaredMethods(javaClass)) {
- methods.add(method);
- }
- }
-
- /**
- * Return the declared methods for the specified class.
- * Make any private/package/protected methods accessible.
- * <p>
- * <code>Class.getAccessibleDeclaredMethods()</code>
- */
- public static Iterable<Method> getDeclaredMethods(Class<?> javaClass) {
- Method[] methods = javaClass.getDeclaredMethods();
- for (Method method : methods) {
- method.setAccessible(true);
- }
- return new ArrayIterable<Method>(methods);
- }
-
-
- // ********** constructors **********
-
- /**
- * Return the default (zero-argument) constructor
- * for the specified class.
- * Make any private/package/protected constructor accessible.
- * <p>
- * <code>Class.getDefaultConstructor()</code>
- */
- public static <T> Constructor<T> getDefaultConstructor(Class<T> javaClass) {
- return getConstructor(javaClass);
- }
-
- /**
- * Convenience method.
- * Return the default (zero-argument) constructor
- * for the specified class.
- * Make any private/package/protected constructor accessible.
- * <p>
- * <code>Class.getConstructor()</code>
- */
- public static <T> Constructor<T> getConstructor(Class<T> javaClass) {
- return getConstructor(javaClass, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Convenience method.
- * Return the constructor for the specified class
- * and formal parameter type.
- * Make any private/package/protected constructor accessible.
- * <p>
- * <code>Class.getConstructor(Class<?> parameterType)</code>
- */
- public static <T> Constructor<T> getConstructor(Class<T> javaClass, Class<?> parameterType) {
- return getConstructor(javaClass, new Class[] {parameterType});
- }
-
- /**
- * Return the constructor for the specified class
- * and formal parameter types.
- * Make any private/package/protected constructor accessible.
- * <p>
- * <code>Class.getConstructor(Class<?>[] parameterTypes)</code>
- */
- public static <T> Constructor<T> getConstructor(Class<T> javaClass, Class<?>[] parameterTypes) {
- try {
- return getConstructor_(javaClass, parameterTypes);
- } catch (NoSuchMethodException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedConstructorSignature(javaClass, parameterTypes), ex);
- }
- }
-
- /**
- * Return the default (zero-argument) constructor
- * for the specified class.
- * Make any private/package/protected constructor accessible.
- * <p>
- * <code>Class.getDefaultConstructor()</code>
- */
- public static <T> Constructor<T> getDefaultConstructor_(Class<T> javaClass)
- throws NoSuchMethodException
- {
- return getConstructor_(javaClass);
- }
-
- /**
- * Convenience method.
- * Return the default (zero-argument) constructor
- * for the specified class.
- * Make any private/package/protected constructor accessible.
- * <p>
- * <code>Class.getConstructor()</code>
- */
- public static <T> Constructor<T> getConstructor_(Class<T> javaClass)
- throws NoSuchMethodException
- {
- return getConstructor_(javaClass, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Convenience method.
- * Return the constructor for the specified class
- * and formal parameter type.
- * Make any private/package/protected constructor accessible.
- * <p>
- * <code>Class.getConstructor(Class<?> parameterType)</code>
- */
- public static <T> Constructor<T> getConstructor_(Class<T> javaClass, Class<?> parameterType)
- throws NoSuchMethodException
- {
- return getConstructor_(javaClass, new Class[] {parameterType});
- }
-
- /**
- * Return the constructor for the specified class
- * and formal parameter types.
- * Make any private/package/protected constructor accessible.
- * <p>
- * <code>Class.getConstructor(Class<?>[] parameterTypes)</code>
- */
- public static <T> Constructor<T> getConstructor_(Class<T> javaClass, Class<?>[] parameterTypes)
- throws NoSuchMethodException
- {
- Constructor<T> constructor = javaClass.getDeclaredConstructor(parameterTypes);
- constructor.setAccessible(true);
- return constructor;
- }
-
- /**
- * Return the declared constructors for the specified class.
- * Make any private/package/protected constructors accessible.
- * <p>
- * <code>Class.getAccessibleDeclaredConstructors()</code>
- */
- public static <T> Iterable<Constructor<T>> getDeclaredConstructors(Class<T> javaClass) {
- @SuppressWarnings("unchecked")
- Constructor<T>[] constructors = javaClass.getDeclaredConstructors();
- for (Constructor<T> constructor : constructors) {
- constructor.setAccessible(true);
- }
- return new ArrayIterable<Constructor<T>>(constructors);
- }
-
-
- // ********** classes **********
-
- /**
- * Convenience method.
- * Return the specified class (without the checked exception).
- */
- public static Class<?> classForName(String className) {
- try {
- return Class.forName(className);
- } catch (ClassNotFoundException ex) {
- throw new RuntimeException(className, ex);
- }
- }
-
- /**
- * Convenience method.
- * Return the specified class (without the checked exception).
- */
- public static Class<?> classForName(String className, boolean initialize, ClassLoader classLoader) {
- try {
- return Class.forName(className, initialize, classLoader);
- } catch (ClassNotFoundException ex) {
- throw new RuntimeException(className, ex);
- }
- }
-
- /**
- * Return the "array depth" of the specified class.
- * The depth is the number of dimensions for an array type.
- * Non-array types have a depth of zero.
- * <p>
- * <code>Class.getArrayDepth()</code>
- */
- public static int getArrayDepth(Class<?> javaClass) {
- int depth = 0;
- while (javaClass.isArray()) {
- depth++;
- javaClass = javaClass.getComponentType();
- }
- return depth;
- }
-
- /**
- * Return the "element type" of the specified class.
- * The element type is the base type held by an array type.
- * A non-array type simply returns itself.
- * <p>
- * <code>Class.getElementType()</code>
- */
- public static Class<?> getElementType(Class<?> javaClass) {
- while (javaClass.isArray()) {
- javaClass = javaClass.getComponentType();
- }
- return javaClass;
- }
-
- /**
- * Return the wrapper class corresponding to the specified
- * primitive class. Return <code>null</code> if the specified class
- * is not a primitive class.
- * <p>
- * <code>Class.getWrapperClass()</code>
- */
- public static Class<?> getWrapperClass(Class<?> primitiveClass) {
- for (Primitive primitive : PRIMITIVES) {
- if (primitive.javaClass == primitiveClass) {
- return primitive.wrapperClass;
- }
- }
- return null;
- }
-
- /**
- * Return whether the specified class is a primitive wrapper
- * class (i.e. <code>java.lang.Void</code> or one of the primitive
- * variable wrapper classes, <code>java.lang.Boolean</code>,
- * <code>java.lang.Integer</code>, <code>java.lang.Float</code>, etc.).
- * <p>
- * <strong>NB:</strong> <code>void.class.isPrimitive() == true</code>
- * <p>
- * <code>Class.isPrimitiveWrapper()</code>
- */
- public static boolean classIsPrimitiveWrapper(Class<?> javaClass) {
- if (javaClass.isArray() || (javaClass.getName().length() > MAX_PRIMITIVE_WRAPPER_CLASS_NAME_LENGTH)) {
- return false; // performance tweak
- }
- for (Primitive primitive : PRIMITIVES) {
- if (javaClass == primitive.wrapperClass) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified class is a "variable" primitive wrapper
- * class (i.e. <code>java.lang.Boolean</code>,
- * <code>java.lang.Integer</code>, <code>java.lang.Float</code>, etc.,
- * but not <code>java.lang.Void</code>).
- * <p>
- * <strong>NB:</strong> <code>void.class.isPrimitive() == true</code>
- * <p>
- * <code>Class.isVariablePrimitiveWrapper()</code>
- */
- public static boolean classIsVariablePrimitiveWrapper(Class<?> javaClass) {
- return classIsPrimitiveWrapper(javaClass)
- && (javaClass != VOID_WRAPPER_CLASS);
- }
-
- /**
- * Return whether the specified class is a "variable" primitive
- * class (i.e. <code>boolean</code>, <code>int</code>,
- * <code>float</code>, etc., but not <code>void</code>).
- * <p>
- * <strong>NB:</strong> <code>void.class.isPrimitive() == true</code>
- * <p>
- * <code>Class.isVariablePrimitive()</code>
- */
- public static boolean classIsVariablePrimitive(Class<?> javaClass) {
- return javaClass.isPrimitive() && (javaClass != VOID_CLASS);
- }
-
- /**
- * Return the primitive class for the specified primitive class code.
- * Return <code>null</code> if the specified code
- * is not a primitive class code.
- * @see java.lang.Class#getName()
- */
- public static Class<?> getClassForCode(int classCode) {
- return getClassForCode((char) classCode);
- }
-
- /**
- * Return the primitive class for the specified primitive class code.
- * Return <code>null</code> if the specified code
- * is not a primitive class code.
- * @see java.lang.Class#getName()
- */
- public static Class<?> getClassForCode(char classCode) {
- for (Primitive primitive : PRIMITIVES) {
- if (primitive.code == classCode) {
- return primitive.javaClass;
- }
- }
- return null;
- }
-
- /**
- * Return the class code for the specified primitive class.
- * Return <code>0</code> if the specified class
- * is not a primitive class.
- * @see java.lang.Class#getName()
- */
- public static char getCodeForClass(Class<?> primitiveClass) {
- if (( ! primitiveClass.isArray()) && (primitiveClass.getName().length() <= MAX_PRIMITIVE_CLASS_NAME_LENGTH)) {
- for (Primitive primitive : PRIMITIVES) {
- if (primitive.javaClass == primitiveClass) {
- return primitive.code;
- }
- }
- }
- return 0;
- }
-
-
- // ********** instantiation **********
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * <p>
- * <code>Class.newInstance()</code>
- */
- public static Object newInstance(String className) {
- return newInstance(className, null);
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter type and argument.
- * <p>
- * <code>Class.newInstance(Class<?> parameterType, Object argument)</code>
- */
- public static Object newInstance(String className, Class<?> parameterType, Object argument) {
- return newInstance(className, parameterType, argument, null);
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and arguments.
- * <p>
- * <code>Class.newInstance(Class<?>[] parameterTypes, Object[] arguments)</code>
- */
- public static Object newInstance(String className, Class<?>[] parameterTypes, Object[] arguments) {
- return newInstance(className, parameterTypes, arguments, null);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * Use the specified class loader to load the class.
- * <p>
- * <code>Class.newInstance()</code>
- */
- public static Object newInstance(String className, ClassLoader classLoader) {
- return newInstance(classForName(className, false, classLoader));
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter type and argument.
- * <p>
- * <code>Class.newInstance(Class<?> parameterType, Object argument)</code>
- */
- public static Object newInstance(String className, Class<?> parameterType, Object argument, ClassLoader classLoader) {
- return newInstance(classForName(className, false, classLoader), parameterType, argument);
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and arguments.
- * <p>
- * <code>Class.newInstance(Class<?>[] parameterTypes, Object[] arguments)</code>
- */
- public static Object newInstance(String className, Class<?>[] parameterTypes, Object[] arguments, ClassLoader classLoader) {
- return newInstance(classForName(className, false, classLoader), parameterTypes, arguments);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * <p>
- * <code>Class.newInstance()</code>
- */
- public static <T> T newInstance(Class<T> javaClass) {
- return newInstance(javaClass, ZERO_PARAMETER_TYPES, ZERO_ARGUMENTS);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * given the constructor parameter type and argument.
- * <p>
- * <code>Class.newInstance(Class<?> parameterType, Object argument)</code>
- */
- public static <T> T newInstance(Class<T> javaClass, Class<?> parameterType, Object argument) {
- return newInstance(javaClass, new Class[] {parameterType}, new Object[] {argument});
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and arguments.
- * <p>
- * <code>Class.newInstance(Class<?>[] parameterTypes, Object[] arguments)</code>
- */
- public static <T> T newInstance(Class<T> javaClass, Class<?>[] parameterTypes, Object[] arguments) {
- try {
- return newInstance_(javaClass, parameterTypes, arguments);
- } catch (InstantiationException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedConstructorSignature(javaClass, parameterTypes), ex);
- } catch (IllegalAccessException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedConstructorSignature(javaClass, parameterTypes), ex);
- } catch (InvocationTargetException ex) {
- throw new RuntimeException(buildFullyQualifiedConstructorSignature(javaClass, parameterTypes) + CR + ex.getTargetException(), ex);
- } catch (NoSuchMethodException ex) {
- throw new RuntimeException(ex + CR + buildFullyQualifiedConstructorSignature(javaClass, parameterTypes), ex);
- }
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * <p>
- * <code>Class.newInstance()</code>
- */
- public static <T> T newInstance_(Class<T> javaClass)
- throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
- {
- return newInstance_(javaClass, ZERO_PARAMETER_TYPES, ZERO_ARGUMENTS);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * given the constructor parameter type and argument.
- * <p>
- * <code>Class.newInstance(Class<?> parameterType, Object argument)</code>
- */
- public static <T> T newInstance_(Class<T> javaClass, Class<?> parameterType, Object argument)
- throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
- {
- return newInstance_(javaClass, new Class[] {parameterType}, new Object[] {argument});
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and arguments.
- * <p>
- * <code>Class.newInstance(Class<?>[] parameterTypes, Object[] arguments)</code>
- */
- public static <T> T newInstance_(Class<T> javaClass, Class<?>[] parameterTypes, Object[] arguments)
- throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException
- {
- return getConstructor_(javaClass, parameterTypes).newInstance(arguments);
- }
-
-
- // ********** type declarations **********
-
- /**
- * Return the class for the specified "type declaration".
- */
- public static Class<?> getClassForTypeDeclaration(String typeDeclaration) {
- return getClassForTypeDeclaration(typeDeclaration, null);
- }
-
- /**
- * Return the class for the specified "type declaration".
- */
- public static Class<?> getClassForTypeDeclaration_(String typeDeclaration)
- throws ClassNotFoundException
- {
- return getClassForTypeDeclaration_(typeDeclaration, null);
- }
-
- /**
- * Return the class for the specified "type declaration",
- * using the specified class loader.
- */
- public static Class<?> getClassForTypeDeclaration(String typeDeclaration, ClassLoader classLoader) {
- TypeDeclaration td = buildTypeDeclaration(typeDeclaration);
- return getClassForTypeDeclaration(td.elementTypeName, td.arrayDepth, classLoader);
- }
-
- /**
- * Return the class for the specified "type declaration",
- * using the specified class loader.
- */
- public static Class<?> getClassForTypeDeclaration_(String typeDeclaration, ClassLoader classLoader)
- throws ClassNotFoundException
- {
- TypeDeclaration td = buildTypeDeclaration(typeDeclaration);
- return getClassForTypeDeclaration_(td.elementTypeName, td.arrayDepth, classLoader);
- }
-
- private static TypeDeclaration buildTypeDeclaration(String typeDeclaration) {
- typeDeclaration = StringTools.removeAllWhitespace(typeDeclaration);
- int arrayDepth = getArrayDepthForTypeDeclaration_(typeDeclaration);
- String elementTypeName = getElementTypeNameForTypeDeclaration_(typeDeclaration, arrayDepth);
- return new TypeDeclaration(elementTypeName, arrayDepth);
- }
-
- /**
- * Return the array depth for the specified "type declaration"; e.g.<ul>
- * <li><code>"int[]"</code> returns <code>1</code>
- * <li><code>"java.lang.String[][][]"</code> returns <code>3</code>
- * </ul>
- */
- public static int getArrayDepthForTypeDeclaration(String typeDeclaration) {
- return getArrayDepthForTypeDeclaration_(StringTools.removeAllWhitespace(typeDeclaration));
- }
-
- /**
- * pre-condition: no whitespace in the type declaration.
- */
- private static int getArrayDepthForTypeDeclaration_(String typeDeclaration) {
- int last = typeDeclaration.length() - 1;
- int depth = 0;
- int close = last;
- while (typeDeclaration.charAt(close) == ']') {
- if (typeDeclaration.charAt(close - 1) == '[') {
- depth++;
- } else {
- throw new IllegalArgumentException("invalid type declaration: " + typeDeclaration); //$NON-NLS-1$
- }
- close = last - (depth * 2);
- }
- return depth;
- }
-
- /**
- * Return the element type name for the specified "type declaration"; e.g.<ul>
- * <li><code>"int[]"</code> returns <code>"int"</code>
- * <li><code>"java.lang.String[][][]"</code> returns <code>"java.lang.String"</code>
- * </ul>
- */
- public static String getElementTypeNameForTypeDeclaration(String typeDeclaration) {
- typeDeclaration = StringTools.removeAllWhitespace(typeDeclaration);
- return getElementTypeNameForTypeDeclaration_(typeDeclaration, getArrayDepthForTypeDeclaration_(typeDeclaration));
- }
-
- /**
- * Return the element type name for the specified "type declaration"; e.g.<ul>
- * <li><code>"int[]"</code> returns <code>"int"</code>
- * <li><code>"java.lang.String[][][]"</code> returns <code>"java.lang.String"</code>
- * </ul>
- * Useful for clients that have already queried the type declaration's array depth.
- */
- public static String getElementTypeNameForTypeDeclaration(String typeDeclaration, int arrayDepth) {
- return getElementTypeNameForTypeDeclaration_(StringTools.removeAllWhitespace(typeDeclaration), arrayDepth);
- }
-
- /**
- * pre-condition: no whitespace in the type declaration.
- */
- private static String getElementTypeNameForTypeDeclaration_(String typeDeclaration, int arrayDepth) {
- return typeDeclaration.substring(0, typeDeclaration.length() - (arrayDepth * 2));
- }
-
- /**
- * Return the class for the specified "type declaration".
- */
- public static Class<?> getClassForTypeDeclaration(String elementTypeName, int arrayDepth) {
- return getClassForTypeDeclaration(elementTypeName, arrayDepth, null);
- }
-
- /**
- * Return the class for the specified "type declaration".
- */
- public static Class<?> getClassForTypeDeclaration_(String elementTypeName, int arrayDepth)
- throws ClassNotFoundException
- {
- return getClassForTypeDeclaration_(elementTypeName, arrayDepth, null);
- }
-
- /**
- * Return the class for the specified "type declaration",
- * using the specified class loader.
- */
- public static Class<?> getClassForTypeDeclaration(String elementTypeName, int arrayDepth, ClassLoader classLoader) {
- try {
- return getClassForTypeDeclaration_(elementTypeName, arrayDepth, classLoader);
- } catch (ClassNotFoundException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * Return the class for the specified "type declaration",
- * using the specified class loader.
- */
- // see the "Evaluation" of JDK bug 6446627 for a discussion of loading classes
- public static Class<?> getClassForTypeDeclaration_(String elementTypeName, int arrayDepth, ClassLoader classLoader)
- throws ClassNotFoundException
- {
- // primitives cannot be loaded via Class.forName(),
- // so check for a primitive class name first
- Primitive pcc = null;
- if (elementTypeName.length() <= MAX_PRIMITIVE_CLASS_NAME_LENGTH) { // performance tweak
- for (Primitive primitive : PRIMITIVES) {
- if (primitive.javaClass.getName().equals(elementTypeName)) {
- pcc = primitive;
- break;
- }
- }
- }
-
- // non-array
- if (arrayDepth == 0) {
- return (pcc == null) ? Class.forName(elementTypeName, false, classLoader) : pcc.javaClass;
- }
-
- // array
- StringBuilder sb = new StringBuilder(100);
- for (int i = arrayDepth; i-- > 0; ) {
- sb.append('[');
- }
- if (pcc == null) {
- ClassName.append(elementTypeName, sb);
- } else {
- sb.append(pcc.code);
- }
- return Class.forName(sb.toString(), false, classLoader);
- }
-
- /**
- * Return the class name for the specified "type declaration"; e.g.<ul>
- * <li><code>"int"</code> returns <code>"int"</code>
- * <li><code>"int[]"</code> returns <code>"[I"</code>
- * <li><code>"java.lang.String"</code> returns <code>"java.lang.String"</code>
- * <li><code>"java.lang.String[][][]"</code> returns <code>"[[[Ljava.lang.String;"</code>
- * </ul>
- * @see java.lang.Class#getName()
- */
- public static String getClassNameForTypeDeclaration(String typeDeclaration) {
- TypeDeclaration td = buildTypeDeclaration(typeDeclaration);
- return getClassNameForTypeDeclaration(td.elementTypeName, td.arrayDepth);
- }
-
- /**
- * Return the class name for the specified "type declaration".
- * @see java.lang.Class#getName()
- */
- public static String getClassNameForTypeDeclaration(String elementTypeName, int arrayDepth) {
- // non-array
- if (arrayDepth == 0) {
- return elementTypeName;
- }
-
- if (elementTypeName.equals(ClassName.VOID_CLASS_NAME)) {
- throw new IllegalArgumentException('\'' + ClassName.VOID_CLASS_NAME + "' must have an array depth of zero: " + arrayDepth + '.'); //$NON-NLS-1$
- }
- // array
- StringBuilder sb = new StringBuilder(100);
- for (int i = arrayDepth; i-- > 0; ) {
- sb.append('[');
- }
-
- // look for a primitive first
- Primitive pcc = null;
- if (elementTypeName.length() <= MAX_PRIMITIVE_CLASS_NAME_LENGTH) { // performance tweak
- for (Primitive primitive : PRIMITIVES) {
- if (primitive.javaClass.getName().equals(elementTypeName)) {
- pcc = primitive;
- break;
- }
- }
- }
-
- if (pcc == null) {
- ClassName.append(elementTypeName, sb);
- } else {
- sb.append(pcc.code);
- }
-
- return sb.toString();
- }
-
-
- // ********** exception messages **********
-
- /**
- * Return a string representation of the specified constructor.
- */
- private static String buildFullyQualifiedConstructorSignature(Class<?> javaClass, Class<?>[] parameterTypes) {
- return buildFullyQualifiedMethodSignature(javaClass, null, parameterTypes);
- }
-
- /**
- * Return a string representation of the specified field.
- */
- private static String buildFullyQualifiedFieldName(Class<?> javaClass, String fieldName) {
- StringBuilder sb = new StringBuilder(200);
- sb.append(javaClass.getName());
- sb.append('.');
- sb.append(fieldName);
- return sb.toString();
- }
-
- /**
- * Return a string representation of the specified field.
- */
- private static String buildFullyQualifiedFieldName(Object object, String fieldName) {
- return buildFullyQualifiedFieldName(object.getClass(), fieldName);
- }
-
- /**
- * Return a string representation of the specified method.
- */
- private static String buildFullyQualifiedMethodSignature(Class<?> javaClass, String methodName, Class<?>[] parameterTypes) {
- StringBuilder sb = new StringBuilder(200);
- sb.append(javaClass.getName());
- // this check allows us to use this code for constructors, where the methodName is null
- if (methodName != null) {
- sb.append('.');
- sb.append(methodName);
- }
- sb.append('(');
- int max = parameterTypes.length - 1;
- if (max != -1) {
- // stop one short of the end of the array
- for (int i = 0; i < max; i++) {
- sb.append(parameterTypes[i].getName());
- sb.append(", "); //$NON-NLS-1$
- }
- sb.append(parameterTypes[max].getName());
- }
- sb.append(')');
- return sb.toString();
- }
-
-
- // ********** primitive constants **********
-
- static final Iterable<Primitive> PRIMITIVES = buildPrimitives();
-
- public static final char BYTE_CODE = 'B';
- public static final char CHAR_CODE = 'C';
- public static final char DOUBLE_CODE = 'D';
- public static final char FLOAT_CODE = 'F';
- public static final char INT_CODE = 'I';
- public static final char LONG_CODE = 'J';
- public static final char SHORT_CODE = 'S';
- public static final char BOOLEAN_CODE = 'Z';
- public static final char VOID_CODE = 'V';
-
- static final int MAX_PRIMITIVE_CLASS_NAME_LENGTH = calculateMaxPrimitiveClassNameLength();
- static final int MAX_PRIMITIVE_WRAPPER_CLASS_NAME_LENGTH = calculateMaxPrimitiveWrapperClassNameLength();
-
- private static int calculateMaxPrimitiveClassNameLength() {
- int max = -1;
- for (Primitive primitive : PRIMITIVES) {
- int len = primitive.javaClass.getName().length();
- if (len > max) {
- max = len;
- }
- }
- return max;
- }
-
- private static int calculateMaxPrimitiveWrapperClassNameLength() {
- int max = -1;
- for (Primitive primitive : PRIMITIVES) {
- int len = primitive.wrapperClass.getName().length();
- if (len > max) {
- max = len;
- }
- }
- return max;
- }
-
- /**
- * <strong>NB:</strong> <code>void.class.isPrimitive() == true</code>
- */
- private static Iterable<Primitive> buildPrimitives() {
- Primitive[] array = new Primitive[9];
- array[0] = new Primitive(BYTE_CODE, java.lang.Byte.class);
- array[1] = new Primitive(CHAR_CODE, java.lang.Character.class);
- array[2] = new Primitive(DOUBLE_CODE, java.lang.Double.class);
- array[3] = new Primitive(FLOAT_CODE, java.lang.Float.class);
- array[4] = new Primitive(INT_CODE, java.lang.Integer.class);
- array[5] = new Primitive(LONG_CODE, java.lang.Long.class);
- array[6] = new Primitive(SHORT_CODE, java.lang.Short.class);
- array[7] = new Primitive(BOOLEAN_CODE, java.lang.Boolean.class);
- array[8] = new Primitive(VOID_CODE, java.lang.Void.class);
- return new ArrayIterable<Primitive>(array);
- }
-
-
- // ********** member classes **********
-
- static class Primitive {
- final char code;
- final Class<?> javaClass;
- final Class<?> wrapperClass;
- private static final String WRAPPER_CLASS_TYPE_FIELD_NAME = "TYPE"; //$NON-NLS-1$
- // e.g. java.lang.Boolean.TYPE => boolean.class
- Primitive(char code, Class<?> wrapperClass) {
- this.code = code;
- this.wrapperClass = wrapperClass;
- this.javaClass = (Class<?>) getStaticFieldValue(wrapperClass, WRAPPER_CLASS_TYPE_FIELD_NAME);
- }
- }
-
- private static class TypeDeclaration {
- final String elementTypeName;
- final int arrayDepth;
- TypeDeclaration(String elementTypeName, int arrayDepth) {
- this.elementTypeName = elementTypeName;
- this.arrayDepth = arrayDepth;
- }
- }
-
-
- // ********** suppressed constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private ReflectionTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ReverseComparator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ReverseComparator.java
deleted file mode 100644
index 948b8588e4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ReverseComparator.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-/**
- * This comparator will reverse the order of the specified comparator.
- * If the comparator is null, the natural ordering of the objects will be used.
- */
-public class ReverseComparator<E extends Comparable<? super E>>
- implements Comparator<E>, Serializable
-{
- private final Comparator<E> comparator;
-
- public ReverseComparator() {
- this(null);
- }
-
- public ReverseComparator(Comparator<E> comparator) {
- super();
- this.comparator = comparator;
- }
-
- public int compare(E e1, E e2) {
- return (this.comparator == null) ?
- e2.compareTo(e1)
- :
- this.comparator.compare(e2, e1);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/RunnableAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/RunnableAdapter.java
deleted file mode 100644
index ef5bcc608d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/RunnableAdapter.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Convenience runnable that does nothing.
- */
-public class RunnableAdapter
- implements Runnable
-{
- public void run() {
- // NOP
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleAssociation.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleAssociation.java
deleted file mode 100644
index 8490c267b4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleAssociation.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * Straightforward implementation of {@link Association}.
- */
-public class SimpleAssociation<K, V>
- extends AbstractAssociation<K, V>
- implements Cloneable, Serializable
-{
- private final K key;
- private V value;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct an association with the specified key
- * and a null value.
- */
- public SimpleAssociation(K key) {
- super();
- this.key = key;
- }
-
- /**
- * Construct an association with the specified key and value.
- */
- public SimpleAssociation(K key, V value) {
- this(key);
- this.value = value;
- }
-
-
- public K getKey() {
- return this.key;
- }
-
- public synchronized V getValue() {
- return this.value;
- }
-
- public synchronized V setValue(V value) {
- V old = this.value;
- this.value = value;
- return old;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public synchronized SimpleAssociation<K, V> clone() {
- try {
- return (SimpleAssociation<K, V>) super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleBooleanReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleBooleanReference.java
deleted file mode 100644
index c514b69892..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleBooleanReference.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * Provide a container for passing a flag that can be changed by the recipient.
- *
- * @see SynchronizedBoolean
- */
-public class SimpleBooleanReference
- implements ModifiableBooleanReference, Cloneable, Serializable
-{
- /** Backing <code>boolean</code>. */
- protected volatile boolean value;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Create a <code>boolean</code> reference with the specified initial value.
- */
- public SimpleBooleanReference(boolean value) {
- super();
- this.value = value;
- }
-
- /**
- * Create a <code>boolean</code> reference with an initial value of
- * <code>false</code>.
- */
- public SimpleBooleanReference() {
- this(false);
- }
-
-
- // ********** accessors **********
-
- public boolean getValue() {
- return this.value;
- }
-
- public boolean is(boolean v) {
- return this.value == v;
- }
-
- public boolean isNot(boolean v) {
- return this.value != v;
- }
-
- public boolean isTrue() {
- return this.value;
- }
-
- public boolean isFalse() {
- return ! this.value;
- }
-
- public boolean setValue(boolean value) {
- boolean old = this.value;
- this.value = value;
- return old;
- }
-
- public boolean flip() {
- return this.value = ! this.value;
- }
-
- public boolean setNot(boolean v) {
- return this.setValue( ! v);
- }
-
- public boolean setTrue() {
- return this.setValue(true);
- }
-
- public boolean setFalse() {
- return this.setValue(false);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public SimpleBooleanReference clone() {
- try {
- return (SimpleBooleanReference) super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- /**
- * Object identity is critical to boolean references.
- * There is no reason for two different boolean references to be
- * <em>equal</em>.
- *
- * @see #is(boolean)
- */
- @Override
- public boolean equals(Object obj) {
- return super.equals(obj);
- }
-
- /**
- * @see #equals(Object)
- */
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-
- @Override
- public String toString() {
- return '[' + String.valueOf(this.value) + ']';
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleFilter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleFilter.java
deleted file mode 100644
index 3d664984b7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleFilter.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.Filter;
-
-/**
- * Simple, abstract implementation of <code>Filter</code>
- * that holds on to a criterion object that can be used in the
- * {@link #accept(Object) accept} or {@link #reject(Object) reject}
- * methods. Subclasses can override either of these methods,
- * depending on which is easier to implement. Note that at least
- * one of these methods <em>must</em> be overridden or
- * an infinite loop will occur. If both of them are overridden,
- * only the {@link #accept(Object) accept} method will be used.
- * <p>
- * This class simplifies the implementation of straightforward inner classes.
- * Here is an example of a filter that can be used by a
- * {@link org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable
- * FilteringIterable} to return only those strings
- * in the nested iterable that start with <code>"prefix"</code>:
- * <pre>
- * Filter<String> filter = new SimpleFilter<String, String>("prefix") {
- * public boolean accept(String string) {
- * return string.startsWith(criterion);
- * }
- * };
- * </pre>
- */
-public abstract class SimpleFilter<T, C>
- implements Filter<T>, Cloneable, Serializable
-{
- protected final C criterion;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a simple filter with a <code>null</code> criterion
- */
- protected SimpleFilter() {
- this(null);
- }
-
- /**
- * More useful constructor. The specified criterion can
- * be used by a subclass to "accept" or "reject" objects.
- */
- protected SimpleFilter(C criterion) {
- super();
- this.criterion = criterion;
- }
-
- /**
- * Return whether the the specified object should be "rejected".
- * The semantics of "rejected" is determined by the client.
- */
- protected boolean reject(T o) {
- return ! this.accept(o);
- }
-
- /**
- * Return whether the the specified object should be "accepted".
- * The semantics of "accepted" is determined by the client.
- */
- public boolean accept(T o) {
- return ! this.reject(o);
- }
-
- /**
- * Return the filter's criterion.
- */
- public C getCriterion() {
- return this.criterion;
- }
-
- @Override
- public SimpleFilter<T, C> clone() {
- try {
- @SuppressWarnings("unchecked")
- SimpleFilter<T, C> clone = (SimpleFilter<T, C>) super.clone();
- return clone;
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if ( ! (o instanceof SimpleFilter<?, ?>)) {
- return false;
- }
- SimpleFilter<?, ?> other = (SimpleFilter<?, ?>) o;
- return Tools.valuesAreEqual(this.criterion, other.criterion);
- }
-
- @Override
- public int hashCode() {
- return (this.criterion == null) ? 0 : this.criterion.hashCode();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.criterion);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleIntReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleIntReference.java
deleted file mode 100644
index 63950ebbb9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleIntReference.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * This class can be used wherever a mutable integer object is needed.
- * It is a cross between an <code>int</code> and an {@link Integer}.
- * It can be stored in a standard container (e.g. {@link java.util.Collection})
- * but can be modified. It is also useful passing a value that can be changed
- * by the recipient.
- *
- * @see SynchronizedInt
- */
-public final class SimpleIntReference
- implements ModifiableIntReference, Cloneable, Serializable
-{
- /** Backing <code>int</code>. */
- private volatile int value = 0;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a <code>int</code> reference with the specified initial value.
- */
- public SimpleIntReference(int count) {
- super();
- this.value = count;
- }
-
- /**
- * Construct a <code>int</code> reference with an initial value of zero.
- */
- public SimpleIntReference() {
- this(0);
- }
-
-
- // ********** methods **********
-
- public int getValue() {
- return this.value;
- }
-
- public boolean equals(int v) {
- return this.value == v;
- }
-
- public boolean notEqual(int v) {
- return this.value != v;
- }
-
- public boolean isZero() {
- return this.value == 0;
- }
-
- public boolean isNotZero() {
- return this.value != 0;
- }
-
- public boolean isGreaterThan(int v) {
- return this.value > v;
- }
-
- public boolean isGreaterThanOrEqual(int v) {
- return this.value >= v;
- }
-
- public boolean isLessThan(int v) {
- return this.value < v;
- }
-
- public boolean isLessThanOrEqual(int v) {
- return this.value <= v;
- }
-
- public boolean isPositive() {
- return this.isGreaterThan(0);
- }
-
- public boolean isNotPositive() {
- return this.isLessThanOrEqual(0);
- }
-
- public boolean isNegative() {
- return this.isLessThan(0);
- }
-
- public boolean isNotNegative() {
- return this.isGreaterThanOrEqual(0);
- }
-
- public int abs() {
- return Math.abs(this.value);
- }
-
- public int neg() {
- return -this.value;
- }
-
- public int add(int v) {
- return this.value + v;
- }
-
- public int subtract(int v) {
- return this.value - v;
- }
-
- public int multiply(int v) {
- return this.value * v;
- }
-
- public int divide(int v) {
- return this.value / v;
- }
-
- public int remainder(int v) {
- return this.value % v;
- }
-
- public int min(int v) {
- return Math.min(this.value, v);
- }
-
- public int max(int v) {
- return Math.max(this.value, v);
- }
-
- public double pow(int v) {
- return Math.pow(this.value, v);
- }
-
- public int setValue(int value) {
- int old = this.value;
- this.value = value;
- return old;
- }
-
- public int setZero() {
- return this.setValue(0);
- }
-
- public int increment() {
- return ++this.value;
- }
-
- public int decrement() {
- return --this.value;
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(IntReference ref) {
- int v = ref.getValue();
- return (this.value < v) ? -1 : ((this.value == v) ? 0 : 1);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public SimpleIntReference clone() {
- try {
- return (SimpleIntReference) super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public String toString() {
- return '[' + String.valueOf(this.value) + ']';
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleJavaType.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleJavaType.java
deleted file mode 100644
index ab9890e013..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleJavaType.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.util.HashMap;
-
-import org.eclipse.jpt.common.utility.JavaType;
-
-/**
- * Straightforward implementation of the {@link JavaType} interface.
- */
-public final class SimpleJavaType
- implements JavaType, Cloneable, Serializable
-{
-
- /**
- * store the type as a name, so we can reference classes
- * that are not loaded
- */
- private final String elementTypeName;
-
- /**
- * non-array types have an array depth of zero
- */
- private final int arrayDepth;
-
- private static final String BRACKETS = "[]"; //$NON-NLS-1$
- private static final long serialVersionUID = 1L;
-
- /**
- * Cache the "standard" java types for performance
- * Defining this as java.lang*, java.util*, java.sql.* for array dimensionality of 0
- * Make this a HashMap for performance, duplicate creation shouldn't be an issue.
- */
- private static final HashMap<String, JavaType> stardardJavaTypesCache = new HashMap<String, JavaType>();
-
- // ********** constructors **********
-
- /**
- * Use this factory method for performance. Standard java types will be cached.
- */
- public static JavaType buildSimpleJavaType(String elementTypeName, int arrayDepth) {
- if (arrayDepth == 0) {
- JavaType javaType = stardardJavaTypesCache.get(elementTypeName);
- if (javaType != null) {
- return javaType;
- }
- if (elementTypeName.startsWith("java.lang.") || //$NON-NLS-1$
- elementTypeName.startsWith("java.util.") || //$NON-NLS-1$
- elementTypeName.startsWith("java.sql.")) { //$NON-NLS-1$
- javaType = new SimpleJavaType(elementTypeName, arrayDepth);
- stardardJavaTypesCache.put(elementTypeName, javaType);
- return javaType;
- }
- }
- return new SimpleJavaType(elementTypeName, arrayDepth);
- }
-
- /**
- * Construct a Java type with the specified element type and array depth.
- */
- public SimpleJavaType(String elementTypeName, int arrayDepth) {
- super();
- if ((elementTypeName == null) || (elementTypeName.length() == 0)) {
- throw new IllegalArgumentException("The element type name is required."); //$NON-NLS-1$
- }
- if (ClassName.getArrayDepth(elementTypeName) != 0) { // e.g. "[Ljava.lang.Object;"
- throw new IllegalArgumentException("The element type must not be an array: " + elementTypeName + '.'); //$NON-NLS-1$
- }
- if (arrayDepth < 0) {
- throw new IllegalArgumentException("The array depth must be greater than or equal to zero: " + arrayDepth + '.'); //$NON-NLS-1$
- }
- if (elementTypeName.equals(void.class.getName()) && (arrayDepth != 0)) {
- throw new IllegalArgumentException("'void' must have an array depth of zero: " + arrayDepth + '.'); //$NON-NLS-1$
- }
- this.elementTypeName = elementTypeName;
- this.arrayDepth = arrayDepth;
- }
-
- /**
- * Construct a Java type for the specified class.
- * The class name can be in one of the following forms:<ul><code>
- * <li>java.lang.Object
- * <li>int
- * <li>java.util.Map$Entry
- * <li>[Ljava.lang.Object;
- * <li>[I
- * <li>[Ljava.util.Map$Entry;
- * </code></ul>
- */
- public SimpleJavaType(String javaClassName) {
- this(ClassName.getElementTypeName(javaClassName), ClassName.getArrayDepth(javaClassName));
- }
-
- /**
- * Construct a Java type for the specified class.
- */
- public SimpleJavaType(Class<?> javaClass) {
- this(javaClass.getName());
- }
-
-
- // ********** accessors **********
-
- public String getElementTypeName() {
- return this.elementTypeName;
- }
-
- public int getArrayDepth() {
- return this.arrayDepth;
- }
-
-
- // ********** queries **********
-
- public boolean isArray() {
- return this.arrayDepth > 0;
- }
-
- public boolean isPrimitive() {
- return (this.arrayDepth == 0) && ClassName.isPrimitive(this.elementTypeName);
- }
-
- public boolean isPrimitiveWrapper() {
- return (this.arrayDepth == 0) && ClassName.isPrimitiveWrapper(this.elementTypeName);
- }
-
- public boolean isVariablePrimitive() {
- return (this.arrayDepth == 0) && ClassName.isVariablePrimitive(this.elementTypeName);
- }
-
- public boolean isVariablePrimitiveWrapper() {
- return (this.arrayDepth == 0) && ClassName.isVariablePrimitiveWrapper(this.elementTypeName);
- }
-
- public Class<?> getJavaClass() throws ClassNotFoundException {
- return ReflectionTools.getClassForTypeDeclaration(this.elementTypeName, this.arrayDepth);
- }
-
- public String getJavaClassName() {
- return ReflectionTools.getClassNameForTypeDeclaration(this.elementTypeName, this.arrayDepth);
- }
-
-
- // ********** comparison **********
-
- public boolean equals(String otherElementTypeName, int otherArrayDepth) {
- return (this.arrayDepth == otherArrayDepth)
- && this.elementTypeName.equals(otherElementTypeName);
- }
-
- public boolean describes(String className) {
- return this.equals(ClassName.getElementTypeName(className), ClassName.getArrayDepth(className));
- }
-
- public boolean describes(Class<?> javaClass) {
- return this.describes(javaClass.getName());
- }
-
- public boolean equals(JavaType other) {
- return this.equals(other.getElementTypeName(), other.getArrayDepth());
- }
-
- @Override
- public boolean equals(Object o) {
- return (this == o) ? true : (o instanceof JavaType) ? this.equals((JavaType) o) : false;
- }
-
- @Override
- public int hashCode() {
- return this.elementTypeName.hashCode() ^ this.arrayDepth;
- }
-
-
- // ********** printing and displaying **********
-
- public String declaration() {
- if (this.arrayDepth == 0) {
- return this.getElementTypeNameDeclaration();
- }
- StringBuilder sb = new StringBuilder(this.elementTypeName.length() + (2 * this.arrayDepth));
- this.appendDeclarationTo(sb);
- return sb.toString();
- }
-
- public void appendDeclarationTo(StringBuilder sb) {
- sb.append(this.getElementTypeNameDeclaration());
- for (int i = this.arrayDepth; i-- > 0; ) {
- sb.append(BRACKETS);
- }
- }
-
- public void printDeclarationOn(PrintWriter pw) {
- pw.print(this.getElementTypeNameDeclaration());
- for (int i = this.arrayDepth; i-- > 0; ) {
- pw.print(BRACKETS);
- }
- }
-
- /**
- * The <code>'$'</code> version of the name is used in {@link Class#forName(String)},
- * but the <code>'.'</code> version of the name is used in source code.
- * Very irritating....
- */
- private String getElementTypeNameDeclaration() {
- return this.elementTypeName.replace('$', '.');
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(this.getClass().getSimpleName());
- sb.append('(');
- this.appendDeclarationTo(sb);
- sb.append(')');
- return sb.toString();
- }
-
-
- // ********** cloning **********
-
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleMethodSignature.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleMethodSignature.java
deleted file mode 100644
index 0a4b523c3e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleMethodSignature.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-import org.eclipse.jpt.common.utility.JavaType;
-import org.eclipse.jpt.common.utility.MethodSignature;
-
-/**
- * Straightforward implementation of the MethodSignature interface.
- */
-public final class SimpleMethodSignature
- implements MethodSignature, Cloneable, Serializable
-{
- private final String name;
-
- /**
- * store the parameter types as names, so we can reference classes
- * that are not loaded
- */
- private final JavaType[] parameterTypes;
-
- public static final JavaType[] EMPTY_PARAMETER_TYPES = new JavaType[0];
-
- private static final String PARAMETER_SEPARATOR = ", "; //$NON-NLS-1$
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a method signature with the specified name and
- * no parameter types.
- */
- public SimpleMethodSignature(String name) {
- this(name, EMPTY_PARAMETER_TYPES);
- }
-
- /**
- * Construct a method signature with the specified name and parameter
- * types.
- */
- public SimpleMethodSignature(String name, JavaType... parameterTypes) {
- super();
- if ((name == null) || (name.length() == 0)) {
- throw new IllegalArgumentException("The name is required."); //$NON-NLS-1$
- }
- if (parameterTypes == null) {
- throw new IllegalArgumentException("The parameter types are required."); //$NON-NLS-1$
- }
- checkParameterTypes(parameterTypes);
- this.name = name;
- this.parameterTypes = parameterTypes;
- }
-
- private static void checkParameterTypes(JavaType[] parameterTypes) {
- for (int i = 0; i < parameterTypes.length; i++) {
- if (parameterTypes[i] == null) {
- throw new IllegalArgumentException("Missing parameter type: " + i); //$NON-NLS-1$
- }
- if (parameterTypes[i].getElementTypeName().equals(void.class.getName())) {
- throw new IllegalArgumentException("A parameter type of 'void' is not allowed: " + i); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Construct a method signature with the specified name and parameter
- * types.
- */
- public SimpleMethodSignature(String name, String... parameterTypeNames) {
- this(name, buildParameterTypes(parameterTypeNames));
- }
-
- private static JavaType[] buildParameterTypes(String[] parameterTypeNames) {
- if (parameterTypeNames == null) {
- throw new IllegalArgumentException("The parameter type names are required."); //$NON-NLS-1$
- }
- JavaType[] parameterTypes = new JavaType[parameterTypeNames.length];
- for (int i = 0; i < parameterTypeNames.length; i++) {
- if (parameterTypeNames[i] == null) {
- throw new IllegalArgumentException("Missing parameter type name: " + i); //$NON-NLS-1$
- }
- parameterTypes[i] = new SimpleJavaType(parameterTypeNames[i]);
- }
- return parameterTypes;
- }
-
- /**
- * Construct a method signature with the specified name and parameter
- * types.
- */
- public SimpleMethodSignature(String name, Class<?>... parameterJavaClasses) {
- this(name, buildParameterTypeNames(parameterJavaClasses));
- }
-
- private static String[] buildParameterTypeNames(Class<?>[] parameterJavaClasses) {
- if (parameterJavaClasses == null) {
- throw new IllegalArgumentException("The parameter Java classes are required."); //$NON-NLS-1$
- }
- String[] parameterTypeNames = new String[parameterJavaClasses.length];
- for (int i = 0; i < parameterJavaClasses.length; i++) {
- if (parameterJavaClasses[i] == null) {
- throw new IllegalArgumentException("Missing parameter Java class: " + i); //$NON-NLS-1$
- }
- parameterTypeNames[i] = parameterJavaClasses[i].getName();
- }
- return parameterTypeNames;
- }
-
- /**
- * Construct a method signature for the specified Java method.
- */
- public SimpleMethodSignature(Method method) {
- this(method.getName(), method.getParameterTypes());
- }
-
-
- // ********** accessors **********
-
- public String getName() {
- return this.name;
- }
-
- public JavaType[] getParameterTypes() {
- return this.parameterTypes;
- }
-
-
- // ********** comparison **********
-
- public boolean describes(Method method) {
- return this.name.equals(method.getName())
- && this.parameterTypesDescribe(method.getParameterTypes());
- }
-
- private boolean parameterTypesDescribe(Class<?>[] otherParameterTypes) {
- JavaType[] localParameterTypes = this.parameterTypes;
- int len = localParameterTypes.length;
- if (otherParameterTypes.length != len) {
- return false;
- }
- for (int i = len; i-- > 0; ) {
- if ( ! localParameterTypes[i].describes(otherParameterTypes[i])) {
- return false;
- }
- }
- return true;
- }
-
- public boolean equals(String otherName, JavaType[] otherParameterTypes) {
- return this.name.equals(otherName)
- && Arrays.equals(this.parameterTypes, otherParameterTypes);
- }
-
- public boolean equals(MethodSignature other) {
- return this.equals(other.getName(), other.getParameterTypes());
- }
-
- @Override
- public boolean equals(Object o) {
- return (this == o) ? true : (o instanceof MethodSignature) ? this.equals((MethodSignature) o) : false;
- }
-
- @Override
- public int hashCode() {
- return this.name.hashCode() ^ Arrays.hashCode(this.parameterTypes);
- }
-
-
- // ********** printing and displaying **********
-
- public String getSignature() {
- StringBuilder sb = new StringBuilder(200);
- this.appendSignatureTo(sb);
- return sb.toString();
- }
-
- public void appendSignatureTo(StringBuilder sb) {
- sb.append(this.name);
- sb.append('(');
- JavaType[] localParameterTypes = this.parameterTypes;
- int len = localParameterTypes.length;
- for (int i = 0; i < len; i++) {
- if (i != 0) {
- sb.append(PARAMETER_SEPARATOR);
- }
- localParameterTypes[i].appendDeclarationTo(sb);
- }
- sb.append(')');
- }
-
- public void printSignatureOn(PrintWriter pw) {
- pw.print(this.name);
- pw.print('(');
- JavaType[] localParameterTypes = this.parameterTypes;
- int len = localParameterTypes.length;
- for (int i = 0; i < len; i++) {
- if (i != 0) {
- pw.print(PARAMETER_SEPARATOR);
- }
- localParameterTypes[i].printDeclarationOn(pw);
- }
- pw.print(')');
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(200);
- sb.append(this.getClass().getSimpleName());
- sb.append('(');
- this.appendSignatureTo(sb);
- sb.append(')');
- return sb.toString();
- }
-
-
- // ********** cloning **********
-
- @Override
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleObjectReference.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleObjectReference.java
deleted file mode 100644
index ea08c4d9ea..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleObjectReference.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.ModifiableObjectReference;
-
-/**
- * Provide a container for passing an object that can be changed by the recipient.
- *
- * @see SynchronizedObject
- */
-public class SimpleObjectReference<V>
- implements ModifiableObjectReference<V>, Cloneable, Serializable
-{
- /** Backing value. */
- private volatile V value;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Create an object reference with the specified initial value.
- */
- public SimpleObjectReference(V value) {
- super();
- this.value = value;
- }
-
- /**
- * Create an object reference with an initial value of
- * <code>null</code>.
- */
- public SimpleObjectReference() {
- this(null);
- }
-
-
- // ********** value **********
-
- public V getValue() {
- return this.value;
- }
-
- public boolean valueEquals(Object object) {
- return Tools.valuesAreEqual(this.value, object);
- }
-
- public boolean valueNotEqual(Object object) {
- return Tools.valuesAreDifferent(this.value, object);
- }
-
- public boolean isNull() {
- return this.value == null;
- }
-
- public boolean isNotNull() {
- return this.value != null;
- }
-
- public V setValue(V value) {
- V old = this.value;
- this.value = value;
- return old;
- }
-
- public V setNull() {
- return this.setValue(null);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public SimpleObjectReference<V> clone() {
- try {
- @SuppressWarnings("unchecked")
- SimpleObjectReference<V> clone = (SimpleObjectReference<V>) super.clone();
- return clone;
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public String toString() {
- return '[' + String.valueOf(this.value) + ']';
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleQueue.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleQueue.java
deleted file mode 100644
index 02e026c7db..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleQueue.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.LinkedList;
-
-/**
- * Straightforward implementation of the {@link Queue} interface.
- */
-public class SimpleQueue<E>
- implements Queue<E>, Cloneable, Serializable
-{
- private LinkedList<E> elements;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct an empty queue.
- */
- public SimpleQueue() {
- super();
- this.elements = new LinkedList<E>();
- }
-
- /**
- * Construct a queue containing the elements of the specified
- * collection. The queue will dequeue its elements in the same
- * order they are returned by the collection's iterator (i.e. the
- * first element returned by the collection's iterator will be the
- * first element returned by {@link #dequeue()}).
- */
- public SimpleQueue(Collection<? extends E> c) {
- super();
- this.elements = new LinkedList<E>(c);
- }
-
-
- // ********** Queue implementation **********
-
- public void enqueue(E o) {
- this.elements.addLast(o);
- }
-
- public E dequeue() {
- return this.elements.removeFirst();
- }
-
- public E peek() {
- return this.elements.getFirst();
- }
-
- public boolean isEmpty() {
- return this.elements.isEmpty();
- }
-
-
- // ********** Cloneable implementation **********
-
- @Override
- public SimpleQueue<E> clone() {
- try {
- @SuppressWarnings("unchecked")
- SimpleQueue<E> clone = (SimpleQueue<E>) super.clone();
- @SuppressWarnings("unchecked")
- LinkedList<E> ll = (LinkedList<E>) this.elements.clone();
- clone.elements = ll;
- return clone;
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.peek());
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleStack.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleStack.java
deleted file mode 100644
index 3816b49a87..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleStack.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.EmptyStackException;
-import java.util.LinkedList;
-import java.util.NoSuchElementException;
-
-/**
- * Straightforward implementation of the {@link Stack} interface.
- */
-public class SimpleStack<E>
- implements Stack<E>, Cloneable, Serializable
-{
- private LinkedList<E> elements;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct an empty stack.
- */
- public SimpleStack() {
- super();
- this.elements = new LinkedList<E>();
- }
-
- /**
- * Construct a stack containing the elements of the specified
- * collection. The stack will pop its elements in reverse of the
- * order they are returned by the collection's iterator (i.e. the
- * last element returned by the collection's iterator will be the
- * first element returned by {@link #pop()}).
- */
- public SimpleStack(Collection<? extends E> collection) {
- super();
- this.elements = new LinkedList<E>(collection);
- }
-
-
- // ********** Stack implementation **********
-
- public void push(E element) {
- this.elements.addLast(element);
- }
-
- public E pop() {
- try {
- return this.elements.removeLast();
- } catch (NoSuchElementException ex) {
- throw new EmptyStackException();
- }
- }
-
- public E peek() {
- try {
- return this.elements.getLast();
- } catch (NoSuchElementException ex) {
- throw new EmptyStackException();
- }
- }
-
- public boolean isEmpty() {
- return this.elements.isEmpty();
- }
-
-
- // ********** standard methods **********
-
- @Override
- public SimpleStack<E> clone() {
- try {
- @SuppressWarnings("unchecked")
- SimpleStack<E> clone = (SimpleStack<E>) super.clone();
- @SuppressWarnings("unchecked")
- LinkedList<E> ll = (LinkedList<E>) this.elements.clone();
- clone.elements = ll;
- return clone;
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.peek());
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleStringMatcher.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleStringMatcher.java
deleted file mode 100644
index 5f85f7895c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleStringMatcher.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.regex.Pattern;
-import org.eclipse.jpt.common.utility.Filter;
-
-// TODO the regex code is not very fast - we could probably do better,
-// hand-coding the matching algorithm (eclipse StringMatcher?)
-/**
- * This class implements a simple string-matching algorithm that is a little
- * more user-friendly than standard regular expressions. Instantiate a
- * string matcher with a filter pattern and then you can use the matcher
- * to determine whether another string (or object) matches the pattern.
- * You can also specify whether the matching should be case-sensitive.
- *
- * The pattern can contain two "meta-characters":
- * '*' will match any set of zero or more characters
- * '?' will match any single character
- *
- * Subclasses can override #prefix() and/or #suffix() to change what
- * strings are prepended or appended to the original pattern string.
- * This can offer a slight performance improvement over concatenating
- * strings before calling #setPatternString(String).
- * By default, a '*' is appended to every string.
- *
- * This class also uses the string-matching algorithm to "filter" objects
- * (and, as a result, also implements the Filter interface).
- * A string converter is used to determine what string aspect of the
- * object is compared to the pattern. By default the string returned
- * by the object's #toString() method is passed to the pattern matcher.
- */
-public class SimpleStringMatcher<T>
- implements StringMatcher, Filter<T>, Serializable
-{
-
- /** An adapter that converts the objects into strings to be matched with the pattern. */
- private StringConverter<T> stringConverter;
-
- /** The string used to construct the regular expression pattern. */
- private String patternString;
-
- /** Whether the matcher ignores case - the default is true. */
- private boolean ignoresCase;
-
- /** The regular expression pattern built from the pattern string. */
- private Pattern pattern;
-
- /** A list of the meta-characters we need to escape if found in the pattern string. */
- public static final char[] REG_EX_META_CHARS = { '(', '[', '{', '\\', '^', '$', '|', ')', '?', '*', '+', '.' };
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a string matcher with an pattern that will match
- * any string and ignore case.
- */
- public SimpleStringMatcher() {
- this("*"); //$NON-NLS-1$
- }
-
- /**
- * Construct a string matcher with the specified pattern
- * that will ignore case.
- */
- public SimpleStringMatcher(String patternString) {
- this(patternString, true);
- }
-
- /**
- * Construct a string matcher with the specified pattern that will
- * ignore case as specified.
- */
- public SimpleStringMatcher(String patternString, boolean ignoresCase) {
- super();
- this.patternString = patternString;
- this.ignoresCase = ignoresCase;
- this.initialize();
- }
-
-
- // ********** initialization **********
-
- protected void initialize() {
- this.stringConverter = StringConverter.Default.instance();
- this.rebuildPattern();
- }
-
- /**
- * Given the current pattern string and case-sensitivity setting,
- * re-build the regular expression pattern.
- */
- protected synchronized void rebuildPattern() {
- this.pattern = this.buildPattern();
- }
-
- /**
- * Given the current pattern string and case-sensitivity setting,
- * build and return a regular expression pattern that can be used
- * to match strings.
- */
- protected Pattern buildPattern() {
- int patternFlags = 0x0;
- if (this.ignoresCase) {
- patternFlags = Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE;
- }
- return Pattern.compile(this.convertToRegEx(this.patternString), patternFlags);
- }
-
-
- // ********** StringMatcher implementation **********
-
- public synchronized void setPatternString(String patternString) {
- this.patternString = patternString;
- this.rebuildPattern();
- }
-
- /**
- * Return whether the specified string matches the pattern.
- */
- public synchronized boolean matches(String string) {
- return this.pattern.matcher(string).matches();
- }
-
-
- // ********** Filter implementation **********
-
- public synchronized boolean accept(T o) {
- return this.matches(this.stringConverter.convertToString(o));
- }
-
-
- // ********** accessors **********
-
- /**
- * Return the string converter used to convert the objects
- * passed to the matcher into strings.
- */
- public synchronized StringConverter<T> stringConverter() {
- return this.stringConverter;
- }
-
- /**
- * Set the string converter used to convert the objects
- * passed to the matcher into strings.
- */
- public synchronized void setStringConverter(StringConverter<T> stringConverter) {
- this.stringConverter = stringConverter;
- }
-
- /**
- * Return the original pattern string.
- */
- public synchronized String patternString() {
- return this.patternString;
- }
-
- /**
- * Return whether the matcher ignores case.
- */
- public synchronized boolean ignoresCase() {
- return this.ignoresCase;
- }
-
- /**
- * Set whether the matcher ignores case.
- */
- public synchronized void setIgnoresCase(boolean ignoresCase) {
- this.ignoresCase = ignoresCase;
- this.rebuildPattern();
- }
-
- /**
- * Return the regular expression pattern.
- */
- public synchronized Pattern pattern() {
- return this.pattern;
- }
-
-
- // ********** other public API **********
-
- /**
- * Return the regular expression corresponding to
- * the original pattern string.
- */
- public synchronized String regularExpression() {
- return this.convertToRegEx(this.patternString);
- }
-
-
- // ********** converting **********
-
- /**
- * Convert the specified string to a regular expression.
- */
- protected String convertToRegEx(String string) {
- StringBuffer sb = new StringBuffer(string.length() + 10);
- this.convertToRegExOn(this.prefix(), sb);
- this.convertToRegExOn(string, sb);
- this.convertToRegExOn(this.suffix(), sb);
- return sb.toString();
- }
-
- /**
- * Return any prefix that should be prepended to the original
- * string. By default, there is no prefix.
- */
- protected String prefix() {
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Return any suffix that should be appended to the original
- * string. Since this class is typically used in UI situation where
- * the user is typing in a pattern used to filter a list, the default
- * suffix is a wildcard character.
- */
- protected String suffix() {
- return "*"; //$NON-NLS-1$
- }
-
- /**
- * Convert the specified string to a regular expression.
- */
- protected void convertToRegExOn(String string, StringBuffer sb) {
- char[] charArray = string.toCharArray();
- int length = charArray.length;
- for (int i = 0; i < length; i++) {
- char c = charArray[i];
- // convert user-friendly meta-chars into regex meta-chars
- if (c == '*') {
- sb.append(".*"); //$NON-NLS-1$
- continue;
- }
- if (c == '?') {
- sb.append('.');
- continue;
- }
- // escape regex meta-chars
- if (ArrayTools.contains(REG_EX_META_CHARS, c)) {
- sb.append('\\');
- }
- sb.append(c);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleThreadFactory.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleThreadFactory.java
deleted file mode 100644
index 62a8cc1c78..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SimpleThreadFactory.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.concurrent.ThreadFactory;
-
-/**
- * A <code>SimpleThreadFactory</code> is a straightforward implementation of
- * the JDK {@link ThreadFactory}.
- */
-public class SimpleThreadFactory
- implements ThreadFactory, Serializable
-{
- // singleton
- private static final SimpleThreadFactory INSTANCE = new SimpleThreadFactory();
-
- /**
- * Return the singleton.
- */
- public static ThreadFactory instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private SimpleThreadFactory() {
- super();
- }
-
- public Thread newThread(Runnable r) {
- return new Thread(r);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Stack.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Stack.java
deleted file mode 100644
index bf9c34c88e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Stack.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.EmptyStackException;
-
-/**
- * Interface defining the classic stack behavior,
- * without the backdoors allowed by {@link java.util.Stack}.
- *
- * @param <E> the type of elements contained by the stack
- */
-public interface Stack<E> {
-
- /**
- * "Push" the specified item on to the top of the stack.
- */
- void push(E element);
-
- /**
- * "Pop" an item from the top of the stack.
- */
- E pop();
-
- /**
- * Return the item on the top of the stack
- * without removing it from the stack.
- */
- E peek();
-
- /**
- * Return whether the stack is empty.
- */
- boolean isEmpty();
-
-
- final class Empty<E>
- implements Stack<E>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Stack INSTANCE = new Empty();
- @SuppressWarnings("unchecked")
- public static <T> Stack<T> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Empty() {
- super();
- }
- public void push(E element) {
- throw new UnsupportedOperationException();
- }
- public E pop() {
- throw new EmptyStackException();
- }
- public E peek() {
- throw new EmptyStackException();
- }
- public boolean isEmpty() {
- return true;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StackTrace.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StackTrace.java
deleted file mode 100644
index 714e06c5ce..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StackTrace.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.IOException;
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-
-/**
- * Container for holding and printing the {@StackTraceElement stack trace
- * elements} produced by a thread or exception.
- *
- * @see Thread#getStackTrace()
- * @see Throwable#getStackTrace()
- */
-public class StackTrace
- implements Serializable
-{
- private final Thread thread;
- private final StackTraceElement[] elements;
- private volatile String string;
- private static final long serialVersionUID = 1L;
-
-
- public StackTrace() {
- this(Thread.currentThread());
- }
-
- public StackTrace(Thread thread) {
- super();
- if (thread == null) {
- throw new NullPointerException();
- }
- this.thread = thread;
- this.elements = this.buildElements();
- }
-
- /**
- * Strip off all the elements associated with this class and {@link Thread}.
- */
- private StackTraceElement[] buildElements() {
- StackTraceElement[] result = this.thread.getStackTrace();
- int len = result.length;
- if (len == 0) {
- return result;
- }
-
- String className = this.getClass().getName();
- boolean found = false;
- int i = 0;
- while (i < len) {
- if (result[i].getClassName().equals(className)) {
- found = true;
- } else {
- if (found) {
- break;
- }
- }
- i++;
- }
- return found ? ArrayTools.subArray(result, i, len) : result;
- }
-
- public Thread getThread() {
- return this.thread;
- }
-
- public Iterable<StackTraceElement> getElements() {
- return new ArrayIterable<StackTraceElement>(this.elements);
- }
-
- /**
- * Append the stack trace to the specified stream.
- */
- public void appendTo(Appendable stream) throws IOException {
- this.appendTo(stream, null);
- }
-
- /**
- * Append the stack trace to the specified stream, prefixing each line
- * with the specified prefix.
- */
- public void appendTo(Appendable stream, String prefix) throws IOException {
- for (StackTraceElement element : this.elements) {
- if (prefix != null) {
- stream.append(prefix);
- }
- stream.append(String.valueOf(element)).append(StringTools.CR);
- }
- }
-
- @Override
- public String toString() {
- return this.getString();
- }
-
- private String getString() {
- if (this.string == null) {
- synchronized (this) {
- if (this.string == null) {
- this.string = this.buildString();
- }
- }
- }
- return this.string;
- }
-
- private String buildString() {
- StringBuffer sb = new StringBuffer(1000);
- try {
- this.appendTo(sb);
- } catch (IOException ex) {
- throw new RuntimeException(ex); // should not happen with a StringBuffer
- }
- return sb.toString();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringCollator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringCollator.java
deleted file mode 100644
index eefb0b0a33..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringCollator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.text.Collator;
-import java.util.Comparator;
-import java.util.Locale;
-
-/**
- * This collator simply wraps a Java text collator and implements a
- * {@link String} {@link Comparator} (instead of an {@link Object}
- * {@link Comparator}, which is what {@link Collator} does, possibly for
- * backward-compatibility reasons(?)).
- *
- * @see Collator
- */
-public class StringCollator
- implements Comparator<String>
-{
- private final Collator collator;
-
-
- /**
- * Wrap the default collator.
- * @see Collator#getInstance()
- */
- public StringCollator() {
- this(Collator.getInstance());
- }
-
- /**
- * Wrap the collator for the specified locale.
- * @see Collator#getInstance(Locale)
- */
- public StringCollator(Locale locale) {
- this(Collator.getInstance(locale));
- }
-
- /**
- * Wrap the specified collator.
- */
- public StringCollator(Collator collator) {
- super();
- this.collator = collator;
- }
-
- public int compare(String string1, String string2) {
- return this.collator.compare(string1, string2);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.collator);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringConverter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringConverter.java
deleted file mode 100644
index 437b41e4ee..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringConverter.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * Used by various "pluggable" classes to transform objects
- * into strings.
- */
-public interface StringConverter<T> {
-
- /**
- * Convert the specified object into a string.
- * The semantics of "convert" is determined by the
- * contract between the client and the server.
- */
- String convertToString(T o);
-
-
- final class Default<S>
- implements StringConverter<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final StringConverter INSTANCE = new Default();
- @SuppressWarnings("unchecked")
- public static <R> StringConverter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- // simply return the object's #toString() result
- public String convertToString(S o) {
- return (o == null) ? null : o.toString();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- final class Disabled<S>
- implements StringConverter<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final StringConverter INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> StringConverter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public String convertToString(S o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringMatcher.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringMatcher.java
deleted file mode 100644
index ceab04044c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringMatcher.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * This interface defines a simple API for allowing "pluggable"
- * string matchers that can be configured with a pattern string
- * then used to determine what strings match the pattern.
- */
-public interface StringMatcher {
-
- /**
- * Set the pattern string used to determine future
- * matches. The format and semantics of the pattern
- * string are determined by the contract between the
- * client and the server.
- */
- void setPatternString(String patternString);
-
- /**
- * Return whether the specified string matches the
- * established pattern string. The semantics of a match
- * is determined by the contract between the
- * client and the server.
- */
- boolean matches(String string);
-
-
- final class Null
- implements StringMatcher, Serializable
- {
- public static final StringMatcher INSTANCE = new Null();
- public static StringMatcher instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void setPatternString(String patternString) {
- // ignore the pattern string
- }
- public boolean matches(String string) {
- // everything is a match
- return true;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java
deleted file mode 100644
index 093e713da9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringTools.java
+++ /dev/null
@@ -1,5141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Arrays;
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-
-/**
- * Convenience methods related to the java.lang.String class.
- *
- * As of jdk 1.5, it's tempting to convert all of these methods to use
- * java.lang.Appendable (instead of StringBuffer, StringBuilder, and Writer);
- * but all the Appendable methods throw java.io.IOException (yech) and we
- * [might?] get a bit better performance invoking methods on classes than
- * we get on interfaces. :-)
- */
-public final class StringTools {
-
- /** carriage return */
- public static final String CR = System.getProperty("line.separator"); //$NON-NLS-1$
-
- /** double quote */
- public static final char QUOTE = '"';
-
- /** XML double quote */
- public static final String XML_QUOTE = "&quot;";
-
- /** parenthesis */
- public static final char OPEN_PARENTHESIS = '(';
- public static final char CLOSE_PARENTHESIS = ')';
-
- /** brackets */
- public static final char OPEN_BRACKET = '[';
- public static final char CLOSE_BRACKET = ']';
-
- /** brackets */
- public static final char OPEN_BRACE = '{';
- public static final char CLOSE_BRACE = '}';
-
- /** brackets */
- public static final char OPEN_CHEVRON = '<';
- public static final char CLOSE_CHEVRON = '>';
-
- /** empty string */
- public static final String EMPTY_STRING = ""; //$NON-NLS-1$
-
- /** empty char array */
- public static final char[] EMPTY_CHAR_ARRAY = new char[0];
-
- /** empty string array */
- public static final String[] EMPTY_STRING_ARRAY = new String[0];
-
-
-
- // ********** padding/truncating **********
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.pad(int)
- * </code>
- */
- public static String pad(String string, int length) {
- return pad(string, length, ' ');
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOn(int, Writer)
- * </code>
- */
- public static void padOn(String string, int length, Writer writer) {
- padOn(string, length, ' ', writer);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOn(int, StringBuffer)
- * </code>
- */
- public static void padOn(String string, int length, StringBuffer sb) {
- padOn(string, length, ' ', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOn(int, StringBuilder)
- * </code>
- */
- public static void padOn(String string, int length, StringBuilder sb) {
- padOn(string, length, ' ', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.pad(int, char)
- * </code>
- */
- public static String pad(String string, int length, char c) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- return string;
- }
- return pad_(string, length, c);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOn(int, char, Writer)
- * </code>
- */
- public static void padOn(String string, int length, char c, Writer writer) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else {
- padOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOn(int, char, StringBuffer)
- * </code>
- */
- public static void padOn(String string, int length, char c, StringBuffer sb) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOn(int, char, StringBuilder)
- * </code>
- */
- public static void padOn(String string, int length, char c, StringBuilder sb) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.pad(int)
- * </code>
- */
- public static char[] pad(char[] string, int length) {
- return pad(string, length, ' ');
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOn(int, writer)
- * </code>
- */
- public static void padOn(char[] string, int length, Writer writer) {
- padOn(string, length, ' ', writer);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOn(int, StringBuffer)
- * </code>
- */
- public static void padOn(char[] string, int length, StringBuffer sb) {
- padOn(string, length, ' ', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOn(int, StringBuilder)
- * </code>
- */
- public static void padOn(char[] string, int length, StringBuilder sb) {
- padOn(string, length, ' ', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.pad(int, char)
- * </code>
- */
- public static char[] pad(char[] string, int length, char c) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- return string;
- }
- return pad_(string, length, c);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOn(int, char, Writer)
- * </code>
- */
- public static void padOn(char[] string, int length, char c, Writer writer) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else {
- padOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOn(int, char, StringBuffer)
- * </code>
- */
- public static void padOn(char[] string, int length, char c, StringBuffer sb) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOn(int, char, StringBuilder)
- * </code>
- */
- public static void padOn(char[] string, int length, char c, StringBuilder sb) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOrTruncate(int)
- * </code>
- */
- public static String padOrTruncate(String string, int length) {
- return padOrTruncate(string, length, ' ');
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, Writer)
- * </code>
- */
- public static void padOrTruncateOn(String string, int length, Writer writer) {
- padOrTruncateOn(string, length, ' ', writer);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, StringBuffer)
- * </code>
- */
- public static void padOrTruncateOn(String string, int length, StringBuffer sb) {
- padOrTruncateOn(string, length, ' ', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, StringBuilder)
- * </code>
- */
- public static void padOrTruncateOn(String string, int length, StringBuilder sb) {
- padOrTruncateOn(string, length, ' ', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOrTruncate(int, char)
- * </code>
- */
- public static String padOrTruncate(String string, int length, char c) {
- int stringLength = string.length();
- if (stringLength == length) {
- return string;
- }
- if (stringLength > length) {
- return string.substring(0, length);
- }
- return pad_(string, length, c);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, char, Writer)
- * </code>
- */
- public static void padOrTruncateOn(String string, int length, char c, Writer writer) {
- int stringLength = string.length();
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else if (stringLength > length) {
- writeStringOn(string.substring(0, length), writer);
- } else {
- padOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, char, StringBuffer)
- * </code>
- */
- public static void padOrTruncateOn(String string, int length, char c, StringBuffer sb) {
- int stringLength = string.length();
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string.substring(0, length));
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, char, StringBuilder)
- * </code>
- */
- public static void padOrTruncateOn(String string, int length, char c, StringBuilder sb) {
- int stringLength = string.length();
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string.substring(0, length));
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOrTruncate(int)
- * </code>
- */
- public static char[] padOrTruncate(char[] string, int length) {
- return padOrTruncate(string, length, ' ');
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, Writer)
- * </code>
- */
- public static void padOrTruncateOn(char[] string, int length, Writer writer) {
- padOrTruncateOn(string, length, ' ', writer);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, StringBuffer)
- * </code>
- */
- public static void padOrTruncate(char[] string, int length, StringBuffer sb) {
- padOrTruncateOn(string, length, ' ', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with spaces at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, StringBuilder)
- * </code>
- */
- public static void padOrTruncate(char[] string, int length, StringBuilder sb) {
- padOrTruncateOn(string, length, ' ', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOrTruncate(int, char)
- * </code>
- */
- public static char[] padOrTruncate(char[] string, int length, char c) {
- int stringLength = string.length;
- if (stringLength == length) {
- return string;
- }
- if (stringLength > length) {
- char[] result = new char[length];
- System.arraycopy(string, 0, result, 0, length);
- return result;
- }
- return pad_(string, length, c);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, char, Writer)
- * </code>
- */
- public static void padOrTruncateOn(char[] string, int length, char c, Writer writer) {
- int stringLength = string.length;
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else if (stringLength > length) {
- writeStringOn(string, 0, length, writer);
- } else {
- padOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, char, StringBuffer)
- * </code>
- */
- public static void padOrTruncateOn(char[] string, int length, char c, StringBuffer sb) {
- int stringLength = string.length;
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string, 0, length);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, it is truncated.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the end.
- * <p>
- * <code>
- * String.padOrTruncateOn(int, char, StringBuilder)
- * </code>
- */
- public static void padOrTruncateOn(char[] string, int length, char c, StringBuilder sb) {
- int stringLength = string.length;
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string, 0, length);
- } else {
- padOn_(string, length, c, sb);
- }
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static String pad_(String string, int length, char c) {
- return new String(pad_(string.toCharArray(), length, c));
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(String string, int length, char c, Writer writer) {
- writeStringOn(string, writer);
- fill_(string, length, c, writer);
- }
-
- /*
- * Add enough characters to the specified writer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(String string, int length, char c, Writer writer) {
- fill_(string.length(), length, c, writer);
- }
-
- /*
- * Add enough characters to the specified writer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(char[] string, int length, char c, Writer writer) {
- fill_(string.length, length, c, writer);
- }
-
- /*
- * Add enough characters to the specified writer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(int stringLength, int length, char c, Writer writer) {
- writeStringOn(ArrayTools.fill(new char[length - stringLength], c), writer);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(String string, int length, char c, StringBuffer sb) {
- sb.append(string);
- fill_(string, length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string buffer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(String string, int length, char c, StringBuffer sb) {
- fill_(string.length(), length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string buffer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(char[] string, int length, char c, StringBuffer sb) {
- fill_(string.length, length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string buffer to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(int stringLength, int length, char c, StringBuffer sb) {
- sb.append(ArrayTools.fill(new char[length - stringLength], c));
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(String string, int length, char c, StringBuilder sb) {
- sb.append(string);
- fill_(string, length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string builder to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(String string, int length, char c, StringBuilder sb) {
- fill_(string.length(), length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string builder to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(char[] string, int length, char c, StringBuilder sb) {
- fill_(string.length, length, c, sb);
- }
-
- /*
- * Add enough characters to the specified string builder to compensate for
- * the difference between the specified string and specified length.
- */
- private static void fill_(int stringLength, int length, char c, StringBuilder sb) {
- sb.append(ArrayTools.fill(new char[length - stringLength], c));
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static char[] pad_(char[] string, int length, char c) {
- char[] result = new char[length];
- int stringLength = string.length;
- System.arraycopy(string, 0, result, 0, stringLength);
- Arrays.fill(result, stringLength, length, c);
- return result;
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(char[] string, int length, char c, Writer writer) {
- writeStringOn(string, writer);
- fill_(string, length, c, writer);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(char[] string, int length, char c, StringBuffer sb) {
- sb.append(string);
- fill_(string, length, c, sb);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void padOn_(char[] string, int length, char c, StringBuilder sb) {
- sb.append(string);
- fill_(string, length, c, sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPad(int)
- * </code>
- */
- public static String zeroPad(String string, int length) {
- return frontPad(string, length, '0');
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOn(int, Writer)
- * </code>
- */
- public static void zeroPadOn(String string, int length, Writer writer) {
- frontPadOn(string, length, '0', writer);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOn(int, StringBuffer)
- * </code>
- */
- public static void zeroPadOn(String string, int length, StringBuffer sb) {
- frontPadOn(string, length, '0', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOn(int, StringBuilder)
- * </code>
- */
- public static void zeroPadOn(String string, int length, StringBuilder sb) {
- frontPadOn(string, length, '0', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPad(int, char)
- * </code>
- */
- public static String frontPad(String string, int length, char c) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- return string;
- }
- return frontPad_(string, length, c);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOn(int, char, Writer)
- * </code>
- */
- public static void frontPadOn(String string, int length, char c, Writer writer) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else {
- frontPadOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOn(int, char, StringBuffer)
- * </code>
- */
- public static void frontPadOn(String string, int length, char c, StringBuffer sb) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOn(int, char, StringBuilder)
- * </code>
- */
- public static void frontPadOn(String string, int length, char c, StringBuilder sb) {
- int stringLength = string.length();
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPad(int)
- * </code>
- */
- public static char[] zeroPad(char[] string, int length) {
- return frontPad(string, length, '0');
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOn(int, Writer)
- * </code>
- */
- public static void zeroPadOn(char[] string, int length, Writer writer) {
- frontPadOn(string, length, '0', writer);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOn(int, StringBuffer)
- * </code>
- */
- public static void zeroPadOn(char[] string, int length, StringBuffer sb) {
- frontPadOn(string, length, '0', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOn(int, StringBuilder)
- * </code>
- */
- public static void zeroPadOn(char[] string, int length, StringBuilder sb) {
- frontPadOn(string, length, '0', sb);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPad(int, char)
- * </code>
- */
- public static char[] frontPad(char[] string, int length, char c) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- return string;
- }
- return frontPad_(string, length, c);
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOn(int, char, Writer)
- * </code>
- */
- public static void frontPadOn(char[] string, int length, char c, Writer writer) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else {
- frontPadOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOn(int, char, StringBuffer)
- * </code>
- */
- public static void frontPadOn(char[] string, int length, char c, StringBuffer sb) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, an IllegalArgumentException is thrown.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOn(int, char, StringBuilder)
- * </code>
- */
- public static void frontPadOn(char[] string, int length, char c, StringBuilder sb) {
- int stringLength = string.length;
- if (stringLength > length) {
- throw new IllegalArgumentException("String is too long: " + stringLength + " > " + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (stringLength == length) {
- sb.append(string);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOrTruncate(int)
- * </code>
- */
- public static String zeroPadOrTruncate(String string, int length) {
- return frontPadOrTruncate(string, length, '0');
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOrTruncateOn(int, Writer)
- * </code>
- */
- public static void zeroPadOrTruncateOn(String string, int length, Writer writer) {
- frontPadOrTruncateOn(string, length, '0', writer);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOrTruncateOn(int, StringBuffer)
- * </code>
- */
- public static void zeroPadOrTruncateOn(String string, int length, StringBuffer sb) {
- frontPadOrTruncateOn(string, length, '0', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOrTruncateOn(int, StringBuilder)
- * </code>
- */
- public static void zeroPadOrTruncateOn(String string, int length, StringBuilder sb) {
- frontPadOrTruncateOn(string, length, '0', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOrTruncate(int, char)
- * </code>
- */
- public static String frontPadOrTruncate(String string, int length, char c) {
- int stringLength = string.length();
- if (stringLength == length) {
- return string;
- }
- if (stringLength > length) {
- return string.substring(stringLength - length);
- }
- return frontPad_(string, length, c);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOrTruncateOn(int, char, Writer)
- * </code>
- */
- public static void frontPadOrTruncateOn(String string, int length, char c, Writer writer) {
- int stringLength = string.length();
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else if (stringLength > length) {
- writeStringOn(string.substring(stringLength - length), writer);
- } else {
- frontPadOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOrTruncateOn(int, char, StringBuffer)
- * </code>
- */
- public static void frontPadOrTruncateOn(String string, int length, char c, StringBuffer sb) {
- int stringLength = string.length();
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string.substring(stringLength - length));
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOrTruncateOn(int, char, StringBuilder)
- * </code>
- */
- public static void frontPadOrTruncateOn(String string, int length, char c, StringBuilder sb) {
- int stringLength = string.length();
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string.substring(stringLength - length));
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOrTruncate(int)
- * </code>
- */
- public static char[] zeroPadOrTruncate(char[] string, int length) {
- return frontPadOrTruncate(string, length, '0');
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOrTruncateOn(int, Writer)
- * </code>
- */
- public static void zeroPadOrTruncateOn(char[] string, int length, Writer writer) {
- frontPadOrTruncateOn(string, length, '0', writer);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOrTruncateOn(int, StringBuffer)
- * </code>
- */
- public static void zeroPadOrTruncateOn(char[] string, int length, StringBuffer sb) {
- frontPadOrTruncateOn(string, length, '0', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with zeros at the front.
- * <p>
- * <code>
- * String.zeroPadOrTruncateOn(int, StringBuilder)
- * </code>
- */
- public static void zeroPadOrTruncateOn(char[] string, int length, StringBuilder sb) {
- frontPadOrTruncateOn(string, length, '0', sb);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOrTruncate(int, char)
- * </code>
- */
- public static char[] frontPadOrTruncate(char[] string, int length, char c) {
- int stringLength = string.length;
- if (stringLength == length) {
- return string;
- }
- if (stringLength > length) {
- char[] result = new char[length];
- System.arraycopy(string, stringLength - length, result, 0, length);
- return result;
- }
- return frontPad_(string, length, c);
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOrTruncateOn(int, char, Writer)
- * </code>
- */
- public static void frontPadOrTruncateOn(char[] string, int length, char c, Writer writer) {
- int stringLength = string.length;
- if (stringLength == length) {
- writeStringOn(string, writer);
- } else if (stringLength > length) {
- writeStringOn(string, stringLength - length, length, writer);
- } else {
- frontPadOn_(string, length, c, writer);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOrTruncateOn(int, char, StringBuffer)
- * </code>
- */
- public static void frontPadOrTruncateOn(char[] string, int length, char c, StringBuffer sb) {
- int stringLength = string.length;
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string, stringLength - length, length);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /**
- * Pad or truncate the specified string to the specified length.
- * If the string is already the specified length, it is returned unchanged.
- * If it is longer than the specified length, only the last part of the string is returned.
- * If it is shorter than the specified length, it is padded with the
- * specified character at the front.
- * <p>
- * <code>
- * String.frontPadOrTruncateOn(int, char, StringBuilder)
- * </code>
- */
- public static void frontPadOrTruncateOn(char[] string, int length, char c, StringBuilder sb) {
- int stringLength = string.length;
- if (stringLength == length) {
- sb.append(string);
- } else if (stringLength > length) {
- sb.append(string, stringLength - length, length);
- } else {
- frontPadOn_(string, length, c, sb);
- }
- }
-
- /*
- * Front-pad the specified string without validating the parms.
- */
- private static String frontPad_(String string, int length, char c) {
- return new String(frontPad_(string.toCharArray(), length, c));
- }
-
- /*
- * Zero-pad the specified string without validating the parms.
- */
- private static char[] frontPad_(char[] string, int length, char c) {
- char[] result = new char[length];
- int stringLength = string.length;
- int padLength = length - stringLength;
- System.arraycopy(string, 0, result, padLength, stringLength);
- Arrays.fill(result, 0, padLength, c);
- return result;
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(String string, int length, char c, Writer writer) {
- fill_(string, length, c, writer);
- writeStringOn(string, writer);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(char[] string, int length, char c, Writer writer) {
- fill_(string, length, c, writer);
- writeStringOn(string, writer);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(String string, int length, char c, StringBuffer sb) {
- fill_(string, length, c, sb);
- sb.append(string);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(char[] string, int length, char c, StringBuffer sb) {
- fill_(string, length, c, sb);
- sb.append(string);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(String string, int length, char c, StringBuilder sb) {
- fill_(string, length, c, sb);
- sb.append(string);
- }
-
- /*
- * Pad the specified string without validating the parms.
- */
- private static void frontPadOn_(char[] string, int length, char c, StringBuilder sb) {
- fill_(string, length, c, sb);
- sb.append(string);
- }
-
-
- // ********** separating **********
-
- /**
- * Separate the segments of the specified string with the specified
- * separator:<pre>
- * separate("012345", '-', 2) => "01-23-45"
- * </pre>
- */
- public static String separate(String string, char separator, int segmentSize) {
- if (segmentSize <= 0) {
- throw new IllegalArgumentException("segment size must be positive: " + segmentSize); //$NON-NLS-1$
- }
- int len = string.length();
- return (len <= segmentSize) ? string : new String(separate(string.toCharArray(), separator, segmentSize, len));
- }
-
- /**
- * Separate the segments of the specified string with the specified
- * separator:<pre>
- * separate("012345", '-', 2) => "01-23-45"
- * </pre>
- */
- public static void separateOn(String string, char separator, int segmentSize, Writer writer) {
- if (segmentSize <= 0) {
- throw new IllegalArgumentException("segment size must be positive: " + segmentSize); //$NON-NLS-1$
- }
- if (string.length() <= segmentSize) {
- writeStringOn(string, writer);
- } else {
- separateOn_(string.toCharArray(), separator, segmentSize, writer);
- }
- }
-
- /**
- * Separate the segments of the specified string with the specified
- * separator:<pre>
- * separate("012345", '-', 2) => "01-23-45"
- * </pre>
- */
- public static void separateOn(String string, char separator, int segmentSize, StringBuffer sb) {
- if (segmentSize <= 0) {
- throw new IllegalArgumentException("segment size must be positive: " + segmentSize); //$NON-NLS-1$
- }
- if (string.length() <= segmentSize) {
- sb.append(string);
- } else {
- separateOn_(string.toCharArray(), separator, segmentSize, sb);
- }
- }
-
- /**
- * Separate the segments of the specified string with the specified
- * separator:<pre>
- * separate("012345", '-', 2) => "01-23-45"
- * </pre>
- */
- public static void separateOn(String string, char separator, int segmentSize, StringBuilder sb) {
- if (segmentSize <= 0) {
- throw new IllegalArgumentException("segment size must be positive: " + segmentSize); //$NON-NLS-1$
- }
- if (string.length() <= segmentSize) {
- sb.append(string);
- } else {
- separateOn_(string.toCharArray(), separator, segmentSize, sb);
- }
- }
-
- /**
- * Separate the segments of the specified string with the specified
- * separator:<pre>
- * separate("012345", '-', 2) => "01-23-45"
- * </pre>
- */
- public static char[] separate(char[] string, char separator, int segmentSize) {
- if (segmentSize <= 0) {
- throw new IllegalArgumentException("segment size must be positive: " + segmentSize); //$NON-NLS-1$
- }
- int len = string.length;
- return (len <= segmentSize) ? string : separate(string, separator, segmentSize, len);
- }
-
- /**
- * pre-conditions: string is longer than segment size; segment size is positive
- */
- private static char[] separate(char[] string, char separator, int segmentSize, int len) {
- int resultLen = len + (len / segmentSize);
- if ((len % segmentSize) == 0) {
- resultLen--; // no separator after the final segment if nothing following it
- }
- char[] result = new char[resultLen];
- int j = 0;
- int segCount = 0;
- for (char c : string) {
- if (segCount == segmentSize) {
- result[j++] = separator;
- segCount = 0;
- }
- segCount++;
- result[j++] = c;
- }
- return result;
- }
-
- /**
- * Separate the segments of the specified string with the specified
- * separator:<pre>
- * separate("012345", '-', 2) => "01-23-45"
- * </pre>
- */
- public static void separateOn(char[] string, char separator, int segmentSize, Writer writer) {
- if (segmentSize <= 0) {
- throw new IllegalArgumentException("segment size must be positive: " + segmentSize); //$NON-NLS-1$
- }
- if (string.length <= segmentSize) {
- writeStringOn(string, writer);
- } else {
- separateOn_(string, separator, segmentSize, writer);
- }
- }
-
- /**
- * pre-conditions: string is longer than segment size; segment size is positive
- */
- private static void separateOn_(char[] string, char separator, int segmentSize, Writer writer) {
- int segCount = 0;
- for (char c : string) {
- if (segCount == segmentSize) {
- writeCharOn(separator, writer);
- segCount = 0;
- }
- segCount++;
- writeCharOn(c, writer);
- }
- }
-
- /**
- * Separate the segments of the specified string with the specified
- * separator:<pre>
- * separate("012345", '-', 2) => "01-23-45"
- * </pre>
- */
- public static void separateOn(char[] string, char separator, int segmentSize, StringBuffer sb) {
- if (segmentSize <= 0) {
- throw new IllegalArgumentException("segment size must be positive: " + segmentSize); //$NON-NLS-1$
- }
- if (string.length <= segmentSize) {
- sb.append(string);
- } else {
- separateOn_(string, separator, segmentSize, sb);
- }
- }
-
- /**
- * pre-conditions: string is longer than segment size; segment size is positive
- */
- private static void separateOn_(char[] string, char separator, int segmentSize, StringBuffer sb) {
- int segCount = 0;
- for (char c : string) {
- if (segCount == segmentSize) {
- sb.append(separator);
- segCount = 0;
- }
- segCount++;
- sb.append(c);
- }
- }
-
- /**
- * Separate the segments of the specified string with the specified
- * separator:<pre>
- * separate("012345", '-', 2) => "01-23-45"
- * </pre>
- */
- public static void separateOn(char[] string, char separator, int segmentSize, StringBuilder sb) {
- if (segmentSize <= 0) {
- throw new IllegalArgumentException("segment size must be positive: " + segmentSize); //$NON-NLS-1$
- }
- if (string.length <= segmentSize) {
- sb.append(string);
- } else {
- separateOn_(string, separator, segmentSize, sb);
- }
- }
-
- /**
- * pre-conditions: string is longer than segment size; segment size is positive
- */
- private static void separateOn_(char[] string, char separator, int segmentSize, StringBuilder sb) {
- int segCount = 0;
- for (char c : string) {
- if (segCount == segmentSize) {
- sb.append(separator);
- segCount = 0;
- }
- segCount++;
- sb.append(c);
- }
- }
-
-
- // ********** delimiting/quoting **********
-
- /**
- * Delimit the specified string with double quotes.
- * Escape any occurrences of a double quote in the string with another
- * double quote.
- */
- public static String quote(String string) {
- return delimit(string, QUOTE);
- }
-
- /**
- * Delimit the specified string with double quotes.
- * Escape any occurrences of a double quote in the string with another
- * double quote.
- */
- public static void quoteOn(String string, Writer writer) {
- delimitOn(string, QUOTE, writer);
- }
-
- /**
- * Delimit the specified string with double quotes.
- * Escape any occurrences of a double quote in the string with another
- * double quote.
- */
- public static void quoteOn(String string, StringBuffer sb) {
- delimitOn(string, QUOTE, sb);
- }
-
- /**
- * Delimit the specified string with double quotes.
- * Escape any occurrences of a double quote in the string with another
- * double quote.
- */
- public static void quoteOn(String string, StringBuilder sb) {
- delimitOn(string, QUOTE, sb);
- }
-
- /**
- * Delimit each of the specified strings with double quotes.
- * Escape any occurrences of a double quote in a string with another
- * double quote.
- */
- public static Iterator<String> quote(Iterator<String> strings) {
- return delimit(strings, QUOTE);
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in the string with another delimiter.
- */
- public static String delimit(String string, char delimiter) {
- return new String(delimit(string.toCharArray(), delimiter));
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in the string with another delimiter.
- */
- public static void delimitOn(String string, char delimiter, Writer writer) {
- delimitOn(string.toCharArray(), delimiter, writer);
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in the string with another delimiter.
- */
- public static void delimitOn(String string, char delimiter, StringBuffer sb) {
- delimitOn(string.toCharArray(), delimiter, sb);
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in the string with another delimiter.
- */
- public static void delimitOn(String string, char delimiter, StringBuilder sb) {
- delimitOn(string.toCharArray(), delimiter, sb);
- }
-
- /**
- * Delimit each of the specified strings with the specified delimiter; i.e. put a
- * copy of the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in a string with another delimiter.
- */
- public static Iterable<String> delimit(Iterable<String> strings, char delimiter) {
- return new TransformationIterable<String, String>(strings, new CharStringDelimiter(delimiter));
- }
-
- /**
- * Delimit each of the specified strings with the specified delimiter; i.e. put a
- * copy of the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in a string with another delimiter.
- */
- public static Iterator<String> delimit(Iterator<String> strings, char delimiter) {
- return new TransformationIterator<String, String>(strings, new CharStringDelimiter(delimiter));
- }
-
- private static class CharStringDelimiter implements Transformer<String, String> {
- private char delimiter;
- CharStringDelimiter(char delimiter) {
- super();
- this.delimiter = delimiter;
- }
- public String transform(String string) {
- return StringTools.delimit(string, this.delimiter);
- }
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in the string with
- * another delimiter.
- */
- public static String delimit(String string, String delimiter) {
- if (delimiter.length() == 1) {
- return delimit(string, delimiter.charAt(0));
- }
- return new String(delimit(string.toCharArray(), delimiter.toCharArray()));
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in the string with
- * another delimiter.
- */
- public static void delimitOn(String string, String delimiter, Writer writer) {
- if (delimiter.length() == 1) {
- delimitOn(string, delimiter.charAt(0), writer);
- } else {
- delimitOn(string.toCharArray(), delimiter.toCharArray(), writer);
- }
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in the string with
- * another delimiter.
- */
- public static void delimitOn(String string, String delimiter, StringBuffer sb) {
- if (delimiter.length() == 1) {
- delimitOn(string, delimiter.charAt(0), sb);
- } else {
- delimitOn(string.toCharArray(), delimiter.toCharArray(), sb);
- }
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in the string with
- * another delimiter.
- */
- public static void delimitOn(String string, String delimiter, StringBuilder sb) {
- if (delimiter.length() == 1) {
- delimitOn(string, delimiter.charAt(0), sb);
- } else {
- delimitOn(string.toCharArray(), delimiter.toCharArray(), sb);
- }
- }
-
- /**
- * Delimit each of the specified strings with the specified delimiter; i.e. put a
- * copy of the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in a string with
- * another delimiter.
- */
- public static Iterable<String> delimit(Iterable<String> strings, String delimiter) {
- return (delimiter.length() == 1) ?
- delimit(strings, delimiter.charAt(0)) :
- new TransformationIterable<String, String>(strings, new StringStringDelimiter(delimiter));
- }
-
- /**
- * Delimit each of the specified strings with the specified delimiter; i.e. put a
- * copy of the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in a string with
- * another delimiter.
- */
- public static Iterator<String> delimit(Iterator<String> strings, String delimiter) {
- return (delimiter.length() == 1) ?
- delimit(strings, delimiter.charAt(0)) :
- new TransformationIterator<String, String>(strings, new StringStringDelimiter(delimiter));
- }
-
- private static class StringStringDelimiter implements Transformer<String, String> {
- private String delimiter;
- StringStringDelimiter(String delimiter) {
- super();
- this.delimiter = delimiter;
- }
- public String transform(String string) {
- return StringTools.delimit(string, this.delimiter);
- }
- }
-
- /**
- * Delimit the specified string with double quotes.
- * Escape any occurrences of a double quote in the string with another
- * double quote.
- */
- public static char[] quote(char[] string) {
- return delimit(string, QUOTE);
- }
-
- /**
- * Delimit the specified string with double quotes.
- * Escape any occurrences of a double quote in the string with another
- * double quote.
- */
- public static void quoteOn(char[] string, Writer writer) {
- delimitOn(string, QUOTE, writer);
- }
-
- /**
- * Delimit the specified string with double quotes.
- * Escape any occurrences of a double quote in the string with another
- * double quote.
- */
- public static void quoteOn(char[] string, StringBuffer sb) {
- delimitOn(string, QUOTE, sb);
- }
-
- /**
- * Delimit the specified string with double quotes.
- * Escape any occurrences of a double quote in the string with another
- * double quote.
- */
- public static void quoteOn(char[] string, StringBuilder sb) {
- delimitOn(string, QUOTE, sb);
- }
-
- /**
- * Delimit each of the specified strings with double quotes.
- * Escape any occurrences of a double quote in a string with another
- * double quote.
- */
- // cannot name method simply 'quote' because of type-erasure...
- public static Iterator<char[]> quoteCharArrays(Iterator<char[]> strings) {
- return delimitCharArrays(strings, QUOTE);
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in the string with another delimiter.
- */
- public static char[] delimit(char[] string, char delimiter) {
- StringBuilder sb = new StringBuilder(string.length + 2);
- delimitOn(string, delimiter, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in the string with another delimiter.
- */
- public static void delimitOn(char[] string, char delimiter, Writer writer) {
- writeCharOn(delimiter, writer);
- writeStringOn(string, delimiter, writer);
- writeCharOn(delimiter, writer);
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in the string with another delimiter.
- */
- public static void delimitOn(char[] string, char delimiter, StringBuffer sb) {
- sb.append(delimiter);
- for (char c : string) {
- if (c == delimiter) {
- sb.append(c);
- }
- sb.append(c);
- }
- sb.append(delimiter);
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in the string with another delimiter.
- */
- public static void delimitOn(char[] string, char delimiter, StringBuilder sb) {
- sb.append(delimiter);
- for (char c : string) {
- if (c == delimiter) {
- sb.append(c);
- }
- sb.append(c);
- }
- sb.append(delimiter);
- }
-
- /**
- * Delimit each of the specified strings with the specified delimiter; i.e. put a
- * copy of the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in a string with another delimiter.
- */
- // cannot name method simply 'delimit' because of type-erasure...
- public static Iterable<char[]> delimitCharArrays(Iterable<char[]> strings, char delimiter) {
- return new TransformationIterable<char[], char[]>(strings, new CharCharArrayDelimiter(delimiter));
- }
-
- /**
- * Delimit each of the specified strings with the specified delimiter; i.e. put a
- * copy of the delimiter at the front and back of the resulting string.
- * Escape any occurrences of the delimiter in a string with another delimiter.
- */
- // cannot name method simply 'delimit' because of type-erasure...
- public static Iterator<char[]> delimitCharArrays(Iterator<char[]> strings, char delimiter) {
- return new TransformationIterator<char[], char[]>(strings, new CharCharArrayDelimiter(delimiter));
- }
-
- private static class CharCharArrayDelimiter implements Transformer<char[], char[]> {
- private char delimiter;
- CharCharArrayDelimiter(char delimiter) {
- super();
- this.delimiter = delimiter;
- }
- public char[] transform(char[] string) {
- return StringTools.delimit(string, this.delimiter);
- }
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in the string with
- * another delimiter.
- */
- public static char[] delimit(char[] string, char[] delimiter) {
- int delimiterLength = delimiter.length;
- if (delimiterLength == 1) {
- return delimit(string, delimiter[0]);
- }
- int stringLength = string.length;
- char[] result = new char[stringLength+(2*delimiterLength)];
- System.arraycopy(delimiter, 0, result, 0, delimiterLength);
- System.arraycopy(string, 0, result, delimiterLength, stringLength);
- System.arraycopy(delimiter, 0, result, stringLength+delimiterLength, delimiterLength);
- return result;
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in the string with
- * another delimiter.
- */
- public static void delimitOn(char[] string, char[] delimiter, Writer writer) {
- if (delimiter.length == 1) {
- delimitOn(string, delimiter[0], writer);
- } else {
- writeStringOn(delimiter, writer);
- writeStringOn(string, writer);
- writeStringOn(delimiter, writer);
- }
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in the string with
- * another delimiter.
- */
- public static void delimitOn(char[] string, char[] delimiter, StringBuffer sb) {
- if (delimiter.length == 1) {
- delimitOn(string, delimiter[0], sb);
- } else {
- sb.append(delimiter);
- sb.append(string);
- sb.append(delimiter);
- }
- }
-
- /**
- * Delimit the specified string with the specified delimiter; i.e. put a copy of
- * the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in the string with
- * another delimiter.
- */
- public static void delimitOn(char[] string, char[] delimiter, StringBuilder sb) {
- if (delimiter.length == 1) {
- delimitOn(string, delimiter[0], sb);
- } else {
- sb.append(delimiter);
- sb.append(string);
- sb.append(delimiter);
- }
- }
-
- /**
- * Delimit each of the specified strings with the specified delimiter; i.e. put a
- * copy of the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in a string with
- * another delimiter.
- */
- // cannot name method simply 'delimit' because of type-erasure...
- public static Iterable<char[]> delimitCharArrays(Iterable<char[]> strings, char[] delimiter) {
- return new TransformationIterable<char[], char[]>(strings, new CharArrayCharArrayDelimiter(delimiter));
- }
-
- /**
- * Delimit each of the specified strings with the specified delimiter; i.e. put a
- * copy of the delimiter at the front and back of the resulting string.
- * Escape any occurrences of a single-character delimiter in a string with
- * another delimiter.
- */
- // cannot name method simply 'delimit' because of type-erasure...
- public static Iterator<char[]> delimitCharArrays(Iterator<char[]> strings, char[] delimiter) {
- return new TransformationIterator<char[], char[]>(strings, new CharArrayCharArrayDelimiter(delimiter));
- }
-
- private static class CharArrayCharArrayDelimiter implements Transformer<char[], char[]> {
- private char[] delimiter;
- CharArrayCharArrayDelimiter(char[] delimiter) {
- super();
- this.delimiter = delimiter;
- }
- public char[] transform(char[] string) {
- return StringTools.delimit(string, this.delimiter);
- }
- }
-
-
- // ********** delimiting queries **********
-
- /**
- * Return whether the specified string is quoted: "\"foo\"".
- */
- public static boolean stringIsQuoted(String string) {
- return stringIsDelimited(string, QUOTE);
- }
-
- /**
- * Return whether the specified string is parenthetical: "(foo)".
- */
- public static boolean stringIsParenthetical(String string) {
- return stringIsDelimited(string, OPEN_PARENTHESIS, CLOSE_PARENTHESIS);
- }
-
- /**
- * Return whether the specified string is bracketed: "[foo]".
- */
- public static boolean stringIsBracketed(String string) {
- return stringIsDelimited(string, OPEN_BRACKET, CLOSE_BRACKET);
- }
-
- /**
- * Return whether the specified string is braced: "{foo}".
- */
- public static boolean stringIsBraced(String string) {
- return stringIsDelimited(string, OPEN_BRACE, CLOSE_BRACE);
- }
-
- /**
- * Return whether the specified string is chevroned: "<foo>".
- */
- public static boolean stringIsChevroned(String string) {
- return stringIsDelimited(string, OPEN_CHEVRON, CLOSE_CHEVRON);
- }
-
- /**
- * Return whether the specified string is delimited by the specified
- * character.
- */
- public static boolean stringIsDelimited(String string, char c) {
- return stringIsDelimited(string, c, c);
- }
-
- /**
- * Return whether the specified string is delimited by the specified
- * characters.
- */
- public static boolean stringIsDelimited(String string, char start, char end) {
- int len = string.length();
- if (len < 2) {
- return false;
- }
- return stringIsDelimited(string.toCharArray(), start, end, len);
- }
-
- /**
- * Return whether the specified string is quoted: "\"foo\"".
- */
- public static boolean stringIsQuoted(char[] string) {
- return stringIsDelimited(string, QUOTE);
- }
-
- /**
- * Return whether the specified string is parenthetical: "(foo)".
- */
- public static boolean stringIsParenthetical(char[] string) {
- return stringIsDelimited(string, OPEN_PARENTHESIS, CLOSE_PARENTHESIS);
- }
-
- /**
- * Return whether the specified string is bracketed: "[foo]".
- */
- public static boolean stringIsBracketed(char[] string) {
- return stringIsDelimited(string, OPEN_BRACKET, CLOSE_BRACKET);
- }
-
- /**
- * Return whether the specified string is braced: "{foo}".
- */
- public static boolean stringIsBraced(char[] string) {
- return stringIsDelimited(string, OPEN_BRACE, CLOSE_BRACE);
- }
-
- /**
- * Return whether the specified string is chevroned: "<foo>".
- */
- public static boolean stringIsChevroned(char[] string) {
- return stringIsDelimited(string, OPEN_CHEVRON, CLOSE_CHEVRON);
- }
-
- /**
- * Return whether the specified string is delimited by the specified
- * character.
- */
- public static boolean stringIsDelimited(char[] string, char c) {
- return stringIsDelimited(string, c, c);
- }
-
- /**
- * Return whether the specified string is delimited by the specified
- * characters.
- */
- public static boolean stringIsDelimited(char[] string, char start, char end) {
- int len = string.length;
- if (len < 2) {
- return false;
- }
- return stringIsDelimited(string, start, end, len);
- }
-
- private static boolean stringIsDelimited(char[] s, char start, char end, int len) {
- return (s[0] == start) && (s[len - 1] == end);
- }
-
-
- // ********** undelimiting **********
-
- /**
- * Remove the delimiters from the specified string, removing any escape
- * characters. Throw an IllegalArgumentException if the string is too short
- * to undelimit (i.e. length < 2).
- */
- public static String undelimit(String string) {
- int len = string.length() - 2;
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + string + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return EMPTY_STRING;
- }
- return new String(undelimit_(string.toCharArray(), len));
- }
-
- /**
- * Remove the first and last count characters from the specified string.
- * If the string is too short to be undelimited, throw an
- * IllegalArgumentException.
- * Use this method to undelimit strings that do not escape embedded
- * delimiters.
- */
- public static String undelimit(String string, int count) {
- int len = string.length() - (2 * count);
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + string + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return EMPTY_STRING;
- }
- return new String(undelimit(string.toCharArray(), len, count));
- }
-
- /**
- * Remove the delimiters from the specified string, removing any escape
- * characters. Throw an IllegalArgumentException if the string is too short
- * to undelimit (i.e. length < 2).
- */
- public static char[] undelimit(char[] string) {
- int len = string.length - 2;
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + new String(string) + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return EMPTY_CHAR_ARRAY;
- }
- return undelimit_(string, len);
- }
-
- private static char[] undelimit_(char[] string, int length) {
- StringBuilder sb = new StringBuilder(length);
- undelimitOn_(string, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Remove the first and last count characters from the specified string.
- * If the string is too short to be undelimited, throw an
- * IllegalArgumentException.
- * Use this method to undelimit strings that do not escape embedded
- * delimiters.
- */
- public static char[] undelimit(char[] string, int count) {
- int len = string.length - (2 * count);
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + new String(string) + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return EMPTY_CHAR_ARRAY;
- }
- return undelimit(string, len, count);
- }
-
- private static char[] undelimit(char[] string, int len, int count) {
- char[] result = new char[len];
- System.arraycopy(string, count, result, 0, len);
- return result;
- }
-
- /**
- * Remove the delimiters from the specified string, removing any escape
- * characters. Throw an IllegalArgumentException if the string is too short
- * to undelimit (i.e. length < 2).
- */
- public static void undelimitOn(String string, Writer writer) {
- undelimitOn(string.toCharArray(), writer);
- }
-
- /**
- * Remove the first and last count characters from the specified string.
- * If the string is too short to be undelimited, throw an
- * IllegalArgumentException.
- * Use this method to undelimit strings that do not escape embedded
- * delimiters.
- */
- public static void undelimitOn(String string, int count, Writer writer) {
- int len = string.length() - (2 * count);
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + string + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return;
- }
- writeStringOn(string, count, len, writer);
- }
-
- /**
- * Remove the delimiters from the specified string, removing any escape
- * characters. Throw an IllegalArgumentException if the string is too short
- * to undelimit (i.e. length < 2).
- */
- public static void undelimitOn(String string, StringBuffer sb) {
- undelimitOn(string.toCharArray(), sb);
- }
-
- /**
- * Remove the first and last count characters from the specified string.
- * If the string is too short to be undelimited, throw an
- * IllegalArgumentException.
- * Use this method to undelimit strings that do not escape embedded
- * delimiters.
- */
- public static void undelimitOn(String string, int count, StringBuffer sb) {
- int len = string.length() - (2 * count);
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + string + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return;
- }
- sb.append(string, count, count + len);
- }
-
- /**
- * Remove the delimiters from the specified string, removing any escape
- * characters. Throw an IllegalArgumentException if the string is too short
- * to undelimit (i.e. length < 2).
- */
- public static void undelimitOn(String string, StringBuilder sb) {
- undelimitOn(string.toCharArray(), sb);
- }
-
- /**
- * Remove the first and last count characters from the specified string.
- * If the string is too short to be undelimited, throw an
- * IllegalArgumentException.
- * Use this method to undelimit strings that do not escape embedded
- * delimiters.
- */
- public static void undelimitOn(String string, int count, StringBuilder sb) {
- int len = string.length() - (2 * count);
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + string + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return;
- }
- sb.append(string, count, count + len);
- }
-
- /**
- * Remove the delimiters from the specified string, removing any escape
- * characters. Throw an IllegalArgumentException if the string is too short
- * to undelimit (i.e. length < 2).
- */
- public static void undelimitOn(char[] string, Writer writer) {
- int len = string.length - 2;
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + new String(string) + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return;
- }
- undelimitOn_(string, writer);
- }
-
- /**
- * pre-condition: string is at least 3 characters long
- */
- private static void undelimitOn_(char[] string, Writer writer) {
- char delimiter = string[0]; // the first char is the delimiter
- char c = string[0];
- char next = string[1];
- int i = 1;
- int last = string.length - 1;
- do {
- c = next;
- writeCharOn(c, writer);
- i++;
- next = string[i];
- if (c == delimiter) {
- if ((next != delimiter) || (i == last)) {
- // an embedded delimiter must be followed by another delimiter
- return;
- }
- i++;
- next = string[i];
- }
- } while (i != last);
- }
-
- /**
- * Remove the first and last count characters from the specified string.
- * If the string is too short to be undelimited, throw an
- * IllegalArgumentException.
- * Use this method to undelimit strings that do not escape embedded
- * delimiters.
- */
- public static void undelimitOn(char[] string, int count, Writer writer) {
- int len = string.length - (2 * count);
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + new String(string) + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return;
- }
- writeStringOn(string, count, len, writer);
- }
-
- /**
- * Remove the delimiters from the specified string, removing any escape
- * characters. Throw an IllegalArgumentException if the string is too short
- * to undelimit (i.e. length < 2).
- */
- public static void undelimitOn(char[] string, StringBuffer sb) {
- int len = string.length - 2;
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + new String(string) + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return;
- }
- undelimitOn_(string, sb);
- }
-
- /**
- * pre-condition: string is at least 3 characters long
- */
- private static void undelimitOn_(char[] string, StringBuffer sb) {
- char delimiter = string[0]; // the first char is the delimiter
- char c = string[0];
- char next = string[1];
- int i = 1;
- int last = string.length - 1;
- do {
- c = next;
- sb.append(c);
- i++;
- next = string[i];
- if (c == delimiter) {
- if ((next != delimiter) || (i == last)) {
- // an embedded delimiter must be followed by another delimiter
- return;
- }
- i++;
- next = string[i];
- }
- } while (i != last);
- }
-
- /**
- * Remove the first and last count characters from the specified string.
- * If the string is too short to be undelimited, throw an
- * IllegalArgumentException.
- * Use this method to undelimit strings that do not escape embedded
- * delimiters.
- */
- public static void undelimitOn(char[] string, int count, StringBuffer sb) {
- int len = string.length - (2 * count);
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + new String(string) + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return;
- }
- sb.append(string, count, len);
- }
-
- /**
- * Remove the delimiters from the specified string, removing any escape
- * characters. Throw an IllegalArgumentException if the string is too short
- * to undelimit (i.e. length < 2).
- */
- public static void undelimitOn(char[] string, StringBuilder sb) {
- int len = string.length - 2;
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + new String(string) + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return;
- }
- undelimitOn_(string, sb);
- }
-
- /**
- * pre-condition: string is at least 3 characters long
- */
- private static void undelimitOn_(char[] string, StringBuilder sb) {
- char delimiter = string[0]; // the first char is the delimiter
- char c = string[0];
- char next = string[1];
- int i = 1;
- int last = string.length - 1;
- do {
- c = next;
- sb.append(c);
- i++;
- next = string[i];
- if (c == delimiter) {
- if ((next != delimiter) || (i == last)) {
- // an embedded delimiter must be followed by another delimiter
- return;
- }
- i++;
- next = string[i];
- }
- } while (i != last);
- }
-
- /**
- * Remove the first and last count characters from the specified string.
- * If the string is too short to be undelimited, throw an
- * IllegalArgumentException.
- * Use this method to undelimit strings that do not escape embedded
- * delimiters.
- */
- public static void undelimitOn(char[] string, int count, StringBuilder sb) {
- int len = string.length - (2 * count);
- if (len < 0) {
- throw new IllegalArgumentException("invalid string: \"" + new String(string) + '"'); //$NON-NLS-1$
- }
- if (len == 0) {
- return;
- }
- sb.append(string, count, len);
- }
-
-
- // ********** removing characters **********
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and return the result.
- * <p>
- * <code>
- * String.removeFirstOccurrence(char)
- * </code>
- */
- public static String removeFirstOccurrence(String string, char c) {
- int index = string.indexOf(c);
- if (index == -1) {
- // character not found
- return string;
- }
- if (index == 0) {
- // character found at the front of string
- return string.substring(1);
- }
- int last = string.length() - 1;
- if (index == last) {
- // character found at the end of string
- return string.substring(0, last);
- }
- // character found somewhere in the middle of the string
- return string.substring(0, index).concat(string.substring(index + 1));
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * <p>
- * <code>
- * String.removeFirstOccurrenceOn(char, Writer)
- * </code>
- */
- public static void removeFirstOccurrenceOn(String string, char c, Writer writer) {
- int index = string.indexOf(c);
- if (index == -1) {
- writeStringOn(string, writer);
- } else {
- removeCharAtIndexOn(string.toCharArray(), index, writer);
- }
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * <p>
- * <code>
- * String.removeFirstOccurrenceOn(char, StringBuffer)
- * </code>
- */
- public static void removeFirstOccurrenceOn(String string, char c, StringBuffer sb) {
- int index = string.indexOf(c);
- if (index == -1) {
- sb.append(string);
- } else {
- removeCharAtIndexOn(string.toCharArray(), index, sb);
- }
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * <p>
- * <code>
- * String.removeFirstOccurrenceOn(char, StringBuilder)
- * </code>
- */
- public static void removeFirstOccurrenceOn(String string, char c, StringBuilder sb) {
- int index = string.indexOf(c);
- if (index == -1) {
- sb.append(string);
- } else {
- removeCharAtIndexOn(string.toCharArray(), index, sb);
- }
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and return the result.
- * <p>
- * <code>
- * String.removeFirstOccurrence(char)
- * </code>
- */
- public static char[] removeFirstOccurrence(char[] string, char c) {
- int index = ArrayTools.indexOf(string, c);
- if (index == -1) {
- // character not found
- return string;
- }
- int last = string.length - 1;
- char[] result = new char[last];
- if (index == 0) {
- // character found at the front of string
- System.arraycopy(string, 1, result, 0, last);
- } else if (index == last) {
- // character found at the end of string
- System.arraycopy(string, 0, result, 0, last);
- } else {
- // character found somewhere in the middle of the string
- System.arraycopy(string, 0, result, 0, index);
- System.arraycopy(string, index + 1, result, index, last - index);
- }
- return result;
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * <p>
- * <code>
- * String.removeFirstOccurrenceOn(char, Writer)
- * </code>
- */
- public static void removeFirstOccurrenceOn(char[] string, char c, Writer writer) {
- int index = ArrayTools.indexOf(string, c);
- if (index == -1) {
- writeStringOn(string, writer);
- } else {
- removeCharAtIndexOn(string, index, writer);
- }
- }
-
- private static void removeCharAtIndexOn(char[] string, int index, Writer writer) {
- int last = string.length - 1;
- if (index == 0) {
- // character found at the front of string
- writeStringOn(string, 1, last, writer);
- } else if (index == last) {
- // character found at the end of string
- writeStringOn(string, 0, last, writer);
- } else {
- // character found somewhere in the middle of the string
- writeStringOn(string, 0, index, writer);
- writeStringOn(string, index + 1, last - index, writer);
- }
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * <p>
- * <code>
- * String.removeFirstOccurrenceOn(char, StringBuffer)
- * </code>
- */
- public static void removeFirstOccurrenceOn(char[] string, char c, StringBuffer sb) {
- int index = ArrayTools.indexOf(string, c);
- if (index == -1) {
- sb.append(string);
- } else {
- removeCharAtIndexOn(string, index, sb);
- }
- }
-
- private static void removeCharAtIndexOn(char[] string, int index, StringBuffer sb) {
- int last = string.length - 1;
- if (index == 0) {
- // character found at the front of string
- sb.append(string, 1, last);
- } else if (index == last) {
- // character found at the end of string
- sb.append(string, 0, last);
- } else {
- // character found somewhere in the middle of the string
- sb.append(string, 0, index);
- sb.append(string, index + 1, last - index);
- }
- }
-
- /**
- * Remove the first occurrence of the specified character
- * from the specified string and print the result on the specified stream.
- * <p>
- * <code>
- * String.removeFirstOccurrenceOn(char, StringBuilder)
- * </code>
- */
- public static void removeFirstOccurrenceOn(char[] string, char c, StringBuilder sb) {
- int index = ArrayTools.indexOf(string, c);
- if (index == -1) {
- sb.append(string);
- } else {
- removeCharAtIndexOn(string, index, sb);
- }
- }
-
- private static void removeCharAtIndexOn(char[] string, int index, StringBuilder sb) {
- int last = string.length - 1;
- if (index == 0) {
- // character found at the front of string
- sb.append(string, 1, last);
- } else if (index == last) {
- // character found at the end of string
- sb.append(string, 0, last);
- } else {
- // character found somewhere in the middle of the string
- sb.append(string, 0, index);
- sb.append(string, index + 1, last - index);
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and return the result.
- * <p>
- * <code>
- * String.removeAllOccurrences(char)
- * </code>
- */
- public static String removeAllOccurrences(String string, char c) {
- int first = string.indexOf(c);
- return (first == -1) ? string : new String(removeAllOccurrences_(string.toCharArray(), c, first));
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and write the result to the specified stream.
- * <p>
- * <code>
- * String.removeAllOccurrencesOn(char, Writer)
- * </code>
- */
- public static void removeAllOccurrencesOn(String string, char c, Writer writer) {
- int first = string.indexOf(c);
- if (first == -1) {
- writeStringOn(string, writer);
- } else {
- removeAllOccurrencesOn_(string.toCharArray(), c, first, writer);
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and write the result to the specified stream.
- * <p>
- * <code>
- * String.removeAllOccurrencesOn(char, StringBuffer)
- * </code>
- */
- public static void removeAllOccurrencesOn(String string, char c, StringBuffer sb) {
- int first = string.indexOf(c);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllOccurrencesOn_(string.toCharArray(), c, first, sb);
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and write the result to the specified stream.
- * <p>
- * <code>
- * String.removeAllOccurrencesOn(char, StringBuilder)
- * </code>
- */
- public static void removeAllOccurrencesOn(String string, char c, StringBuilder sb) {
- int first = string.indexOf(c);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllOccurrencesOn_(string.toCharArray(), c, first, sb);
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and return the result.
- * <p>
- * <code>
- * String.removeAllOccurrences(char)
- * </code>
- */
- public static char[] removeAllOccurrences(char[] string, char c) {
- int first = ArrayTools.indexOf(string, c);
- return (first == -1) ? string : removeAllOccurrences_(string, c, first);
- }
-
- /*
- * The index of the first matching character is passed in.
- */
- private static char[] removeAllOccurrences_(char[] string, char c, int first) {
- StringBuilder sb = new StringBuilder(string.length);
- removeAllOccurrencesOn_(string, c, first, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and write the result to the
- * specified writer.
- * <p>
- * <code>
- * String.removeAllOccurrencesOn(char, Writer)
- * </code>
- */
- public static void removeAllOccurrencesOn(char[] string, char c, Writer writer) {
- int first = ArrayTools.indexOf(string, c);
- if (first == -1) {
- writeStringOn(string, writer);
- } else {
- removeAllOccurrencesOn_(string, c, first, writer);
- }
- }
-
- /*
- * The index of the first matching character is passed in.
- */
- private static void removeAllOccurrencesOn_(char[] string, char c, int first, Writer writer) {
- writeStringOn(string, 0, first, writer);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char d = string[i];
- if (d != c) {
- writeCharOn(d, writer);
- }
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and append the result to the
- * specified string buffer.
- * <p>
- * <code>
- * String.removeAllOccurrencesOn(char, StringBuffer)
- * </code>
- */
- public static void removeAllOccurrencesOn(char[] string, char c, StringBuffer sb) {
- int first = ArrayTools.indexOf(string, c);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllOccurrencesOn_(string, c, first, sb);
- }
- }
-
- /*
- * The index of the first matching character is passed in.
- */
- private static void removeAllOccurrencesOn_(char[] string, char c, int first, StringBuffer sb) {
- sb.append(string, 0, first);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char d = string[i];
- if (d != c) {
- sb.append(d);
- }
- }
- }
-
- /**
- * Remove all occurrences of the specified character
- * from the specified string and append the result to the
- * specified string builder.
- * <p>
- * <code>
- * String.removeAllOccurrencesOn(char, StringBuilder)
- * </code>
- */
- public static void removeAllOccurrencesOn(char[] string, char c, StringBuilder sb) {
- int first = ArrayTools.indexOf(string, c);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllOccurrencesOn_(string, c, first, sb);
- }
- }
-
- /*
- * The index of the first matching character is passed in.
- */
- private static void removeAllOccurrencesOn_(char[] string, char c, int first, StringBuilder sb) {
- sb.append(string, 0, first);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char d = string[i];
- if (d != c) {
- sb.append(d);
- }
- }
- }
-
- /**
- * Remove all the spaces from the specified string and return the result.
- * <p>
- * <code>
- * String.removeAllSpaces()
- * </code>
- */
- public static String removeAllSpaces(String string) {
- return removeAllOccurrences(string, ' ');
- }
-
- /**
- * Remove all the spaces
- * from the specified string and write the result to the specified writer.
- * <p>
- * <code>
- * String.removeAllSpacesOn(Writer)
- * </code>
- */
- public static void removeAllSpacesOn(String string, Writer writer) {
- removeAllOccurrencesOn(string, ' ', writer);
- }
-
- /**
- * Remove all the spaces
- * from the specified string and write the result to the specified
- * string buffer.
- * <p>
- * <code>
- * String.removeAllSpacesOn(StringBuffer)
- * </code>
- */
- public static void removeAllSpacesOn(String string, StringBuffer sb) {
- removeAllOccurrencesOn(string, ' ', sb);
- }
-
- /**
- * Remove all the spaces
- * from the specified string and write the result to the specified
- * string builder.
- * <p>
- * <code>
- * String.removeAllSpacesOn(StringBuilder)
- * </code>
- */
- public static void removeAllSpacesOn(String string, StringBuilder sb) {
- removeAllOccurrencesOn(string, ' ', sb);
- }
-
- /**
- * Remove all the spaces from the specified string and return the result.
- * <p>
- * <code>
- * String.removeAllSpaces()
- * </code>
- */
- public static char[] removeAllSpaces(char[] string) {
- return removeAllOccurrences(string, ' ');
- }
-
- /**
- * Remove all the spaces
- * from the specified string and write the result to the
- * specified writer.
- * <p>
- * <code>
- * String.removeAllSpacesOn(Writer)
- * </code>
- */
- public static void removeAllSpacesOn(char[] string, Writer writer) {
- removeAllOccurrencesOn(string, ' ', writer);
- }
-
- /**
- * Remove all the spaces
- * from the specified string and append the result to the
- * specified string buffer.
- * <p>
- * <code>
- * String.removeAllSpacesOn(StringBuffer)
- * </code>
- */
- public static void removeAllSpacesOn(char[] string, StringBuffer sb) {
- removeAllOccurrencesOn(string, ' ', sb);
- }
-
- /**
- * Remove all the spaces
- * from the specified string and append the result to the
- * specified string builder.
- * <p>
- * <code>
- * String.removeAllSpacesOn(StringBuilder)
- * </code>
- */
- public static void removeAllSpacesOn(char[] string, StringBuilder sb) {
- removeAllOccurrencesOn(string, ' ', sb);
- }
-
- /**
- * Remove all the whitespace from the specified string and return the result.
- * <p>
- * <code>
- * String.removeAllWhitespace()
- * </code>
- */
- public static String removeAllWhitespace(String string) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- return (first == -1) ? string : new String(removeAllWhitespace_(string2, first));
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified writer.
- * <p>
- * <code>
- * String.removeAllWhitespaceOn(Writer)
- * </code>
- */
- public static void removeAllWhitespaceOn(String string, Writer writer) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- if (first == -1) {
- writeStringOn(string, writer);
- } else {
- removeAllWhitespaceOn_(string2, first, writer);
- }
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified string buffer.
- * <p>
- * <code>
- * String.removeAllWhitespaceOn(StringBuffer)
- * </code>
- */
- public static void removeAllWhitespaceOn(String string, StringBuffer sb) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllWhitespaceOn_(string2, first, sb);
- }
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified string builder.
- * <p>
- * <code>
- * String.removeAllWhitespaceOn(StringBuilder)
- * </code>
- */
- public static void removeAllWhitespaceOn(String string, StringBuilder sb) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllWhitespaceOn_(string2, first, sb);
- }
- }
-
- /**
- * Remove all the whitespace from the specified string and return the result.
- * <p>
- * <code>
- * String.removeAllWhitespace()
- * </code>
- */
- public static char[] removeAllWhitespace(char[] string) {
- int first = indexOfWhitespace_(string);
- return (first == -1) ? string : removeAllWhitespace_(string, first);
- }
-
- private static int indexOfWhitespace_(char[] string) {
- int len = string.length;
- for (int i = 0; i < len; i++) {
- if (Character.isWhitespace(string[i])) {
- return i;
- }
- }
- return -1;
- }
-
- /*
- * The index of the first non-whitespace character is passed in.
- */
- private static char[] removeAllWhitespace_(char[] string, int first) {
- StringBuilder sb = new StringBuilder(string.length);
- removeAllWhitespaceOn_(string, first, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified writer.
- * <p>
- * <code>
- * String.removeAllWhitespaceOn(Writer)
- * </code>
- */
- public static void removeAllWhitespaceOn(char[] string, Writer writer) {
- int first = indexOfWhitespace_(string);
- if (first == -1) {
- writeStringOn(string, writer);
- } else {
- removeAllWhitespaceOn_(string, first, writer);
- }
- }
-
- /*
- * The index of the first whitespace character is passed in.
- */
- private static void removeAllWhitespaceOn_(char[] string, int first, Writer writer) {
- writeStringOn(string, 0, first, writer);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char c = string[i];
- if ( ! Character.isWhitespace(c)) {
- writeCharOn(c, writer);
- }
- }
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified string buffer.
- * <p>
- * <code>
- * String.removeAllWhitespaceOn(StringBuffer)
- * </code>
- */
- public static void removeAllWhitespaceOn(char[] string, StringBuffer sb) {
- int first = indexOfWhitespace_(string);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllWhitespaceOn_(string, first, sb);
- }
- }
-
- /*
- * The index of the first whitespace character is passed in.
- */
- private static void removeAllWhitespaceOn_(char[] string, int first, StringBuffer sb) {
- sb.append(string, 0, first);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char c = string[i];
- if ( ! Character.isWhitespace(c)) {
- sb.append(c);
- }
- }
- }
-
- /**
- * Remove all the whitespace
- * from the specified string and append the result to the
- * specified string builder.
- * <p>
- * <code>
- * String.removeAllWhitespaceOn(StringBuilder)
- * </code>
- */
- public static void removeAllWhitespaceOn(char[] string, StringBuilder sb) {
- int first = indexOfWhitespace_(string);
- if (first == -1) {
- sb.append(string);
- } else {
- removeAllWhitespaceOn_(string, first, sb);
- }
- }
-
- /*
- * The index of the first whitespace character is passed in.
- */
- private static void removeAllWhitespaceOn_(char[] string, int first, StringBuilder sb) {
- sb.append(string, 0, first);
- int len = string.length;
- for (int i = first; i < len; i++) {
- char c = string[i];
- if ( ! Character.isWhitespace(c)) {
- sb.append(c);
- }
- }
- }
-//===============================
- /**
- * Compress the whitespace in the specified string and return the result.
- * The whitespace is compressed by replacing any occurrence of one or more
- * whitespace characters with a single space.
- * <p>
- * <code>
- * String.compressWhitespace()
- * </code>
- */
- public static String compressWhitespace(String string) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- return (first == -1) ? string : new String(compressWhitespace_(string2, first));
- }
-
- /**
- * Compress the whitespace
- * in the specified string and append the result to the
- * specified writer.
- * The whitespace is compressed by replacing any occurrence of one or more
- * whitespace characters with a single space.
- * <p>
- * <code>
- * String.compressWhitespaceOn(Writer)
- * </code>
- */
- public static void compressWhitespaceOn(String string, Writer writer) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- if (first == -1) {
- writeStringOn(string, writer);
- } else {
- compressWhitespaceOn_(string2, first, writer);
- }
- }
-
- /**
- * Compress the whitespace
- * in the specified string and append the result to the
- * specified string buffer.
- * The whitespace is compressed by replacing any occurrence of one or more
- * whitespace characters with a single space.
- * <p>
- * <code>
- * String.compressWhitespaceOn(StringBuffer)
- * </code>
- */
- public static void compressWhitespaceOn(String string, StringBuffer sb) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- if (first == -1) {
- sb.append(string);
- } else {
- compressWhitespaceOn_(string2, first, sb);
- }
- }
-
- /**
- * Compress the whitespace
- * in the specified string and append the result to the
- * specified string builder.
- * The whitespace is compressed by replacing any occurrence of one or more
- * whitespace characters with a single space.
- * <p>
- * <code>
- * String.compressWhitespaceOn(StringBuilder)
- * </code>
- */
- public static void compressWhitespaceOn(String string, StringBuilder sb) {
- char[] string2 = string.toCharArray();
- int first = indexOfWhitespace_(string2);
- if (first == -1) {
- sb.append(string);
- } else {
- compressWhitespaceOn_(string2, first, sb);
- }
- }
-
- /**
- * Compress the whitespace in the specified string and return the result.
- * The whitespace is compressed by replacing any occurrence of one or more
- * whitespace characters with a single space.
- * <p>
- * <code>
- * String.compressWhitespace()
- * </code>
- */
- public static char[] compressWhitespace(char[] string) {
- int first = indexOfWhitespace_(string);
- return (first == -1) ? string : compressWhitespace_(string, first);
- }
-
- /*
- * The index of the first whitespace character is passed in.
- */
- private static char[] compressWhitespace_(char[] string, int first) {
- StringBuilder sb = new StringBuilder(string.length);
- compressWhitespaceOn_(string, first, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Compress the whitespace
- * in the specified string and append the result to the
- * specified writer.
- * The whitespace is compressed by replacing any occurrence of one or more
- * whitespace characters with a single space.
- * <p>
- * <code>
- * String.compressWhitespaceOn(Writer)
- * </code>
- */
- public static void compressWhitespaceOn(char[] string, Writer writer) {
- int first = indexOfWhitespace_(string);
- if (first == -1) {
- writeStringOn(string, writer);
- } else {
- compressWhitespaceOn_(string, first, writer);
- }
- }
-
- /*
- * The index of the first whitespace character is passed in.
- */
- private static void compressWhitespaceOn_(char[] string, int first, Writer writer) {
- writeStringOn(string, 0, first, writer);
- boolean spaceWritten = false;
- int len = string.length;
- for (int i = first; i < len; i++) {
- char c = string[i];
- if (Character.isWhitespace(c)) {
- if (spaceWritten) {
- // skip subsequent whitespace characters
- } else {
- // replace first whitespace character with a space
- spaceWritten = true;
- writeCharOn(' ', writer);
- }
- } else {
- spaceWritten = false;
- writeCharOn(c, writer);
- }
- }
- }
-
- /**
- * Compress the whitespace
- * in the specified string and append the result to the
- * specified string buffer.
- * The whitespace is compressed by replacing any occurrence of one or more
- * whitespace characters with a single space.
- * <p>
- * <code>
- * String.compressWhitespaceOn(StringBuffer)
- * </code>
- */
- public static void compressWhitespaceOn(char[] string, StringBuffer sb) {
- int first = indexOfWhitespace_(string);
- if (first == -1) {
- sb.append(string);
- } else {
- compressWhitespaceOn_(string, first, sb);
- }
- }
-
- /*
- * The index of the first whitespace character is passed in.
- */
- private static void compressWhitespaceOn_(char[] string, int first, StringBuffer sb) {
- sb.append(string, 0, first);
- boolean spaceWritten = false;
- int len = string.length;
- for (int i = first; i < len; i++) {
- char c = string[i];
- if (Character.isWhitespace(c)) {
- if (spaceWritten) {
- // skip subsequent whitespace characters
- } else {
- // replace first whitespace character with a space
- spaceWritten = true;
- sb.append(' ');
- }
- } else {
- spaceWritten = false;
- sb.append(c);
- }
- }
- }
-
- /**
- * Compress the whitespace
- * in the specified string and append the result to the
- * specified string builder.
- * The whitespace is compressed by replacing any occurrence of one or more
- * whitespace characters with a single space.
- * <p>
- * <code>
- * String.compressWhitespaceOn(StringBuilder)
- * </code>
- */
- public static void compressWhitespaceOn(char[] string, StringBuilder sb) {
- int first = indexOfWhitespace_(string);
- if (first == -1) {
- sb.append(string);
- } else {
- compressWhitespaceOn_(string, first, sb);
- }
- }
-
- /*
- * The index of the first whitespace character is passed in.
- */
- private static void compressWhitespaceOn_(char[] string, int first, StringBuilder sb) {
- sb.append(string, 0, first);
- boolean spaceWritten = false;
- int len = string.length;
- for (int i = first; i < len; i++) {
- char c = string[i];
- if (Character.isWhitespace(c)) {
- if (spaceWritten) {
- // skip subsequent whitespace characters
- } else {
- // replace first whitespace character with a space
- spaceWritten = true;
- sb.append(' ');
- }
- } else {
- spaceWritten = false;
- sb.append(c);
- }
- }
- }
-
-
- // ********** common prefix **********
-
- /**
- * Return the length of the common prefix shared by the specified strings.
- * <p>
- * <code>
- * String.commonPrefixLength(String)
- * </code>
- */
- public static int commonPrefixLength(String s1, String s2) {
- return commonPrefixLength(s1.toCharArray(), s2.toCharArray());
- }
-
- /**
- * Return the length of the common prefix shared by the specified strings.
- */
- public static int commonPrefixLength(char[] s1, char[] s2) {
- return commonPrefixLength_(s1, s2, Math.min(s1.length, s2.length));
- }
-
- /**
- * Return the length of the common prefix shared by the specified strings;
- * but limit the length to the specified maximum.
- * <p>
- * <code>
- * String.commonPrefixLength(String, int)
- * </code>
- */
- public static int commonPrefixLength(String s1, String s2, int max) {
- return commonPrefixLength(s1.toCharArray(), s2.toCharArray(), max);
- }
-
- /**
- * Return the length of the common prefix shared by the specified strings;
- * but limit the length to the specified maximum.
- */
- public static int commonPrefixLength(char[] s1, char[] s2, int max) {
- return commonPrefixLength_(s1, s2, Math.min(max, Math.min(s1.length, s2.length)));
- }
-
- /*
- * Return the length of the common prefix shared by the specified strings;
- * but limit the length to the specified maximum. Assume the specified
- * maximum is less than the lengths of the specified strings.
- */
- private static int commonPrefixLength_(char[] s1, char[] s2, int max) {
- for (int i = 0; i < max; i++) {
- if (s1[i] != s2[i]) {
- return i;
- }
- }
- return max; // all the characters up to 'max' are the same
- }
-
-
- // ********** capitalization **********
-
- /*
- * no zero-length check or lower case check
- */
- private static char[] capitalize_(char[] string) {
- string[0] = Character.toUpperCase(string[0]);
- return string;
- }
-
- /**
- * Modify and return the specified string with
- * its first letter capitalized.
- */
- public static char[] capitalize(char[] string) {
- if ((string.length == 0) || Character.isUpperCase(string[0])) {
- return string;
- }
- return capitalize_(string);
- }
-
- /**
- * Return the specified string with its first letter capitalized.
- * <p>
- * <code>
- * String.capitalize()
- * </code>
- */
- public static String capitalize(String string) {
- if ((string.length() == 0) || Character.isUpperCase(string.charAt(0))) {
- return string;
- }
- return new String(capitalize_(string.toCharArray()));
- }
-
- /**
- * Modify each of the specified strings, capitalizing the first letter of
- * each.
- */
- public static Iterable<String> capitalize(Iterable<String> strings) {
- return new TransformationIterable<String, String>(strings, STRING_CAPITALIZER);
- }
-
- /**
- * Modify each of the specified strings, capitalizing the first letter of
- * each.
- */
- public static Iterator<String> capitalize(Iterator<String> strings) {
- return new TransformationIterator<String, String>(strings, STRING_CAPITALIZER);
- }
-
- private static final Transformer<String, String> STRING_CAPITALIZER = new Transformer<String, String>() {
- public String transform(String string) {
- return StringTools.capitalize(string);
- }
- };
-
- /**
- * Modify each of the specified strings, capitalizing the first letter of
- * each.
- */
- // cannot name method simply 'capitalize' because of type-erasure...
- public static Iterable<char[]> capitalizeCharArrays(Iterable<char[]> strings) {
- return new TransformationIterable<char[], char[]>(strings, CHAR_ARRAY_CAPITALIZER);
- }
-
- /**
- * Modify each of the specified strings, capitalizing the first letter of
- * each.
- */
- // cannot name method simply 'capitalize' because of type-erasure...
- public static Iterator<char[]> capitalizeCharArrays(Iterator<char[]> strings) {
- return new TransformationIterator<char[], char[]>(strings, CHAR_ARRAY_CAPITALIZER);
- }
-
- private static final Transformer<char[], char[]> CHAR_ARRAY_CAPITALIZER = new Transformer<char[], char[]>() {
- public char[] transform(char[] string) {
- return StringTools.capitalize(string);
- }
- };
-
- /*
- * no zero-length check or upper case check
- */
- private static void capitalizeOn_(char[] string, StringBuffer sb) {
- sb.append(Character.toUpperCase(string[0]));
- sb.append(string, 1, string.length - 1);
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter capitalized.
- */
- public static void capitalizeOn(char[] string, StringBuffer sb) {
- if (string.length == 0) {
- return;
- }
- if (Character.isUpperCase(string[0])) {
- sb.append(string);
- } else {
- capitalizeOn_(string, sb);
- }
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter capitalized.
- * <p>
- * <code>
- * String.capitalizeOn(StringBuffer)
- * </code>
- */
- public static void capitalizeOn(String string, StringBuffer sb) {
- if (string.length() == 0) {
- return;
- }
- if (Character.isUpperCase(string.charAt(0))) {
- sb.append(string);
- } else {
- capitalizeOn_(string.toCharArray(), sb);
- }
- }
-
- /*
- * no zero-length check or upper case check
- */
- private static void capitalizeOn_(char[] string, StringBuilder sb) {
- sb.append(Character.toUpperCase(string[0]));
- sb.append(string, 1, string.length - 1);
- }
-
- /**
- * Append the specified string to the specified string builder
- * with its first letter capitalized.
- */
- public static void capitalizeOn(char[] string, StringBuilder sb) {
- if (string.length == 0) {
- return;
- }
- if (Character.isUpperCase(string[0])) {
- sb.append(string);
- } else {
- capitalizeOn_(string, sb);
- }
- }
-
- /**
- * Append the specified string to the specified string builder
- * with its first letter capitalized.
- * <p>
- * <code>
- * String.capitalizeOn(StringBuffer)
- * </code>
- */
- public static void capitalizeOn(String string, StringBuilder sb) {
- if (string.length() == 0) {
- return;
- }
- if (Character.isUpperCase(string.charAt(0))) {
- sb.append(string);
- } else {
- capitalizeOn_(string.toCharArray(), sb);
- }
- }
-
- /*
- * no zero-length check or upper case check
- */
- private static void capitalizeOn_(char[] string, Writer writer) {
- writeCharOn(Character.toUpperCase(string[0]), writer);
- writeStringOn(string, 1, string.length - 1, writer);
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter capitalized.
- */
- public static void capitalizeOn(char[] string, Writer writer) {
- if (string.length == 0) {
- return;
- }
- if (Character.isUpperCase(string[0])) {
- writeStringOn(string, writer);
- } else {
- capitalizeOn_(string, writer);
- }
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter capitalized.
- * <p>
- * <code>
- * String.capitalizeOn(Writer)
- * </code>
- */
- public static void capitalizeOn(String string, Writer writer) {
- if (string.length() == 0) {
- return;
- }
- if (Character.isUpperCase(string.charAt(0))) {
- writeStringOn(string, writer);
- } else {
- capitalizeOn_(string.toCharArray(), writer);
- }
- }
-
- /*
- * no zero-length check or lower case check
- */
- private static char[] uncapitalize_(char[] string) {
- string[0] = Character.toLowerCase(string[0]);
- return string;
- }
-
- private static boolean stringNeedNotBeUncapitalized_(char[] string) {
- if (string.length == 0) {
- return true;
- }
- if (Character.isLowerCase(string[0])) {
- return true;
- }
- // if both the first and second characters are capitalized,
- // return the string unchanged
- if ((string.length > 1)
- && Character.isUpperCase(string[1])
- && Character.isUpperCase(string[0])){
- return true;
- }
- return false;
- }
-
- /**
- * Modify and return the specified string with its
- * first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- */
- public static char[] uncapitalize(char[] string) {
- if (stringNeedNotBeUncapitalized_(string)) {
- return string;
- }
- return uncapitalize_(string);
- }
-
- private static boolean stringNeedNotBeUncapitalized_(String string) {
- if (string.length() == 0) {
- return true;
- }
- if (Character.isLowerCase(string.charAt(0))) {
- return true;
- }
- // if both the first and second characters are capitalized,
- // return the string unchanged
- if ((string.length() > 1)
- && Character.isUpperCase(string.charAt(1))
- && Character.isUpperCase(string.charAt(0))){
- return true;
- }
- return false;
- }
-
- /**
- * Return the specified string with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- * <p>
- * <code>
- * String.uncapitalize()
- * </code>
- */
- public static String uncapitalize(String string) {
- if (stringNeedNotBeUncapitalized_(string)) {
- return string;
- }
- return new String(uncapitalize_(string.toCharArray()));
- }
-
- /*
- * no zero-length check or lower case check
- */
- private static void uncapitalizeOn_(char[] string, StringBuffer sb) {
- sb.append(Character.toLowerCase(string[0]));
- sb.append(string, 1, string.length - 1);
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- */
- public static void uncapitalizeOn(char[] string, StringBuffer sb) {
- if (stringNeedNotBeUncapitalized_(string)) {
- sb.append(string);
- } else {
- uncapitalizeOn_(string, sb);
- }
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- * <p>
- * <code>
- * String.uncapitalizeOn(StringBuffer)
- * </code>
- */
- public static void uncapitalizeOn(String string, StringBuffer sb) {
- if (stringNeedNotBeUncapitalized_(string)) {
- sb.append(string);
- } else {
- uncapitalizeOn_(string.toCharArray(), sb);
- }
- }
-
- /*
- * no zero-length check or lower case check
- */
- private static void uncapitalizeOn_(char[] string, StringBuilder sb) {
- sb.append(Character.toLowerCase(string[0]));
- sb.append(string, 1, string.length - 1);
- }
-
- /**
- * Append the specified string to the specified string builder
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- */
- public static void uncapitalizeOn(char[] string, StringBuilder sb) {
- if (stringNeedNotBeUncapitalized_(string)) {
- sb.append(string);
- } else {
- uncapitalizeOn_(string, sb);
- }
- }
-
- /**
- * Append the specified string to the specified string builder
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- * <p>
- * <code>
- * String.uncapitalizeOn(StringBuffer)
- * </code>
- */
- public static void uncapitalizeOn(String string, StringBuilder sb) {
- if (stringNeedNotBeUncapitalized_(string)) {
- sb.append(string);
- } else {
- uncapitalizeOn_(string.toCharArray(), sb);
- }
- }
-
- /*
- * no zero-length check or upper case check
- */
- private static void uncapitalizeOn_(char[] string, Writer writer) {
- writeCharOn(Character.toLowerCase(string[0]), writer);
- writeStringOn(string, 1, string.length - 1, writer);
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- */
- public static void uncapitalizeOn(char[] string, Writer writer) {
- if (stringNeedNotBeUncapitalized_(string)) {
- writeStringOn(string, writer);
- } else {
- uncapitalizeOn_(string, writer);
- }
- }
-
- /**
- * Append the specified string to the specified string buffer
- * with its first letter converted to lower case.
- * (Unless both the first and second letters are upper case,
- * in which case the string is returned unchanged.)
- * <p>
- * <code>
- * String.uncapitalizeOn(Writer)
- * </code>
- */
- public static void uncapitalizeOn(String string, Writer writer) {
- if (stringNeedNotBeUncapitalized_(string)) {
- writeStringOn(string, writer);
- } else {
- uncapitalizeOn_(string.toCharArray(), writer);
- }
- }
-
-
- // ********** toString() helper methods **********
-
- /**
- * Build a "Dali standard" {@link Object#toString() toString()} result for
- * the specified object and additional information:<pre>
- * ClassName[00-F3-EE-42](add'l info)
- * </pre>
- */
- public static String buildToStringFor(Object o, Object additionalInfo) {
- StringBuilder sb = new StringBuilder();
- appendSimpleToString(sb, o);
- sb.append('(');
- sb.append(additionalInfo);
- sb.append(')');
- return sb.toString();
- }
-
- /**
- * Build a "Dali standard" {@link Object#toString() toString()} result for
- * the specified object:<pre>
- * ClassName[00-F3-EE-42]
- * </pre>
- */
- public static String buildToStringFor(Object o) {
- StringBuilder sb = new StringBuilder();
- appendSimpleToString(sb, o);
- return sb.toString();
- }
-
- /**
- * Append a "Dali standard" {@link Object#toString() toString()} result for
- * the specified object to the specified string builder:<pre>
- * ClassName[00-F3-EE-42]
- */
- public static void appendSimpleToString(StringBuilder sb, Object o) {
- appendToStringClassName(sb, o.getClass());
- sb.append('[');
- separateOn(buildHashCode(o), '-', 2, sb);
- sb.append(']');
- }
-
- private static String buildHashCode(Object o) {
- // use System.identityHashCode(Object), since Object.hashCode() may be overridden
- return zeroPad(Integer.toHexString(System.identityHashCode(o)).toUpperCase(), 8);
- }
-
- /**
- * Return a name suitable for a "Dali standard"
- * {@link Object#toString() toString()} implementation.
- * {@link Class#getSimpleName()} isn't quite useful enough:<ul>
- * <li>An <em>anonymous</em> class's simple name is an empty string.
- * Return the "Dali standard" name of the anonymous class's super class
- * instead, which is a bit more helpful.
- * <li>A <em>member</em> or <em>local</em> class's simple name does not
- * include its context. Prefix the class's simple name with its
- * enclosing class's "Dali standard" name.
- * </ul>
- */
- public static String buildToStringClassName(Class<?> javaClass) {
- StringBuilder sb = new StringBuilder();
- appendToStringClassName(sb, javaClass);
- return sb.toString();
- }
-
- /**
- * Return a string suitable for a <em>singleton</em>; which is the simple
- * name of the object's class, since there should only be one.
- */
- public static String buildSingletonToString(Object o) {
- return buildToStringClassName(o.getClass());
- }
-
- /**
- * Append a name suitable for a "Dali standard"
- * {@link Object#toString() toString()} implementation to the specified
- * string builder.
- * @see #buildToStringClassName(Class)
- */
- public static void appendToStringClassName(StringBuilder sb, Class<?> javaClass) {
- if (javaClass.isAnonymousClass()) {
- appendToStringClassName(sb, javaClass.getSuperclass()); // recurse
- } else {
- Class<?> enclosingClass = javaClass.getEnclosingClass();
- if (enclosingClass == null) {
- appendToStringClassName_(sb, javaClass); // top-level class
- } else {
- appendToStringClassName(sb, enclosingClass); // recurse
- sb.append('.');
- sb.append(javaClass.getSimpleName());
- }
- }
- }
-
- /**
- * pre-condition: the specified class is a top-level class
- */
- private static void appendToStringClassName_(StringBuilder sb, Class<?> javaClass) {
- String fullName = javaClass.getName();
- int dot = fullName.lastIndexOf('.');
- if (dot == -1) {
- sb.append(fullName); // "default" package
- } else {
- sb.append(fullName, dot + 1, fullName.length());
- }
- }
-
- /**
- * Append the string representations of the objects in the specified array
- * to the specified string builder:<pre>
- * ["foo", "bar", "baz"]
- * </pre>
- * <p>
- * <code>
- * StringBuilder.append(Object[])
- * </code>
- */
- public static <T> String append(StringBuilder sb, T[] array) {
- return append(sb, new ArrayListIterator<T>(array));
- }
-
- /**
- * Append the string representations of the objects in the specified iterable
- * to the specified string builder:<pre>
- * ["foo", "bar", "baz"]
- * </pre>
- * <p>
- * <code>
- * StringBuilder.append(Iterable)
- * </code>
- */
- public static <T> String append(StringBuilder sb, Iterable<T> iterable) {
- return append(sb, iterable.iterator());
- }
-
- /**
- * Append the string representations of the objects in the specified iterator
- * to the specified string builder:<pre>
- * ["foo", "bar", "baz"]
- * </pre>
- * <p>
- * <code>
- * StringBuilder.append(Iterator)
- * </code>
- */
- public static <T> String append(StringBuilder sb, Iterator<T> iterator) {
- sb.append('[');
- while (iterator.hasNext()) {
- sb.append(iterator.next());
- if (iterator.hasNext()) {
- sb.append(", "); //$NON-NLS-1$
- }
- }
- sb.append(']');
- return sb.toString();
- }
-
- /**
- * Return a concatenation of the given strings
- *
- * @param strings - the strings to concatenate
- * @return the resultant concatenated string
- */
- public static String concatenate(String ... strings) {
- StringBuilder sb = new StringBuilder();
- for (String string : strings) {
- sb.append(string);
- }
- return sb.toString();
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether the specified string is <code>null</code>, empty, or
- * contains only whitespace characters.
- */
- public static boolean stringIsEmpty(String string) {
- if (string == null) {
- return true;
- }
- int len = string.length();
- if (len == 0) {
- return true;
- }
- return stringIsEmpty_(string.toCharArray(), len);
- }
-
- /**
- * Return whether the specified string is <code>null</code>, empty, or
- * contains only whitespace characters.
- */
- public static boolean stringIsEmpty(char[] string) {
- if (string == null) {
- return true;
- }
- int len = string.length;
- if (len == 0) {
- return true;
- }
- return stringIsEmpty_(string, len);
- }
-
- private static boolean stringIsEmpty_(char[] s, int len) {
- for (int i = len; i-- > 0; ) {
- if ( ! Character.isWhitespace(s[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified string is non-<code>null</code>, non-empty,
- * and does not contain only whitespace characters.
- */
- public static boolean stringIsNotEmpty(String string) {
- return ! stringIsEmpty(string);
- }
-
- /**
- * Return whether the specified string is non-<code>null</code>, non-empty,
- * and does not contain only whitespace characters.
- */
- public static boolean stringIsNotEmpty(char[] string) {
- return ! stringIsEmpty(string);
- }
-
- /**
- * Return whether the specified strings are equal.
- * Check for <code>null</code>s.
- */
- public static boolean stringsAreEqual(String s1, String s2) {
- return Tools.valuesAreEqual(s1, s2);
- }
-
- /**
- * Return whether the specified strings are equal.
- * Check for <code>null</code>s.
- */
- public static boolean stringsAreEqual(char[] s1, char[] s2) {
- return (s1 == null) ?
- (s2 == null) :
- ((s2 != null) && stringsAreEqual_(s1, s2));
- }
-
- /**
- * no <code>null</code> checks
- */
- private static boolean stringsAreEqual_(char[] s1, char[] s2) {
- int len = s1.length;
- if (len != s2.length) {
- return false;
- }
- for (int i = len; i-- > 0; ) {
- if (s1[i] != s2[i]) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified strings are equal, ignoring case.
- * Check for <code>null</code>s.
- */
- public static boolean stringsAreEqualIgnoreCase(String s1, String s2) {
- return (s1 == null) ?
- (s2 == null) :
- ((s2 != null) && s1.equalsIgnoreCase(s2));
- }
-
- /**
- * Return whether the specified strings are equal, ignoring case.
- * Check for <code>null</code>s.
- */
- public static boolean stringsAreEqualIgnoreCase(char[] s1, char[] s2) {
- return (s1 == null) ?
- (s2 == null) :
- ((s2 != null) && stringsAreEqualIgnoreCase_(s1, s2));
- }
-
- /**
- * no <code>null</code> checks
- */
- private static boolean stringsAreEqualIgnoreCase_(char[] s1, char[] s2) {
- int len = s1.length;
- if (len != s2.length) {
- return false;
- }
- for (int i = len; i-- > 0; ) {
- if ( ! charactersAreEqualIgnoreCase(s1[i], s2[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified string starts with the specified prefix,
- * ignoring case.
- */
- public static boolean stringStartsWithIgnoreCase(char[] string, char[] prefix) {
- int prefixLength = prefix.length;
- if (string.length < prefixLength) {
- return false;
- }
- for (int i = prefixLength; i-- > 0; ) {
- if ( ! charactersAreEqualIgnoreCase(string[i], prefix[i])) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Return whether the specified string starts with the specified prefix,
- * ignoring case.
- */
- public static boolean stringStartsWithIgnoreCase(String string, String prefix) {
- return string.regionMatches(true, 0, prefix, 0, prefix.length());
- }
-
- /**
- * Return whether the specified characters are are equal, ignoring case.
- * @see String#regionMatches(boolean, int, String, int, int)
- */
- public static boolean charactersAreEqualIgnoreCase(char c1, char c2) {
- // something about the Georgian alphabet requires us to check lower case also
- return (c1 == c2)
- || (Character.toUpperCase(c1) == Character.toUpperCase(c2))
- || (Character.toLowerCase(c1) == Character.toLowerCase(c2));
- }
-
- /**
- * Return whether the specified string is uppercase.
- */
- public static boolean stringIsUppercase(String string) {
- return (string.length() == 0) ? false : stringIsUppercase_(string);
- }
-
- /**
- * Return whether the specified string is uppercase.
- */
- public static boolean stringIsUppercase(char[] string) {
- return (string.length == 0) ? false : stringIsUppercase_(new String(string));
- }
-
- private static boolean stringIsUppercase_(String string) {
- return string.equals(string.toUpperCase());
- }
-
- /**
- * Return whether the specified string is lowercase.
- */
- public static boolean stringIsLowercase(String string) {
- return (string.length() == 0) ? false : stringIsLowercase_(string);
- }
-
- /**
- * Return whether the specified string is lowercase.
- */
- public static boolean stringIsLowercase(char[] string) {
- return (string.length == 0) ? false : stringIsLowercase_(new String(string));
- }
-
- private static boolean stringIsLowercase_(String string) {
- return string.equals(string.toLowerCase());
- }
-
-
- // ********** convert camel case to all caps **********
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static String convertCamelCaseToAllCaps(String camelCaseString) {
- int len = camelCaseString.length();
- if (len == 0) {
- return camelCaseString;
- }
- return new String(convertCamelCaseToAllCaps_(camelCaseString.toCharArray(), len));
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static char[] convertCamelCaseToAllCaps(char[] camelCaseString) {
- int len = camelCaseString.length;
- if (len == 0) {
- return camelCaseString;
- }
- return convertCamelCaseToAllCaps_(camelCaseString, len);
- }
-
- private static char[] convertCamelCaseToAllCaps_(char[] camelCaseString, int len) {
- StringBuilder sb = new StringBuilder(len * 2);
- convertCamelCaseToAllCapsOn_(camelCaseString, len, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, StringBuffer sb) {
- int len = camelCaseString.length();
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), len, sb);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, StringBuffer sb) {
- int len = camelCaseString.length;
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString, len, sb);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int len, StringBuffer sb) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- sb.append('_');
- }
- sb.append(Character.toUpperCase(c));
- prev = c;
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, StringBuilder sb) {
- int len = camelCaseString.length();
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), len, sb);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, StringBuilder sb) {
- int len = camelCaseString.length;
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString, len, sb);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int len, StringBuilder sb) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- sb.append('_');
- }
- sb.append(Character.toUpperCase(c));
- prev = c;
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, Writer writer) {
- int len = camelCaseString.length();
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), len, writer);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, Writer writer) {
- int len = camelCaseString.length;
- if (len != 0) {
- convertCamelCaseToAllCapsOn_(camelCaseString, len, writer);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int len, Writer writer) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- writeCharOn('_', writer);
- }
- writeCharOn(Character.toUpperCase(c), writer);
- prev = c;
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static String convertCamelCaseToAllCaps(String camelCaseString, int maxLength) {
- int len = camelCaseString.length();
- if ((len == 0) || (maxLength == 0)) {
- return camelCaseString;
- }
- return new String(convertCamelCaseToAllCaps_(camelCaseString.toCharArray(), maxLength, len));
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static char[] convertCamelCaseToAllCaps(char[] camelCaseString, int maxLength) {
- int len = camelCaseString.length;
- if ((len == 0) || (maxLength == 0)) {
- return camelCaseString;
- }
- return convertCamelCaseToAllCaps_(camelCaseString, maxLength, len);
- }
-
- private static char[] convertCamelCaseToAllCaps_(char[] camelCaseString, int maxLength, int len) {
- StringBuilder sb = new StringBuilder(maxLength);
- convertCamelCaseToAllCapsOn_(camelCaseString, maxLength, len, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, int maxLength, StringBuffer sb) {
- int len = camelCaseString.length();
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), maxLength, len, sb);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, int maxLength, StringBuffer sb) {
- int len = camelCaseString.length;
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString, maxLength, len, sb);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int maxLength, int len, StringBuffer sb) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- sb.append('_');
- if (sb.length() == maxLength) {
- return;
- }
- }
- sb.append(Character.toUpperCase(c));
- if (sb.length() == maxLength) {
- return;
- }
- prev = c;
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, int maxLength, StringBuilder sb) {
- int len = camelCaseString.length();
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), maxLength, len, sb);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, int maxLength, StringBuilder sb) {
- int len = camelCaseString.length;
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString, maxLength, len, sb);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int maxLength, int len, StringBuilder sb) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- sb.append('_');
- if (sb.length() == maxLength) {
- return;
- }
- }
- sb.append(Character.toUpperCase(c));
- if (sb.length() == maxLength) {
- return;
- }
- prev = c;
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(String camelCaseString, int maxLength, Writer writer) {
- int len = camelCaseString.length();
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString.toCharArray(), maxLength, len, writer);
- }
- }
-
- /**
- * Convert the specified "camel case" string to an "all caps" string:
- * "largeProject" -> "LARGE_PROJECT"
- * Limit the resulting string to the specified maximum length.
- */
- public static void convertCamelCaseToAllCapsOn(char[] camelCaseString, int maxLength, Writer writer) {
- int len = camelCaseString.length;
- if ((len != 0) && (maxLength != 0)) {
- convertCamelCaseToAllCapsOn_(camelCaseString, maxLength, len, writer);
- }
- }
-
- private static void convertCamelCaseToAllCapsOn_(char[] camelCaseString, int maxLength, int len, Writer writer) {
- char prev = 0; // assume 0 is not a valid char
- char c = 0;
- char next = camelCaseString[0];
- int writerLength = 0;
- for (int i = 1; i <= len; i++) { // NB: start at 1 and end at len!
- c = next;
- next = ((i == len) ? 0 : camelCaseString[i]);
- if (camelCaseWordBreak_(prev, c, next)) {
- writeCharOn('_', writer);
- if (++writerLength == maxLength) {
- return;
- }
- }
- writeCharOn(Character.toUpperCase(c), writer);
- if (++writerLength == maxLength) {
- return;
- }
- prev = c;
- }
- }
-
- /*
- * Return whether the specified series of characters occur at
- * a "camel case" work break:
- * "*aa" -> false
- * "*AA" -> false
- * "*Aa" -> false
- * "AaA" -> false
- * "AAA" -> false
- * "aa*" -> false
- * "AaA" -> false
- * "aAa" -> true
- * "AA*" -> false
- * "AAa" -> true
- * where '*' == any char
- */
- private static boolean camelCaseWordBreak_(char prev, char c, char next) {
- if (prev == 0) { // start of string
- return false;
- }
- if (Character.isLowerCase(c)) {
- return false;
- }
- if (Character.isLowerCase(prev)) {
- return true;
- }
- if (next == 0) { // end of string
- return false;
- }
- return Character.isLowerCase(next);
- }
-
-
- // ********** convert underscores to camel case **********
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "LargeProject"
- * Capitalize the first letter.
- */
- public static String convertUnderscoresToCamelCase(String underscoreString) {
- return convertUnderscoresToCamelCase(underscoreString, true);
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "LargeProject"
- * Capitalize the first letter.
- */
- public static char[] convertUnderscoresToCamelCase(char[] underscoreString) {
- return convertUnderscoresToCamelCase(underscoreString, true);
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static String convertUnderscoresToCamelCase(String underscoreString, boolean capitalizeFirstLetter) {
- int len = underscoreString.length();
- if (len == 0) {
- return underscoreString;
- }
- return new String(convertUnderscoresToCamelCase_(underscoreString.toCharArray(), capitalizeFirstLetter, len));
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static char[] convertUnderscoresToCamelCase(char[] underscoreString, boolean capitalizeFirstLetter) {
- int len = underscoreString.length;
- if (len == 0) {
- return underscoreString;
- }
- return convertUnderscoresToCamelCase_(underscoreString, capitalizeFirstLetter, len);
- }
-
- private static char[] convertUnderscoresToCamelCase_(char[] underscoreString, boolean capitalizeFirstLetter, int len) {
- StringBuilder sb = new StringBuilder(len);
- convertUnderscoresToCamelCaseOn_(underscoreString, capitalizeFirstLetter, len, sb);
- return convertToCharArray(sb);
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(String underscoreString, boolean capitalizeFirstLetter, StringBuffer sb) {
- int len = underscoreString.length();
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString.toCharArray(), capitalizeFirstLetter, len, sb);
- }
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(char[] underscoreString, boolean capitalizeFirstLetter, StringBuffer sb) {
- int len = underscoreString.length;
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString, capitalizeFirstLetter, len, sb);
- }
- }
-
- private static void convertUnderscoresToCamelCaseOn_(char[] underscoreString, boolean capitalizeFirstLetter, int len, StringBuffer sb) {
- char prev = 0;
- char c = 0;
- boolean first = true;
- for (int i = 0; i < len; i++) {
- prev = c;
- c = underscoreString[i];
- if (c == '_') {
- continue;
- }
- if (first) {
- first = false;
- sb.append(capitalizeFirstLetter ? Character.toUpperCase(c) : Character.toLowerCase(c));
- } else {
- sb.append((prev == '_') ? Character.toUpperCase(c) : Character.toLowerCase(c));
- }
- }
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(String underscoreString, boolean capitalizeFirstLetter, StringBuilder sb) {
- int len = underscoreString.length();
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString.toCharArray(), capitalizeFirstLetter, len, sb);
- }
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(char[] underscoreString, boolean capitalizeFirstLetter, StringBuilder sb) {
- int len = underscoreString.length;
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString, capitalizeFirstLetter, len, sb);
- }
- }
-
- private static void convertUnderscoresToCamelCaseOn_(char[] underscoreString, boolean capitalizeFirstLetter, int len, StringBuilder sb) {
- char prev = 0;
- char c = 0;
- boolean first = true;
- for (int i = 0; i < len; i++) {
- prev = c;
- c = underscoreString[i];
- if (c == '_') {
- continue;
- }
- if (first) {
- first = false;
- sb.append(capitalizeFirstLetter ? Character.toUpperCase(c) : Character.toLowerCase(c));
- } else {
- sb.append((prev == '_') ? Character.toUpperCase(c) : Character.toLowerCase(c));
- }
- }
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(String underscoreString, boolean capitalizeFirstLetter, Writer writer) {
- int len = underscoreString.length();
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString.toCharArray(), capitalizeFirstLetter, len, writer);
- }
- }
-
- /**
- * Convert the specified "underscore" string to a "camel case" string:
- * "LARGE_PROJECT" -> "largeProject"
- * Optionally capitalize the first letter.
- */
- public static void convertUnderscoresToCamelCaseOn(char[] underscoreString, boolean capitalizeFirstLetter, Writer writer) {
- int len = underscoreString.length;
- if (len != 0) {
- convertUnderscoresToCamelCaseOn_(underscoreString, capitalizeFirstLetter, len, writer);
- }
- }
-
- private static void convertUnderscoresToCamelCaseOn_(char[] underscoreString, boolean capitalizeFirstLetter, int len, Writer writer) {
- char prev = 0;
- char c = 0;
- boolean first = true;
- for (int i = 0; i < len; i++) {
- prev = c;
- c = underscoreString[i];
- if (c == '_') {
- continue;
- }
- if (first) {
- first = false;
- writeCharOn(capitalizeFirstLetter ? Character.toUpperCase(c) : Character.toLowerCase(c), writer);
- } else {
- writeCharOn((prev == '_') ? Character.toUpperCase(c) : Character.toLowerCase(c), writer);
- }
- }
- }
-
-
- // ********** convert to Java string literal **********
-
- public static final String EMPTY_JAVA_STRING_LITERAL = "\"\""; //$NON-NLS-1$
- public static final char[] EMPTY_JAVA_STRING_LITERAL_CHAR_ARRAY = EMPTY_JAVA_STRING_LITERAL.toCharArray();
-
- public static String convertToJavaStringLiteral(String string) {
- int len = string.length();
- if (len == 0) {
- return EMPTY_JAVA_STRING_LITERAL;
- }
- StringBuilder sb = new StringBuilder(len + 5);
- convertToJavaStringLiteralOn_(string.toCharArray(), sb, len);
- return sb.toString();
- }
-
- public static char[] convertToJavaStringLiteral(char[] string) {
- int len = string.length;
- if (len == 0) {
- return EMPTY_JAVA_STRING_LITERAL_CHAR_ARRAY;
- }
- StringBuilder sb = new StringBuilder(len + 5);
- convertToJavaStringLiteralOn_(string, sb, len);
- len = sb.length();
- char[] result = new char[len];
- sb.getChars(0, len, result, 0);
- return result;
- }
-
- public static Iterable<String> convertToJavaStringLiterals(Iterable<String> strings) {
- return new TransformationIterable<String, String>(strings, STRING_TO_JAVA_STRING_LITERAL_TRANSFORMER);
- }
-
- public static Iterator<String> convertToJavaStringLiterals(Iterator<String> strings) {
- return new TransformationIterator<String, String>(strings, STRING_TO_JAVA_STRING_LITERAL_TRANSFORMER);
- }
-
- private static final Transformer<String, String> STRING_TO_JAVA_STRING_LITERAL_TRANSFORMER = new Transformer<String, String>() {
- public String transform(String string) {
- return StringTools.convertToJavaStringLiteral(string);
- }
- };
-
- // cannot name method simply 'convertToJavaStringLiterals' because of type-erasure...
- public static Iterable<char[]> convertToJavaCharArrayLiterals(Iterable<char[]> strings) {
- return new TransformationIterable<char[], char[]>(strings, CHAR_ARRAY_TO_JAVA_STRING_LITERAL_TRANSFORMER);
- }
-
- // cannot name method simply 'convertToJavaStringLiterals' because of type-erasure...
- public static Iterator<char[]> convertToJavaCharArrayLiterals(Iterator<char[]> strings) {
- return new TransformationIterator<char[], char[]>(strings, CHAR_ARRAY_TO_JAVA_STRING_LITERAL_TRANSFORMER);
- }
-
- private static final Transformer<char[], char[]> CHAR_ARRAY_TO_JAVA_STRING_LITERAL_TRANSFORMER = new Transformer<char[], char[]>() {
- public char[] transform(char[] string) {
- return StringTools.convertToJavaStringLiteral(string);
- }
- };
-
- public static void convertToJavaStringLiteralOn(String string, StringBuffer sb) {
- int len = string.length();
- if (len == 0) {
- sb.append(EMPTY_JAVA_STRING_LITERAL);
- } else {
- convertToJavaStringLiteralOn_(string.toCharArray(), sb, len);
- }
- }
-
- public static void convertToJavaStringLiteralOn(char[] string, StringBuffer sb) {
- int len = string.length;
- if (len == 0) {
- sb.append(EMPTY_JAVA_STRING_LITERAL);
- } else {
- convertToJavaStringLiteralOn_(string, sb, len);
- }
- }
-
- /*
- * no length checks
- */
- private static void convertToJavaStringLiteralOn_(char[] string, StringBuffer sb, int len) {
- sb.ensureCapacity(sb.length() + len + 5);
- sb.append(QUOTE);
- for (char c : string) {
- switch (c) {
- case '\b': // backspace
- sb.append("\\b"); //$NON-NLS-1$
- break;
- case '\t': // horizontal tab
- sb.append("\\t"); //$NON-NLS-1$
- break;
- case '\n': // line-feed LF
- sb.append("\\n"); //$NON-NLS-1$
- break;
- case '\f': // form-feed FF
- sb.append("\\f"); //$NON-NLS-1$
- break;
- case '\r': // carriage-return CR
- sb.append("\\r"); //$NON-NLS-1$
- break;
- case '"': // double-quote
- sb.append("\\\""); //$NON-NLS-1$
- break;
-// case '\'': // single-quote
-// sb.append("\\'"); //$NON-NLS-1$
-// break;
- case '\\': // backslash
- sb.append("\\\\"); //$NON-NLS-1$
- break;
- default:
- sb.append(c);
- break;
- }
- }
- sb.append(QUOTE);
- }
-
- public static void convertToJavaStringLiteralOn(String string, StringBuilder sb) {
- int len = string.length();
- if (len == 0) {
- sb.append(EMPTY_JAVA_STRING_LITERAL);
- } else {
- convertToJavaStringLiteralOn_(string.toCharArray(), sb, len);
- }
- }
-
- public static void convertToJavaStringLiteralOn(char[] string, StringBuilder sb) {
- int len = string.length;
- if (len == 0) {
- sb.append(EMPTY_JAVA_STRING_LITERAL);
- } else {
- convertToJavaStringLiteralOn_(string, sb, len);
- }
- }
-
- /*
- * no length checks
- */
- private static void convertToJavaStringLiteralOn_(char[] string, StringBuilder sb, int len) {
- sb.ensureCapacity(sb.length() + len + 5);
- sb.append(QUOTE);
- for (char c : string) {
- switch (c) {
- case '\b': // backspace
- sb.append("\\b"); //$NON-NLS-1$
- break;
- case '\t': // horizontal tab
- sb.append("\\t"); //$NON-NLS-1$
- break;
- case '\n': // line-feed LF
- sb.append("\\n"); //$NON-NLS-1$
- break;
- case '\f': // form-feed FF
- sb.append("\\f"); //$NON-NLS-1$
- break;
- case '\r': // carriage-return CR
- sb.append("\\r"); //$NON-NLS-1$
- break;
- case '"': // double-quote
- sb.append("\\\""); //$NON-NLS-1$
- break;
-// case '\'': // single-quote
-// sb.append("\\'"); //$NON-NLS-1$
-// break;
- case '\\': // backslash
- sb.append("\\\\"); //$NON-NLS-1$
- break;
- default:
- sb.append(c);
- break;
- }
- }
- sb.append(QUOTE);
- }
-
- public static void convertToJavaStringLiteralOn(String string, Writer writer) {
- if (string.length() == 0) {
- writeStringOn(EMPTY_JAVA_STRING_LITERAL, writer);
- } else {
- convertToJavaStringLiteralOn_(string.toCharArray(), writer);
- }
- }
-
- public static void convertToJavaStringLiteralOn(char[] string, Writer writer) {
- if (string.length == 0) {
- writeStringOn(EMPTY_JAVA_STRING_LITERAL, writer);
- } else {
- convertToJavaStringLiteralOn_(string, writer);
- }
- }
-
- /*
- * no length checks
- */
- private static void convertToJavaStringLiteralOn_(char[] string, Writer writer) {
- writeCharOn(QUOTE, writer);
- for (char c : string) {
- switch (c) {
- case '\b': // backspace
- writeStringOn("\\b", writer); //$NON-NLS-1$
- break;
- case '\t': // horizontal tab
- writeStringOn("\\t", writer); //$NON-NLS-1$
- break;
- case '\n': // line-feed LF
- writeStringOn("\\n", writer); //$NON-NLS-1$
- break;
- case '\f': // form-feed FF
- writeStringOn("\\f", writer); //$NON-NLS-1$
- break;
- case '\r': // carriage-return CR
- writeStringOn("\\r", writer); //$NON-NLS-1$
- break;
- case '"': // double-quote
- writeStringOn("\\\"", writer); //$NON-NLS-1$
- break;
-// case '\'': // single-quote
-// writeStringOn("\\'", writer); //$NON-NLS-1$
-// break;
- case '\\': // backslash
- writeStringOn("\\\\", writer); //$NON-NLS-1$
- break;
- default:
- writeCharOn(c, writer);
- break;
- }
- }
- writeCharOn(QUOTE, writer);
- }
-
- // ********** convert to XML string literal **********
-
- public static String convertToXmlStringLiteral(String string) {
- int len = string.length();
- if (len == 0) {
- return EMPTY_JAVA_STRING_LITERAL;
- }
- StringBuilder sb = new StringBuilder(len + 5);
- convertToXmlStringLiteralOn_(string.toCharArray(), sb, len);
- return sb.toString();
- }
-
- //TODO need to add the rest of the predifende entities to this switch (amp, apos, lt, and gt)
- private static void convertToXmlStringLiteralOn_(char[] string, StringBuilder sb, int len) {
- sb.ensureCapacity(sb.length() + len + 5);
- sb.append(QUOTE);
- for (char c : string) {
- switch (c) {
- case '"': // double-quote
- sb.append(XML_QUOTE); //$NON-NLS-1$
- break;
- default:
- sb.append(c);
- break;
- }
- }
- sb.append(QUOTE);
- }
-
-
- // ********** convenience **********
-
- public static char[] convertToCharArray(StringBuffer sb) {
- int len = sb.length();
- char[] result = new char[len];
- sb.getChars(0, len, result, 0);
- return result;
- }
-
- public static char[] convertToCharArray(StringBuilder sb) {
- int len = sb.length();
- char[] result = new char[len];
- sb.getChars(0, len, result, 0);
- return result;
- }
-
- private static void writeStringOn(char[] string, Writer writer) {
- try {
- writer.write(string);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private static void writeStringOn(char[] string, char escape, Writer writer) {
- try {
- for (char c : string) {
- if (c == escape) {
- writer.write(c);
- }
- writer.write(c);
- }
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private static void writeStringOn(char[] string, int off, int len, Writer writer) {
- try {
- writer.write(string, off, len);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private static void writeStringOn(String string, int off, int len, Writer writer) {
- try {
- writer.write(string, off, len);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private static void writeStringOn(String string, Writer writer) {
- try {
- writer.write(string);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private static void writeCharOn(char c, Writer writer) {
- try {
- writer.write(c);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
-
- // ********** constructor **********
-
- /*
- * Suppress default constructor, ensuring non-instantiability.
- */
- private StringTools() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedBag.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedBag.java
deleted file mode 100644
index 5bcce38db1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedBag.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * Thread-safe implementation of the {@link Bag} interface.
- */
-public class SynchronizedBag<E>
- implements Bag<E>, Serializable
-{
- /** Backing bag. */
- private final Bag<E> bag;
-
- /** Object to synchronize on. */
- private final Object mutex;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a synchronized bag that wraps the
- * specified bag and locks on the specified mutex.
- */
- public SynchronizedBag(Bag<E> bag, Object mutex) {
- super();
- if (bag == null) {
- throw new NullPointerException();
- }
- this.bag = bag;
- this.mutex = mutex;
- }
-
- /**
- * Construct a synchronized bag that wraps the
- * specified bag and locks on itself.
- */
- public SynchronizedBag(Bag<E> bag) {
- super();
- if (bag == null) {
- throw new NullPointerException();
- }
- this.bag = bag;
- this.mutex = this;
- }
-
- /**
- * Construct a synchronized bag that locks on the specified mutex.
- */
- public SynchronizedBag(Object mutex) {
- this(new HashBag<E>(), mutex);
- }
-
- /**
- * Construct a synchronized bag that locks on itself.
- */
- public SynchronizedBag() {
- this(new HashBag<E>());
- }
-
-
- // ********** Bag implementation **********
-
- public boolean add(E o, int count) {
- synchronized (this.mutex) {
- return this.bag.add(o, count);
- }
- }
-
- public int count(Object o) {
- synchronized (this.mutex) {
- return this.bag.count(o);
- }
- }
-
- public Iterator<Bag.Entry<E>> entries() {
- synchronized (this.mutex) {
- return this.bag.entries();
- }
- }
-
- public boolean remove(Object o, int count) {
- synchronized (this.mutex) {
- return this.bag.remove(o, count);
- }
- }
-
- public int uniqueCount() {
- synchronized (this.mutex) {
- return this.bag.uniqueCount();
- }
- }
-
- public Iterator<E> uniqueIterator() {
- synchronized (this.mutex) {
- return this.bag.uniqueIterator();
- }
- }
-
-
- // ********** Collection implementation **********
-
- public boolean add(E e) {
- synchronized (this.mutex) {
- return this.bag.add(e);
- }
- }
-
- public boolean addAll(Collection<? extends E> c) {
- synchronized (this.mutex) {
- return this.bag.addAll(c);
- }
- }
-
- public void clear() {
- synchronized (this.mutex) {
- this.bag.clear();
- }
- }
-
- public boolean contains(Object o) {
- synchronized (this.mutex) {
- return this.bag.contains(o);
- }
- }
-
- public boolean containsAll(Collection<?> c) {
- synchronized (this.mutex) {
- return this.bag.containsAll(c);
- }
- }
-
- public boolean isEmpty() {
- synchronized (this.mutex) {
- return this.bag.isEmpty();
- }
- }
-
- public Iterator<E> iterator() {
- synchronized (this.mutex) {
- return this.bag.iterator();
- }
- }
-
- public boolean remove(Object o) {
- synchronized (this.mutex) {
- return this.bag.remove(o);
- }
- }
-
- public boolean removeAll(Collection<?> c) {
- synchronized (this.mutex) {
- return this.bag.removeAll(c);
- }
- }
-
- public boolean retainAll(Collection<?> c) {
- synchronized (this.mutex) {
- return this.bag.retainAll(c);
- }
- }
-
- public int size() {
- synchronized (this.mutex) {
- return this.bag.size();
- }
- }
-
- public Object[] toArray() {
- synchronized (this.mutex) {
- return this.bag.toArray();
- }
- }
-
- public <T> T[] toArray(T[] a) {
- synchronized (this.mutex) {
- return this.bag.toArray(a);
- }
- }
-
-
- // ********** additional public protocol **********
-
- /**
- * Return the object the stack locks on while performing
- * its operations.
- */
- public Object getMutex() {
- return this.mutex;
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- synchronized (this.mutex) {
- return this.bag.toString();
- }
- }
-
- private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
- synchronized (this.mutex) {
- s.defaultWriteObject();
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedBoolean.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedBoolean.java
deleted file mode 100644
index f4bc28d4b3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedBoolean.java
+++ /dev/null
@@ -1,650 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.command.InterruptibleCommand;
-import org.eclipse.jpt.common.utility.command.InterruptibleCommandExecutor;
-
-/**
- * This class provides synchronized access to a <code>boolean</code> value.
- * It also provides protocol for suspending a thread until the
- * <code>boolean</code> value is set to <code>true</code> or <code>false</code>,
- * with optional time-outs.
- *
- * @see SimpleBooleanReference
- */
-public class SynchronizedBoolean
- implements InterruptibleCommandExecutor, ModifiableBooleanReference, Cloneable, Serializable
-{
- /** Backing <code>boolean</code>. */
- private boolean value;
-
- /** Object to synchronize on. */
- private final Object mutex;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Create a synchronized <code>boolean</code> with the specified
- * initial value and mutex.
- */
- public SynchronizedBoolean(boolean value, Object mutex) {
- super();
- this.value = value;
- this.mutex = mutex;
- }
-
- /**
- * Create a synchronized <code>boolean</code> with the
- * specified initial value.
- * The synchronized <code>boolean</code> itself will be the mutex.
- */
- public SynchronizedBoolean(boolean value) {
- super();
- this.value = value;
- this.mutex = this;
- }
-
- /**
- * Create a synchronized <code>boolean</code>
- * with an initial value of <code>false</code>
- * and specified mutex.
- */
- public SynchronizedBoolean(Object mutex) {
- this(false, mutex);
- }
-
- /**
- * Create a synchronized <code>boolean</code>
- * with an initial value of <code>false</code>.
- * The synchronized <code>boolean</code> itself will be the mutex.
- */
- public SynchronizedBoolean() {
- this(false);
- }
-
-
- // ********** accessors **********
-
- public boolean getValue() {
- synchronized (this.mutex) {
- return this.value;
- }
- }
-
- public boolean is(boolean b) {
- synchronized (this.mutex) {
- return this.value == b;
- }
- }
-
- public boolean isNot(boolean b) {
- synchronized (this.mutex) {
- return this.value != b;
- }
- }
-
- public boolean isTrue() {
- synchronized (this.mutex) {
- return this.value;
- }
- }
-
- public boolean isFalse() {
- synchronized (this.mutex) {
- return ! this.value;
- }
- }
-
- /**
- * If the value changes, all waiting threads are notified.
- * Return the <em>old</em> value.
- */
- public boolean setValue(boolean value) {
- synchronized (this.mutex) {
- return (value == this.value) ? value : ! this.setChangedValue_(value);
- }
- }
-
- /**
- * Pre-condition: synchronized; new value is different
- * <br>
- * Return the <em>new</em> value.
- */
- private boolean setChangedValue_(boolean v) {
- this.value = v;
- this.mutex.notifyAll();
- return v;
- }
-
- /**
- * If the value changes, all waiting threads are notified.
- * Return the new value.
- */
- public boolean flip() {
- synchronized (this.mutex) {
- return this.setChangedValue_( ! this.value);
- }
- }
-
- /**
- * Set the value to <code>value & b</code> and return the new value.
- * If the value changes, all waiting threads are notified.
- */
- public boolean and(boolean b) {
- synchronized (this.mutex) {
- return this.setValue_(this.value & b);
- }
- }
-
- /**
- * Set the value to <code>value | b</code> and return the new value.
- * If the value changes, all waiting threads are notified.
- */
- public boolean or(boolean b) {
- synchronized (this.mutex) {
- return this.setValue_(this.value | b);
- }
- }
-
- /**
- * Set the value to <code>value ^ b</code> and return the new value.
- * If the value changes, all waiting threads are notified.
- */
- public boolean xor(boolean b) {
- synchronized (this.mutex) {
- return this.setValue_(this.value ^ b);
- }
- }
-
- /**
- * Pre-condition: synchronized
- * <br>
- * Return the <em>new</em> value.
- */
- private boolean setValue_(boolean v) {
- return (v == this.value) ? v : this.setChangedValue_(v);
- }
-
- /**
- * If the value changes, all waiting threads are notified.
- */
- public boolean setNot(boolean b) {
- return this.setValue( ! b);
- }
-
- /**
- * If the value changes, all waiting threads are notified.
- */
- public boolean setTrue() {
- return this.setValue(true);
- }
-
- /**
- * If the value changes, all waiting threads are notified.
- */
- public boolean setFalse() {
- return this.setValue(false);
- }
-
- /**
- * Set the value to the specified new value if it is currently the specified
- * expected value. If the value changes, all waiting threads are notified.
- * Return whether the commit was successful.
- */
- public boolean commit(boolean expectedValue, boolean newValue) {
- synchronized (this.mutex) {
- boolean success = (this.value == expectedValue);
- if (success) {
- this.setValue_(newValue);
- }
- return success;
- }
- }
-
- /**
- * Atomically swap the value of this synchronized boolean with the value of
- * the specified synchronized boolean. Make assumptions about the value of
- * <em>identity hash code</em> to avoid deadlock when two synchronized
- * booleans swap values with each other simultaneously.
- * If either value changes, the corresponding waiting threads are notified.
- * Return the new value.
- */
- public boolean swap(SynchronizedBoolean other) {
- if (other == this) {
- return this.getValue();
- }
- boolean thisFirst = System.identityHashCode(this) < System.identityHashCode(other);
- SynchronizedBoolean first = thisFirst ? this : other;
- SynchronizedBoolean second = thisFirst ? other : this;
- synchronized (first.mutex) {
- synchronized (second.mutex) {
- boolean thisValue = this.value;
- boolean otherValue = other.value;
- if (thisValue == otherValue) {
- return thisValue; // nothing changes
- }
- other.setChangedValue_(thisValue);
- return this.setChangedValue_(otherValue);
- }
- }
- }
-
- /**
- * Return the object this object locks on while performing
- * its operations.
- */
- public Object getMutex() {
- return this.mutex;
- }
-
-
- // ********** indefinite waits **********
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes
- * to the specified value. If the <code>boolean</code> value is already the
- * specified value, return immediately.
- */
- public void waitUntilValueIs(boolean b) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs_(b);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void waitUntilValueIs_(boolean b) throws InterruptedException {
- while (this.value != b) {
- this.mutex.wait();
- }
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value
- * changes to the NOT of the specified value.
- * If the <code>boolean</code> value is already the NOT of the specified
- * value, return immediately.
- */
- public void waitUntilValueIsNot(boolean b) throws InterruptedException {
- this.waitUntilValueIs( ! b);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value
- * changes to <code>true</code>.
- * If the <code>boolean</code> value is already <code>true</code>,
- * return immediately.
- */
- public void waitUntilTrue() throws InterruptedException {
- this.waitUntilValueIs(true);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value
- * changes to <code>false</code>.
- * If the <code>boolean</code> value is already <code>false</code>,
- * return immediately.
- */
- public void waitUntilFalse() throws InterruptedException {
- this.waitUntilValueIs(false);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes to
- * the NOT of the specified value, then change it back to the specified
- * value and continue executing. If the <code>boolean</code> value is already
- * the NOT of the specified value, set the value to the specified value
- * immediately.
- */
- public void waitToSetValue(boolean b) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs_( ! b);
- this.setChangedValue_(b);
- }
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value
- * changes to <code>false</code>,
- * then change it back to <code>true</code> and continue executing.
- * If the <code>boolean</code> value is already <code>false</code>,
- * set the value to <code>true</code> immediately.
- */
- public void waitToSetTrue() throws InterruptedException {
- this.waitToSetValue(true);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value
- * changes to <code>true</code>,
- * then change it back to <code>false</code> and continue executing.
- * If the <code>boolean</code> value is already <code>true</code>,
- * set the value to <code>false</code> immediately.
- */
- public void waitToSetFalse() throws InterruptedException {
- this.waitToSetValue(false);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value
- * changes to the specified value,
- * then execute the specified command.
- * If the <code>boolean</code> value is already equal to the specified
- * value, execute the specified command immediately.
- */
- public void whenEqual(boolean b, InterruptibleCommand command) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs_(b);
- command.execute();
- }
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value
- * changes to the NOT of the specified value,
- * then execute the specified command.
- * If the <code>boolean</code> value is already the NOT of the specified
- * value, execute the specified command immediately.
- */
- public void whenNotEqual(boolean b, InterruptibleCommand command) throws InterruptedException {
- this.whenEqual( ! b, command);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value
- * changes to <code>true</code>,
- * then execute the specified command.
- * If the <code>boolean</code> value is already <code>true</code>,
- * execute the specified command immediately.
- */
- public void whenTrue(InterruptibleCommand command) throws InterruptedException {
- this.whenEqual(true, command);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value
- * changes to <code>false</code>,
- * then execute the specified command.
- * If the <code>boolean</code> value is already <code>false</code>,
- * execute the specified command immediately.
- */
- public void whenFalse(InterruptibleCommand command) throws InterruptedException {
- this.whenEqual(false, command);
- }
-
-
- // ********** timed waits **********
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes
- * to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the specified value was achieved;
- * return <code>false</code> if a time-out occurred.
- * If the <code>boolean</code> value is already the specified value,
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilValueIs(boolean b, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilValueIs_(b, timeout);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private boolean waitUntilValueIs_(boolean b, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitUntilValueIs_(b); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value != b) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value == b);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value
- * changes to the NOT of the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the NOT of the specified value was achieved;
- * return <code>false</code> if a time-out occurred.
- * If the <code>boolean</code> value is already the NOT of the specified
- * value, return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilValueIsNot(boolean b, long timeout) throws InterruptedException {
- return this.waitUntilValueIs( ! b, timeout);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes
- * to <code>true</code> or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * <code>true</code> was achieved;
- * return <code>false</code> if a time-out occurred.
- * If the <code>boolean</code> value is already <code>true</code>,
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilTrue(long timeout) throws InterruptedException {
- return this.waitUntilValueIs(true, timeout);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes
- * to <code>false</code> or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * <code>false</code> was achieved;
- * return <code>false</code> if a time-out occurred.
- * If the <code>boolean</code> value is already <code>false</code>,
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilFalse(long timeout) throws InterruptedException {
- return this.waitUntilValueIs(false, timeout);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes
- * to the NOT of the specified value, then change it back to the specified
- * value and continue executing. If the <code>boolean</code> value does not
- * change to <code>false</code> before the time-out, simply continue
- * executing without changing the value.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value was set to the specified value; return <code>false</code>
- * if a time-out occurred.
- * If the <code>boolean</code> value is already
- * the NOT of the specified value, set the value to the specified value
- * immediately and return <code>true</code>.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitToSetValue(boolean b, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilValueIs_( ! b, timeout);
- if (success) {
- this.setChangedValue_(b);
- }
- return success;
- }
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes
- * to <code>false</code>, then change it back to <code>true</code> and
- * continue executing. If the <code>boolean</code> value does not change to
- * <code>false</code> before the time-out, simply continue executing without
- * changing the value.
- * The time-out is specified in milliseconds. Return
- * <code>true</code> if the value was set to <code>true</code>;
- * return <code>false</code> if a time-out occurred.
- * If the <code>boolean</code> value is already <code>false</code>, set the
- * value to <code>true</code> immediately and return <code>true</code>.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitToSetTrue(long timeout) throws InterruptedException {
- return this.waitToSetValue(true, timeout);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes
- * to <code>true</code>, then change it back to <code>false</code> and
- * continue executing. If the <code>boolean</code> value does not change to
- * <code>true</code> before the time-out, simply continue executing without
- * changing the value.
- * The time-out is specified in milliseconds. Return
- * <code>true</code> if the value was set to <code>false</code>;
- * return <code>false</code> if a time-out occurred.
- * If the <code>boolean</code> value is already <code>true</code>, set the
- * value to <code>false</code> immediately and return <code>true</code>.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitToSetFalse(long timeout) throws InterruptedException {
- return this.waitToSetValue(false, timeout);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes
- * to the specified value or the specified time-out occurs;
- * then, if a time-out did not occur, execute the specified command.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the command was executed;
- * return <code>false</code> if a time-out occurred.
- * If the <code>boolean</code> value is already the specified value,
- * execute the specified command immediately and return <code>true</code>.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean whenEqual(boolean b, InterruptibleCommand command, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilValueIs_(b, timeout);
- if (success) {
- command.execute();
- }
- return success;
- }
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes
- * to the NOT of the specified value or the specified time-out occurs;
- * then, if a time-out did not occur, execute the specified command.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the command was executed;
- * return <code>false</code> if a time-out occurred.
- * If the <code>boolean</code> value is already the NOT of the specified value,
- * execute the specified command immediately and return <code>true</code>.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean whenNotEqual(boolean b, InterruptibleCommand command, long timeout) throws InterruptedException {
- return this.whenEqual( ! b, command, timeout);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes
- * to <code>true</code> or the specified time-out occurs;
- * then, if a time-out did not occur, execute the specified command.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the command was executed;
- * return <code>false</code> if a time-out occurred.
- * If the <code>boolean</code> value is already <code>true</code>,
- * execute the specified command immediately and return <code>true</code>.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean whenTrue(InterruptibleCommand command, long timeout) throws InterruptedException {
- return this.whenEqual(true, command, timeout);
- }
-
- /**
- * Suspend the current thread until the <code>boolean</code> value changes
- * to <code>false</code> or the specified time-out occurs;
- * then, if a time-out did not occur, execute the specified command.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the command was executed;
- * return <code>false</code> if a time-out occurred.
- * If the <code>boolean</code> value is already <code>false</code>,
- * execute the specified command immediately and return <code>true</code>.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean whenFalse(InterruptibleCommand command, long timeout) throws InterruptedException {
- return this.whenEqual(false, command, timeout);
- }
-
-
- // ********** synchronized behavior **********
-
- /**
- * If the current thread is not interrupted, execute the specified command
- * with the mutex locked. This is useful for initializing the value from another
- * thread.
- */
- public void execute(InterruptibleCommand command) throws InterruptedException {
- if (Thread.currentThread().isInterrupted()) {
- throw new InterruptedException();
- }
- synchronized (this.mutex) {
- command.execute();
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public SynchronizedBoolean clone() {
- try {
- synchronized (this.mutex) {
- return (SynchronizedBoolean) super.clone();
- }
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- /**
- * Object identity is critical to synchronized booleans.
- * There is no reason for two different synchronized booleans to be
- * <em>equal</em>.
- */
- @Override
- public boolean equals(Object obj) {
- return super.equals(obj);
- }
-
- /**
- * @see #equals(Object)
- */
- @Override
- public int hashCode() {
- return super.hashCode();
- }
-
- @Override
- public String toString() {
- return '[' + String.valueOf(this.getValue()) + ']';
- }
-
- private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
- synchronized (this.mutex) {
- s.defaultWriteObject();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedInt.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedInt.java
deleted file mode 100644
index 3c0a12ed93..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedInt.java
+++ /dev/null
@@ -1,914 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-import org.eclipse.jpt.common.utility.command.Command;
-
-/**
- * This class provides synchronized access to an <code>int</code>.
- * It also provides protocol for suspending a thread until the
- * value is set to a specified value, with optional time-outs.
- *
- * @see SimpleIntReference
- */
-public class SynchronizedInt
- implements ModifiableIntReference, Cloneable, Serializable
-{
- /** Backing <code>int</code>. */
- private int value;
-
- /** Object to synchronize on. */
- private final Object mutex;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Create a synchronized integer with the specified initial value
- * and mutex.
- */
- public SynchronizedInt(int value, Object mutex) {
- super();
- this.value = value;
- this.mutex = mutex;
- }
-
- /**
- * Create a synchronized integer with the specified initial value.
- * The synchronized integer itself will be the mutex.
- */
- public SynchronizedInt(int value) {
- super();
- this.value = value;
- this.mutex = this;
- }
-
- /**
- * Create a synchronized integer with an initial value of zero
- * and the specified mutex.
- */
- public SynchronizedInt(Object mutex) {
- this(0, mutex);
- }
-
- /**
- * Create a synchronized object with an initial value of zero.
- * The synchronized integer itself will be the mutex.
- */
- public SynchronizedInt() {
- this(0);
- }
-
-
- // ********** methods **********
-
- public int getValue() {
- synchronized (this.mutex) {
- return this.value;
- }
- }
-
- public boolean equals(int v) {
- synchronized (this.mutex) {
- return this.value == v;
- }
- }
-
- public boolean notEqual(int v) {
- synchronized (this.mutex) {
- return this.value != v;
- }
- }
-
- public boolean isZero() {
- synchronized (this.mutex) {
- return this.value == 0;
- }
- }
-
- public boolean isNotZero() {
- synchronized (this.mutex) {
- return this.value != 0;
- }
- }
-
- public boolean isGreaterThan(int v) {
- synchronized (this.mutex) {
- return this.value > v;
- }
- }
-
- public boolean isGreaterThanOrEqual(int v) {
- synchronized (this.mutex) {
- return this.value >= v;
- }
- }
-
- public boolean isLessThan(int v) {
- synchronized (this.mutex) {
- return this.value < v;
- }
- }
-
- public boolean isLessThanOrEqual(int v) {
- synchronized (this.mutex) {
- return this.value <= v;
- }
- }
-
- public boolean isPositive() {
- return this.isGreaterThan(0);
- }
-
- public boolean isNotPositive() {
- return this.isLessThanOrEqual(0);
- }
-
- public boolean isNegative() {
- return this.isLessThan(0);
- }
-
- public boolean isNotNegative() {
- return this.isGreaterThanOrEqual(0);
- }
-
- public int abs() {
- synchronized (this.mutex) {
- return Math.abs(this.value);
- }
- }
-
- public int neg() {
- synchronized (this.mutex) {
- return -this.value;
- }
- }
-
- public int add(int v) {
- synchronized (this.mutex) {
- return this.value + v;
- }
- }
-
- public int subtract(int v) {
- synchronized (this.mutex) {
- return this.value - v;
- }
- }
-
- public int multiply(int v) {
- synchronized (this.mutex) {
- return this.value * v;
- }
- }
-
- public int divide(int v) {
- synchronized (this.mutex) {
- return this.value / v;
- }
- }
-
- public int remainder(int v) {
- synchronized (this.mutex) {
- return this.value % v;
- }
- }
-
- public int min(int v) {
- synchronized (this.mutex) {
- return Math.min(this.value, v);
- }
- }
-
- public int max(int v) {
- synchronized (this.mutex) {
- return Math.max(this.value, v);
- }
- }
-
- public double pow(int v) {
- synchronized (this.mutex) {
- return Math.pow(this.value, v);
- }
- }
-
- /**
- * If the value changes, all waiting threads are notified.
- */
- public int setValue(int value) {
- synchronized (this.mutex) {
- return this.setValue_(value);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private int setValue_(int v) {
- int old = this.value;
- return (old == v) ? old : this.setValue_(v, old);
- }
-
- /**
- * Pre-condition: synchronized and new value is different
- */
- private int setChangedValue_(int v) {
- return this.setValue_(v, this.value);
- }
-
- /**
- * Pre-condition: synchronized and new value is different
- */
- private int setValue_(int v, int old) {
- this.value = v;
- this.mutex.notifyAll();
- return old;
- }
-
- /**
- * Set the value to zero. If the value changes, all waiting
- * threads are notified. Return the previous value.
- */
- public int setZero() {
- return this.setValue(0);
- }
-
- /**
- * Increment the value by one.
- * Return the new value.
- */
- public int increment() {
- synchronized (this.mutex) {
- this.value++;
- this.mutex.notifyAll();
- return this.value;
- }
- }
-
- /**
- * Decrement the value by one.
- * Return the new value.
- */
- public int decrement() {
- synchronized (this.mutex) {
- this.value--;
- this.mutex.notifyAll();
- return this.value;
- }
- }
-
- /**
- * If the current value is the specified expected value, set it to the
- * specified new value. Return the previous value.
- */
- public int compareAndSwap(int expectedValue, int newValue) {
- synchronized (this.mutex) {
- return this.compareAndSwap_(expectedValue, newValue);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private int compareAndSwap_(int expectedValue, int newValue) {
- return (this.value == expectedValue) ? this.setValue_(newValue) : this.value;
- }
-
- /**
- * Return the object the synchronized integer locks on while performing
- * its operations.
- */
- public Object getMutex() {
- return this.mutex;
- }
-
-
- // ********** indefinite waits **********
-
- /**
- * Suspend the current thread until the value changes
- * to the specified value. If the value is already the
- * specified value, return immediately.
- */
- public void waitUntilEqual(int v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilEqual_(v);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void waitUntilEqual_(int v) throws InterruptedException {
- while (this.value != v) {
- this.mutex.wait();
- }
- }
-
- /**
- * Suspend the current thread until the value changes
- * to something other than the specified value. If the
- * value is already <em>not</em> the specified value,
- * return immediately.
- */
- public void waitUntilNotEqual(int v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilNotEqual_(v);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void waitUntilNotEqual_(int v) throws InterruptedException {
- while (this.value == v) {
- this.mutex.wait();
- }
- }
-
- /**
- * Suspend the current thread until the value changes to zero.
- * If the value is already zero, return immediately.
- */
- public void waitUntilZero() throws InterruptedException {
- this.waitUntilEqual(0);
- }
-
- /**
- * Suspend the current thread until the value changes
- * to something other than zero.
- * If the value is already <em>not</em> zero,
- * return immediately.
- */
- public void waitUntilNotZero() throws InterruptedException {
- this.waitUntilNotEqual(0);
- }
-
- /**
- * Suspend the current thread until the value changes
- * to a value greater than the specified value. If the value is already
- * greater than the specified value, return immediately.
- */
- public void waitUntilGreaterThan(int v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilGreaterThan_(v);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void waitUntilGreaterThan_(int v) throws InterruptedException {
- while (this.value <= v) {
- this.mutex.wait();
- }
- }
-
- /**
- * Suspend the current thread until the value changes
- * to a value greater than or equal to the specified value. If the value is already
- * greater than or equal the specified value, return immediately.
- */
- public void waitUntilGreaterThanOrEqual(int v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilGreaterThanOrEqual_(v);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void waitUntilGreaterThanOrEqual_(int v) throws InterruptedException {
- while (this.value < v) {
- this.mutex.wait();
- }
- }
-
- /**
- * Suspend the current thread until the value changes
- * to a value less than the specified value. If the value is already
- * less than the specified value, return immediately.
- */
- public void waitUntilLessThan(int v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilLessThan_(v);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void waitUntilLessThan_(int v) throws InterruptedException {
- while (this.value >= v) {
- this.mutex.wait();
- }
- }
-
- /**
- * Suspend the current thread until the value changes
- * to a value less than or equal to the specified value. If the value is already
- * less than or equal the specified value, return immediately.
- */
- public void waitUntilLessThanOrEqual(int v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilLessThanOrEqual_(v);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void waitUntilLessThanOrEqual_(int v) throws InterruptedException {
- while (this.value > v) {
- this.mutex.wait();
- }
- }
-
- /**
- * Suspend the current thread until the value is positive.
- * If the value is already positive, return immediately.
- */
- public void waitUntilPositive() throws InterruptedException {
- this.waitUntilGreaterThan(0);
- }
-
- /**
- * Suspend the current thread until the value is not positive
- * (i.e. negative or zero).
- * If the value is already <em>not</em> positive,
- * return immediately.
- */
- public void waitUntilNotPositive() throws InterruptedException {
- this.waitUntilLessThanOrEqual(0);
- }
-
- /**
- * Suspend the current thread until the value is negative.
- * If the value is already negative, return immediately.
- */
- public void waitUntilNegative() throws InterruptedException {
- this.waitUntilLessThan(0);
- }
-
- /**
- * Suspend the current thread until the value is not negative
- * (i.e. zero or positive).
- * If the value is already <em>not</em> negative,
- * return immediately.
- */
- public void waitUntilNotNegative() throws InterruptedException {
- this.waitUntilGreaterThanOrEqual(0);
- }
-
- /**
- * Suspend the current thread until the value changes to
- * something other than the specified value, then change
- * it back to the specified value and continue executing.
- * If the value is already <em>not</em> the specified value, set
- * the value immediately.
- * Return the previous value.
- */
- public int waitToSetValue(int v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilNotEqual_(v);
- return this.setChangedValue_(v);
- }
- }
-
- /**
- * Suspend the current thread until the value changes to
- * something other than zero, then change it
- * back to zero and continue executing.
- * If the value is already <em>not</em> zero,
- * set the value to zero immediately.
- * Return the previous value.
- */
- public int waitToSetZero() throws InterruptedException {
- return this.waitToSetValue(0);
- }
-
- /**
- * Suspend the current thread until the value changes to
- * the specified expected value, then change it
- * to the specified new value and continue executing.
- * If the value is already the specified expected value,
- * set the value to the specified new value immediately.
- * Return the previous value.
- */
- public int waitToSwap(int expectedValue, int newValue) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilEqual_(expectedValue);
- return this.setValue_(newValue);
- }
- }
-
-
- // ********** timed waits **********
-
- /**
- * Suspend the current thread until the value changes
- * to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the specified value was achieved; return <code>false</code>
- * if a time-out occurred.
- * If the value is already the specified value, return true immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilEqual(int v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilEqual_(v, timeout);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private boolean waitUntilEqual_(int v, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitUntilEqual_(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value != v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value == v);
- }
-
- /**
- * Suspend the current thread until the value changes to something
- * other than the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the specified value was removed; return <code>false</code> if a
- * time-out occurred. If the value is already <em>not</em> the specified
- * value, return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilNotEqual(int v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilNotEqual_(v, timeout);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private boolean waitUntilNotEqual_(int v, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitUntilNotEqual_(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value == v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value != v);
- }
-
- /**
- * Suspend the current thread until the value changes
- * to zero or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value is now zero; return <code>false</code>
- * if a time-out occurred. If the value is already zero,
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilZero(long timeout) throws InterruptedException {
- return this.waitUntilEqual(0, timeout);
- }
-
- /**
- * Suspend the current thread until the value changes
- * to something other than zero or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value is now not zero; return <code>false</code>
- * if a time-out occurred. If the value is already <em>not</em>
- * zero, return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilNotZero(long timeout) throws InterruptedException {
- return this.waitUntilNotEqual(0, timeout);
- }
-
- /**
- * Suspend the current thread until the value changes to a value greater
- * than the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the specified value was achieved; return <code>false</code>
- * if a time-out occurred.
- * If the value is already greater than the specified value, return immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilGreaterThan(int v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilGreaterThan_(v, timeout);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private boolean waitUntilGreaterThan_(int v, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitUntilGreaterThan_(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value <= v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value > v);
- }
-
- /**
- * Suspend the current thread until the value changes to a value greater
- * than or equal to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the specified value was achieved; return <code>false</code>
- * if a time-out occurred.
- * If the value is already greater than or equal to the specified value,
- * return immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilGreaterThanOrEqual(int v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilGreaterThanOrEqual_(v, timeout);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private boolean waitUntilGreaterThanOrEqual_(int v, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitUntilGreaterThanOrEqual_(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value < v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value >= v);
- }
-
- /**
- * Suspend the current thread until the value changes to a value less
- * than the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the specified value was achieved; return <code>false</code>
- * if a time-out occurred.
- * If the value is already less than the specified value, return immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilLessThan(int v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilLessThan_(v, timeout);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private boolean waitUntilLessThan_(int v, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitUntilLessThan_(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value >= v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value < v);
- }
-
- /**
- * Suspend the current thread until the value changes to a value less
- * than or equal to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the specified value was achieved; return <code>false</code>
- * if a time-out occurred.
- * If the value is already less than or equal to the specified value,
- * return immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilLessThanOrEqual(int v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilLessThanOrEqual_(v, timeout);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private boolean waitUntilLessThanOrEqual_(int v, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitUntilLessThanOrEqual_(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.value > v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.value <= v);
- }
-
- /**
- * Suspend the current thread until the value is positive
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value is now positive; return <code>false</code>
- * if a time-out occurred. If the value is already positive,
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilPositive(long timeout) throws InterruptedException {
- return this.waitUntilGreaterThan(0, timeout);
- }
-
- /**
- * Suspend the current thread until the value is not positive
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value is now not positive; return <code>false</code>
- * if a time-out occurred. If the value is already not positive,
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilNotPositive(long timeout) throws InterruptedException {
- return this.waitUntilLessThanOrEqual(0, timeout);
- }
-
- /**
- * Suspend the current thread until the value is negative
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value is now negative; return <code>false</code>
- * if a time-out occurred. If the value is already negative,
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilNegative(long timeout) throws InterruptedException {
- return this.waitUntilLessThan(0, timeout);
- }
-
- /**
- * Suspend the current thread until the value is not negative
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value is now not negative; return <code>false</code>
- * if a time-out occurred. If the value is already not negative,
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilNotNegative(long timeout) throws InterruptedException {
- return this.waitUntilGreaterThanOrEqual(0, timeout);
- }
-
- /**
- * Suspend the current thread until the value changes to
- * something other than the specified value, then change
- * it back to the specified value and continue executing.
- * If the value does not change to something other than the
- * specified value before the time-out, simply continue executing
- * without changing the value.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value was set to the specified value; return <code>false</code>
- * if a time-out occurred.
- * If the value is already something other than the specified value, set
- * the value immediately and return <code>true</code>.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitToSetValue(int v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilNotEqual_(v, timeout);
- if (success) {
- this.setChangedValue_(v);
- }
- return success;
- }
- }
-
- /**
- * Suspend the current thread until the value changes to something
- * other than zero, then change it back to zero
- * and continue executing. If the value does not change to something
- * other than zero before the time-out, simply continue
- * executing without changing the value.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value was set to zero; return <code>false</code>
- * if a time-out occurred.
- * If the value is already something other than zero, set
- * the value to zero immediately and return <code>true</code>.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitToSetZero(long timeout) throws InterruptedException {
- return this.waitToSetValue(0, timeout);
- }
-
- /**
- * Suspend the current thread until the value changes to
- * the specified expected value, then change it
- * to the specified new value and continue executing.
- * If the value does not change to the specified expected value
- * before the time-out, simply continue executing without changing
- * the value.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value was set to the specified new value; return
- * <code>false</code> if a time-out occurred.
- * If the value is already the specified expected value,
- * set the value to the specified new value immediately.
- * Return the previous value.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitToSwap(int expectedValue, int newValue, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilEqual_(expectedValue, timeout);
- if (success) {
- this.setValue_(newValue);
- }
- return success;
- }
- }
-
-
- // ********** synchronized behavior **********
-
- /**
- * If current thread is not interrupted, execute the specified command
- * with the mutex locked. This is useful for initializing the value from another
- * thread.
- */
- public void execute(Command command) throws InterruptedException {
- if (Thread.currentThread().isInterrupted()) {
- throw new InterruptedException();
- }
- synchronized (this.mutex) {
- command.execute();
- }
- }
-
-
- // ********** Comparable implementation **********
-
- public int compareTo(IntReference ref) {
- int thisValue = this.getValue();
- int otherValue = ref.getValue();
- return (thisValue < otherValue) ? -1 : ((thisValue == otherValue) ? 0 : 1);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public SynchronizedInt clone() {
- try {
- synchronized (this.mutex) {
- return (SynchronizedInt) super.clone();
- }
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public String toString() {
- return '[' + String.valueOf(this.getValue()) + ']';
- }
-
- private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
- synchronized (this.mutex) {
- s.defaultWriteObject();
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedObject.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedObject.java
deleted file mode 100644
index 60f282916b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedObject.java
+++ /dev/null
@@ -1,472 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.ModifiableObjectReference;
-import org.eclipse.jpt.common.utility.command.Command;
-
-/**
- * This class provides synchronized access to an object of type <code>V</code>.
- * It also provides protocol for suspending a thread until the
- * value is set to <code>null</code> or a non-<code>null</code> value,
- * with optional time-outs.
- *
- * @parm V the type of the synchronized object's value
- * @see SimpleObjectReference
- */
-public class SynchronizedObject<V>
- implements ModifiableObjectReference<V>, Cloneable, Serializable
-{
- /** Backing value. */
- private V value;
-
- /** Object to synchronize on. */
- private final Object mutex;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Create a synchronized object with the specified initial value
- * and mutex.
- */
- public SynchronizedObject(V value, Object mutex) {
- super();
- this.value = value;
- this.mutex = mutex;
- }
-
- /**
- * Create a synchronized object with the specified initial value.
- * The synchronized object itself will be the mutex.
- */
- public SynchronizedObject(V value) {
- super();
- this.value = value;
- this.mutex = this;
- }
-
- /**
- * Create a synchronized object with an initial value of <code>null</code>.
- * The synchronized object itself will be the mutex.
- */
- public SynchronizedObject() {
- this(null);
- }
-
-
- // ********** accessors **********
-
- public V getValue() {
- synchronized (this.mutex) {
- return this.value;
- }
- }
-
- public boolean valueEquals(Object object) {
- return Tools.valuesAreEqual(this.getValue(), object);
- }
-
- public boolean valueNotEqual(Object object) {
- return Tools.valuesAreDifferent(this.getValue(), object);
- }
-
- public boolean isNull() {
- synchronized (this.mutex) {
- return this.value == null;
- }
- }
-
- public boolean isNotNull() {
- synchronized (this.mutex) {
- return this.value != null;
- }
- }
-
- /**
- * Set the value. If the value changes, all waiting
- * threads are notified. Return the previous value.
- */
- public V setValue(V value) {
- synchronized (this.mutex) {
- return this.setValue_(value);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private V setValue_(V v) {
- V old = this.value;
- return Tools.valuesAreEqual(old, v) ? old : this.setValue_(v, old);
- }
-
- /**
- * Pre-condition: synchronized and new value is different
- */
- private V setChangedValue_(V v) {
- return this.setValue_(v, this.value);
- }
-
- /**
- * Pre-condition: synchronized and new value is different
- */
- private V setValue_(V v, V old) {
- this.value = v;
- this.mutex.notifyAll();
- return old;
- }
-
- /**
- * Set the value to <code>null</code>. If the value changes, all waiting
- * threads are notified. Return the previous value.
- */
- public V setNull() {
- return this.setValue(null);
- }
-
- /**
- * If the current value is the specified expected value, set it to the
- * specified new value. Return the previous value.
- */
- public V compareAndSwap(V expectedValue, V newValue) {
- synchronized (this.mutex) {
- return this.compareAndSwap_(expectedValue, newValue);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private V compareAndSwap_(V expectedValue, V newValue) {
- return Tools.valuesAreEqual(this.value, expectedValue) ? this.setValue_(newValue) : this.value;
- }
-
- /**
- * Return the object the synchronized object locks on while performing
- * its operations.
- */
- public Object getMutex() {
- return this.mutex;
- }
-
-
- // ********** indefinite waits **********
-
- /**
- * Suspend the current thread until the value changes
- * to the specified value. If the value is already the
- * specified value, return immediately.
- */
- public void waitUntilValueIs(V v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs_(v);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void waitUntilValueIs_(V v) throws InterruptedException {
- while (Tools.valuesAreDifferent(this.value, v)) {
- this.mutex.wait();
- }
- }
-
- /**
- * Suspend the current thread until the value changes
- * to something other than the specified value. If the
- * value is already <em>not</em> the specified value,
- * return immediately.
- */
- public void waitUntilValueIsNot(V v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIsNot_(v);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void waitUntilValueIsNot_(V v) throws InterruptedException {
- while (Tools.valuesAreEqual(this.value, v)) {
- this.mutex.wait();
- }
- }
-
- /**
- * Suspend the current thread until the value changes to <code>null</code>.
- * If the value is already <code>null</code>, return immediately.
- */
- public void waitUntilNull() throws InterruptedException {
- this.waitUntilValueIs(null);
- }
-
- /**
- * Suspend the current thread until the value changes
- * to something other than <code>null</code>.
- * If the value is already <em>not</em> <code>null</code>,
- * return immediately.
- */
- public void waitUntilNotNull() throws InterruptedException {
- this.waitUntilValueIsNot(null);
- }
-
- /**
- * Suspend the current thread until the value changes to
- * something other than the specified value, then change
- * it back to the specified value and continue executing.
- * If the value is already <em>not</em> the specified value, set
- * the value immediately.
- * Return the previous value.
- */
- public V waitToSetValue(V v) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIsNot_(v);
- return this.setChangedValue_(v);
- }
- }
-
- /**
- * Suspend the current thread until the value changes to
- * something other than <code>null</code>, then change it
- * back to <code>null</code> and continue executing.
- * If the value is already <em>not</em> <code>null</code>,
- * set the value to <code>null</code> immediately.
- * Return the previous value.
- */
- public V waitToSetNull() throws InterruptedException {
- return this.waitToSetValue(null);
- }
-
- /**
- * Suspend the current thread until the value changes to
- * the specified expected value, then change it
- * to the specified new value and continue executing.
- * If the value is already the specified expected value,
- * set the value to the specified new value immediately.
- * Return the previous value.
- */
- public V waitToSwap(V expectedValue, V newValue) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilValueIs_(expectedValue);
- return this.setValue_(newValue);
- }
- }
-
-
- // ********** timed waits **********
-
- /**
- * Suspend the current thread until the value changes
- * to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the specified value was achieved; return <code>false</code>
- * if a time-out occurred.
- * If the value is already the specified value, return true immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilValueIs(V v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilValueIs_(v, timeout);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private boolean waitUntilValueIs_(V v, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitUntilValueIs_(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while (Tools.valuesAreDifferent(this.value, v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return Tools.valuesAreEqual(this.value, v);
- }
-
- /**
- * Suspend the current thread until the value changes to something
- * other than the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the specified value was removed; return <code>false</code> if a
- * time-out occurred. If the value is already <em>not</em> the specified
- * value, return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilValueIsNot(V v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilValueIsNot_(v, timeout);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private boolean waitUntilValueIsNot_(V v, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitUntilValueIsNot_(v); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while (Tools.valuesAreEqual(this.value, v) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return Tools.valuesAreDifferent(this.value, v);
- }
-
- /**
- * Suspend the current thread until the value changes
- * to <code>null</code> or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the specified value was achieved; return <code>false</code>
- * if a time-out occurred. If the value is already <code>null</code>,
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilNull(long timeout) throws InterruptedException {
- return this.waitUntilValueIs(null, timeout);
- }
-
- /**
- * Suspend the current thread until the value changes
- * to something other than <code>null</code> or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the specified value was achieved; return <code>false</code>
- * if a time-out occurred. If the value is already <em>not</em>
- * <code>null</code>, return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilNotNull(long timeout) throws InterruptedException {
- return this.waitUntilValueIsNot(null, timeout);
- }
-
- /**
- * Suspend the current thread until the value changes to
- * something other than the specified value, then change
- * it back to the specified value and continue executing.
- * If the value does not change to something other than the
- * specified value before the time-out, simply continue executing
- * without changing the value.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value was set to the specified value; return <code>false</code>
- * if a time-out occurred.
- * If the value is already something other than the specified value, set
- * the value immediately and return <code>true</code>.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitToSetValue(V v, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilValueIsNot_(v, timeout);
- if (success) {
- this.setChangedValue_(v);
- }
- return success;
- }
- }
-
- /**
- * Suspend the current thread until the value changes to something
- * other than <code>null</code>, then change it back to <code>null</code>
- * and continue executing. If the value does not change to something
- * other than <code>null</code> before the time-out, simply continue
- * executing without changing the value.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value was set to <code>null</code>; return <code>false</code>
- * if a time-out occurred.
- * If the value is already something other than <code>null</code>, set
- * the value to <code>null</code> immediately and return <code>true</code>.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitToSetNull(long timeout) throws InterruptedException {
- return this.waitToSetValue(null, timeout);
- }
-
- /**
- * Suspend the current thread until the value changes to
- * the specified expected value, then change it
- * to the specified new value and continue executing.
- * If the value does not change to the specified expected value
- * before the time-out, simply continue executing without changing
- * the value.
- * The time-out is specified in milliseconds. Return <code>true</code>
- * if the value was set to the specified new value; return
- * <code>false</code> if a time-out occurred.
- * If the value is already the specified expected value,
- * set the value to the specified new value immediately.
- * Return the previous value.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitToSwap(V expectedValue, V newValue, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilValueIs_(expectedValue, timeout);
- if (success) {
- this.setValue_(newValue);
- }
- return success;
- }
- }
-
-
- // ********** synchronized behavior **********
-
- /**
- * If current thread is not interrupted, execute the specified command
- * with the mutex locked. This is useful for initializing the value from another
- * thread.
- */
- public void execute(Command command) throws InterruptedException {
- if (Thread.currentThread().isInterrupted()) {
- throw new InterruptedException();
- }
- synchronized (this.mutex) {
- command.execute();
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public SynchronizedObject<V> clone() {
- try {
- synchronized (this.mutex) {
- @SuppressWarnings("unchecked")
- SynchronizedObject<V> clone = (SynchronizedObject<V>) super.clone();
- return clone;
- }
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- @Override
- public String toString() {
- return '[' + String.valueOf(this.getValue()) + ']';
- }
-
- private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
- synchronized (this.mutex) {
- s.defaultWriteObject();
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedQueue.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedQueue.java
deleted file mode 100644
index e1aa3f97e4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedQueue.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.command.Command;
-
-/**
- * Thread-safe implementation of the {@link Queue} interface.
- * This also provides protocol for suspending a thread until the
- * queue is empty or not empty, with optional time-outs.
- */
-public class SynchronizedQueue<E>
- implements Queue<E>, Serializable
-{
- /** Backing queue. */
- private final Queue<E> queue;
-
- /** Object to synchronize on. */
- private final Object mutex;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a synchronized queue that wraps the
- * specified queue and locks on the specified mutex.
- */
- public SynchronizedQueue(Queue<E> queue, Object mutex) {
- super();
- if ((queue == null) || (mutex == null)) {
- throw new NullPointerException();
- }
- this.queue = queue;
- this.mutex = mutex;
- }
-
- /**
- * Construct a synchronized queue that wraps the
- * specified queue and locks on itself.
- */
- public SynchronizedQueue(Queue<E> queue) {
- super();
- if (queue == null) {
- throw new NullPointerException();
- }
- this.queue = queue;
- this.mutex = this;
- }
-
- /**
- * Construct an empty synchronized queue that locks on the specified mutex.
- */
- public SynchronizedQueue(Object mutex) {
- this(new SimpleQueue<E>(), mutex);
- }
-
- /**
- * Construct an empty synchronized queue that locks on itself.
- */
- public SynchronizedQueue() {
- this(new SimpleQueue<E>());
- }
-
-
- // ********** Queue implementation **********
-
- public void enqueue(E element) {
- synchronized (this.mutex) {
- this.enqueue_(element);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void enqueue_(E element) {
- this.queue.enqueue(element);
- this.mutex.notifyAll();
- }
-
- public E dequeue() {
- synchronized (this.mutex) {
- return this.dequeue_();
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private E dequeue_() {
- E element = this.queue.dequeue();
- this.mutex.notifyAll();
- return element;
- }
-
- public E peek() {
- synchronized (this.mutex) {
- return this.queue.peek();
- }
- }
-
- public boolean isEmpty() {
- synchronized (this.mutex) {
- return this.queue.isEmpty();
- }
- }
-
-
- // ********** indefinite waits **********
-
- /**
- * Suspend the current thread until the queue's empty status changes
- * to the specified value.
- */
- public void waitUntilEmptyIs(boolean empty) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilEmptyIs_(empty);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void waitUntilEmptyIs_(boolean empty) throws InterruptedException {
- while (this.queue.isEmpty() != empty) {
- this.mutex.wait();
- }
- }
-
- /**
- * Suspend the current thread until the queue is empty.
- */
- public void waitUntilEmpty() throws InterruptedException {
- this.waitUntilEmptyIs(true);
- }
-
- /**
- * Suspend the current thread until the queue has something on it.
- */
- public void waitUntilNotEmpty() throws InterruptedException {
- this.waitUntilEmptyIs(false);
- }
-
- /**
- * Suspend the current thread until the queue is empty,
- * then "enqueue" the specified item to the tail of the queue
- * and continue executing.
- */
- public void waitToEnqueue(E element) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilEmptyIs_(true);
- this.enqueue_(element);
- }
- }
-
- /**
- * Suspend the current thread until the queue has something on it,
- * then "dequeue" an item from the head of the queue and return it.
- */
- public Object waitToDequeue() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilEmptyIs_(false);
- return this.dequeue_();
- }
- }
-
-
- // ********** timed waits **********
-
- /**
- * Suspend the current thread until the queue's empty status changes
- * to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if the specified
- * empty status was achieved; return <code>false</code> if a time-out occurred.
- * If the queue's empty status is already the specified value,
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilEmptyIs(boolean empty, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilEmptyIs_(empty, timeout);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private boolean waitUntilEmptyIs_(boolean empty, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitUntilEmptyIs_(empty); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.queue.isEmpty() != empty) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.queue.isEmpty() == empty);
- }
-
- /**
- * Suspend the current thread until the queue is empty
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the queue is empty; return <code>false</code> if a time-out occurred.
- * If the queue is already empty, return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilEmpty(long timeout) throws InterruptedException {
- return this.waitUntilEmptyIs(true, timeout);
- }
-
- /**
- * Suspend the current thread until the queue has something on it.
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the queue is not empty; return <code>false</code> if a time-out occurred.
- * If the queue already has something on it, return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilNotEmpty(long timeout) throws InterruptedException {
- return this.waitUntilEmptyIs(false, timeout);
- }
-
- /**
- * Suspend the current thread until the queue is empty,
- * then "enqueue" the specified item to the tail of the queue
- * and continue executing. If the queue is not emptied out
- * before the time-out, simply continue executing without
- * "enqueueing" the item.
- * The time-out is specified in milliseconds. Return <code>true</code> if the
- * item was enqueued; return <code>false</code> if a time-out occurred.
- * If the queue is already empty, "enqueue" the specified item and
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitToEnqueue(E element, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilEmptyIs_(true, timeout);
- if (success) {
- this.enqueue_(element);
- }
- return success;
- }
- }
-
- /**
- * Suspend the current thread until the queue has something on it,
- * then "dequeue" an item from the head of the queue and return it.
- * If the queue is empty and nothing is "enqueued" on to it before the
- * time-out, throw a no such element exception.
- * The time-out is specified in milliseconds.
- * If the queue is not empty, "dequeue" an item and
- * return it immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public Object waitToDequeue(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilEmptyIs_(false, timeout);
- if (success) {
- return this.dequeue_();
- }
- throw new NoSuchElementException();
- }
- }
-
-
- // ********** synchronized behavior **********
-
- /**
- * If the current thread is not interrupted, execute the specified command
- * with the mutex locked. This is useful for initializing the queue in another
- * thread.
- */
- public void execute(Command command) throws InterruptedException {
- if (Thread.currentThread().isInterrupted()) {
- throw new InterruptedException();
- }
- synchronized (this.mutex) {
- command.execute();
- }
- }
-
-
- // ********** additional public protocol **********
-
- /**
- * "Drain" all the current items from the queue into specified queue.
- */
- public void drainTo(Queue<E> q) {
- synchronized (this.mutex) {
- this.drainTo_(q);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void drainTo_(Queue<E> q) {
- boolean changed = false;
- while ( ! this.queue.isEmpty()) {
- q.enqueue(this.queue.dequeue());
- changed = true;
- }
- if (changed) {
- this.mutex.notifyAll();
- }
- }
-
- /**
- * Return the object the queue locks on while performing
- * its operations.
- */
- public Object getMutex() {
- return this.mutex;
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- synchronized (this.mutex) {
- return '[' + this.queue.toString() + ']';
- }
- }
-
- private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
- synchronized (this.mutex) {
- s.defaultWriteObject();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedStack.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedStack.java
deleted file mode 100644
index 21bb4ce347..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/SynchronizedStack.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.EmptyStackException;
-
-import org.eclipse.jpt.common.utility.command.Command;
-
-/**
- * Thread-safe implementation of the {@link Stack} interface.
- * This also provides protocol for suspending a thread until the
- * stack is empty or not empty, with optional time-outs.
- */
-public class SynchronizedStack<E>
- implements Stack<E>, Serializable
-{
- /** Backing stack. */
- private final Stack<E> stack;
-
- /** Object to synchronize on. */
- private final Object mutex;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a synchronized stack that wraps the
- * specified stack and locks on the specified mutex.
- */
- public SynchronizedStack(Stack<E> stack, Object mutex) {
- super();
- if (stack == null) {
- throw new NullPointerException();
- }
- this.stack = stack;
- this.mutex = mutex;
- }
-
- /**
- * Construct a synchronized stack that wraps the
- * specified stack and locks on itself.
- */
- public SynchronizedStack(Stack<E> stack) {
- super();
- if (stack == null) {
- throw new NullPointerException();
- }
- this.stack = stack;
- this.mutex = this;
- }
-
- /**
- * Construct an empty synchronized stack that locks on the specified mutex.
- */
- public SynchronizedStack(Object mutex) {
- this(new SimpleStack<E>(), mutex);
- }
-
- /**
- * Construct an empty synchronized stack that locks on itself.
- */
- public SynchronizedStack() {
- this(new SimpleStack<E>());
- }
-
-
- // ********** Stack implementation **********
-
- public void push(E element) {
- synchronized (this.mutex) {
- this.push_(element);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void push_(E element) {
- this.stack.push(element);
- this.mutex.notifyAll();
- }
-
- public E pop() {
- synchronized (this.mutex) {
- return this.pop_();
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private E pop_() {
- E o = this.stack.pop();
- this.mutex.notifyAll();
- return o;
- }
-
- public E peek() {
- synchronized (this.mutex) {
- return this.stack.peek();
- }
- }
-
- public boolean isEmpty() {
- synchronized (this.mutex) {
- return this.stack.isEmpty();
- }
- }
-
-
- // ********** indefinite waits **********
-
- /**
- * Suspend the current thread until the stack's empty status changes
- * to the specified value.
- */
- public void waitUntilEmptyIs(boolean empty) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilEmptyIs_(empty);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private void waitUntilEmptyIs_(boolean empty) throws InterruptedException {
- while (this.stack.isEmpty() != empty) {
- this.mutex.wait();
- }
- }
-
- /**
- * Suspend the current thread until the stack is empty.
- */
- public void waitUntilEmpty() throws InterruptedException {
- this.waitUntilEmptyIs(true);
- }
-
- /**
- * Suspend the current thread until the stack has something on it.
- */
- public void waitUntilNotEmpty() throws InterruptedException {
- this.waitUntilEmptyIs(false);
- }
-
- /**
- * Suspend the current thread until the stack is empty,
- * then "push" the specified item on to the top of the stack
- * and continue executing.
- */
- public void waitToPush(E element) throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilEmptyIs_(true);
- this.push_(element);
- }
- }
-
- /**
- * Suspend the current thread until the stack has something on it,
- * then "pop" an item from the top of the stack and return it.
- */
- public Object waitToPop() throws InterruptedException {
- synchronized (this.mutex) {
- this.waitUntilEmptyIs_(false);
- return this.pop_();
- }
- }
-
-
- // ********** timed waits **********
-
- /**
- * Suspend the current thread until the stack's empty status changes
- * to the specified value or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if the specified
- * empty status was achieved; return <code>false</code> if a time-out occurred.
- * If the stack's empty status is already the specified value,
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilEmptyIs(boolean empty, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- return this.waitUntilEmptyIs_(empty, timeout);
- }
- }
-
- /**
- * Pre-condition: synchronized
- */
- private boolean waitUntilEmptyIs_(boolean empty, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitUntilEmptyIs_(empty); // wait indefinitely until notified
- return true; // if it ever comes back, the condition was met
- }
-
- long stop = System.currentTimeMillis() + timeout;
- long remaining = timeout;
- while ((this.stack.isEmpty() != empty) && (remaining > 0L)) {
- this.mutex.wait(remaining);
- remaining = stop - System.currentTimeMillis();
- }
- return (this.stack.isEmpty() == empty);
- }
-
- /**
- * Suspend the current thread until the stack is empty
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the stack is empty; return <code>false</code> if a time-out occurred.
- * If the stack is already empty, return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilEmpty(long timeout) throws InterruptedException {
- return this.waitUntilEmptyIs(true, timeout);
- }
-
- /**
- * Suspend the current thread until the stack has something on it.
- * or the specified time-out occurs.
- * The time-out is specified in milliseconds. Return <code>true</code> if
- * the stack is not empty; return <code>false</code> if a time-out occurred.
- * If the stack already has something on it, return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitUntilNotEmpty(long timeout) throws InterruptedException {
- return this.waitUntilEmptyIs(false, timeout);
- }
-
- /**
- * Suspend the current thread until the stack is empty,
- * then "push" the specified item on to the top of the stack
- * and continue executing. If the stack is not emptied out
- * before the time-out, simply continue executing without
- * "pushing" the item.
- * The time-out is specified in milliseconds. Return <code>true</code> if the
- * item was pushed; return <code>false</code> if a time-out occurred.
- * If the stack is already empty, "push" the specified item and
- * return <code>true</code> immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public boolean waitToPush(E element, long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilEmptyIs_(true, timeout);
- if (success) {
- this.push_(element);
- }
- return success;
- }
- }
-
- /**
- * Suspend the current thread until the stack has something on it,
- * then "pop" an item from the top of the stack and return it.
- * If the stack is empty and nothing is "pushed" on to it before the
- * time-out, throw an empty stack exception.
- * The time-out is specified in milliseconds.
- * If the stack is not empty, "pop" an item and
- * return it immediately.
- * If the time-out is zero, wait indefinitely.
- */
- public Object waitToPop(long timeout) throws InterruptedException {
- synchronized (this.mutex) {
- boolean success = this.waitUntilEmptyIs_(false, timeout);
- if (success) {
- return this.pop_();
- }
- throw new EmptyStackException();
- }
- }
-
-
- // ********** synchronized behavior **********
-
- /**
- * If the current thread is not interrupted, execute the specified command
- * with the mutex locked. This is useful for initializing the stack in another
- * thread.
- */
- public void execute(Command command) throws InterruptedException {
- if (Thread.currentThread().isInterrupted()) {
- throw new InterruptedException();
- }
- synchronized (this.mutex) {
- command.execute();
- }
- }
-
-
- // ********** additional public protocol **********
-
- /**
- * Return the object the stack locks on while performing
- * its operations.
- */
- public Object getMutex() {
- return this.mutex;
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- synchronized (this.mutex) {
- return '[' + this.stack.toString() + ']';
- }
- }
-
- private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
- synchronized (this.mutex) {
- s.defaultWriteObject();
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Tools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Tools.java
deleted file mode 100644
index 10e36e7b22..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Tools.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Various utility methods.
- */
-@SuppressWarnings("nls")
-public final class Tools {
-
- // ********** object comparison **********
-
- /**
- * Return whether the specified values are equal, with the appropriate
- * <code>null</code> checks.
- */
- public static boolean valuesAreEqual(Object value1, Object value2) {
- return (value1 == null) ?
- (value2 == null) :
- ((value2 != null) && value1.equals(value2));
- }
-
- /**
- * Return whether the specified values are different, with the appropriate
- * <code>null</code> checks.
- */
- public static boolean valuesAreDifferent(Object value1, Object value2) {
- return (value1 == null) ?
- (value2 != null) :
- ((value2 == null) || ! value1.equals(value2));
- }
-
-
- // ********** System properties **********
-
- /**
- * Return whether the current JVM is Sun's (or Oracle's).
- */
- public static boolean jvmIsSun() {
- return jvmIs("Sun") || jvmIs("Oracle");
- }
-
- /**
- * Return whether the current JVM is IBM's.
- */
- public static boolean jvmIsIBM() {
- return jvmIs("IBM");
- }
-
- private static boolean jvmIs(String jvmVendorName) {
- return System.getProperty("java.vendor").startsWith(jvmVendorName);
- }
-
- /**
- * Return whether the current operating system is Microsoft Windows.
- */
- public static boolean osIsWindows() {
- return osIs("Windows");
- }
-
- /**
- * Return whether the current operating system is Linux.
- */
- public static boolean osIsLinux() {
- return osIs("Linux");
- }
-
- /**
- * Return whether the current operating system is Mac OS X.
- */
- public static boolean osIsMac() {
- return osIs("Mac");
- }
-
- private static boolean osIs(String osName) {
- return System.getProperty("os.name").indexOf(osName) != -1;
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private Tools() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Transformer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Transformer.java
deleted file mode 100644
index 2aa982a3bb..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/Transformer.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-
-/**
- * Used by various "pluggable" classes to transform objects.
- * Transform an object of type <code>T1</code> to an object of type
- * <code>T2</code>.
- *
- * @param <T1> the type of the object passed to the transformer
- * @param <T2> the type of the object returned by the transformer
- */
-public interface Transformer<T1, T2> {
-
- /**
- * Return the transformed object.
- * The semantics of "transform" is determined by the
- * contract between the client and the server.
- */
- T2 transform(T1 o);
-
-
- /**
- * A "null" transformer will perform no transformation at all;
- * it will simply return the object "untransformed".
- */
- final class Null<S1, S2>
- implements Transformer<S1, S2>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Transformer INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R1, R2> Transformer<R1, R2> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // simply return the object, unchanged
- @SuppressWarnings("unchecked")
- public S2 transform(S1 o) {
- return (S2) o;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- /**
- * A "disabled" transformer will throw an exception if
- * {@link #transform(Object)} is called. This is useful in situations
- * where a transformer is optional and the default transformer should
- * not be used.
- */
- final class Disabled<S1, S2>
- implements Transformer<S1, S2>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Transformer INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R1, R2> Transformer<R1, R2> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public S2 transform(S1 o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/TransformerAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/TransformerAdapter.java
deleted file mode 100644
index d5427a271a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/TransformerAdapter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-/**
- * Convenience transformer that returns <code>null</code> for every
- * transformation.
- */
-public class TransformerAdapter<T1, T2>
- implements Transformer<T1, T2>
-{
- public T2 transform(T1 o) {
- return null;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/VersionComparator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/VersionComparator.java
deleted file mode 100644
index 9aa9603a9d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/VersionComparator.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.StringTokenizer;
-
-/**
- * This comparator can be used to compare version strings (e.g. "2.2.2" vs.
- * "2.14.3"). Clients can specify the delimiter(s) that separates a version's
- * <em>segments</em> as well as a parser to be used for parsing each
- * <em>segment</em>.
- *
- * @see #INTEGER_VERSION_COMPARATOR
- */
-public class VersionComparator<T extends Comparable<T>>
- implements Comparator<String>
-{
- private final String delimiters;
- private final SegmentParser<T> segmentParser;
-
-
- /**
- * Static implementation of the version comparator interface that converts
- * each version into a series of integers and compares them.
- * <p>
- * <strong>NB:</strong> With this comparator <code>"2.14" > "2.2"</code>
- */
- public static final Comparator<String> INTEGER_VERSION_COMPARATOR = new VersionComparator<Integer>(SegmentParser.IntegerSegmentParser.instance());
-
-
- /**
- * The default delimiter is <code>'.'</code>.
- * The default segment parser is disabled.
- * <p>
- * <strong>NB:</strong> Subclass must override:<ul>
- * <li>{@link #parseSegment(int, String)}
- * <li>{@link #getZero()}
- * </ul>
- */
- protected VersionComparator() {
- this("."); //$NON-NLS-1$
- }
-
- /**
- * The default segment parser is disabled.
- * <p>
- * <strong>NB:</strong> Subclass must override:<ul>
- * <li>{@link #parseSegment(int, String)}
- * <li>{@link #getZero()}
- * </ul>
- */
- protected VersionComparator(String delimiters) {
- this(delimiters, SegmentParser.Disabled.<T>instance());
- }
-
- /**
- * Use the specified segment parser.
- * The default delimiter is <code>'.'</code>.
- */
- public VersionComparator(SegmentParser<T> segmentParser) {
- this(".", segmentParser); //$NON-NLS-1$
- }
-
- /**
- * Use the specified delimiters and segment parser.
- */
- public VersionComparator(String delimiters, SegmentParser<T> segmentParser) {
- super();
- this.delimiters = delimiters;
- this.segmentParser = segmentParser;
- }
-
-
- /**
- * <strong>NB:</strong> Callers must handle any exceptions thrown by the
- * segment parser supplied to the comparator. In particular, the pre-built
- * integer segment parser {@link #INTEGER_VERSION_COMPARATOR} can throw a
- * {@link NumberFormatException} if any segement string contains non-numeric
- * characters.
- */
- public int compare(String version1, String version2) {
- ArrayList<T> segments1 = this.parseVersion(version1);
- ArrayList<T> segments2 = this.parseVersion(version2);
- int size1 = segments1.size();
- int size2 = segments2.size();
- int min = Math.min(size1, size2);
- for (int i = 0; i < min; i++) {
- int segmentCompare = segments1.get(i).compareTo(segments2.get(i));
- if (segmentCompare != 0) {
- return segmentCompare;
- }
- }
-
- if (size1 == size2) {
- return 0;
- }
-
- int max = Math.max(size1, size2);
- T zero = this.getZero();
- if (size1 < size2) {
- for (int i = min; i < max; i++) {
- int segmentCompare = zero.compareTo(segments2.get(i));
- if (segmentCompare != 0) {
- return segmentCompare;
- }
- }
- } else {
- for (int i = min; i < max; i++) {
- int segmentCompare = segments1.get(i).compareTo(zero);
- if (segmentCompare != 0) {
- return segmentCompare;
- }
- }
- }
- return 0;
- }
-
- /**
- * Parse the specified version into a list of segments that can be
- * compared individually.
- */
- protected ArrayList<T> parseVersion(String s) {
- ArrayList<T> segments = new ArrayList<T>();
- int i = 0;
- for (StringTokenizer stream = new StringTokenizer(s, this.delimiters); stream.hasMoreTokens(); ) {
- segments.add(this.parseSegment(i++, stream.nextToken()));
- }
- return segments;
- }
-
- /**
- * Parse the specified segment into the appropriate comparable.
- * Subclasses must override this method if a segment parser is not passed
- * to the version comparator's constructor.
- */
- protected T parseSegment(int index, String s) {
- return this.segmentParser.parse(index, s);
- }
-
- protected T getZero() {
- return this.segmentParser.getZero();
- }
-
-
- /**
- * A segment parser is used by a version comparator to convert each
- * <em>segment</em> of a version into something that can be compared to the
- * corresponding <em>segment</em> in another version.
- */
- public interface SegmentParser<T extends Comparable<T>> {
- /**
- * Convert the specified version <em>segment</em> into something that
- * can be compared to the corresponding <em>segment</em> in another
- * version.
- */
- T parse(int segmentIndex, String segment);
-
- /**
- * Return a "zero" <em>segment</em> value that can be compared to
- * trailing segments when two version have differing numbers of
- * <em>segments</em>.
- */
- T getZero();
-
- /**
- * Singleton implementation of the segment parser interface that converts
- * each segment into an integer, irrespective of position.
- * <p>
- * <strong>NB:</strong> With this parser <code>"2.14" > "2.2"</code>
- */
- final class IntegerSegmentParser
- implements SegmentParser<Integer>, Serializable
- {
- public static final SegmentParser<Integer> INSTANCE = new IntegerSegmentParser();
- public static SegmentParser<Integer> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private IntegerSegmentParser() {
- super();
- }
- // simply parse the segment as an integer
- public Integer parse(int segmentIndex, String segment) {
- return Integer.valueOf(segment);
- }
- public Integer getZero() {
- return ZERO;
- }
- private static final Integer ZERO = Integer.valueOf(0);
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- /**
- * Singleton implementation of the segment parser interface that throws
- * an exception if called.
- */
- final class Disabled<S extends Comparable<S>>
- implements SegmentParser<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final SegmentParser INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R extends Comparable<R>> SegmentParser<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public S parse(int segmentIndex, String segment) {
- throw new UnsupportedOperationException();
- }
- public S getZero() {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/XMLStringEncoder.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/XMLStringEncoder.java
deleted file mode 100644
index baf7d30684..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/XMLStringEncoder.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-
-/**
- * This encoder will replace any of a specified set of characters with an XML
- * "character reference": '/' => "&#x2f;"
- */
-public final class XMLStringEncoder {
-
- /** The set of characters to be converted into XML character references. */
- private final char[] chars;
-
- /** Cache the value of the highest character in the set above. */
- private final char maxChar;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct an encoder that converts the specified set of characters
- * into XML character references.
- */
- public XMLStringEncoder(char[] chars) {
- super();
- if (chars == null) {
- throw new NullPointerException();
- }
- // the ampersand must be included since it is the escape character
- if (ArrayTools.contains(chars, '&')) {
- this.chars = chars;
- } else {
- this.chars = ArrayTools.add(chars, '&');
- }
- this.maxChar = this.calculateMaxInvalidFileNameChar();
- }
-
- /**
- * Calculate the maximum value of the set of characters to be converted
- * into XML character references. This will be used to short-circuit the
- * search for a character in the set.
- * @see #charIsToBeEncoded(char)
- */
- private char calculateMaxInvalidFileNameChar() {
- char[] localChars = this.chars;
- char max = 0;
- for (int i = localChars.length; i-- > 0; ) {
- char c = localChars[i];
- if (max < c) {
- max = c;
- }
- }
- return max;
- }
-
-
- // ********** API **********
-
- /**
- * Return the specified string with any characters in the set
- * replaced with XML character references.
- */
- public String encode(String s) {
- int len = s.length();
- // allow for a few encoded characters
- StringBuilder sb = new StringBuilder(len + 20);
- for (int i = 0; i < len; i++) {
- this.appendCharacterTo(s.charAt(i), sb);
- }
- return sb.toString();
- }
-
- /**
- * Return the specified string with any XML character references
- * replaced by the characters themselves.
- */
- public String decode(String s) {
- StringBuilder sb = new StringBuilder(s.length());
- StringBuilder temp = new StringBuilder(); // performance tweak
- this.decodeTo(new StringReader(s), sb, temp);
- return sb.toString();
- }
-
-
- // ********** internal methods **********
-
- /**
- * Append the specified character to the string buffer,
- * converting it to an XML character reference if necessary.
- */
- private void appendCharacterTo(char c, StringBuilder sb) {
- if (this.charIsToBeEncoded(c)) {
- this.appendCharacterReferenceTo(c, sb);
- } else {
- sb.append(c);
- }
- }
-
- /**
- * Return whether the specified character is one of the characters
- * to be converted to XML character references.
- */
- private boolean charIsToBeEncoded(char c) {
- return (c <= this.maxChar) && ArrayTools.contains(this.chars, c);
- }
-
- /**
- * Append the specified character's XML character reference to the
- * specified string buffer (e.g. '/' => "&#x2f;").
- */
- private void appendCharacterReferenceTo(char c, StringBuilder sb) {
- sb.append("&#x"); //$NON-NLS-1$
- sb.append(Integer.toString(c, 16));
- sb.append(';');
- }
-
- private void decodeTo(Reader reader, StringBuilder sb, StringBuilder temp) {
- try {
- this.decodeTo_(reader, sb, temp);
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private void decodeTo_(Reader reader, StringBuilder sb, StringBuilder temp) throws IOException {
- int c = reader.read();
- while (c != -1) {
- if (c == '&') {
- this.decodeCharacterReferenceTo(reader, sb, temp);
- } else {
- sb.append((char) c);
- }
- c = reader.read();
- }
- reader.close();
- }
-
- private void decodeCharacterReferenceTo(Reader reader, StringBuilder sb, StringBuilder temp) throws IOException {
- int c = reader.read();
- this.checkChar(c, '#');
- c = reader.read();
- this.checkChar(c, 'x');
-
- temp.setLength(0); // re-use temp
- c = reader.read();
- while (c != ';') {
- this.checkEndOfStream(c);
- temp.append((char) c);
- c = reader.read();
- }
- String charValue = temp.toString();
- if (charValue.length() == 0) {
- throw new IllegalStateException("missing numeric string"); //$NON-NLS-1$
- }
- sb.append((char) Integer.parseInt(charValue, 16));
- }
-
- private void checkChar(int c, int expected) {
- this.checkEndOfStream(c);
- if (c != expected) {
- throw new IllegalStateException("expected '" + (char) expected + "', but encountered '" + (char) c + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- private void checkEndOfStream(int c) {
- if (c == -1) {
- throw new IllegalStateException("unexpected end of string"); //$NON-NLS-1$
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractAsynchronousCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractAsynchronousCommandExecutor.java
deleted file mode 100644
index 8a059e1f9b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractAsynchronousCommandExecutor.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import java.util.concurrent.ThreadFactory;
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.ConsumerThreadCoordinator;
-import org.eclipse.jpt.common.utility.internal.SimpleThreadFactory;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.SynchronizedQueue;
-
-/**
- * This command executor will dispatch commands to be executed in a separate
- * thread, allowing calls to
- * {@link org.eclipse.jpt.common.utility.command.CommandExecutor#execute(Command)}
- * to return immediately.
- * <p>
- * <strong>NB:</strong> If a client-supplied command throws a runtime exception
- * while it is executing, the command executor will use its
- * {@link ExceptionHandler exception handler} to handle the exception.
- */
-public abstract class AbstractAsynchronousCommandExecutor<E extends StatefulCommandExecutor>
- implements StatefulCommandExecutor
-{
- /**
- * The wrapped command executor.
- */
- protected final E commandExecutor;
-
- /**
- * This command queue is shared with the command execution/consumer thread.
- * Adding a command to it will trigger the command to be executed by the
- * command execution thread or, if another command is currently executing,
- * to execute the new command once the currently executing command has
- * finished executing.
- */
- private final SynchronizedQueue<Command> commands = new SynchronizedQueue<Command>();
-
- /**
- * Most of the thread-related behavior is delegated to this coordinator.
- */
- private final ConsumerThreadCoordinator consumerThreadCoordinator;
-
-
- // ********** construction **********
-
- /**
- * Construct an asynchronous command executor.
- * Delegate command execution to the specified command executor.
- * Use the specified thread factory to construct the command execution
- * thread(s) and assign them the specified name.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- protected AbstractAsynchronousCommandExecutor(Config<E> config) {
- this(config.getCommandExecutor(), config.getThreadFactory(), config.getThreadName(), config.getExceptionHandler());
- }
-
- /**
- * Construct an asynchronous command executor.
- * Delegate command execution to the specified command executor.
- * Use the specified thread factory to construct the command execution
- * thread(s) and assign them the specified name.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- protected AbstractAsynchronousCommandExecutor(
- E commandExecutor,
- ThreadFactory threadFactory,
- String threadName,
- ExceptionHandler exceptionHandler
- ) {
- super();
- if (commandExecutor == null) {
- throw new NullPointerException();
- }
- this.commandExecutor = commandExecutor;
- this.consumerThreadCoordinator = this.buildConsumerThreadCoordinator(threadFactory, threadName, exceptionHandler);
- }
-
- private ConsumerThreadCoordinator buildConsumerThreadCoordinator(ThreadFactory threadFactory, String threadName, ExceptionHandler exceptionHandler) {
- return new ConsumerThreadCoordinator(this.buildConsumer(), threadFactory, threadName, exceptionHandler);
- }
-
- private ConsumerThreadCoordinator.Consumer buildConsumer() {
- return new Consumer();
- }
-
-
- // ********** StatefulCommandExecutor implementation **********
-
- /**
- * Build and start the command execution/consumer thread.
- * <p>
- * Note: We don't clear the command queue here; so if a command has been
- * added to the queue <em>before</em> getting here, the first command will
- * be executed promptly (albeit, asynchronously).
- * The command queue will be non-empty if:<ul>
- * <li>{@link #execute(Command)} was called after the command executor was
- * constructed but before {@link #start()} was called; or
- * <li>{@link #execute(Command)} was called after {@link #stop()} was called
- * but before {@link #start()} was called (to restart the command executor); or
- * <li>{@link #stop()} was called when there were still outstanding commands
- * remaining in the command queue
- * </ul>
- *
- * @exception IllegalStateException if the executor has already been started
- */
- public synchronized void start() {
- this.commandExecutor.start();
- this.consumerThreadCoordinator.start();
- }
-
- /**
- * Put the specified command on the command queue, to be consumed by the
- * command execution thread. If the executor is stopped, the command will
- * be queued and executed once the executor is, if ever, started.
- */
- public synchronized void execute(Command command) {
- this.commands.enqueue(command);
- }
-
- /**
- * Interrupt the command execution thread so that it stops executing at the
- * end of the current command. Suspend the current thread until
- * the command execution thread is finished executing. If any uncaught
- * exceptions were thrown while the execution thread was executing,
- * wrap them in a composite exception and throw the composite exception.
- * Any remaining commands will be executed once the exector is, if ever,
- * restarted.
- *
- * @exception IllegalStateException if the executor has not been started
- */
- public synchronized void stop() throws InterruptedException {
- this.consumerThreadCoordinator.stop();
- this.commandExecutor.stop();
- }
-
-
- // ********** misc **********
-
- /* CU private */ void waitForCommand() throws InterruptedException {
- this.commands.waitUntilNotEmpty();
- }
-
- /* CU private */ void executeNextCommand() {
- this.commandExecutor.execute(this.commands.dequeue());
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.consumerThreadCoordinator);
- }
-
-
- // ********** consumer **********
-
- /**
- * This implementation of
- * {@link org.eclipse.jpt.common.utility.internal.ConsumerThreadCoordinator.Consumer}
- * will execute the commands enqueued by the asynchronous command executor.
- * It will wait until the shared command queue is non-empty to begin executing the
- * commands in the queue. Once a comand is executed, the thread will quiesce until
- * another command is placed in the command queue. If a new command is
- * enqueued during the execution of another command (either recursively by
- * the command itself or by another thread),
- * the new command will be executed immediately after the currently
- * executing command is finished.
- * Stop the thread by calling {@link Thread#interrupt()}.
- */
- class Consumer
- implements ConsumerThreadCoordinator.Consumer
- {
- /**
- * Wait until a command has been placed in the queue.
- */
- public void waitForProducer() throws InterruptedException {
- AbstractAsynchronousCommandExecutor.this.waitForCommand();
- }
-
- /**
- * Execute the first command in the queue.
- */
- public void consume() {
- AbstractAsynchronousCommandExecutor.this.executeNextCommand();
- }
- }
-
-
- // ********** config **********
-
- /**
- * Config useful for instantiating an {@link AbstractAsynchronousCommandExecutor}.
- */
- public interface Config<E extends StatefulCommandExecutor> {
- E getCommandExecutor();
- ThreadFactory getThreadFactory();
- String getThreadName();
- ExceptionHandler getExceptionHandler();
- }
-
- /**
- * Config useful for instantiating an {@link AbstractAsynchronousCommandExecutor}.
- */
- protected abstract static class SimpleConfig<E extends StatefulCommandExecutor>
- implements Config<E>
- {
- private volatile E commandExecutor;
- private volatile ThreadFactory threadFactory;
- private volatile String threadName;
- private volatile ExceptionHandler exceptionHandler;
-
- protected SimpleConfig() {
- super();
- this.commandExecutor = this.buildDefaultCommandExecutor();
- this.threadFactory = this.buildDefaultThreadFactory();
- this.threadName = this.buildDefaultThreadName();
- this.exceptionHandler = this.buildDefaultExceptionHandler();
- }
-
- protected SimpleConfig(E commandExecutor, ThreadFactory threadFactory, String threadName, ExceptionHandler exceptionHandler) {
- super();
- this.commandExecutor = commandExecutor;
- this.threadFactory = threadFactory;
- this.threadName = threadName;
- this.exceptionHandler = exceptionHandler;
- }
-
- public void setCommandExecutor(E commandExecutor) {
- this.commandExecutor = commandExecutor;
- }
- public E getCommandExecutor() {
- return this.commandExecutor;
- }
- protected abstract E buildDefaultCommandExecutor();
-
- public void setThreadFactory(ThreadFactory threadFactory) {
- this.threadFactory = threadFactory;
- }
- public ThreadFactory getThreadFactory() {
- return this.threadFactory;
- }
- protected ThreadFactory buildDefaultThreadFactory() {
- return SimpleThreadFactory.instance();
- }
-
- public void setThreadName(String threadName) {
- this.threadName = threadName;
- }
- public String getThreadName() {
- return this.threadName;
- }
- protected String buildDefaultThreadName() {
- return null;
- }
-
- public void setExceptionHandler(ExceptionHandler exceptionHandler) {
- this.exceptionHandler = exceptionHandler;
- }
- public ExceptionHandler getExceptionHandler() {
- return this.exceptionHandler;
- }
- protected ExceptionHandler buildDefaultExceptionHandler() {
- return ExceptionHandler.Runtime.instance();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractQueueingCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractQueueingCommandExecutor.java
deleted file mode 100644
index 6edd43eae8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractQueueingCommandExecutor.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.SimpleQueue;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean;
-
-/**
- * This is a command executor that queues up any commands
- * that are {@link #execute(Command) executed} while the executor is
- * {@link #stop() stopped}. These commands will be
- * executed when the executor is {@link #start() started}.
- */
-public abstract class AbstractQueueingCommandExecutor<E extends StatefulCommandExecutor>
- implements StatefulCommandExecutor
-{
- protected final E commandExecutor;
- protected final SynchronizedBoolean active = new SynchronizedBoolean(false);
- private SimpleQueue<Command> queue = new SimpleQueue<Command>();
-
-
- protected AbstractQueueingCommandExecutor(E commandExecutor) {
- super();
- if (commandExecutor == null) {
- throw new NullPointerException();
- }
- this.commandExecutor = commandExecutor;
- }
-
- /**
- * Start the command executor, executing all the commands that were
- * queued up while the executor was {@link #stop() stopped}.
- */
- public synchronized void start() {
- if (this.active.isTrue()) {
- throw new IllegalStateException("Not stopped."); //$NON-NLS-1$
- }
- this.commandExecutor.start();
- while ( ! this.queue.isEmpty()) {
- this.commandExecutor.execute(this.queue.dequeue());
- }
- this.active.setTrue();
- }
-
- /**
- * If the command executor is active, execute the specified command;
- * otherwise, queue the command to be executed once the executor is
- * {@link #start() started}.
- */
- public void execute(Command command) {
- if (this.commandIsToBeExecuted(command)) {
- this.commandExecutor.execute(command);
- }
- }
-
- /**
- * Return whether the command executor is active and, if it is <em>in</em>active,
- * place the specified command in the queue for later execution.
- */
- private synchronized boolean commandIsToBeExecuted(Command command) {
- if (this.active.isFalse()) {
- this.queue.enqueue(command);
- return false;
- }
- return true;
- }
-
- /**
- * Stop the command executor. Any further requests to
- * {@link #execute(Command) execute} a command will result in the command
- * being queued up to be executed once the command executor is
- * {@link #start() restarted}.
- */
- public synchronized void stop() throws InterruptedException {
- if (this.active.isFalse()) {
- throw new IllegalStateException("Not started."); //$NON-NLS-1$
- }
- this.active.setFalse();
- this.commandExecutor.stop();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.queue);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractSafeCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractSafeCommandExecutor.java
deleted file mode 100644
index adc2abffa6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractSafeCommandExecutor.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This command executor wraps another command executor and uses an exception
- * handler to handle any exceptions thrown by an executing command.
- */
-public abstract class AbstractSafeCommandExecutor<E extends CommandExecutor>
- implements CommandExecutor
-{
- protected final E commandExecutor;
- protected final ExceptionHandler exceptionHandler;
-
-
- /**
- * <strong>NB:</strong> The default exception handler simply
- * <em>ignores</em> any and all exceptions.
- */
- protected AbstractSafeCommandExecutor(E commandExecutor) {
- this(commandExecutor, ExceptionHandler.Null.instance());
- }
-
- protected AbstractSafeCommandExecutor(E commandExecutor, ExceptionHandler exceptionHandler) {
- super();
- if ((commandExecutor == null) || (exceptionHandler == null)) {
- throw new NullPointerException();
- }
- this.commandExecutor = commandExecutor;
- this.exceptionHandler = exceptionHandler;
- }
-
- public void execute(Command command) {
- try {
- this.commandExecutor.execute(command);
- } catch (RuntimeException ex) {
- this.exceptionHandler.handleException(ex);
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.commandExecutor);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractSingleUseQueueingCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractSingleUseQueueingCommandExecutor.java
deleted file mode 100644
index 19dca1845d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractSingleUseQueueingCommandExecutor.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.SimpleQueue;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This is a command executor that queues up any commands that are
- * {@link #execute(Command) executed} before the executor has been
- * {@link #start() started} or while the executor is
- * {@link #suspend() suspended}. These commands will be
- * executed once the executor is {@link #start() started} or
- * {@link #resume() resumed}. Once the executor is {@link #start() started},
- * all commands are executed <em>synchronously</em>.
- * Once the executor is {@link #stop() stopped}, no further commands will be
- * executed; and the executor can<em>not</em> be {@link #start() restarted}.
- */
-public abstract class AbstractSingleUseQueueingCommandExecutor<E extends StatefulCommandExecutor>
- implements StatefulCommandExecutor
-{
- protected final E commandExecutor;
- private State state;
- private SimpleQueue<Command> queue = new SimpleQueue<Command>();
-
- private enum State {
- PRE_START,
- ACTIVE,
- SUSPENDED,
- DEAD
- }
-
-
- protected AbstractSingleUseQueueingCommandExecutor(E commandExecutor) {
- super();
- if (commandExecutor == null) {
- throw new NullPointerException();
- }
- this.commandExecutor = commandExecutor;
- this.state = State.PRE_START;
- }
-
- /**
- * Start the command executor, executing all the commands that were
- * queued up since the executor was first constructed.
- */
- public synchronized void start() {
- if (this.state != State.PRE_START) {
- throw this.buildISE();
- }
- this.commandExecutor.start();
- while ( ! this.queue.isEmpty()) {
- this.commandExecutor.execute(this.queue.dequeue());
- }
- this.state = State.ACTIVE;
- }
-
- public void execute(Command command) {
- if (this.commandIsToBeExecuted(command)) {
- this.commandExecutor.execute(command);
- }
- }
-
- /**
- * If the command executor is active (i.e. it has been
- * {@link #start() started}), execute the specified command.
- * If the command executor has not been {@link #start() started} or it is
- * {@link #suspend() suspended}, queue the
- * command to be executed when the executor is {@link #start() started} or
- * {@link #resume() resumed}.
- * If the command executor is dead (i.e. it has been
- * {@link #stop() stopped}), ignore the command.
- */
- private synchronized boolean commandIsToBeExecuted(Command command) {
- switch (this.state) {
- case ACTIVE:
- // execute the command outside the lock
- return true;
- case PRE_START:
- case SUSPENDED:
- this.queue.enqueue(command);
- return false;
- case DEAD:
- // ignore
- return false;
- }
- throw this.buildISE();
- }
-
- /**
- * Suspend the command executor. Any further requests to
- * {@link #execute(Command) execute} a command will result in the command
- * being queued up to be executed once the command executor is
- * {@link #resume() resumed}.
- */
- public synchronized void suspend() {
- if (this.state != State.ACTIVE) {
- throw this.buildISE();
- }
- this.state = State.SUSPENDED;
- }
-
- /**
- * Resume the command executor, executing all the commands that were
- * queued up since the executor was {@link #suspend() suspended}.
- */
- public synchronized void resume() {
- if (this.state != State.SUSPENDED) {
- throw this.buildISE();
- }
- while ( ! this.queue.isEmpty()) {
- this.commandExecutor.execute(this.queue.dequeue());
- }
- this.state = State.ACTIVE;
- }
-
- /**
- * Stop the command executor. Any queued commands (i.e. the commands
- * {@link #execute(Command) executed} while the command executor had not
- * been {@link #start() started} or was
- * {@link #suspend() suspended}) will be ignored.
- * Any further requests to
- * {@link #execute(Command) execute} a command will be ignored.
- * The command executor <em>cannot</em> be {@link #start() restarted},
- * {@link #suspend() suspended} or {@link #resume() resumed} once it has
- * been stopped.
- */
- public synchronized void stop() throws InterruptedException {
- switch (this.state) {
- case ACTIVE:
- // nothing to do
- break;
- case SUSPENDED:
- // drain the queue
- while ( ! this.queue.isEmpty()) {
- this.queue.dequeue();
- }
- break;
- case PRE_START:
- case DEAD:
- throw this.buildISE();
- }
-
- this.commandExecutor.stop();
- this.state = State.DEAD;
- }
-
- private IllegalStateException buildISE() {
- return new IllegalStateException(String.valueOf(this.state));
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.state);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractStatefulCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractStatefulCommandExecutor.java
deleted file mode 100644
index 724565ae92..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractStatefulCommandExecutor.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean;
-
-/**
- * Straightforward implementation of {@link StatefulCommandExecutor}
- * that executes commands immediately by default. This executor can
- * also be used to adapt simple {@link CommandExecutor}s to the
- * {@link StatefulCommandExecutor} interface, providing support for
- * lifecycle state.
- */
-public abstract class AbstractStatefulCommandExecutor<E extends CommandExecutor>
- implements StatefulCommandExecutor
-{
- protected final SynchronizedBoolean active = new SynchronizedBoolean(false);
- protected final E commandExecutor;
-
-
- protected AbstractStatefulCommandExecutor(E commandExecutor) {
- super();
- if (commandExecutor == null) {
- throw new NullPointerException();
- }
- this.commandExecutor = commandExecutor;
- }
-
- public synchronized void start() {
- if (this.active.isTrue()) {
- throw new IllegalStateException("Not stopped."); //$NON-NLS-1$
- }
- this.active.setTrue();
- }
-
- /**
- * If the command executor is inactive the command is simply ignored.
- */
- public void execute(Command command) {
- if (this.active.isTrue()) {
- this.commandExecutor.execute(command);
- }
- }
-
- public synchronized void stop() {
- if (this.active.isFalse()) {
- throw new IllegalStateException("Not started."); //$NON-NLS-1$
- }
- this.active.setFalse();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.commandExecutor);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractThreadLocalCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractThreadLocalCommandExecutor.java
deleted file mode 100644
index b14779de7d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AbstractThreadLocalCommandExecutor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-
-/**
- * This command executor allows the client to
- * specify a different command executor for each thread.
- */
-public abstract class AbstractThreadLocalCommandExecutor<E extends CommandExecutor>
- implements CommandExecutor
-{
- protected final ThreadLocal<E> threadLocal;
- protected final E defaultCommandExecutor;
-
-
- protected AbstractThreadLocalCommandExecutor(E defaultCommandExecutor) {
- super();
- if (defaultCommandExecutor == null) {
- throw new NullPointerException();
- }
- this.defaultCommandExecutor = defaultCommandExecutor;
- this.threadLocal = this.buildThreadLocal();
- }
-
- protected ThreadLocal<E> buildThreadLocal() {
- return new ThreadLocal<E>();
- }
-
- public void execute(Command command) {
- this.getThreadLocalCommandExecutor().execute(command);
- }
-
- protected E getThreadLocalCommandExecutor() {
- E ce = this.threadLocal.get();
- return (ce != null) ? ce : this.defaultCommandExecutor;
- }
-
- /**
- * Set the current thread's command executor to the specified value.
- */
- public void set(E commandExecutor) {
- this.threadLocal.set(commandExecutor);
- }
-
- /**
- * Return the string representation of the current thread's command
- * executor.
- */
- @Override
- public String toString() {
- return '[' + this.getThreadLocalCommandExecutor().toString() + ']';
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousCommandExecutor.java
deleted file mode 100644
index b07ed385c6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousCommandExecutor.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import java.util.concurrent.ThreadFactory;
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.SimpleThreadFactory;
-
-/**
- * @see AbstractAsynchronousCommandExecutor
- */
-public class AsynchronousCommandExecutor
- extends AbstractAsynchronousCommandExecutor<StatefulCommandExecutor>
-{
- /**
- * Construct an asynchronous command executor.
- * Use simple JDK thread(s) for the command execution thread(s).
- * Allow the command execution thread(s) to be assigned JDK-generated names.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousCommandExecutor(ExceptionHandler exceptionHandler) {
- this(null, exceptionHandler);
- }
-
- /**
- * Construct an asynchronous command executor.
- * Use simple JDK thread(s) for the command execution thread(s).
- * Assign the command execution thread(s) the specified name.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousCommandExecutor(String threadName, ExceptionHandler exceptionHandler) {
- this(new SimpleStatefulCommandExecutor(CommandExecutor.Default.instance()), SimpleThreadFactory.instance(), threadName, exceptionHandler);
- }
-
- /**
- * Construct an asynchronous command executor.
- * Delegate command execution to the specified command executor.
- * Use the specified thread factory to construct the command execution
- * thread(s) and assign them the specified name.
- * Any exceptions thrown by a command will be handled by the
- * specified exception handler.
- */
- public AsynchronousCommandExecutor(StatefulCommandExecutor commandExecutor, ThreadFactory threadFactory, String threadName, ExceptionHandler exceptionHandler) {
- super(commandExecutor, threadFactory, threadName, exceptionHandler);
- }
-
- /**
- * Construct an asynchronous command executor.
- * Delegate command execution to the specified command executor.
- * Use the specified thread factory to construct the command execution
- * thread(s) and assign them the specified name.
- * Any exceptions thrown by a command will be handled by the
- * specified exception handler.
- */
- public AsynchronousCommandExecutor(Config config) {
- super(config);
- }
-
-
- // ********** config **********
-
- /**
- * Config useful for instantiating an {@link AsynchronousCommandExecutor}.
- */
- public interface Config
- extends AbstractAsynchronousCommandExecutor.Config<StatefulCommandExecutor>
- {
- // generic
- }
-
- /**
- * Config useful for instantiating an {@link AsynchronousCommandExecutor}.
- */
- public static class SimpleConfig
- extends AbstractAsynchronousCommandExecutor.SimpleConfig<StatefulCommandExecutor>
- implements Config
- {
- public SimpleConfig() {
- super();
- }
- public SimpleConfig(StatefulCommandExecutor commandExecutor, ThreadFactory threadFactory, String threadName, ExceptionHandler exceptionHandler) {
- super(commandExecutor, threadFactory, threadName, exceptionHandler);
- }
- @Override
- protected StatefulCommandExecutor buildDefaultCommandExecutor() {
- return new SimpleStatefulCommandExecutor();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousExtendedCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousExtendedCommandExecutor.java
deleted file mode 100644
index 700ac65783..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousExtendedCommandExecutor.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import java.util.concurrent.ThreadFactory;
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.command.StatefulExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.SimpleThreadFactory;
-
-/**
- * {@link Command}s executed via calls to {@link #waitToExecute(Command)} will
- * execute on the <em>current</em> thread <em>after</em> all the commands
- * already dispatched to the other thread have executed.
- *
- * @see AbstractAsynchronousCommandExecutor
- */
-public class AsynchronousExtendedCommandExecutor
- extends AbstractAsynchronousCommandExecutor<StatefulExtendedCommandExecutor>
- implements StatefulExtendedCommandExecutor
-{
- /**
- * Construct an asynchronous command executor.
- * Use simple JDK thread(s) for the command execution thread(s).
- * Allow the command execution thread(s) to be assigned JDK-generated names.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousExtendedCommandExecutor(ExceptionHandler exceptionHandler) {
- this(null, exceptionHandler);
- }
-
- /**
- * Construct an asynchronous command executor.
- * Use simple JDK thread(s) for the command execution thread(s).
- * Assign the command execution thread(s) the specified name.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousExtendedCommandExecutor(String threadName, ExceptionHandler exceptionHandler) {
- this(new SimpleStatefulExtendedCommandExecutor(ExtendedCommandExecutor.Default.instance()), SimpleThreadFactory.instance(), threadName, exceptionHandler);
- }
-
- /**
- * Construct an asynchronous command executor.
- * Delegate command execution to the specified command executor.
- * Use the specified thread factory to construct the command execution
- * thread(s) and assign them the specified name.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousExtendedCommandExecutor(StatefulExtendedCommandExecutor commandExecutor, ThreadFactory threadFactory, String threadName, ExceptionHandler exceptionHandler) {
- super(commandExecutor, threadFactory, threadName, exceptionHandler);
- }
-
- /**
- * Construct an asynchronous command executor.
- * Delegate command execution to the specified command executor.
- * Use the specified thread factory to construct the command execution
- * thread(s) and assign them the specified name.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousExtendedCommandExecutor(Config config) {
- super(config);
- }
-
-
- /**
- * Wait until all the commands currently on the queue have been executed,
- * then execute the specified command. Suspend the command-executing thread
- * while we execute the specified command.
- */
- public void waitToExecute(Command command) throws InterruptedException {
- SynchronizingCommand syncCommand = new SynchronizingCommand();
-
- this.execute(syncCommand); // dispatch the sync command to the other thread
-
- try {
- syncCommand.waitForExecution();
- this.commandExecutor.waitToExecute(command);
- } finally {
- syncCommand.release();
- }
- }
-
- /**
- * Wait until all the commands currently on the queue have been executed,
- * then execute the specified command. Suspend the command-executing thread
- * while we execute the specified command.
- */
- public boolean waitToExecute(Command command, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitToExecute(command);
- return true;
- }
-
- long stop = System.currentTimeMillis() + timeout;
- SynchronizingCommand syncCommand = new SynchronizingCommand();
-
- this.execute(syncCommand); // dispatch the sync command to the other thread
-
- try {
- if (syncCommand.waitForExecution(timeout)) {
- // adjust the time
- timeout = stop - System.currentTimeMillis();
- return (timeout > 0) && this.commandExecutor.waitToExecute(command, timeout);
- }
- return false;
- } finally {
- syncCommand.release();
- }
- }
-
-
- // ********** config **********
-
- /**
- * Config useful for instantiating an {@link AsynchronousExtendedCommandExecutor}.
- */
- public interface Config
- extends AbstractAsynchronousCommandExecutor.Config<StatefulExtendedCommandExecutor>
- {
- // generic
- }
-
- /**
- * Config useful for instantiating an {@link AsynchronousExtendedCommandExecutor}.
- */
- public static class SimpleConfig
- extends AbstractAsynchronousCommandExecutor.SimpleConfig<StatefulExtendedCommandExecutor>
- implements Config
- {
- public SimpleConfig() {
- super();
- }
- public SimpleConfig(StatefulExtendedCommandExecutor commandExecutor, ThreadFactory threadFactory, String threadName, ExceptionHandler exceptionHandler) {
- super(commandExecutor, threadFactory, threadName, exceptionHandler);
- }
- @Override
- protected StatefulExtendedCommandExecutor buildDefaultCommandExecutor() {
- return new SimpleStatefulExtendedCommandExecutor();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousNotifyingRepeatingCommandWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousNotifyingRepeatingCommandWrapper.java
deleted file mode 100644
index 98e973bd5a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousNotifyingRepeatingCommandWrapper.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import java.util.concurrent.ThreadFactory;
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.NotifyingRepeatingCommand;
-import org.eclipse.jpt.common.utility.internal.ConsumerThreadCoordinator;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-
-/**
- * Extend the asynchronous repeating command to notify listeners
- * when an execution "cycle" is complete; i.e. the command has,
- * for the moment, handled every outstanding "execute" request and quiesced.
- * This notification is <em>not</em> guaranteed to occur with <em>every</em>
- * execution "cycle"; since other, unrelated, executions can be
- * triggered concurrently.
- */
-public class AsynchronousNotifyingRepeatingCommandWrapper
- extends AsynchronousRepeatingCommandWrapper
- implements NotifyingRepeatingCommand
-{
- private final ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
-
- /**
- * This handles any exceptions thrown by the listeners.
- */
- private final ExceptionHandler exceptionHandler;
-
-
- // ********** construction **********
-
- /**
- * Construct an asynchronous notifying repeating command that executes the
- * specified command.
- * Allow the execution thread(s) to be assigned JDK-generated names.
- */
- public AsynchronousNotifyingRepeatingCommandWrapper(Command command, ExceptionHandler exceptionHandler) {
- super(command, exceptionHandler);
- this.exceptionHandler = exceptionHandler;
- }
-
- /**
- * Construct an asynchronous notifying repeating command that executes the
- * specified command.
- * Assign the synchronization thread(s) the specified name.
- */
- public AsynchronousNotifyingRepeatingCommandWrapper(Command command, String threadName, ExceptionHandler exceptionHandler) {
- super(command, threadName, exceptionHandler);
- this.exceptionHandler = exceptionHandler;
- }
-
- /**
- * Construct an asynchronous repeating command that executes the
- * specified command.
- * Use the specified thread factory to construct the synchronization thread(s).
- * Assign the synchronization thread(s) the specified name.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousNotifyingRepeatingCommandWrapper(Config config) {
- super(config);
- this.exceptionHandler = config.getExceptionHandler();
- }
-
- /**
- * Construct an asynchronous notifying repeating command that executes the
- * specified command.
- * Use the specified thread factory to construct the synchronization thread(s).
- * Assign the synchronization thread(s) the specified name.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousNotifyingRepeatingCommandWrapper(Command command, ThreadFactory threadFactory, String threadName, ExceptionHandler exceptionHandler) {
- super(command, threadFactory, threadName, exceptionHandler);
- this.exceptionHandler = exceptionHandler;
- }
-
- /**
- * Build a consumer that will let us know when the execution thread has
- * quiesced.
- */
- @Override
- ConsumerThreadCoordinator.Consumer buildConsumer(Command command) {
- return new NotifyingConsumer(command);
- }
-
-
- // ********** NotifyingRepeatingCommand implementation **********
-
- public void addListener(Listener listener) {
- this.listenerList.add(listener);
- }
-
- public void removeListener(Listener listener) {
- this.listenerList.remove(listener);
- }
-
- /**
- * Notify our listeners.
- */
- /* CU private */ void executionQuiesced() {
- for (Listener listener : this.listenerList.getListeners()) {
- try {
- listener.executionQuiesced(this);
- } catch (RuntimeException ex) {
- // we could let the ConsumerThreadCoordinator handle these;
- // but then the loop would be stopped with the first exception...
- this.exceptionHandler.handleException(ex);
- }
- }
- }
-
-
- // ********** consumer **********
-
- /**
- * Extend {@link AsynchronousRepeatingCommandWrapper.Consumer}
- * to notify the repeating command when execution has quiesced
- * (i.e. the command has finished executing and there are no further
- * requests for execution).
- * Because execution is asynchronous, no other thread will be able to
- * initiate another execution until the command's listeners have been
- * notified. Note also, the command's listeners can, themselves,
- * trigger another execution (by directly or indirectly calling
- * {@link org.eclipse.jpt.common.utility.command.Command#execute()});
- * but this execution will not occur until <em>after</em> all the
- * listeners have been notified.
- */
- /* CU private */ class NotifyingConsumer
- extends Consumer
- {
- NotifyingConsumer(Command command) {
- super(command);
- }
-
- @Override
- public void consume() {
- super.consume();
- // hmmm - we will notify listeners even when we our thread is "interrupted";
- // that seems ok... ~bjv
- if (AsynchronousNotifyingRepeatingCommandWrapper.this.executeFlag.isFalse()) {
- AsynchronousNotifyingRepeatingCommandWrapper.this.executionQuiesced();
- }
- }
-
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousRepeatingCommandWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousRepeatingCommandWrapper.java
deleted file mode 100644
index 7baa423bb8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/AsynchronousRepeatingCommandWrapper.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import java.util.ArrayList;
-import java.util.concurrent.ThreadFactory;
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.RepeatingCommand;
-import org.eclipse.jpt.common.utility.internal.ConsumerThreadCoordinator;
-import org.eclipse.jpt.common.utility.internal.SimpleThreadFactory;
-import org.eclipse.jpt.common.utility.internal.StackTrace;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean;
-
-/**
- * This repeating command will perform a client-supplied command in a separate
- * thread, allowing calls to {@link org.eclipse.jpt.common.utility.command.Command#execute()}
- * to return immediately.
- */
-public class AsynchronousRepeatingCommandWrapper
- implements RepeatingCommand
-{
- /**
- * This flag is shared with the execution/consumer thread. Setting it to
- * <code>true</code> will trigger the execution to begin or, if the
- * execution is currently under way, to execute again, once the current
- * execution is complete.
- */
- final SynchronizedBoolean executeFlag = new SynchronizedBoolean(false);
-
- /**
- * Most of the thread-related behavior is delegated to this coordinator.
- */
- private final ConsumerThreadCoordinator consumerThreadCoordinator;
-
- /**
- * List of stack traces for each (repeating) invocation of the command,
- * starting with the initial invocation. The list is cleared with each
- * initial invocation of the command.
- */
- private final ArrayList<StackTrace> stackTraces = DEBUG ? new ArrayList<StackTrace>() : null;
- // see AsynchronousRepeatingCommandWrapperTests.testDEBUG()
- private static final boolean DEBUG = false;
-
-
- // ********** construction **********
-
- /**
- * Construct an asynchronous repeating command that executes the specified
- * command.
- * Use simple JDK thread(s) for the execution thread(s).
- * Allow the execution thread(s) to be assigned JDK-generated names.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousRepeatingCommandWrapper(Command command, ExceptionHandler exceptionHandler) {
- this(command, null, null, exceptionHandler);
- }
-
- /**
- * Construct an asynchronous repeating command that executes the specified
- * command. Assign the execution thread(s) the specified name.
- * Use simple JDK thread(s) for the execution thread(s).
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousRepeatingCommandWrapper(Command command, String threadName, ExceptionHandler exceptionHandler) {
- this(command, null, threadName, exceptionHandler);
- }
-
- /**
- * Construct an asynchronous repeating command that executes the specified
- * command.
- * Use the specified thread factory to construct the synchronization thread(s).
- * Assign the synchronization thread(s) the specified name.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousRepeatingCommandWrapper(Config config) {
- this(config.getCommand(), config.getThreadFactory(), config.getThreadName(), config.getExceptionHandler());
- }
-
- /**
- * Construct an asynchronous repeating command that executes the specified
- * command.
- * Use the specified thread factory to construct the synchronization thread(s).
- * Assign the synchronization thread(s) the specified name.
- * Any exceptions thrown by the consumer will be handled by the
- * specified exception handler.
- */
- public AsynchronousRepeatingCommandWrapper(Command command, ThreadFactory threadFactory, String threadName, ExceptionHandler exceptionHandler) {
- super();
- this.consumerThreadCoordinator = new ConsumerThreadCoordinator(this.buildConsumer(command), threadFactory, threadName, exceptionHandler);
- }
-
- ConsumerThreadCoordinator.Consumer buildConsumer(Command command) {
- return new Consumer(command);
- }
-
-
- // ********** RepeatingCommand implementation **********
-
- /**
- * Build and start the execution thread, but postpone the first
- * execution until requested, i.e. via a call to {@link #execute()}.
- * <p>
- * Note: We don't clear the "execute" flag here; so if the flag has
- * been set to <code>true</code> <em>before</em> getting here, the first
- * execution will start promptly (albeit, asynchronously).
- * The "execute" flag will be set if:<ul>
- * <li>{@link #execute()} was called after the repeating command was
- * constructed but before {@link #start()} was called; or
- * <li>{@link #execute()} was called after {@link #stop()} was called
- * but before {@link #start()} was called (to restart the repeating
- * command); or
- * <li>{@link #stop()} was called when there was an outstanding request
- * for an execution (i.e. the "execute" flag was <code>true</code> at
- * the time {@link #stop()} was called)
- * </ul>
- *
- * @exception IllegalStateException if the command has already been started
- */
- public void start() {
- this.consumerThreadCoordinator.start();
- }
-
- /**
- * Set the "execute" flag so the execution thread will either<ul>
- * <li>if the thread is quiesced, start an execution immediately, or
- * <li>if the thread is currently executing, execute again,
- * once the current execution is complete
- * </ul>
- */
- public void execute() {
- synchronized (this.executeFlag) {
- if (DEBUG) {
- if (this.executeFlag.isFalse()) {
- this.stackTraces.clear();
- }
- this.stackTraces.add(new StackTrace());
- }
- this.executeFlag.setTrue();
- }
- }
-
- /**
- * Interrupt the execution thread so that it stops executing at the
- * end of the current execution. Suspend the current thread until
- * the execution thread is finished executing. If any uncaught
- * exceptions were thrown while the execution thread was executing,
- * wrap them in a composite exception and throw the composite exception.
- *
- * @exception IllegalStateException if the coordinator has not been started
- */
- public void stop() throws InterruptedException {
- this.consumerThreadCoordinator.stop();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.consumerThreadCoordinator);
- }
-
-
- // ********** consumer **********
-
- /**
- * This implementation of
- * {@link org.eclipse.jpt.common.utility.internal.ConsumerThreadCoordinator.Consumer}
- * will execute the client-supplied command.
- * It will wait until the shared "execute" flag is set to execute the
- * command. Once the comand is executed, the thread will quiesce until
- * the flag is set again. If the flag was set during the execution of the
- * command (either recursively by the command itself or by another thread),
- * the command will be re-executed immediately. Stop the thread by calling
- * {@link Thread#interrupt()}.
- */
- class Consumer
- implements ConsumerThreadCoordinator.Consumer
- {
- /**
- * The client-supplied command that executes on the
- * execution/consumer thread.
- */
- private final Command command;
-
- Consumer(Command command) {
- super();
- if (command == null) {
- throw new NullPointerException();
- }
- this.command = command;
- }
-
- /**
- * Wait until the "execute" flag is set,
- * then clear it and allow the command to execute.
- */
- public void waitForProducer() throws InterruptedException {
- AsynchronousRepeatingCommandWrapper.this.executeFlag.waitToSetFalse();
- }
-
- /**
- * Execute the client-supplied command.
- */
- public void consume() {
- this.command.execute();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.command);
- }
- }
-
-
- // ********** config **********
-
- /**
- * Config useful for instantiating an {@link AbstractAsynchronousCommandExecutor}.
- */
- public interface Config {
- Command getCommand();
- ThreadFactory getThreadFactory();
- String getThreadName();
- ExceptionHandler getExceptionHandler();
- }
-
- /**
- * Config useful for instantiating an {@link AbstractAsynchronousCommandExecutor}.
- */
- protected abstract static class SimpleConfig
- implements Config
- {
- private volatile Command command;
- private volatile ThreadFactory threadFactory;
- private volatile String threadName;
- private volatile ExceptionHandler exceptionHandler;
-
- protected SimpleConfig() {
- super();
- this.command = this.buildDefaultCommand();
- this.threadFactory = this.buildDefaultThreadFactory();
- this.threadName = this.buildDefaultThreadName();
- this.exceptionHandler = this.buildDefaultExceptionHandler();
- }
-
- protected SimpleConfig(Command command, ThreadFactory threadFactory, String threadName, ExceptionHandler exceptionHandler) {
- super();
- this.command = command;
- this.threadFactory = threadFactory;
- this.threadName = threadName;
- this.exceptionHandler = exceptionHandler;
- }
-
- public void setCommand(Command command) {
- this.command = command;
- }
- public Command getCommand() {
- return this.command;
- }
- protected abstract Command buildDefaultCommand();
-
- public void setThreadFactory(ThreadFactory threadFactory) {
- this.threadFactory = threadFactory;
- }
- public ThreadFactory getThreadFactory() {
- return this.threadFactory;
- }
- protected ThreadFactory buildDefaultThreadFactory() {
- return SimpleThreadFactory.instance();
- }
-
- public void setThreadName(String threadName) {
- this.threadName = threadName;
- }
- public String getThreadName() {
- return this.threadName;
- }
- protected String buildDefaultThreadName() {
- return null;
- }
-
- public void setExceptionHandler(ExceptionHandler exceptionHandler) {
- this.exceptionHandler = exceptionHandler;
- }
- public ExceptionHandler getExceptionHandler() {
- return this.exceptionHandler;
- }
- protected ExceptionHandler buildDefaultExceptionHandler() {
- return ExceptionHandler.Runtime.instance();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/CommandRunnable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/CommandRunnable.java
deleted file mode 100644
index e5abcaaeca..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/CommandRunnable.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-
-/**
- * Wrap a {@link Command} so it can be used as a {@link Runnable}.
- */
-public class CommandRunnable
- implements Runnable
-{
- protected final Command command;
-
- public CommandRunnable(Command command) {
- super();
- if (command == null) {
- throw new NullPointerException();
- }
- this.command = command;
- }
-
- public void run() {
- this.command.execute();
- }
-
- @Override
- public String toString() {
- return "Runnable[" + this.command +']'; //$NON-NLS-1$
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/CompositeCommand.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/CompositeCommand.java
deleted file mode 100644
index c1fa124415..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/CompositeCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-
-/**
- * <code>CompositeCommand</code> provides support for treating a collection of
- * {@link Command}s as a single command.
- */
-public class CompositeCommand
- implements Command
-{
- private final Iterable<Command> commands;
-
- public CompositeCommand(Command... commands) {
- this(new ArrayIterable<Command>(commands));
- }
-
- public CompositeCommand(Iterable<Command> commands) {
- super();
- if (commands == null) {
- throw new NullPointerException();
- }
- this.commands = commands;
- }
-
- public void execute() {
- for (Command command : this.commands) {
- command.execute();
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.commands);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/NotifyingRepeatingCommandWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/NotifyingRepeatingCommandWrapper.java
deleted file mode 100644
index 03bb6ebb61..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/NotifyingRepeatingCommandWrapper.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.NotifyingRepeatingCommand;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-
-/**
- * <strong>NB:</strong> If another execution cycle is initiated while we are
- * notifying the command's listeners (i.e. the {@link #state} is set
- * to "repeat"), the new
- * execution will not start until all the listeners are notified.
- * <p>
- * <strong>NB2:</strong> The command's listeners can, themselves,
- * trigger another execution (by directly or indirectly calling
- * {@link #execute()});
- * but, again, this execution will not occur until <em>after</em> all the
- * listeners have been notified.
- * <p>
- * <strong>NB3:</strong> Along with any exceptions thrown by the wrapped
- * command, any exceptions thrown by the command's listeners will
- * be passed to the {@link #exceptionHandler exception handler}.
- */
-public class NotifyingRepeatingCommandWrapper
- extends RepeatingCommandWrapper
- implements NotifyingRepeatingCommand
-{
- private final ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
-
-
- // ********** construction **********
-
- /**
- * Construct a notifying repeating command wrapper that executes the
- * specified command. Any exceptions thrown by the command or listener
- * will be handled by the specified exception handler.
- */
- public NotifyingRepeatingCommandWrapper(Command command, ExceptionHandler exceptionHandler) {
- super(command, exceptionHandler);
- }
-
- /**
- * Construct a notifying repeating command wrapper that executes the specified
- * command and uses the specified command executor to execute the wrapped
- * command whenever it is not already executing.
- * Any exceptions thrown by the command or listener will be handled by the
- * specified exception handler.
- */
- public NotifyingRepeatingCommandWrapper(Command command, CommandExecutor startCommandExecutor, ExceptionHandler exceptionHandler) {
- super(command, startCommandExecutor, exceptionHandler);
- }
-
-
- // ********** listeners **********
-
- public void addListener(Listener listener) {
- this.listenerList.add(listener);
- }
-
- public void removeListener(Listener listener) {
- this.listenerList.remove(listener);
- }
-
-
- // ********** override **********
-
- @Override
- /* private protected */ void executeCommand() {
- super.executeCommand();
- if (this.state.isQuiesced()) {
- // hmmm - we will notify listeners even when we are "stopped"; that seems OK...
- this.executionQuiesced();
- }
- }
-
- /**
- * Notify our listeners.
- */
- private void executionQuiesced() {
- for (Listener listener : this.listenerList.getListeners()) {
- try {
- listener.executionQuiesced(this);
- } catch (Throwable ex) {
- this.exceptionHandler.handleException(ex);
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/QueueingCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/QueueingCommandExecutor.java
deleted file mode 100644
index 3898cbd44d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/QueueingCommandExecutor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
-
-/**
- * @see AbstractQueueingCommandExecutor
- */
-public class QueueingCommandExecutor
- extends AbstractQueueingCommandExecutor<StatefulCommandExecutor>
-{
- public QueueingCommandExecutor() {
- this(CommandExecutor.Default.instance());
- }
-
- public QueueingCommandExecutor(CommandExecutor commandExecutor) {
- this(new SimpleStatefulCommandExecutor(commandExecutor));
- }
-
- public QueueingCommandExecutor(StatefulCommandExecutor commandExecutor) {
- super(commandExecutor);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/QueueingExtendedCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/QueueingExtendedCommandExecutor.java
deleted file mode 100644
index b030ed4175..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/QueueingExtendedCommandExecutor.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.command.StatefulExtendedCommandExecutor;
-
-/**
- * Calls to {@link #waitToExecute(Command)} will suspend the current thread
- * until the command executor is {@link #start() started} and any previously-
- * dispatched commands have executed.
- *
- * @see AbstractQueueingCommandExecutor
- */
-public class QueueingExtendedCommandExecutor
- extends AbstractQueueingCommandExecutor<StatefulExtendedCommandExecutor>
- implements StatefulExtendedCommandExecutor
-{
- public QueueingExtendedCommandExecutor() {
- this(ExtendedCommandExecutor.Default.instance());
- }
-
- public QueueingExtendedCommandExecutor(ExtendedCommandExecutor commandExecutor) {
- this(new SimpleStatefulExtendedCommandExecutor(commandExecutor));
- }
-
- public QueueingExtendedCommandExecutor(StatefulExtendedCommandExecutor commandExecutor) {
- super(commandExecutor);
- }
-
- /**
- * Suspend the current thread until the command executor is
- * {@link #start() started}.
- */
- public void waitToExecute(Command command) throws InterruptedException {
- SynchronizingCommand syncCommand = new SynchronizingCommand();
-
- this.execute(syncCommand); // put the sync command on the queue and wait until it has executed
-
- try {
- syncCommand.waitForExecution();
- this.commandExecutor.waitToExecute(command);
- } finally {
- syncCommand.release();
- }
- }
-
- /**
- * Wait until all the commands currently on the queue have been executed,
- * then execute the specified command. Suspend the command-executing thread
- * while we execute the specified command.
- */
- public boolean waitToExecute(Command command, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitToExecute(command);
- return true;
- }
-
- long stop = System.currentTimeMillis() + timeout;
- SynchronizingCommand syncCommand = new SynchronizingCommand();
-
- this.execute(syncCommand); // dispatch the sync command to the other thread
-
- try {
- if (syncCommand.waitForExecution(timeout)) {
- // adjust the time
- timeout = stop - System.currentTimeMillis();
- return (timeout > 0) && this.commandExecutor.waitToExecute(command, timeout);
- }
- return false;
- } finally {
- syncCommand.release();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandState.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandState.java
deleted file mode 100644
index 20a7463b0b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandState.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.SynchronizedObject;
-
-/**
- * Provide the state machine to support minimal repeat command executions.
- */
-public class RepeatingCommandState {
- /**
- * The current state.
- */
- private final SynchronizedObject<State> state;
-
- /**
- * The initial {@link #state} is {@link #STOPPED}.
- * Clients must call {@link #start()} before the command can be
- * executed.
- */
- private enum State {
- STOPPED,
- READY,
- PRE_EXECUTION,
- EXECUTING,
- REPEAT,
- STOPPING
- }
-
-
- // ********** construction **********
-
- /**
- * Construct a repeating command state.
- */
- public RepeatingCommandState() {
- super();
- // use the command wrapper as the mutex so it is freed up by the wait in #stop()
- this.state = new SynchronizedObject<State>(State.STOPPED, this);
- }
-
-
- /**
- * Set the {@link #state} to {@link State#READY READY}.
- * @exception IllegalStateException if the command wrapper is not
- * {@link State#STOPPED STOPPED}.
- */
- public synchronized void start() {
- switch (this.state.getValue()) {
- case STOPPED:
- this.state.setValue(State.READY);
- break;
- case READY:
- case PRE_EXECUTION:
- case EXECUTING:
- case REPEAT:
- case STOPPING:
- throw this.buildISE();
- }
- }
-
- /**
- * A client has requested an execution.
- * Return whether we are ready to begin a new execution "cycle".
- * If an execution is already under way, return <code>false</code>;
- * but set the {@link #state} to {@link State#REPEAT REPEAT}
- * so another execution will occur once the current
- * execution is complete.
- * <p>
- * <strong>NB:</strong> This method has possible side-effects:
- * The value of {@link #state} may be changed.
- */
- public synchronized boolean isReadyToStartExecutionCycle() {
- switch (this.state.getValue()) {
- case STOPPED:
- // execution is not allowed
- return false;
- case READY:
- // start a new execution, possibly asynchronously
- this.state.setValue(State.PRE_EXECUTION);
- return true;
- case PRE_EXECUTION:
- // no need to set 'state' to PRE_EXECUTION again,
- // the command has not yet begun executing
- return false;
- case EXECUTING:
- // set 'state' to REPEAT so a new execution will occur once the current one is finished
- this.state.setValue(State.REPEAT);
- return false;
- case REPEAT:
- // no need to set 'state' to REPEAT again
- return false;
- case STOPPING:
- // no further executions are allowed
- return false;
- }
- throw this.buildISE();
- }
-
- /**
- * An execution "cycle" is ready to begin.
- * Make sure a call to {@link #stop()} did not slip in between the
- * dispatching of the initial wrapped command execution (when
- * {@link #isReadyToStartExecutionCycle()} returns <code>true</code>) and the
- * actual execution of the wrapped command.
- * This can happen if the wrapped command was dispatched asynchronously.
- * <p>
- * This method should be called from the actual execution method, before it
- * starts looping.
- */
- public synchronized boolean wasStoppedBeforeFirstExecutionCouldStart() {
- switch (this.state.getValue()) {
- case STOPPED:
- // a call to stop() slipped in before the command could start
- // executing, probably because it was dispatched asynchronously
- // by 'startCommandExecutor' (e.g. in a job)
- return true;
- case PRE_EXECUTION:
- this.state.setValue(State.EXECUTING);
- return false;
- case READY:
- case EXECUTING:
- case REPEAT:
- case STOPPING:
- throw this.buildISE();
- }
- throw this.buildISE();
- }
-
- /**
- * The current execution has finished.
- * Return whether we should begin another execution because a call to
- * execute occurred <em>during</em> the just-completed execution.
- */
- public synchronized boolean isRepeat() {
- switch (this.state.getValue()) {
- case STOPPED:
- case READY:
- case PRE_EXECUTION:
- throw this.buildISE();
- case EXECUTING:
- // execution has finished and there are no outstanding requests for another; return to READY
- this.state.setValue(State.READY);
- return false;
- case REPEAT:
- // set 'state' back to EXECUTING and begin another execution
- this.state.setValue(State.EXECUTING);
- return true;
- case STOPPING:
- // a client initiated a "stop" during the previous execution;
- // mark the "stop" complete and perform no more executions
- this.state.setValue(State.STOPPED);
- return false;
- }
- throw this.buildISE();
- }
-
- /**
- * Return whether the execution "cycle" is "quiesced" (i.e. there are no
- * outstanding execution requests).
- */
- public boolean isQuiesced() {
- return this.state.getValue() != State.REPEAT;
- }
-
- /**
- * Set {@link #state} so no further executions occur.
- * @exception IllegalStateException if the command wrapper is already
- * {@link State#STOPPED STOPPED} or {@link State#STOPPING STOPPING}.
- */
- public synchronized void stop() throws InterruptedException {
- switch (this.state.getValue()) {
- case READY:
- case PRE_EXECUTION:
- // simply set 'state' to STOPPED and return
- this.state.setValue(State.STOPPED);
- break;
- case EXECUTING:
- case REPEAT:
- // set 'state' to STOPPING and wait until the current execution has finished
- this.state.setValue(State.STOPPING);
- this.waitUntilStopped();
- break;
- case STOPPED:
- case STOPPING:
- throw this.buildISE();
- }
- }
-
- /**
- * This wait will free up the command wrapper's synchronized methods
- * (since the command wrapper is the mutex for {@link #state}).
- * <p>
- * If the thread that called {@link #stop()} is interrupted while waiting
- * for the current command to finish executing on another thread,
- * {@link #state} will still be {@link State#STOPPING STOPPING}, so the loop
- * begun by the command wrapper will still stop and set {@link #state} to
- * {@link State#STOPPED STOPPED}, we just won't wait around for it....
- */
- private void waitUntilStopped() throws InterruptedException {
- this.state.waitUntilValueIs(State.STOPPED);
- }
-
- private IllegalStateException buildISE() {
- return new IllegalStateException("state: " + this.state); //$NON-NLS-1$
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.state);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandWrapper.java
deleted file mode 100644
index fcdb26b33b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RepeatingCommandWrapper.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import java.util.ArrayList;
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.command.RepeatingCommand;
-import org.eclipse.jpt.common.utility.internal.StackTrace;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Wrap a repeating {@link Command}.
- */
-public class RepeatingCommandWrapper
- implements RepeatingCommand
-{
- /**
- * The client-supplied command that performs the execution. It may
- * trigger further calls to {@link #execute()} (i.e. the <em>wrapped</em>
- * command's execution may recurse back to the client code that executes the
- * <em>wrapper</em> command).
- */
- /* CU private */ final Command command;
-
- /**
- * The command executed whenever the wrapped {@link #command} must be
- * executed and it is not already executing. If the wrapped {@link #command}
- * is already executing, it will simply be re-executed directly (once it has
- * completed its current execution), as opposed to calling the start
- * command.
- */
- private final Command startCommand;
-
- /**
- * The client-supplied command executor that provides the context for the
- * {@link #startCommand start command}. By default, the start command is
- * executed directly; but this executor provides a hook for executing the
- * {@link #startCommand start command} asynchronously; after which,
- * subsequent overlapping executions are executed synchronously.
- */
- private final CommandExecutor startCommandExecutor;
-
- /**
- * This handles the exceptions thrown by the <em>wrapped</em> command.
- */
- final ExceptionHandler exceptionHandler;
-
- /**
- * The command wrapper's state.
- */
- final RepeatingCommandState state;
-
- /**
- * List of stack traces for each (repeating) invocation of the command,
- * starting with the initial invocation. The list is cleared with each
- * initial invocation of the command.
- */
- private final ArrayList<StackTrace> stackTraces = DEBUG ? new ArrayList<StackTrace>() : null;
- // see RepeatingCommandWrapperTests.testDEBUG()
- private static final boolean DEBUG = false;
-
-
- // ********** construction **********
-
- /**
- * Construct a repeating command wrapper that executes the specified
- * command. Any exceptions thrown by the command will be handled by the
- * specified exception handler.
- */
- public RepeatingCommandWrapper(Command command, ExceptionHandler exceptionHandler) {
- this(command, CommandExecutor.Default.instance(), exceptionHandler);
- }
-
- /**
- * Construct a repeating command wrapper that executes the specified
- * command and uses the specified command executor to execute the wrapped
- * command whenever it is not already executing.
- * Any exceptions thrown by the command will be handled by the
- * specified exception handler.
- */
- public RepeatingCommandWrapper(Command command, CommandExecutor startCommandExecutor, ExceptionHandler exceptionHandler) {
- super();
- if ((command == null) || (startCommandExecutor == null) || (exceptionHandler == null)) {
- throw new NullPointerException();
- }
- this.command = command;
- this.startCommandExecutor = startCommandExecutor;
- this.startCommand = this.buildStartCommand();
- this.exceptionHandler = exceptionHandler;
- this.state = this.buildState();
- }
-
- private Command buildStartCommand() {
- return new StartCommand();
- }
-
- private RepeatingCommandState buildState() {
- return new RepeatingCommandState();
- }
-
-
- // ********** RepeatingCommand implementation **********
-
- public void start() {
- this.state.start();
- }
-
- /**
- * It is possible to come back here if the wrapped command recurses
- * to the client and triggers another execution.
- */
- public synchronized void execute() {
- if (this.state.isReadyToStartExecutionCycle()) {
- if (DEBUG) {
- this.stackTraces.clear();
- this.stackTraces.add(new StackTrace());
- }
- this.executeStartCommand();
- } else {
- if (DEBUG) {
- this.stackTraces.add(new StackTrace());
- }
- }
- }
-
- /* private protected */ void executeStartCommand() {
- this.startCommandExecutor.execute(this.startCommand);
- }
-
- public void stop() throws InterruptedException {
- this.state.stop();
- }
-
- /**
- * The start command.
- * @see #startCommandExecutor
- */
- /* CU private */ class StartCommand
- implements Command
- {
- public void execute() {
- RepeatingCommandWrapper.this.execute_();
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, RepeatingCommandWrapper.this.command);
- }
- }
-
- /**
- * This method will be called only once per execution cycle.
- * Any further calls to {@link #execute()} will
- * simply set the {@link #state} to "repeat",
- * causing the command to execute again.
- */
- /* CU private */ void execute_() {
- if (this.state.wasStoppedBeforeFirstExecutionCouldStart()) {
- return;
- }
-
- do {
- this.executeCommand();
- } while (this.state.isRepeat());
- }
-
- /**
- * Execute the client-supplied command. Do not allow any unhandled
- * exceptions to kill the wrapper. Pass to the exception handler.
- * @see NotifyingRepeatingCommandWrapper
- */
- /* private protected */ void executeCommand() {
- try {
- this.command.execute();
- } catch (Throwable ex) {
- this.exceptionHandler.handleException(ex);
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.command);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RunnableCommand.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RunnableCommand.java
deleted file mode 100644
index 1ce0c1c60a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/RunnableCommand.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-
-/**
- * Wrap a {@link Runnable} so it can be used as a {@link Command}.
- */
-public class RunnableCommand
- implements Command
-{
- protected final Runnable runnable;
-
- public RunnableCommand(Runnable runnable) {
- super();
- if (runnable == null) {
- throw new NullPointerException();
- }
- this.runnable = runnable;
- }
-
- public void execute() {
- this.runnable.run();
- }
-
- @Override
- public String toString() {
- return "Command[" + this.runnable +']'; //$NON-NLS-1$
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SafeCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SafeCommandExecutor.java
deleted file mode 100644
index 00233bc53b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SafeCommandExecutor.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-
-/**
- * @see AbstractSafeCommandExecutor
- */
-public class SafeCommandExecutor
- extends AbstractSafeCommandExecutor<CommandExecutor>
-{
- /**
- * <strong>NB:</strong> The default exception handler simply
- * <em>ignores</em> any and all exceptions.
- */
- public SafeCommandExecutor() {
- this(CommandExecutor.Default.instance());
- }
-
- /**
- * <strong>NB:</strong> The default exception handler simply
- * <em>ignores</em> any and all exceptions.
- */
- public SafeCommandExecutor(CommandExecutor commandExecutor) {
- super(commandExecutor);
- }
-
- public SafeCommandExecutor(ExceptionHandler exceptionHandler) {
- this(CommandExecutor.Default.instance(), exceptionHandler);
- }
-
- public SafeCommandExecutor(CommandExecutor commandExecutor, ExceptionHandler exceptionHandler) {
- super(commandExecutor, exceptionHandler);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SafeExtendedCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SafeExtendedCommandExecutor.java
deleted file mode 100644
index ecfdce4ccb..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SafeExtendedCommandExecutor.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-
-/**
- * @see AbstractSafeCommandExecutor
- */
-public class SafeExtendedCommandExecutor
- extends AbstractSafeCommandExecutor<ExtendedCommandExecutor>
- implements ExtendedCommandExecutor
-{
- /**
- * <strong>NB:</strong> The default exception handler simply
- * <em>ignores</em> any and all exceptions.
- */
- public SafeExtendedCommandExecutor() {
- this(ExtendedCommandExecutor.Default.instance());
- }
-
- /**
- * <strong>NB:</strong> The default exception handler simply
- * <em>ignores</em> any and all exceptions.
- */
- public SafeExtendedCommandExecutor(ExtendedCommandExecutor commandExecutor) {
- super(commandExecutor);
- }
-
- public SafeExtendedCommandExecutor(ExceptionHandler exceptionHandler) {
- this(ExtendedCommandExecutor.Default.instance(), exceptionHandler);
- }
-
- public SafeExtendedCommandExecutor(ExtendedCommandExecutor commandExecutor, ExceptionHandler exceptionHandler) {
- super(commandExecutor, exceptionHandler);
- }
-
- public void waitToExecute(Command command) throws InterruptedException {
- try {
- this.commandExecutor.waitToExecute(command);
- } catch (RuntimeException ex) {
- this.exceptionHandler.handleException(ex);
- }
- }
-
- public boolean waitToExecute(Command command, long timeout) throws InterruptedException {
- try {
- return this.commandExecutor.waitToExecute(command, timeout);
- } catch (RuntimeException ex) {
- this.exceptionHandler.handleException(ex);
- return true; // hmmm... seems like we get here only if the command executed
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SimpleStatefulCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SimpleStatefulCommandExecutor.java
deleted file mode 100644
index 1c95bd1ec6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SimpleStatefulCommandExecutor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
-
-/**
- * Straightforward implementation of {@link StatefulCommandExecutor}
- * that executes commands immediately by default. This executor can
- * also be used to adapt simple {@link CommandExecutor}s to the
- * {@link StatefulCommandExecutor} interface, providing support for
- * lifecycle state.
- */
-public class SimpleStatefulCommandExecutor
- extends AbstractStatefulCommandExecutor<CommandExecutor>
-{
- public SimpleStatefulCommandExecutor() {
- this(CommandExecutor.Default.instance());
- }
-
- public SimpleStatefulCommandExecutor(CommandExecutor commandExecutor) {
- super(commandExecutor);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SimpleStatefulExtendedCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SimpleStatefulExtendedCommandExecutor.java
deleted file mode 100644
index 88b20bd779..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SimpleStatefulExtendedCommandExecutor.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.command.StatefulExtendedCommandExecutor;
-
-/**
- * Straightforward implementation of {@link StatefulExtendedCommandExecutor}
- * that executes commands immediately by default. This executor can
- * also be used to adapt simple {@link CommandExecutor}s to the
- * {@link StatefulExtendedCommandExecutor} interface, providing support for
- * lifecycle state. Any calls to {@link #waitToExecute(Command)} suspend the
- * calling thread until the command executor is {@link #start() started}.
- */
-public class SimpleStatefulExtendedCommandExecutor
- extends AbstractStatefulCommandExecutor<ExtendedCommandExecutor>
- implements StatefulExtendedCommandExecutor
-{
- public SimpleStatefulExtendedCommandExecutor() {
- this(ExtendedCommandExecutor.Default.instance());
- }
-
- public SimpleStatefulExtendedCommandExecutor(ExtendedCommandExecutor commandExecutor) {
- super(commandExecutor);
- }
-
- /**
- * Suspend the current thread until the command executor is
- * {@link #start() started}.
- */
- public void waitToExecute(Command command) throws InterruptedException {
- this.active.waitUntilTrue();
- this.commandExecutor.waitToExecute(command);
- }
-
- /**
- * Suspend the current thread until the command executor is
- * {@link #start() started}.
- */
- public boolean waitToExecute(Command command, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitToExecute(command);
- return true;
- }
-
- long stop = System.currentTimeMillis() + timeout;
- if (this.active.waitUntilTrue(timeout)) {
- // adjust the time
- timeout = stop - System.currentTimeMillis();
- return (timeout > 0) && this.commandExecutor.waitToExecute(command, timeout);
- }
- return false;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SingleUseQueueingCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SingleUseQueueingCommandExecutor.java
deleted file mode 100644
index 5bd07e12f2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SingleUseQueueingCommandExecutor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
-
-/**
- * @see AbstractSingleUseQueueingCommandExecutor
- */
-public class SingleUseQueueingCommandExecutor
- extends AbstractSingleUseQueueingCommandExecutor<StatefulCommandExecutor>
-{
- public SingleUseQueueingCommandExecutor() {
- this(ExtendedCommandExecutor.Default.instance());
- }
-
- public SingleUseQueueingCommandExecutor(CommandExecutor commandExecutor) {
- this(new SimpleStatefulCommandExecutor(commandExecutor));
- }
-
- public SingleUseQueueingCommandExecutor(StatefulCommandExecutor commandExecutor) {
- super(commandExecutor);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SingleUseQueueingExtendedCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SingleUseQueueingExtendedCommandExecutor.java
deleted file mode 100644
index ab7b130b40..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SingleUseQueueingExtendedCommandExecutor.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.command.StatefulExtendedCommandExecutor;
-
-/**
- * Calls to {@link #waitToExecute(Command)} will suspend the current thread
- * until the command executor is {@link #start() started} and any previously-
- * dispatched commands have executed.
- * <p>
- * <strong>NB:</strong> Calls to {@link #waitToExecute(Command)} will suspend
- * the current thread <em>indefinitely</em> if the command executor is
- * {@link #stop() stopped}.
- *
- * @see AbstractSingleUseQueueingCommandExecutor
- */
-public class SingleUseQueueingExtendedCommandExecutor
- extends AbstractSingleUseQueueingCommandExecutor<StatefulExtendedCommandExecutor>
- implements StatefulExtendedCommandExecutor
-{
- public SingleUseQueueingExtendedCommandExecutor() {
- this(ExtendedCommandExecutor.Default.instance());
- }
-
- public SingleUseQueueingExtendedCommandExecutor(ExtendedCommandExecutor commandExecutor) {
- this(new SimpleStatefulExtendedCommandExecutor(commandExecutor));
- }
-
- public SingleUseQueueingExtendedCommandExecutor(StatefulExtendedCommandExecutor commandExecutor) {
- super(commandExecutor);
- }
-
- public void waitToExecute(Command command) throws InterruptedException {
- SynchronizingCommand syncCommand = new SynchronizingCommand();
-
- this.execute(syncCommand); // put the sync command on the queue and wait until it has executed
-
- try {
- syncCommand.waitForExecution();
- this.commandExecutor.waitToExecute(command);
- } finally {
- syncCommand.release();
- }
- }
-
- public boolean waitToExecute(Command command, long timeout) throws InterruptedException {
- if (timeout == 0L) {
- this.waitToExecute(command);
- return true;
- }
-
- long stop = System.currentTimeMillis() + timeout;
- SynchronizingCommand syncCommand = new SynchronizingCommand();
-
- this.execute(syncCommand); // dispatch the sync command to the other thread
-
- try {
- if (syncCommand.waitForExecution(timeout)) {
- // adjust the time
- timeout = stop - System.currentTimeMillis();
- return (timeout > 0) && this.commandExecutor.waitToExecute(command, timeout);
- }
- return false;
- } finally {
- syncCommand.release();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SynchronizingCommand.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SynchronizingCommand.java
deleted file mode 100644
index d6300d8e71..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/SynchronizingCommand.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean;
-
-/**
- * A <em>synchronizing</em> command can be used to coordinate the execution of
- * the {@link Thread thread} that <em>creates</em> the <em>synchronizing</em>
- * command (Thread A, the "primary" thread) with another {@link Thread thread}
- * that <em>executes</em> the <em>synchronizing</em> command (Thread B, the
- * "secondary" thread).
- * <p>
- * Typically, Thread A dispatches {@Command commands} to a
- * {@link org.eclipse.jpt.common.utility.command.CommandExecutor command
- * executor}) that executes the {@Command commands} asynchronously on Thread B.
- * A <em>synchronizing</em> command allows Thread A to
- * dispatch a <em>synchronizing</em> command to Thread B and suspend until
- * the {@link #command} held by the <em>synchronizing</em> command
- * has executed (on <em>Thread B</em>). (This can be useful when Thread B is the
- * UI {@link Thread thread} and the {@link #command} must modify a UI widget.)
- * Once the {@link #command} held by the <em>synchronizing</em> command has
- * executed, Thread B suspends and notifies Thread A to proceed. Thread A can
- * optionally execute yet another {@Command command} (on <em>Thread A</em>).
- * Once Thread A has executed its command, it must notify Thread B that it may
- * proceed (now independently of Thread A).
- * <p>
- * <strong>Timeouts:</strong> If Thread A specifies a time-limit
- * ({@link #waitForExecution(long)}) for its suspension, and a timeout occurs
- * (i.e. it takes too long for the <em>synchronizing</em> command to begin
- * executing or its {@link #command} takes too long to execute),
- * the {@link #command} held by the <em>synchronizing</em> command will
- * <em>still be executed</em>; but Thread A will not be notified when the
- * execution is complete. [It seems reasonable that the {@link #command} always
- * execute, since, if it is too long-running, it will execute anyway....]
- * <p>
- * <strong>Synchronous Execution:</strong> If the <em>synchronizing</em> command
- * is <em>created</em> and <em>executed</em> on the same {@link Thread thread},
- * the assumption is Thread A and Thread B are the same {@link Thread thread}
- * and all {@Command commands} are executing synchronously (e.g. during testing
- * or "batch" executing).
- * In that situation, the <em>synchronizing</em> command will <em>not</em>
- * suspend its {@link Thread thread}.
- */
-public class SynchronizingCommand
- implements Command
-{
- private final Thread thread = Thread.currentThread(); // Thread A
- private final SynchronizedBoolean flag = new SynchronizedBoolean(false);
- private volatile boolean expired = false; // guarded by #flag
- private final Command command;
-
-
- /**
- * Construct a <em>synchronizing</em> command that does <em>not</em> execute
- * a {@link #command} on the "secondary" {@link Thread thread} (Thread B),
- * but simply suspends that thread until the <em>synchronizing</em> command
- * is {@link #release() released} by the "primary" thread (Thread A).
- */
- public SynchronizingCommand() {
- this(Command.Null.instance());
- }
-
- /**
- * Construct a <em>synchronizing</em> command that executes the specified
- * a command on the "secondary" {@link Thread thread} (Thread B),
- * and then suspends that thread until the <em>synchronizing</em> command
- * is {@link #release() released} by the "primary" thread (Thread A).
- */
- public SynchronizingCommand(Command command) {
- super();
- if (command == null) {
- throw new NullPointerException();
- }
- this.command = command;
- }
-
- /**
- * Typically called by a
- * {@link org.eclipse.jpt.common.utility.command.CommandExecutor command
- * executor} executing Thread B.
- * <p>
- * The "synchronizing" command has reached the front of the command queue
- * and is executing on Thread B.
- * Execute the wrapped command and return control to the Thread A.
- * Suspend Thread B until Thread A resets the flag.
- * <p>
- * If the "synchronizing" command is executed (synchronously) on the same
- * thread where the command was created (i.e. Thread A),
- * it will simply set the flag appropriately and return.
- * Otherwise, the current thread would stall indefinitely.
- * <p>
- * If Thread A has timed out, skip any further synchronization.
- */
- public void execute() {
- this.command.execute();
-
- synchronized (this.flag) {
- if (this.expired) {
- // reset the 'expired' flag and exit (don't wait for Thread A)
- this.expired = false;
- return;
- }
- // Thread A is still waiting - notify it
- this.flag.setTrue();
- }
-
- if (Thread.currentThread() != this.thread) {
- try {
- this.flag.waitUntilFalse();
- } catch (InterruptedException ex) {
- // something has interrupted Thread B (the "secondary" thread);
- // it must not want us to wait for Thread A to finish executing...
- Thread.currentThread().interrupt(); // set the Thread's interrupt status
- }
- }
- }
-
- /**
- * Called by Thread A to wait on Thread B to execute its command.
- * @see #waitForExecution(long)
- */
- public void waitForExecution() throws InterruptedException {
- this.flag.waitUntilTrue();
- }
-
- /**
- * Called by Thread A to wait on Thread B to execute its command.
- * @see #waitForExecution()
- */
- public boolean waitForExecution(long timeout) throws InterruptedException {
- synchronized (this.flag) {
- if (this.flag.waitUntilTrue(timeout) ) {
- return true;
- }
- this.expired = true;
- return false;
- }
- }
-
- /**
- * Called by Thread A to indicate it has executed its command.
- * At this point the threads are independent and no longer synchronized
- * with each other.
- */
- public void release() {
- this.flag.setFalse();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.flag);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalCommand.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalCommand.java
deleted file mode 100644
index e22b6199a9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalCommand.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-
-/**
- * This implementation of the Command interface allows the client to
- * specify a different Command for each thread.
- */
-public class ThreadLocalCommand
- implements Command
-{
- protected final ThreadLocal<Command> threadLocal;
- protected final Command defaultCommand;
-
- /**
- * The default command does nothing.
- */
- public ThreadLocalCommand() {
- this(Command.Null.instance());
- }
-
- public ThreadLocalCommand(Command defaultCommand) {
- super();
- if (defaultCommand == null) {
- throw new NullPointerException();
- }
- this.defaultCommand = defaultCommand;
- this.threadLocal = this.buildThreadLocal();
- }
-
- protected ThreadLocal<Command> buildThreadLocal() {
- return new ThreadLocal<Command>();
- }
-
- public void execute() {
- this.get().execute();
- }
-
- protected Command get() {
- Command command = this.threadLocal.get();
- return (command != null) ? command : this.defaultCommand;
- }
-
- /**
- * Set the current thread's command to the specified value.
- */
- public void set(Command command) {
- this.threadLocal.set(command);
- }
-
- /**
- * Return the string representation of the current thread's command.
- */
- @Override
- public String toString() {
- return this.get().toString();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalCommandExecutor.java
deleted file mode 100644
index d47329efd4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalCommandExecutor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-
-/**
- * @see AbstractThreadLocalCommandExecutor
- */
-public class ThreadLocalCommandExecutor
- extends AbstractThreadLocalCommandExecutor<CommandExecutor>
-{
- /**
- * The default command executor simply executes commands directly.
- */
- public ThreadLocalCommandExecutor() {
- this(CommandExecutor.Default.instance());
- }
-
- public ThreadLocalCommandExecutor(CommandExecutor defaultCommandExecutor) {
- super(defaultCommandExecutor);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalExtendedCommandExecutor.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalExtendedCommandExecutor.java
deleted file mode 100644
index b84ef42108..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/command/ThreadLocalExtendedCommandExecutor.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-
-/**
- * @see AbstractThreadLocalCommandExecutor
- */
-public class ThreadLocalExtendedCommandExecutor
- extends AbstractThreadLocalCommandExecutor<ExtendedCommandExecutor>
- implements ExtendedCommandExecutor
-{
- /**
- * The default command executor simply executes commands directly.
- */
- public ThreadLocalExtendedCommandExecutor() {
- this(ExtendedCommandExecutor.Default.instance());
- }
-
- public ThreadLocalExtendedCommandExecutor(ExtendedCommandExecutor defaultCommandExecutor) {
- super(defaultCommandExecutor);
- }
-
- public void waitToExecute(Command command) throws InterruptedException {
- this.getThreadLocalCommandExecutor().waitToExecute(command);
- }
-
- public boolean waitToExecute(Command command, long timeout) throws InterruptedException {
- return this.getThreadLocalCommandExecutor().waitToExecute(command, timeout);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/enumerations/EmptyEnumeration.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/enumerations/EmptyEnumeration.java
deleted file mode 100644
index 1e0ea9625b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/enumerations/EmptyEnumeration.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.enumerations;
-
-import java.io.Serializable;
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-/**
- * An <code>EmptyEnumeration</code> is just that.
- *
- * @param <E> the type of elements returned by the enumeration
- */
-public final class EmptyEnumeration<E>
- implements Enumeration<E>, Serializable
-{
-
- // singleton
- @SuppressWarnings("rawtypes")
- private static final EmptyEnumeration INSTANCE = new EmptyEnumeration();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <T> Enumeration<T> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private EmptyEnumeration() {
- super();
- }
-
- public boolean hasMoreElements() {
- return false;
- }
-
- public E nextElement() {
- throw new NoSuchElementException();
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/enumerations/IteratorEnumeration.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/enumerations/IteratorEnumeration.java
deleted file mode 100644
index ee6000c172..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/enumerations/IteratorEnumeration.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.enumerations;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * An <code>IteratorEnumeration</code> wraps an
- * {@link Iterator} so that it can be treated like an
- * {@link Enumeration}.
- * Hopefully we don't have much need for this....
- *
- * @param <E> the type of elements returned by the enumeration
- */
-public class IteratorEnumeration<E>
- implements Enumeration<E>
-{
- private final Iterator<? extends E> iterator;
-
- /**
- * Construct an enumeration that wraps the specified iterable.
- */
- public IteratorEnumeration(Iterable<? extends E> iterable) {
- this(iterable.iterator());
- }
-
- /**
- * Construct an enumeration that wraps the specified iterator.
- */
- public IteratorEnumeration(Iterator<? extends E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasMoreElements() {
- return this.iterator.hasNext();
- }
-
- public E nextElement() {
- return this.iterator.next();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterator);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ArrayIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ArrayIterable.java
deleted file mode 100644
index 5f67e72a49..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ArrayIterable.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-
-/**
- * An <code>ArrayIterable</code> provides an {@link Iterable}
- * for an array of objects of type <code>E</code>.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see ArrayIterator
- * @see ArrayListIterable
- */
-public class ArrayIterable<E>
- implements Iterable<E>
-{
- final E[] array;
- final int start;
- final int length;
-
- /**
- * Construct an iterable for the specified array.
- */
- public ArrayIterable(E... array) {
- this(array, 0, array.length);
- }
-
- /**
- * Construct an iterable for the specified array,
- * starting at the specified start index and continuing for
- * the rest of the array.
- */
- public ArrayIterable(E[] array, int start) {
- this(array, start, array.length - start);
- }
-
- /**
- * Construct an iterable for the specified array,
- * starting at the specified start index and continuing for
- * the specified length.
- */
- public ArrayIterable(E[] array, int start, int length) {
- super();
- if ((start < 0) || (start > array.length)) {
- throw new IllegalArgumentException("start: " + start); //$NON-NLS-1$
- }
- if ((length < 0) || (length > array.length - start)) {
- throw new IllegalArgumentException("length: " + length); //$NON-NLS-1$
- }
- this.array = array;
- this.start = start;
- this.length = length;
- }
-
- public Iterator<E> iterator() {
- return new ArrayIterator<E>(this.array, this.start, this.length);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, Arrays.toString(this.array));
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ArrayListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ArrayListIterable.java
deleted file mode 100644
index 78ceb0e23d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ArrayListIterable.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayListIterator;
-
-/**
- * An <code>ArrayListIterable</code> provides a {@link ListIterable}
- * for an array of objects of type <code>E</code>.
- *
- * @param <E> the type of elements returned by the list iterable's list iterator
- *
- * @see ArrayIterable
- * @see ArrayListIterator
- */
-public class ArrayListIterable<E>
- extends ArrayIterable<E>
- implements ListIterable<E>
-{
- /**
- * Construct a list iterable for the specified array.
- */
- public ArrayListIterable(E... array) {
- this(array, 0, array.length);
- }
-
- /**
- * Construct a list iterable for the specified array,
- * starting at the specified start index and continuing for
- * the rest of the array.
- */
- public ArrayListIterable(E[] array, int start) {
- this(array, start, array.length - start);
- }
-
- /**
- * Construct a list iterable for the specified array,
- * starting at the specified start index and continuing for
- * the specified length.
- */
- public ArrayListIterable(E[] array, int start, int length) {
- super(array, start, length);
- }
-
- @Override
- public ListIterator<E> iterator() {
- return new ArrayListIterator<E>(this.array, this.start, this.length);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ChainIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ChainIterable.java
deleted file mode 100644
index 12dcc76816..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ChainIterable.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ChainIterator;
-
-/**
- * A <code>ChainIterable</code> provides a pluggable {@link Iterable}
- * that loops over a chain of arbitrarily linked objects. The chain
- * should be null-terminated (i.e. a call to the {@link #nextLink(Object)}
- * method should return <code>null</code> when it is passed the last
- * link of the chain).
- * To use, supply a starting link and supply a {@link ChainIterator.Linker} or
- * subclass <code>ChainIterable</code> and override the
- * {@link #nextLink(Object)} method.
- * The starting link will be the first object returned by the iterable's iterator.
- * If the starting link is <code>null</code>, the iterable will be empty.
- * Note this iterable does not support <code>null</code> elements.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see ChainIterator
- */
-public class ChainIterable<E>
- implements Iterable<E>
-{
- private final E startLink;
- private final ChainIterator.Linker<E> linker;
-
-
- /**
- * Construct an iterable with the specified starting link
- * and a default linker that calls back to the iterable.
- * Use this constructor if you want to override the
- * {@link #nextLink(Object)} method instead of building
- * a {@link ChainIterator.Linker}.
- */
- public ChainIterable(E startLink) {
- super();
- this.startLink = startLink;
- this.linker = this.buildDefaultLinker();
- }
-
- /**
- * Construct an iterator with the specified starting link
- * and linker.
- */
- public ChainIterable(E startLink, ChainIterator.Linker<E> linker) {
- super();
- this.startLink = startLink;
- this.linker = linker;
- }
-
- protected ChainIterator.Linker<E> buildDefaultLinker() {
- return new DefaultLinker();
- }
-
- public Iterator<E> iterator() {
- return new ChainIterator<E>(this.startLink, this.linker);
- }
-
- /**
- * Return the next link in the chain; null if there are no more links.
- * <p>
- * This method can be overridden by a subclass as an alternative to
- * building a {@link ChainIterator.Linker}.
- */
- protected E nextLink(@SuppressWarnings("unused") E currentLink) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.startLink);
- }
-
-
- //********** default linker **********
-
- protected class DefaultLinker implements ChainIterator.Linker<E> {
- public E nextLink(E currentLink) {
- return ChainIterable.this.nextLink(currentLink);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CloneIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CloneIterable.java
deleted file mode 100644
index 22a21a4979..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CloneIterable.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator;
-
-/**
- * Pull together remover state and behavior for subclasses.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see SnapshotCloneIterable
- * @see LiveCloneIterable
- */
-public abstract class CloneIterable<E>
- implements Iterable<E>
-{
- final CloneIterator.Remover<E> remover;
-
-
- // ********** constructors **********
-
- protected CloneIterable() {
- super();
- this.remover = this.buildDefaultRemover();
- }
-
- protected CloneIterable(CloneIterator.Remover<E> remover) {
- super();
- this.remover = remover;
- }
-
- protected CloneIterator.Remover<E> buildDefaultRemover() {
- return new DefaultRemover();
- }
-
-
- // ********** default removal **********
-
- /**
- * Remove the specified element from the original collection.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link CloneIterator.Remover}.
- */
- protected void remove(@SuppressWarnings("unused") E element) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
-
- //********** default mutator **********
-
- protected class DefaultRemover implements CloneIterator.Remover<E> {
- public void remove(E element) {
- CloneIterable.this.remove(element);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CloneListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CloneListIterable.java
deleted file mode 100644
index b98c42303a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CloneListIterable.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
-
-/**
- * Pull together mutator state and behavior for subclasses.
- *
- * @param <E> the type of elements returned by the list iterable's list iterator
- *
- * @see SnapshotCloneListIterable
- * @see LiveCloneListIterable
- */
-public abstract class CloneListIterable<E>
- implements ListIterable<E>
-{
- final CloneListIterator.Mutator<E> mutator;
-
-
- // ********** constructors **********
-
- protected CloneListIterable() {
- super();
- this.mutator = this.buildDefaultMutator();
- }
-
- protected CloneListIterable(CloneListIterator.Mutator<E> mutator) {
- super();
- this.mutator = mutator;
- }
-
- protected CloneListIterator.Mutator<E> buildDefaultMutator() {
- return new DefaultMutator();
- }
-
-
- // ********** default mutations **********
-
- /**
- * At the specified index, add the specified element to the original list.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link CloneListIterator.Mutator}.
- */
- protected void add(@SuppressWarnings("unused") int index, @SuppressWarnings("unused") E element) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- /**
- * Remove the element at the specified index from the original list.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link CloneListIterator.Mutator}.
- */
- protected void remove(@SuppressWarnings("unused") int index) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- /**
- * At the specified index, set the specified element in the original list.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link CloneListIterator.Mutator}.
- */
- protected void set(@SuppressWarnings("unused") int index, @SuppressWarnings("unused") E element) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
-
- //********** default mutator **********
-
- protected class DefaultMutator implements CloneListIterator.Mutator<E> {
- public void add(int index, E element) {
- CloneListIterable.this.add(index, element);
- }
- public void remove(int index) {
- CloneListIterable.this.remove(index);
- }
- public void set(int index, E element) {
- CloneListIterable.this.set(index, element);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CompositeIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CompositeIterable.java
deleted file mode 100644
index 442737ede9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CompositeIterable.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-
-/**
- * A <code>CompositeIterable</code> wraps an {@link Iterable}
- * of {@link Iterable}s and makes them appear to be a single
- * {@link Iterable}.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see CompositeIterator
- * @see CompositeListIterable
- */
-public class CompositeIterable<E>
- implements Iterable<E>
-{
- private final Iterable<? extends Iterable<? extends E>> iterables;
-
-
- /**
- * Construct an iterable with the specified collection of iterables.
- */
- public CompositeIterable(Iterable<? extends Iterable<? extends E>> iterables) {
- super();
- this.iterables = iterables;
- }
-
- /**
- * Construct an iterable with the specified object prepended
- * to the specified iterable.
- */
- @SuppressWarnings("unchecked")
- public CompositeIterable(E object, Iterable<? extends E> iterable) {
- this(new SingleElementIterable<E>(object), iterable);
- }
-
- /**
- * Construct an iterable with the specified object appended
- * to the specified iterable.
- */
- @SuppressWarnings("unchecked")
- public CompositeIterable(Iterable<? extends E> iterable, E object) {
- this(iterable, new SingleElementIterable<E>(object));
- }
-
- /**
- * Construct an iterable with the specified iterables.
- */
- public CompositeIterable(Iterable<? extends E>... iterables) {
- this(new ArrayIterable<Iterable<? extends E>>(iterables));
- }
-
- /**
- * combined iterators
- */
- public Iterator<E> iterator() {
- return new CompositeIterator<E>(this.iterators());
- }
-
- /**
- * iterator of iterators
- */
- protected Iterator<? extends Iterator<? extends E>> iterators() {
- return new TransformationIterator<Iterable<? extends E>, Iterator<? extends E>>(this.iterables()) {
- @Override
- protected Iterator<? extends E> transform(Iterable<? extends E> next) {
- return next.iterator();
- }
- };
- }
-
- /**
- * iterator of iterables
- */
- protected Iterator<? extends Iterable<? extends E>> iterables() {
- return this.iterables.iterator();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterables);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CompositeListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CompositeListIterable.java
deleted file mode 100644
index 66f75626ef..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/CompositeListIterable.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationListIterator;
-
-/**
- * A <code>CompositeListIterable</code> wraps a {@link ListIterable}
- * of {@link ListIterable}s and makes them appear to be a single
- * {@link ListIterable}.
- *
- * @param <E> the type of elements returned by the list iterable's list iterator
- *
- * @see CompositeListIterator
- * @see CompositeIterable
- * @see ReadOnlyCompositeListIterable
- */
-public class CompositeListIterable<E>
- implements ListIterable<E>
-{
- private final ListIterable<? extends ListIterable<E>> iterables;
-
-
- /**
- * Construct a list iterable with the specified list of list iterables.
- */
- public CompositeListIterable(List<ListIterable<E>> iterables) {
- this(new ListListIterable<ListIterable<E>>(iterables));
- }
-
- /**
- * Construct a list iterable with the specified list of list iterables.
- */
- public CompositeListIterable(ListIterable<? extends ListIterable<E>> iterables) {
- super();
- this.iterables = iterables;
- }
-
- /**
- * Construct a list iterable with the specified object prepended
- * to the specified list.
- */
- public CompositeListIterable(E object, List<E> list) {
- this(object, new ListListIterable<E>(list));
- }
-
- /**
- * Construct a list iterable with the specified object prepended
- * to the specified list iterable.
- */
- @SuppressWarnings("unchecked")
- public CompositeListIterable(E object, ListIterable<E> iterable) {
- this(new SingleElementListIterable<E>(object), iterable);
- }
-
- /**
- * Construct a list iterable with the specified object appended
- * to the specified list.
- */
- public CompositeListIterable(List<E> list, E object) {
- this(new ListListIterable<E>(list), object);
- }
-
- /**
- * Construct a list iterable with the specified object appended
- * to the specified list iterable.
- */
- @SuppressWarnings("unchecked")
- public CompositeListIterable(ListIterable<E> iterable, E object) {
- this(iterable, new SingleElementListIterable<E>(object));
- }
-
- /**
- * Construct a list iterable with the specified list iterables.
- */
- public CompositeListIterable(ListIterable<E>... iterables) {
- this(new ArrayListIterable<ListIterable<E>>(iterables));
- }
-
- /**
- * Construct a list iterable with the specified lists.
- */
- public CompositeListIterable(List<E>... lists) {
- this(new TransformationListIterable<List<E>, ListIterable<E>>(new ArrayListIterable<List<E>>(lists)) {
- @Override
- protected ListIterable<E> transform(List<E> list) {
- return new ListListIterable<E>(list);
- }
- });
- }
-
- /**
- * combined list iterators
- */
- public ListIterator<E> iterator() {
- return new CompositeListIterator<E>(this.iterators());
- }
-
- /**
- * list iterator of list iterators
- */
- protected ListIterator<? extends ListIterator<E>> iterators() {
- return new TransformationListIterator<ListIterable<E>, ListIterator<E>>(this.iterables()) {
- @Override
- protected ListIterator<E> transform(ListIterable<E> next) {
- return next.iterator();
- }
- };
- }
-
- /**
- * list iterator of list iterables
- */
- protected ListIterator<? extends ListIterable<E>> iterables() {
- return this.iterables.iterator();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterables);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/EmptyIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/EmptyIterable.java
deleted file mode 100644
index c3ed1c49dc..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/EmptyIterable.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-
-/**
- * An <code>EmptyIterable</code> is just that.
- * Maybe just a touch better-performing than {@link java.util.Collections#EMPTY_SET}
- * since we don't create a new {@link Iterator} every time {@link #iterator()} is called.
- * (Not sure why they do that....)
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see EmptyIterator
- * @see EmptyListIterable
- */
-public final class EmptyIterable<E>
- implements Iterable<E>, Serializable
-{
- // singleton
- @SuppressWarnings("rawtypes")
- private static final Iterable INSTANCE = new EmptyIterable();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <T> Iterable<T> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private EmptyIterable() {
- super();
- }
-
- public Iterator<E> iterator() {
- return EmptyIterator.instance();
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/EmptyListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/EmptyListIterable.java
deleted file mode 100644
index 028f34f857..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/EmptyListIterable.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.io.Serializable;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
-
-/**
- * An <code>EmptyListIterable</code> is just that.
- * Maybe just a touch better-performing than {@link java.util.Collections#EMPTY_LIST}
- * since we don't create a new {@link java.util.Iterator} every time
- * {@link #iterator()} is called. (Not sure why they do that....)
- *
- * @param <E> the type of elements returned by the list iterable's list iterator
- *
- * @see EmptyListIterator
- * @see EmptyIterable
- */
-public final class EmptyListIterable<E>
- implements ListIterable<E>, Serializable
-{
- // singleton
- @SuppressWarnings("rawtypes")
- private static final ListIterable INSTANCE = new EmptyListIterable();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <T> ListIterable<T> instance() {
- return INSTANCE;
- }
-
- /**
- * Ensure single instance.
- */
- private EmptyListIterable() {
- super();
- }
-
- public ListIterator<E> iterator() {
- return EmptyListIterator.instance();
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/FilteringIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/FilteringIterable.java
deleted file mode 100644
index 897f0d908e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/FilteringIterable.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-
-/**
- * A <code>FilteringIterable</code> wraps another {@link Iterable}
- * and uses a {@link Filter} to determine which elements in the
- * nested iterable are to be returned by the iterable's iterator.
- * <p>
- * As an alternative to building a {@link Filter}, a subclass
- * of <code>FilteringIterable</code> can override the
- * {@link #accept(Object)} method.
- *
- * @param <E> the type of elements to be filtered
- *
- * @see FilteringIterator
- */
-public class FilteringIterable<E>
- implements Iterable<E>
-{
- private final Iterable<? extends E> iterable;
- private final Filter<E> filter;
-
-
- /**
- * Construct an iterable with the specified nested
- * iterable and a default filter that calls back to the iterable.
- * Use this constructor if you want to override the
- * {@link #accept(Object)} method instead of building
- * a {@link Filter}.
- */
- public FilteringIterable(Iterable<? extends E> iterable) {
- super();
- this.iterable = iterable;
- this.filter = this.buildDefaultFilter();
- }
-
- /**
- * Construct an iterable with the specified nested
- * iterable and filter.
- */
- public FilteringIterable(Iterable<? extends E> iterable, Filter<E> filter) {
- super();
- this.iterable = iterable;
- this.filter = filter;
- }
-
- protected Filter<E> buildDefaultFilter() {
- return new DefaultFilter();
- }
-
- public Iterator<E> iterator() {
- return new FilteringIterator<E>(this.iterable.iterator(), this.filter);
- }
-
- /**
- * Return whether the iterable's iterator
- * should return the specified next element from a call to the
- * {@link Iterator#next()} method.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link Filter}.
- */
- protected boolean accept(@SuppressWarnings("unused") E o) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterable);
- }
-
-
- //********** default filter **********
-
- protected class DefaultFilter implements Filter<E> {
- public boolean accept(E o) {
- return FilteringIterable.this.accept(o);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/GraphIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/GraphIterable.java
deleted file mode 100644
index 01912a47b5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/GraphIterable.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.GraphIterator;
-
-/**
- * A <code>GraphIterable</code> is similar to a {@link TreeIterable}
- * except that it cannot be assumed that all nodes assume a strict tree
- * structure. For instance, in a tree, a node cannot be a descendent of
- * itself, but a graph may have a cyclical structure.
- *
- * A <code>GraphIterable</code> simplifies the traversal of a
- * graph of objects, where the objects' protocol(s) provides
- * a method for getting the next collection of nodes in the graph,
- * (or <em>neighbors</em>), but does not provide a method for
- * getting <em>all</em> of the nodes in the graph.
- * (e.g. a neighbor can return his neighbors, and those neighbors
- * can return their neighbors, which might also include the original
- * neighbor, but you only want to visit the original neighbor once.)
- * <p>
- * If a neighbor has already been visited (determined by using
- * {@link #equals(Object)}), that neighbor is not visited again,
- * nor are the neighbors of that object.
- * <p>
- * It is up to the user of this class to ensure a <em>complete</em> graph.
- * <p>
- * To use, supply:<ul>
- * <li> either the initial node of the graph or an {@link Iterable}
- * of the initial collection of graph nodes
- * <li> a {@link GraphIterator.MisterRogers} that tells who the neighbors are
- * of each node
- * (alternatively, subclass <code>GraphIterable</code>
- * and override the {@link #neighbors(Object)} method)
- * </ul>
- * The {@link Iterator#remove()} operation is not supported. This behavior, if
- * desired, must be implemented by the user of this class.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see GraphIterator
- */
-public class GraphIterable<E>
- implements Iterable<E>
-{
- private final Iterable<? extends E> roots;
- private final GraphIterator.MisterRogers<E> misterRogers;
-
-
- /**
- * Construct an iterable containing the nodes of a graph with the specified root
- * and a default Mr. Rogers that calls back to the iterable.
- * Use this constructor if you want to override the
- * {@link #neighbors(Object)} method instead of building
- * a {@link GraphIterator.MisterRogers}.
- */
- public GraphIterable(E root) {
- this(new SingleElementIterable<E>(root));
- }
-
- /**
- * Construct an iterable containing the nodes of a graph
- * with the specified root and Mr. Rogers.
- */
- public GraphIterable(E root, GraphIterator.MisterRogers<E> misterRogers) {
- this(new SingleElementIterable<E>(root), misterRogers);
- }
-
- /**
- * Construct an iterable containing the nodes of a graph
- * with the specified collection of roots
- * and a default Mr. Rogers that calls back to the iterable.
- * Use this constructor if you want to override the
- * {@link #neighbors(Object)} method instead of building
- * a {@link GraphIterator.MisterRogers}.
- */
- public GraphIterable(E... roots) {
- this(Arrays.asList(roots));
- }
-
- /**
- * Construct an iterable containing the nodes of a graph
- * with the specified roots and Mr. Rogers.
- */
- public GraphIterable(E[] roots, GraphIterator.MisterRogers<E> misterRogers) {
- this(Arrays.asList(roots), misterRogers);
- }
-
- /**
- * Construct an iterable containing the nodes of a graph
- * with the specified collection of roots
- * and a default Mr. Rogers that calls back to the iterable.
- * Use this constructor if you want to override the
- * {@link #neighbors(Object)} method instead of building
- * a {@link GraphIterator.MisterRogers}.
- */
- public GraphIterable(Iterable<? extends E> roots) {
- super();
- this.roots = roots;
- this.misterRogers = this.buildDefaultMisterRogers();
- }
-
- /**
- * Construct an iterable containing the nodes of a graph
- * with the specified roots and Mr. Rogers.
- */
- public GraphIterable(Iterable<? extends E> roots, GraphIterator.MisterRogers<E> misterRogers) {
- super();
- this.roots = roots;
- this.misterRogers = misterRogers;
- }
-
- protected GraphIterator.MisterRogers<E> buildDefaultMisterRogers() {
- return new DefaultMisterRogers();
- }
-
- public Iterator<E> iterator() {
- return new GraphIterator<E>(this.roots, this.misterRogers);
- }
-
- /**
- * Return the immediate neighbors of the specified object.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link GraphIterator.MisterRogers}.
- */
- protected Iterator<? extends E> neighbors(@SuppressWarnings("unused") E next) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.roots);
- }
-
-
- //********** default Mr. Rogers **********
-
- protected class DefaultMisterRogers implements GraphIterator.MisterRogers<E> {
- public Iterator<? extends E> neighbors(E node) {
- return GraphIterable.this.neighbors(node);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LateralIterableWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LateralIterableWrapper.java
deleted file mode 100644
index acb656d79e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LateralIterableWrapper.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.LateralIteratorWrapper;
-
-/**
- * Wrap an iterable of elements of type <code>E1</code>, converting it into an
- * iterable of elements of type <code>E2</code>. <em>Assume</em> the wrapped
- * iterable contains only elements of type <code>E2</code>. The result is a
- * {@link ClassCastException} if this assumption is false.
- *
- * @param <E1> input: the type of elements contained by the wrapped iterable
- * @param <E2> output: the type of elements returned by the iterable's iterators
- *
- * @see LateralIteratorWrapper
- * @see SubIterableWrapper
- */
-public class LateralIterableWrapper<E1, E2>
- implements Iterable<E2>
-{
- private final Iterable<E1> iterable;
-
-
- public LateralIterableWrapper(Iterable<E1> iterable) {
- super();
- this.iterable = iterable;
- }
-
- public Iterator<E2> iterator() {
- return new LateralIteratorWrapper<E1, E2>(this.iterable.iterator());
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterable);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LateralListIterableWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LateralListIterableWrapper.java
deleted file mode 100644
index 3847723a63..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LateralListIterableWrapper.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.LateralListIteratorWrapper;
-
-/**
- * Wrap a list iterable of elements of type <code>E1</code>, converting it into
- * a list iterable of elements of type <code>E2</code>. <em>Assume</em> the
- * wrapped iterable contains only elements of type <code>E2</code>.
- * The result is a {@link ClassCastException} if this assumption is false.
- *
- * @param <E1> input: the type of elements contained by the wrapped list iterable
- * @param <E2> output: the type of elements returned by the iterable's list iterators
- *
- * @see LateralListIteratorWrapper
- * @see SubListIterableWrapper
- */
-public class LateralListIterableWrapper<E1, E2>
- implements ListIterable<E2>
-{
- private final ListIterable<E1> iterable;
-
-
- public LateralListIterableWrapper(List<E1> list) {
- this(new ListListIterable<E1>(list));
- }
-
- public LateralListIterableWrapper(ListIterable<E1> iterable) {
- super();
- this.iterable = iterable;
- }
-
- public ListIterator<E2> iterator() {
- return new LateralListIteratorWrapper<E1, E2>(this.iterable.iterator());
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterable);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ListIterable.java
deleted file mode 100644
index 91bab82950..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ListIterable.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.ListIterator;
-
-/**
- * A <code>ListIterable</code> simply extends {@link Iterable}
- * to return a {@link ListIterator} of type <code>E</code>.
- *
- * @param <E> the type of elements returned by the iterable's iterators
- */
-public interface ListIterable<E>
- extends Iterable<E>
-{
- /**
- * Return a list iterator over a set of elements of type E.
- */
- ListIterator<E> iterator();
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ListListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ListListIterable.java
deleted file mode 100644
index ad5a5d7926..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ListListIterable.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- * A <code>ListListIterable</code> adapts a {@link List}
- * to the {@link ListIterable} interface.
- *
- * @param <E> the type of elements returned by the iterable's iterators
- */
-public class ListListIterable<E>
- implements ListIterable<E>
-{
- private final List<E> list;
-
- public ListListIterable(List<E> list) {
- super();
- this.list = list;
- }
-
- public ListIterator<E> iterator() {
- return this.list.listIterator();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LiveCloneIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LiveCloneIterable.java
deleted file mode 100644
index e8aaccff06..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LiveCloneIterable.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator;
-
-/**
- * A <code>LiveCloneIterable</code> returns an iterator on a current copy of a
- * collection, allowing for concurrent access to the original collection. A
- * copy of the collection is created every time {@link #iterator()} is
- * called. As a result, the contents of the collection can be different with
- * each call to {@link #iterator()} (i.e. it is "live").
- * <p>
- * The original collection passed to the <code>LiveCloneIterable</code>'s
- * constructor should be thread-safe (e.g. {@link java.util.Vector});
- * otherwise you run the risk of a corrupted collection.
- * <p>
- * By default, the iterator returned by a <code>LiveCloneIterable</code> does not
- * support the {@link Iterator#remove()} operation; this is because it does not
- * have access to the original collection. But if the <code>LiveCloneIterable</code>
- * is supplied with an {@link CloneIterator.Remover} it will delegate the
- * {@link Iterator#remove()} operation to the <code>Remover</code>.
- * Alternatively, a subclass can override the iterable's {@link #remove(Object)}
- * method.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see CloneIterator
- * @see SnapshotCloneIterable
- * @see LiveCloneListIterable
- */
-public class LiveCloneIterable<E>
- extends CloneIterable<E>
-{
- private final Collection<? extends E> collection;
-
-
- // ********** constructors **********
-
- /**
- * Construct a "live" iterable for the specified collection.
- * The {@link Iterator#remove()} operation will not be supported
- * by the iterator returned by {@link #iterator()}
- * unless a subclass overrides the iterable's {@link #remove(Object)}
- * method.
- */
- public LiveCloneIterable(Collection<? extends E> collection) {
- super();
- this.collection = collection;
- }
-
- /**
- * Construct a "live" iterable for the specified collection.
- * The specified remover will be used by any generated iterators to
- * remove objects from the original collection.
- */
- public LiveCloneIterable(Collection<? extends E> collection, CloneIterator.Remover<E> remover) {
- super(remover);
- this.collection = collection;
- }
-
-
- // ********** Iterable implementation **********
-
- public Iterator<E> iterator() {
- return new CloneIterator<E>(this.collection, this.remover);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.collection);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LiveCloneListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LiveCloneListIterable.java
deleted file mode 100644
index 9d26554db1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/LiveCloneListIterable.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
-
-/**
- * A <code>LiveCloneListIterable</code> returns a list iterator on a current
- * copy of a list, allowing for concurrent access to the original list. A
- * copy of the list is created every time {@link #iterator()} is
- * called. As a result, the contents of the list can be different with
- * each call to {@link #iterator()} (i.e. it is "live").
- * <p>
- * The original list passed to the <code>LiveCloneListIterable</code>'s
- * constructor should be thread-safe (e.g. {@link java.util.Vector});
- * otherwise you run the risk of a corrupted list.
- * <p>
- * By default, the list iterator returned by a <code>LiveCloneListIterable</code>
- * does not support the modify operations; this is because it does not
- * have access to the original list. But if the <code>LiveCloneListIterable</code>
- * is supplied with an {@link CloneListIterator.Mutator} it will delegate the
- * modify operations to the <code>Mutator</code>.
- * Alternatively, a subclass can override the list iterable's mutation
- * methods.
- *
- * @param <E> the type of elements returned by the list iterable's list iterator
- *
- * @see CloneListIterator
- * @see SnapshotCloneListIterable
- * @see LiveCloneIterable
- */
-public class LiveCloneListIterable<E>
- extends CloneListIterable<E>
-{
- private final List<? extends E> list;
-
-
- // ********** constructors **********
-
- /**
- * Construct a "live" list iterable for the specified list.
- * The {@link ListIterator} mutation operations will not be supported
- * by the list iterator returned by {@link #iterator()}
- * unless a subclass overrides the iterable's mutation
- * methods.
- */
- public LiveCloneListIterable(List<? extends E> list) {
- super();
- this.list = list;
- }
-
- /**
- * Construct a "live" list iterable for the specified list.
- * The specified mutator will be used by any generated list iterators to
- * modify the original list.
- */
- public LiveCloneListIterable(List<? extends E> list, CloneListIterator.Mutator<E> mutator) {
- super(mutator);
- this.list = list;
- }
-
-
- // ********** ListIterable implementation **********
-
- public ListIterator<E> iterator() {
- return new CloneListIterator<E>(this.list, this.mutator);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.list);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/PeekableIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/PeekableIterable.java
deleted file mode 100644
index ad381ee41c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/PeekableIterable.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.PeekableIterator;
-
-/**
- * A <code>PeekableIterable</code> wraps another {@link Iterable}
- * and returns an {@link PeekableIterator} that allows a
- * {@link PeekableIterator#peek() peek} at the next element to be
- * returned by {@link Iterator#next()}.
- * <p>
- * One, possibly undesirable, side-effect of using this iterator is that
- * the nested iterator's <code>next()</code> method will be invoked
- * <em>before</em> the peekable iterator's {@link Iterator#next()}
- * method is invoked. This is because the "next" element must be
- * pre-loaded for the {@link PeekableIterator#peek()} method.
- * This also prevents a peekable iterator from supporting the optional
- * {@link Iterator#remove()} method.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see PeekableIterator
- */
-public class PeekableIterable<E>
- implements Iterable<E>
-{
- private final Iterable<? extends E> iterable;
-
- /**
- * Construct a peekable iterable that wraps the specified
- * iterable.
- */
- public PeekableIterable(Iterable<? extends E> iterable) {
- super();
- this.iterable = iterable;
- }
-
- public PeekableIterator<E> iterator() {
- return new PeekableIterator<E>(this.iterable);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterable);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/QueueIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/QueueIterable.java
deleted file mode 100644
index 5b2aa6d0b4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/QueueIterable.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.Queue;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.QueueIterator;
-
-/**
- * A <code>QueueIterable</code> provides an {@link Iterable}
- * for a {@link Queue} of objects of type <code>E</code>. The queue's elements
- * are {@link Queue#dequeue() dequeue}d" as the iterable's iterator returns
- * them with calls to {@link Iterator#next()}.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see Queue
- * @see QueueIterator
- */
-public class QueueIterable<E>
- implements Iterable<E>
-{
- private final Queue<E> queue;
-
- /**
- * Construct an iterable for the specified queue.
- */
- public QueueIterable(Queue<E> queue) {
- super();
- this.queue = queue;
- }
-
- public Iterator<E> iterator() {
- return new QueueIterator<E>(this.queue);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.queue);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyCompositeListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyCompositeListIterable.java
deleted file mode 100644
index ff2810fdda..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyCompositeListIterable.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyCompositeListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationListIterator;
-
-/**
- * A <code>ReadOnlyCompositeListIterable</code> wraps a {@link ListIterable}
- * of {@link ListIterable}s and makes them appear to be a single
- * read-only {@link ListIterable}. A read-only composite list
- * iterable is more flexible than a normal composite list iterable when it
- * comes to the element types of the nested list iterables.
- *
- * @param <E> the type of elements returned by the list iterable's list iterator
- *
- * @see ReadOnlyCompositeListIterator
- * @see CompositeListIterable
- */
-public class ReadOnlyCompositeListIterable<E>
- implements ListIterable<E>
-{
- private final ListIterable<? extends ListIterable<? extends E>> iterables;
-
-
- /**
- * Construct a list iterable with the specified list of list iterables.
- */
- public ReadOnlyCompositeListIterable(ListIterable<? extends ListIterable<? extends E>> iterables) {
- super();
- this.iterables = iterables;
- }
-
- /**
- * Construct a list iterable with the specified object prepended
- * to the specified list iterable.
- */
- @SuppressWarnings("unchecked")
- public ReadOnlyCompositeListIterable(E object, ListIterable<? extends E> iterable) {
- this(new SingleElementListIterable<E>(object), iterable);
- }
-
- /**
- * Construct a list iterable with the specified object appended
- * to the specified list iterable.
- */
- @SuppressWarnings("unchecked")
- public ReadOnlyCompositeListIterable(ListIterable<? extends E> iterable, E object) {
- this(iterable, new SingleElementListIterable<E>(object));
- }
-
- /**
- * Construct a list iterable with the specified list iterables.
- */
- public ReadOnlyCompositeListIterable(ListIterable<? extends E>... iterables) {
- this(new ArrayListIterable<ListIterable<? extends E>>(iterables));
- }
-
- /**
- * combined list iterators
- */
- public ListIterator<E> iterator() {
- return new ReadOnlyCompositeListIterator<E>(this.iterators());
- }
-
- /**
- * list iterator of list iterators
- */
- protected ListIterator<? extends ListIterator<? extends E>> iterators() {
- return new TransformationListIterator<ListIterable<? extends E>, ListIterator<? extends E>>(this.iterables()) {
- @Override
- protected ListIterator<? extends E> transform(ListIterable<? extends E> next) {
- return next.iterator();
- }
- };
- }
-
- /**
- * list iterator of list iterables
- */
- protected ListIterator<? extends ListIterable<? extends E>> iterables() {
- return this.iterables.iterator();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterables);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyIterable.java
deleted file mode 100644
index 0483928be6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyIterable.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyIterator;
-
-/**
- * A <code>ReadOnlyIterable</code> wraps another {@link Iterable}
- * and returns a read-only {@link Iterator}.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see ReadOnlyIterator
- * @see ReadOnlyListIterable
- */
-public class ReadOnlyIterable<E>
- implements Iterable<E>
-{
- private final Iterable<? extends E> iterable;
-
-
- /**
- * Construct an iterable the returns a read-only iterator on the elements
- * in the specified iterable.
- */
- public ReadOnlyIterable(Iterable<? extends E> iterable) {
- super();
- this.iterable = iterable;
- }
-
- public Iterator<E> iterator() {
- return new ReadOnlyIterator<E>(this.iterable);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterable);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyListIterable.java
deleted file mode 100644
index 1efde41a59..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/ReadOnlyListIterable.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-
-/**
- * A <code>ReadOnlyListIterable</code> wraps another {@link ListIterable}
- * and returns a read-only {@link ListIterator}.
- *
- * @param <E> the type of elements returned by the list iterable's list iterator
- *
- * @see ReadOnlyListIterator
- * @see ReadOnlyIterable
- */
-public class ReadOnlyListIterable<E>
- implements ListIterable<E>
-{
- private final ListIterable<? extends E> listIterable;
-
-
- /**
- * Construct a list iterable the returns a read-only list iterator on the elements
- * in the specified list iterable.
- */
- public ReadOnlyListIterable(ListIterable<? extends E> iterable) {
- super();
- this.listIterable = iterable;
- }
-
- public ListIterator<E> iterator() {
- return new ReadOnlyListIterator<E>(this.listIterable);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listIterable);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SingleElementIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SingleElementIterable.java
deleted file mode 100644
index 34ea3a7e24..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SingleElementIterable.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementIterator;
-
-/**
- * A <code>SingleElementIterable</code> returns an {@link Iterator}
- * that holds a single element
- * and returns it with the first call to {@link Iterator#next()}, at
- * which point it will return <code>false</code> to any subsequent
- * call to {@link Iterator#hasNext()}.
- * <p>
- * A <code>SingleElementIterable</code> is equivalent to the
- * {@link Iterable} returned by:
- * {@link java.util.Collections#singleton(Object)}.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see SingleElementIterator
- * @see SingleElementListIterable
- */
-public class SingleElementIterable<E>
- implements Iterable<E>
-{
- private final E element;
-
- /**
- * Construct an iterable that contains only the specified element.
- */
- public SingleElementIterable(E element) {
- super();
- this.element = element;
- }
-
- public Iterator<E> iterator() {
- return new SingleElementIterator<E>(this.element);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.element);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SingleElementListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SingleElementListIterable.java
deleted file mode 100644
index c6e2100367..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SingleElementListIterable.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementListIterator;
-
-/**
- * A <code>SingleElementListIterable</code> returns a {@link ListIterator}
- * that holds a single element
- * and returns it with the first call to {@link ListIterator#next()}, at
- * which point it will return <code>false</code> to any subsequent
- * call to {@link ListIterator#hasNext()}. Likewise, it will return <code>false</code>
- * to a call to {@link ListIterator#hasPrevious()} until a call to {@link ListIterator#next()},
- * at which point a call to {@link ListIterator#previous()} will return the
- * single element.
- * <p>
- * A <code>SingleElementListIterable</code> is equivalent to the
- * {@link Iterable} returned by:
- * {@link java.util.Collections#singletonList(Object)}.
- *
- * @param <E> the type of elements returned by the list iterable's list iterator
- *
- * @see SingleElementListIterator
- * @see SingleElementIterable
- */
-public class SingleElementListIterable<E>
- implements ListIterable<E>
-{
- private final E element;
-
- /**
- * Construct a list iterable that contains only the specified element.
- */
- public SingleElementListIterable(E element) {
- super();
- this.element = element;
- }
-
- public ListIterator<E> iterator() {
- return new SingleElementListIterator<E>(this.element);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.element);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SnapshotCloneIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SnapshotCloneIterable.java
deleted file mode 100644
index 72beebec70..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SnapshotCloneIterable.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator;
-
-/**
- * A <code>SnapshotCloneIterable</code> returns an iterator on a "snapshot" of a
- * collection, allowing for concurrent access to the original collection. A
- * copy of the collection is created when the iterable is constructed.
- * As a result, the contents of the collection will be the same with
- * every call to {@link #iterator()}.
- * <p>
- * The original collection passed to the <code>SnapshotCloneIterable</code>'s
- * constructor should be thread-safe (e.g. {@link java.util.Vector});
- * otherwise you run the risk of a corrupted collection.
- * <p>
- * By default, the iterator returned by a <code>SnapshotCloneIterable</code> does not
- * support the {@link Iterator#remove()} operation; this is because it does not
- * have access to the original collection. But if the <code>SnapshotCloneIterable</code>
- * is supplied with a {@link CloneIterator.Remover} it will delegate the
- * {@link Iterator#remove()} operation to the <code>Remover</code>.
- * Alternatively, a subclass can override the iterable's {@link #remove(Object)}
- * method.
- * <p>
- * This iterable is useful for multiple passes over a collection that should not
- * be changed (e.g. by another thread) between passes.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see CloneIterator
- * @see LiveCloneIterable
- * @see SnapshotCloneListIterable
- */
-public class SnapshotCloneIterable<E>
- extends CloneIterable<E>
-{
- private final Object[] array;
-
-
- // ********** constructors **********
-
- /**
- * Construct a "snapshot" iterable for the specified iterator.
- * The {@link Iterator#remove()} operation will not be supported
- * by the iterator returned by {@link #iterator()}
- * unless a subclass overrides the iterable's {@link #remove(Object)}
- * method.
- */
- public SnapshotCloneIterable(Iterator<? extends E> iterator) {
- super();
- this.array = ArrayTools.array(iterator);
- }
-
- /**
- * Construct a "snapshot" iterable for the specified iterator.
- * The specified remover will be used by any generated iterators to
- * remove objects from the original collection.
- */
- public SnapshotCloneIterable(Iterator<? extends E> iterator, CloneIterator.Remover<E> remover) {
- super(remover);
- this.array = ArrayTools.array(iterator);
- }
-
- /**
- * Construct a "snapshot" iterable for the specified collection.
- * The {@link Iterator#remove()} operation will not be supported
- * by the iterator returned by {@link #iterator()}
- * unless a subclass overrides the iterable's {@link #remove(Object)}
- * method.
- */
- public SnapshotCloneIterable(Collection<? extends E> collection) {
- super();
- this.array = collection.toArray();
- }
-
- /**
- * Construct a "snapshot" iterable for the specified collection.
- * The specified remover will be used by any generated iterators to
- * remove objects from the original collection.
- */
- public SnapshotCloneIterable(Collection<? extends E> collection, CloneIterator.Remover<E> remover) {
- super(remover);
- this.array = collection.toArray();
- }
-
-
- // ********** Iterable implementation **********
-
- public Iterator<E> iterator() {
- return new LocalCloneIterator<E>(this.remover, this.array);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, Arrays.toString(this.array));
- }
-
-
- // ********** clone iterator **********
-
- /**
- * provide access to "internal" constructor
- */
- protected static class LocalCloneIterator<E> extends CloneIterator<E> {
- protected LocalCloneIterator(Remover<E> remover, Object[] array) {
- super(remover, array);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SnapshotCloneListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SnapshotCloneListIterable.java
deleted file mode 100644
index f242ab70f5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SnapshotCloneListIterable.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
-
-/**
- * A <code>SnapshotCloneListIterable</code> returns a list iterator on a
- * "snapshot" of a list, allowing for concurrent access to the original list.
- * A copy of the list is created when the list iterable is constructed.
- * As a result, the contents of the list will be the same with
- * every call to {@link #iterator()}, even if the original list is modified via
- * the list iterator's mutation methods.
- * <p>
- * The original list passed to the <code>SnapshotCloneListIterable</code>'s
- * constructor should be thread-safe (e.g. {@link java.util.Vector});
- * otherwise you run the risk of a corrupted list.
- * <p>
- * By default, the list iterator returned by a <code>SnapshotCloneListIterable</code> does not
- * support the {@link ListIterator} mutation operations; this is because it does not
- * have access to the original list. But if the <code>SnapshotCloneListIterable</code>
- * is supplied with a {@link CloneListIterator.Mutator} it will delegate the
- * {@link ListIterator} mutation operations to the <code>Mutator</code>.
- * Alternatively, a subclass can override the list iterable's mutation
- * methods.
- * <p>
- * This list iterable is useful for multiple passes over a list that should not
- * be changed (e.g. by another thread) between passes.
- *
- * @param <E> the type of elements returned by the list iterable's list iterator
- *
- * @see CloneListIterator
- * @see LiveCloneListIterable
- * @see SnapshotCloneIterable
- */
-public class SnapshotCloneListIterable<E>
- extends CloneListIterable<E>
-{
- private final Object[] array;
-
-
- // ********** constructors **********
-
- /**
- * Construct a "snapshot" list iterable for the specified list.
- * The {@link ListIterator} modify operations will not be supported
- * by the list iterator returned by {@link #iterator()}
- * unless a subclass overrides the list iterable's modify
- * method.
- */
- public SnapshotCloneListIterable(List<? extends E> list) {
- super();
- this.array = list.toArray();
- }
-
- /**
- * Construct a "snapshot" list iterable for the specified list.
- * The specified mutator will be used by any generated list iterators to
- * modify the original list.
- */
- public SnapshotCloneListIterable(List<? extends E> list, CloneListIterator.Mutator<E> mutator) {
- super(mutator);
- this.array = list.toArray();
- }
-
-
- // ********** ListIterable implementation **********
-
- public ListIterator<E> iterator() {
- return new LocalCloneListIterator<E>(this.mutator, this.array);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, Arrays.toString(this.array));
- }
-
-
- // ********** clone iterator **********
-
- /**
- * provide access to "internal" constructor
- */
- protected static class LocalCloneListIterator<E> extends CloneListIterator<E> {
- protected LocalCloneListIterator(Mutator<E> mutator, Object[] array) {
- super(mutator, array);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/StackIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/StackIterable.java
deleted file mode 100644
index 211fe3f61a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/StackIterable.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.Stack;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.StackIterator;
-
-/**
- * A <code>StackIterable</code> provides an {@link Iterable}
- * for a {@link Stack} of objects of type <code>E</code>. The stack's elements
- * are {@link Stack#pop() "popped"} as the iterable's iterator returns
- * them with calls to {@link Iterator#next()}.
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see Stack
- * @see StackIterator
- */
-public class StackIterable<E>
- implements Iterable<E>
-{
- private final Stack<E> stack;
-
- /**
- * Construct an iterable for the specified stack.
- */
- public StackIterable(Stack<E> stack) {
- super();
- this.stack = stack;
- }
-
- public Iterator<E> iterator() {
- return new StackIterator<E>(this.stack);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.stack);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SubIterableWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SubIterableWrapper.java
deleted file mode 100644
index 13f5cb058c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SubIterableWrapper.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.SubIteratorWrapper;
-
-/**
- * Wrap an iterable of elements of type <code>E1</code>, converting it into an
- * iterable of elements of type <code>E2</code>. <em>Assume</em> the wrapped
- * iterable contains only elements of type <code>E2</code>. The result is a
- * {@link ClassCastException} if this assumption is false.
- * <p>
- * This is like a {@link LateralIterableWrapper} but with more restrictive type
- * parameters.
- *
- * @param <E1> input: the type of elements contained by the wrapped iterable
- * @param <E2> output: the type of elements returned by the iterable's iterators
- *
- * @see SubIteratorWrapper
- */
-public class SubIterableWrapper<E1, E2 extends E1>
- implements Iterable<E2>
-{
- private final Iterable<E1> iterable;
-
-
- public SubIterableWrapper(Iterable<E1> iterable) {
- super();
- this.iterable = iterable;
- }
-
- public Iterator<E2> iterator() {
- return new SubIteratorWrapper<E1, E2>(this.iterable.iterator());
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterable);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SubListIterableWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SubListIterableWrapper.java
deleted file mode 100644
index d565d1bd1b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SubListIterableWrapper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.SubListIteratorWrapper;
-
-/**
- * Wrap a list iterable of elements of type <code>E1</code>, converting it into
- * a list iterable of elements of type <code>E2</code>. <em>Assume</em> the
- * wrapped iterable contains only elements of type <code>E2</code>.
- * The result is a {@link ClassCastException} if this assumption is false.
- * <p>
- * This is like a {@link LateralListIterableWrapper} but with more restrictive type
- * parameters.
- *
- * @param <E1> input: the type of elements contained by the wrapped list iterable
- * @param <E2> output: the type of elements returned by the iterable's list iterators
- *
- * @see SubListIteratorWrapper
- */
-public class SubListIterableWrapper<E1, E2 extends E1>
- implements ListIterable<E2>
-{
- private final ListIterable<E1> iterable;
-
-
- public SubListIterableWrapper(List<E1> list) {
- this(new ListListIterable<E1>(list));
- }
-
- public SubListIterableWrapper(ListIterable<E1> iterable) {
- super();
- this.iterable = iterable;
- }
-
- public ListIterator<E2> iterator() {
- return new SubListIteratorWrapper<E1, E2>(this.iterable.iterator());
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterable);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SuperIterableWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SuperIterableWrapper.java
deleted file mode 100644
index 0b3e83ea32..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SuperIterableWrapper.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Wrap an iterable of elements of any sub-type of <code>E</code>, converting it into an
- * iterable of elements of type <code>E</code>. This shouldn't be a problem since there
- * is no way to add invalid elements to the iterable.
- *
- * @param <E> the type of elements returned by the iterable's iterators
- */
-public class SuperIterableWrapper<E>
- implements Iterable<E>
-{
- private final Iterable<E> iterable;
-
-
- @SuppressWarnings("unchecked")
- public SuperIterableWrapper(Iterable<? extends E> iterable) {
- super();
- // this should be a safe cast - the iterator will only ever
- // return E (or a sub-type) from #next()
- this.iterable = (Iterable<E>) iterable;
- }
-
- public Iterator<E> iterator() {
- return this.iterable.iterator();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterable);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SuperListIterableWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SuperListIterableWrapper.java
deleted file mode 100644
index 7abe433983..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/SuperListIterableWrapper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.SuperListIteratorWrapper;
-
-/**
- * Wrap a list iterable of elements of any sub-type of <code>E</code>,
- * converting it into a <em>non-writable</em> list iterable of elements
- * of type <code>E</code>.
- * This shouldn't be a problem since the resulting list iterable's list
- * iterator disables the methods that would put invalid elements in the list
- * iterator's backing list (i.e. {@link SuperListIteratorWrapper#set(Object)}
- * and {@link SuperListIteratorWrapper#add(Object)}).
- *
- * @param <E> the type of elements returned by the iterable's iterators
- *
- * @see SuperListIteratorWrapper
- */
-public class SuperListIterableWrapper<E>
- implements ListIterable<E>
-{
- private final ListIterable<? extends E> iterable;
-
-
- public <T extends E> SuperListIterableWrapper(List<T> list) {
- this(new ListListIterable<T>(list));
- }
-
- public SuperListIterableWrapper(ListIterable<? extends E> iterable) {
- super();
- this.iterable = iterable;
- }
-
- public ListIterator<E> iterator() {
- return new SuperListIteratorWrapper<E>(this.iterable.iterator());
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterable);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TransformationIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TransformationIterable.java
deleted file mode 100644
index 124c15d07d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TransformationIterable.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-
-/**
- * A <code>TransformationIterable</code> wraps another {@link Iterable}
- * and transforms its elements for client consumption. To use, supply a
- * {@link Transformer} or subclass <code>TransformationIterable</code>
- * and override the {@link #transform(Object)} method.
- * Objects of type <code>E1</code> are transformed into objects of type <code>E2</code>;
- * i.e. the iterable's iterator returns objects of type <code>E2</code>.
- *
- * @param <E1> input: the type of elements to be transformed
- * @param <E2> output: the type of elements returned by the iterable's iterator
- *
- * @see TransformationIterator
- * @see TransformationListIterable
- */
-public class TransformationIterable<E1, E2>
- implements Iterable<E2>
-{
- private final Iterable<? extends E1> iterable;
- private final Transformer<E1, ? extends E2> transformer;
-
-
- /**
- * Construct an iterable with the specified nested iterable
- * and a default transformer that calls back to the iterable.
- * Use this constructor if you want to override the
- * {@link #transform(Object)} method instead of building
- * a {@link Transformer}.
- */
- public TransformationIterable(Iterable<? extends E1> iterable) {
- super();
- this.iterable = iterable;
- this.transformer = this.buildDefaultTransformer();
- }
-
- /**
- * Construct an iterable with the specified nested iterable
- * and transformer.
- */
- public TransformationIterable(Iterable<? extends E1> iterable, Transformer<E1, ? extends E2> transformer) {
- super();
- this.iterable = iterable;
- this.transformer = transformer;
- }
-
- protected Transformer<E1, ? extends E2> buildDefaultTransformer() {
- return new DefaultTransformer();
- }
-
- public Iterator<E2> iterator() {
- return new TransformationIterator<E1, E2>(this.iterable.iterator(), this.transformer);
- }
-
- /**
- * Transform the specified object and return the result.
- */
- protected E2 transform(@SuppressWarnings("unused") E1 o) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterable);
- }
-
-
- //********** default linker **********
-
- protected class DefaultTransformer implements Transformer<E1, E2> {
- public E2 transform(E1 o) {
- return TransformationIterable.this.transform(o);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TransformationListIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TransformationListIterable.java
deleted file mode 100644
index 0f2d058f57..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TransformationListIterable.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationListIterator;
-
-/**
- * A <code>TransformationListIterable</code> wraps another {@link ListIterable}
- * and transforms its elements for client consumption. To use, supply a
- * {@link Transformer} or subclass <code>TransformationListIterable</code>
- * and override the {@link #transform(Object)} method.
- * Objects of type <code>E1</code> are transformed into objects of type <code>E2</code>;
- * i.e. the list iterable's list iterator returns objects of type <code>E2</code>.
- *
- * @param <E1> input: the type of elements to be transformed
- * @param <E2> output: the type of elements returned by the iterable's iterator
- *
- * @see TransformationListIterator
- * @see TransformationIterable
- */
-public class TransformationListIterable<E1, E2>
- implements ListIterable<E2>
-{
- private final ListIterable<? extends E1> iterable;
- private final Transformer<E1, ? extends E2> transformer;
-
-
- /**
- * Construct a list iterable with the specified nested list
- * and a default transformer that calls back to the list iterable.
- * Use this constructor if you want to override the
- * {@link #transform(Object)} method instead of building
- * a {@link Transformer}.
- */
- public TransformationListIterable(List<E1> list) {
- this(new ListListIterable<E1>(list));
- }
-
- /**
- * Construct a list iterable with the specified nested list iterable
- * and a default transformer that calls back to the list iterable.
- * Use this constructor if you want to override the
- * {@link #transform(Object)} method instead of building
- * a {@link Transformer}.
- */
- public TransformationListIterable(ListIterable<? extends E1> iterable) {
- super();
- this.iterable = iterable;
- this.transformer = this.buildDefaultTransformer();
- }
-
- /**
- * Construct a list iterable with the specified nested list
- * and transformer.
- */
- public TransformationListIterable(List<E1> list, Transformer<E1, ? extends E2> transformer) {
- this(new ListListIterable<E1>(list), transformer);
- }
-
- /**
- * Construct a list iterable with the specified nested list iterable
- * and transformer.
- */
- public TransformationListIterable(ListIterable<? extends E1> iterable, Transformer<E1, ? extends E2> transformer) {
- super();
- this.iterable = iterable;
- this.transformer = transformer;
- }
-
- protected Transformer<E1, ? extends E2> buildDefaultTransformer() {
- return new DefaultTransformer();
- }
-
- public ListIterator<E2> iterator() {
- return new TransformationListIterator<E1, E2>(this.iterable.iterator(), this.transformer);
- }
-
- /**
- * Transform the specified object and return the result.
- */
- protected E2 transform(@SuppressWarnings("unused") E1 o) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterable);
- }
-
-
- //********** default linker **********
-
- protected class DefaultTransformer implements Transformer<E1, E2> {
- public E2 transform(E1 o) {
- return TransformationListIterable.this.transform(o);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TreeIterable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TreeIterable.java
deleted file mode 100644
index 8e3e1ff336..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterables/TreeIterable.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterables;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.TreeIterator;
-
-/**
- * A <code>TreeIterable</code> simplifies the traversal of a
- * tree of objects, where the objects' protocol(s) provides
- * a method for getting the immediate children of the given
- * node but does not provide a method for getting all the
- * descendants (children, grandchildren, etc.) of the given node.
- * <p>
- * To use, supply:<ul>
- * <li> either the root element of the tree or, if the tree has
- * multiple roots, an {@link Iterable} of the set of roots
- * <li> a {@link TreeIterator.Midwife} that delivers the children of each child
- * (alternatively, subclass <code>TreeIterable</code>
- * and override the {@link #children(Object)} method)
- * </ul>
- *
- * @param <E> the type of elements returned by the iterable's iterator
- *
- * @see TreeIterator
- */
-public class TreeIterable<E>
- implements Iterable<E>
-{
- private final Iterable<? extends E> roots;
- private final TreeIterator.Midwife<E> midwife;
-
-
- /**
- * Construct an iterable containing the nodes of a tree with the specified root
- * and a default midwife that calls back to the iterable.
- * Use this constructor if you want to override the
- * {@link #children(Object)} method instead of building
- * a {@link TreeIterator.Midwife}.
- */
- public TreeIterable(E root) {
- this(new SingleElementIterable<E>(root));
- }
-
- /**
- * Construct an iterable containing the nodes of a tree with the specified root
- * and midwife.
- */
- public TreeIterable(E root, TreeIterator.Midwife<E> midwife) {
- this(new SingleElementIterable<E>(root), midwife);
- }
-
- /**
- * Construct an iterable containing the nodes of a tree with the specified roots
- * and a default midwife that calls back to the iterable.
- * Use this constructor if you want to override the
- * {@link #children(Object)} method instead of building
- * a {@link TreeIterator.Midwife}.
- */
- public TreeIterable(E... roots) {
- this(Arrays.asList(roots));
- }
-
- /**
- * Construct an iterable containing the nodes of a tree with the specified roots
- * and midwife.
- */
- public TreeIterable(E[] roots, TreeIterator.Midwife<E> midwife) {
- this(Arrays.asList(roots), midwife);
- }
-
- /**
- * Construct an iterable containing the nodes of a tree with the specified roots
- * and a default midwife that calls back to the iterable.
- * Use this constructor if you want to override the
- * {@link #children(Object)} method instead of building
- * a {@link TreeIterator.Midwife}.
- */
- public TreeIterable(Iterable<? extends E> roots) {
- super();
- this.roots = roots;
- this.midwife = this.buildDefaultMidwife();
- }
-
- /**
- * Construct an iterable containing the nodes of a tree with the specified roots
- * and midwife.
- */
- public TreeIterable(Iterable<? extends E> roots, TreeIterator.Midwife<E> midwife) {
- super();
- this.roots = roots;
- this.midwife = midwife;
- }
-
- protected TreeIterator.Midwife<E> buildDefaultMidwife() {
- return new DefaultMidwife();
- }
-
- public Iterator<E> iterator() {
- return new TreeIterator<E>(this.roots, this.midwife);
- }
-
- /**
- * Return the immediate children of the specified object.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link TreeIterator.Midwife}.
- */
- protected Iterator<? extends E> children(@SuppressWarnings("unused") E next) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.roots);
- }
-
-
- //********** default midwife **********
-
- protected class DefaultMidwife implements TreeIterator.Midwife<E> {
- public Iterator<? extends E> children(E node) {
- return TreeIterable.this.children(node);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ArrayIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ArrayIterator.java
deleted file mode 100644
index 4b0e277339..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ArrayIterator.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * An <code>ArrayIterator</code> provides an {@link Iterator}
- * for an array of objects of type <code>E</code>.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable
- */
-public class ArrayIterator<E>
- implements Iterator<E>
-{
- final E[] array; // private-protected
- int cursor; // private-protected
- private final int max;
-
-
- /**
- * Construct an iterator for the specified array.
- */
- public ArrayIterator(E... array) {
- this(array, 0, array.length);
- }
-
- /**
- * Construct an iterator for the specified array,
- * starting at the specified start index and continuing for
- * the rest of the array.
- */
- public ArrayIterator(E[] array, int start) {
- this(array, start, array.length - start);
- }
-
- /**
- * Construct an iterator for the specified array,
- * starting at the specified start index and continuing for
- * the specified length.
- */
- public ArrayIterator(E[] array, int start, int length) {
- super();
- if ((start < 0) || (start > array.length)) {
- throw new IllegalArgumentException("start: " + start); //$NON-NLS-1$
- }
- if ((length < 0) || (length > array.length - start)) {
- throw new IllegalArgumentException("length: " + length); //$NON-NLS-1$
- }
- this.array = array;
- this.cursor = start;
- this.max = start + length;
- }
-
- public boolean hasNext() {
- return this.cursor != this.max;
- }
-
- public E next() {
- if (this.hasNext()) {
- return this.array[this.cursor++];
- }
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, Arrays.toString(this.array));
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ArrayListIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ArrayListIterator.java
deleted file mode 100644
index b08cfe9092..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ArrayListIterator.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-/**
- * An <code>ArrayListIterator</code> provides a {@link ListIterator}
- * for an array of objects.
- * <p>
- * The name might be a bit confusing:
- * This is a {@link ListIterator} for an <code>Array</code>;
- * <em>not</em> an {@link java.util.Iterator Iterator} for an
- * {@link java.util.ArrayList ArrayList}.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable
- */
-public class ArrayListIterator<E>
- extends ArrayIterator<E>
- implements ListIterator<E>
-{
- private final int min;
-
-
- /**
- * Construct a list iterator for the specified array.
- */
- public ArrayListIterator(E... array) {
- this(array, 0, array.length);
- }
-
- /**
- * Construct a list iterator for the specified array,
- * starting at the specified start index and continuing for
- * the rest of the array.
- */
- public ArrayListIterator(E[] array, int start) {
- this(array, start, array.length - start);
- }
-
- /**
- * Construct a list iterator for the specified array,
- * starting at the specified start index and continuing for
- * the specified length.
- */
- public ArrayListIterator(E[] array, int start, int length) {
- super(array, start, length);
- this.min = start;
- }
-
- public int nextIndex() {
- return this.cursor;
- }
-
- public int previousIndex() {
- return this.cursor - 1;
- }
-
- public boolean hasPrevious() {
- return this.cursor != this.min;
- }
-
- public E previous() {
- if (this.hasPrevious()) {
- return this.array[--this.cursor];
- }
- throw new NoSuchElementException();
- }
-
- public void add(E e) {
- throw new UnsupportedOperationException();
- }
-
- public void set(E e) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return super.toString();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ChainIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ChainIterator.java
deleted file mode 100644
index 16eb696d05..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ChainIterator.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>ChainIterator</code> provides a pluggable {@link Iterator}
- * that loops over a chain of arbitrarily linked objects. The chain
- * should be null-terminated (i.e. a call to the {@link #nextLink(Object)}
- * method should return <code>null</code> when it is passed the last
- * link of the chain).
- * To use, supply a starting link and supply a {@link Linker} or
- * subclass <code>ChainIterator</code> and override the
- * {@link #nextLink(Object)} method.
- * The starting link will be the first object returned by the iterator.
- * If the starting link is <code>null</code>, the iterator will be empty.
- * Note this iterator does not support <code>null</code> elements.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.ChainIterable
- */
-public class ChainIterator<E>
- implements Iterator<E>
-{
- private E nextLink;
- private final Linker<E> linker;
-
-
- /**
- * Construct an iterator with the specified starting link
- * and a disabled linker.
- * Use this constructor if you want to override the
- * {@link #nextLink(Object)} method instead of building
- * a {@link Linker}.
- */
- public ChainIterator(E startLink) {
- this(startLink, Linker.Disabled.<E>instance());
- }
-
- /**
- * Construct an iterator with the specified starting link
- * and linker.
- */
- public ChainIterator(E startLink, Linker<E> linker) {
- super();
- this.nextLink = startLink;
- this.linker = linker;
- }
-
- public boolean hasNext() {
- return this.nextLink != null;
- }
-
- public E next() {
- if (this.nextLink == null) {
- throw new NoSuchElementException();
- }
- E result = this.nextLink;
- this.nextLink = this.nextLink(this.nextLink);
- return result;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Return the next link in the chain; null if there are no more links.
- */
- protected E nextLink(E currentLink) {
- return this.linker.nextLink(currentLink);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.nextLink);
- }
-
-
- //********** member interface **********
-
- /**
- * Used by {@link ChainIterator} to link
- * the elements in the chain.
- */
- public interface Linker<T> {
-
- /**
- * Return the next link in the chain; null if there are no more links.
- */
- T nextLink(T currentLink);
-
-
- final class Null<S>
- implements Linker<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Linker INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R> Linker<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // simply return null, indicating the chain is ended
- public S nextLink(S currentLink) {
- return null;
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
-
- final class Disabled<S>
- implements Linker<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Linker INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> Linker<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public S nextLink(S currentLink) {
- throw new UnsupportedOperationException(); // ChainIterator.nextLink(Object) was not implemented
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CloneIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CloneIterator.java
deleted file mode 100644
index 5b70feba9a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CloneIterator.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>CloneIterator</code> iterates over a copy of a collection,
- * allowing for concurrent access to the original collection.
- * <p>
- * The original collection passed to the <code>CloneIterator</code>'s
- * constructor should be synchronized (e.g. {@link java.util.Vector});
- * otherwise you run the risk of a corrupted collection.
- * <p>
- * By default, a <code>CloneIterator</code> does not support the
- * {@link #remove()} operation; this is because it does not have
- * access to the original collection. But if the <code>CloneIterator</code>
- * is supplied with an {@link Remover} it will delegate the
- * {@link #remove()} operation to the {@link Remover}.
- * Alternatively, a subclass can override the {@link #remove(Object)}
- * method.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable
- * @see org.eclipse.jpt.common.utility.internal.iterables.SnapshotCloneIterable
- */
-public class CloneIterator<E>
- implements Iterator<E>
-{
- private final Iterator<Object> iterator;
- private E current;
- private final Remover<E> remover;
- private boolean removeAllowed;
-
-
- // ********** constructors **********
-
- /**
- * Construct an iterator on a copy of the specified collection.
- * The {@link #remove()} method will not be supported,
- * unless a subclass overrides the {@link #remove(Object)}.
- */
- public CloneIterator(Collection<? extends E> collection) {
- this(collection, Remover.ReadOnly.<E>instance());
- }
-
- /**
- * Construct an iterator on a copy of the specified array.
- * The {@link #remove()} method will not be supported,
- * unless a subclass overrides the {@link #remove(Object)}.
- */
- public CloneIterator(E[] array) {
- this(array, Remover.ReadOnly.<E>instance());
- }
-
- /**
- * Construct an iterator on a copy of the specified collection.
- * Use the specified remover to remove objects from the
- * original collection.
- */
- public CloneIterator(Collection<? extends E> collection, Remover<E> remover) {
- this(remover, collection.toArray());
- }
-
- /**
- * Construct an iterator on a copy of the specified array.
- * Use the specified remover to remove objects from the
- * original array.
- */
- public CloneIterator(E[] array, Remover<E> remover) {
- this(remover, array.clone());
- }
-
- /**
- * Internal constructor used by subclasses.
- * Swap order of arguments to prevent collision with other constructor.
- * The passed in array will *not* be cloned.
- */
- protected CloneIterator(Remover<E> remover, Object... array) {
- super();
- this.iterator = new ArrayIterator<Object>(array);
- this.current = null;
- this.remover = remover;
- this.removeAllowed = false;
- }
-
-
- // ********** Iterator implementation **********
-
- public boolean hasNext() {
- return this.iterator.hasNext();
- }
-
- public E next() {
- this.current = this.nestedNext();
- this.removeAllowed = true;
- return this.current;
- }
-
- public void remove() {
- if ( ! this.removeAllowed) {
- throw new IllegalStateException();
- }
- this.remove(this.current);
- this.removeAllowed = false;
- }
-
-
- // ********** internal methods **********
-
- /**
- * The collection passed in during construction held elements of type <code>E</code>,
- * so this cast is not a problem. We need this cast because
- * all the elements of the original collection were copied into
- * an object array (<code>Object[]</code>).
- */
- @SuppressWarnings("unchecked")
- protected E nestedNext() {
- return (E) this.iterator.next();
- }
-
- /**
- * Remove the specified element from the original collection.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link Remover}.
- */
- protected void remove(E e) {
- this.remover.remove(e);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-
- //********** member interface **********
-
- /**
- * Used by {@link CloneIterator} to remove
- * elements from the original collection; since the iterator
- * does not have direct access to the original collection.
- */
- public interface Remover<T> {
-
- /**
- * Remove the specified object from the original collection.
- */
- void remove(T element);
-
-
- final class ReadOnly<S>
- implements Remover<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Remover INSTANCE = new ReadOnly();
- @SuppressWarnings("unchecked")
- public static <R> Remover<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private ReadOnly() {
- super();
- }
- // remove is not supported
- public void remove(Object element) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CloneListIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CloneListIterator.java
deleted file mode 100644
index 66bc0ca42f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CloneListIterator.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>CloneListIterator</code> iterates over a copy of a list,
- * allowing for concurrent access to the original list.
- * <p>
- * The original list passed to the <code>CloneListIterator</code>'s
- * constructor should be synchronized; otherwise you run the risk of
- * a corrupted list (e.g. {@link java.util.Vector}.
- * <p>
- * By default, a <code>CloneListIterator</code> does not support the
- * modification operations; this is because it does not have
- * access to the original list. But if the <code>CloneListIterator</code>
- * is supplied with a {@link Mutator} it will delegate the
- * modification operations to the {@link Mutator}.
- * Alternatively, a subclass can override the modification methods.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable
- * @see org.eclipse.jpt.common.utility.internal.iterables.SnapshotCloneListIterable
- */
-public class CloneListIterator<E>
- implements ListIterator<E>
-{
- private final ListIterator<Object> listIterator;
- private int cursor;
- private State state;
- private final Mutator<E> mutator;
-
- private enum State {
- UNKNOWN,
- PREVIOUS,
- NEXT
- }
-
-
- // ********** constructors **********
-
- /**
- * Construct a list iterator on a copy of the specified list.
- * The modification methods will not be supported,
- * unless a subclass overrides them.
- */
- public CloneListIterator(List<? extends E> list) {
- this(list, Mutator.ReadOnly.<E>instance());
- }
-
- /**
- * Construct a list iterator on a copy of the specified array.
- * The modification methods will not be supported,
- * unless a subclass overrides them.
- */
- public CloneListIterator(E[] array) {
- this(array, Mutator.ReadOnly.<E>instance());
- }
-
- /**
- * Construct a list iterator on a copy of the specified list.
- * Use the specified list mutator to modify the original list.
- */
- public CloneListIterator(List<? extends E> list, Mutator<E> mutator) {
- this(mutator, list.toArray());
- }
-
- /**
- * Construct a list iterator on a copy of the specified array.
- * Use the specified list mutator to modify the original list.
- */
- public CloneListIterator(E[] array, Mutator<E> mutator) {
- this(mutator, array.clone());
- }
-
- /**
- * Internal constructor used by subclasses.
- * Swap order of arguments to prevent collision with other constructor.
- * The passed in array will *not* be cloned.
- */
- protected CloneListIterator(Mutator<E> mutator, Object... array) {
- super();
- // build a copy of the list and keep it in sync with original (if the mutator allows changes)
- // that way the nested list iterator will maintain some of our state
- this.listIterator = CollectionTools.list(array).listIterator();
- this.mutator = mutator;
- this.cursor = 0;
- this.state = State.UNKNOWN;
- }
-
-
- // ********** ListIterator implementation **********
-
- public boolean hasNext() {
- return this.listIterator.hasNext();
- }
-
- public E next() {
- // allow the nested iterator to throw an exception before we modify the index
- E next = this.nestedNext();
- this.cursor++;
- this.state = State.NEXT;
- return next;
- }
-
- public void remove() {
- // allow the nested iterator to throw an exception before we modify the original list
- this.listIterator.remove();
- if (this.state == State.PREVIOUS) {
- this.remove(this.cursor);
- } else {
- this.cursor--;
- this.remove(this.cursor);
- }
- }
-
- public int nextIndex() {
- return this.listIterator.nextIndex();
- }
-
- public int previousIndex() {
- return this.listIterator.previousIndex();
- }
-
- public boolean hasPrevious() {
- return this.listIterator.hasPrevious();
- }
-
- public E previous() {
- // allow the nested iterator to throw an exception before we modify the index
- E previous = this.nestedPrevious();
- this.cursor--;
- this.state = State.PREVIOUS;
- return previous;
- }
-
- public void add(E o) {
- // allow the nested iterator to throw an exception before we modify the original list
- this.listIterator.add(o);
- this.add(this.cursor, o);
- this.cursor++;
- }
-
- public void set(E o) {
- // allow the nested iterator to throw an exception before we modify the original list
- this.listIterator.set(o);
- if (this.state == State.PREVIOUS) {
- this.set(this.cursor, o);
- } else {
- this.set(this.cursor - 1, o);
- }
- }
-
-
- // ********** internal methods **********
-
- /**
- * The list passed in during construction held elements of type <code>E</code>,
- * so this cast is not a problem. We need this cast because
- * all the elements of the original collection were copied into
- * an object array (<code>Object[]</code>).
- */
- @SuppressWarnings("unchecked")
- protected E nestedNext() {
- return (E) this.listIterator.next();
- }
-
- /**
- * The list passed in during construction held elements of type <code>E</code>,
- * so this cast is not a problem. We need this cast because
- * all the elements of the original collection were copied into
- * an object array (<code>Object[]</code>).
- */
- @SuppressWarnings("unchecked")
- protected E nestedPrevious() {
- return (E) this.listIterator.previous();
- }
-
- /**
- * Add the specified element to the original list.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link Mutator}.
- */
- protected void add(int index, E o) {
- this.mutator.add(index, o);
- }
-
- /**
- * Remove the specified element from the original list.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link Mutator}.
- */
- protected void remove(int index) {
- this.mutator.remove(index);
- }
-
- /**
- * Set the specified element in the original list.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link Mutator}.
- */
- protected void set(int index, E o) {
- this.mutator.set(index, o);
- }
-
-
- // ********** overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-
-
- //********** member interface **********
-
- /**
- * Used by {@link CloneListIterator} to remove
- * elements from the original list; since the list iterator
- * does not have direct access to the original list.
- */
- public interface Mutator<T> {
-
- /**
- * Add the specified object to the original list.
- */
- void add(int index, T o);
-
- /**
- * Remove the specified object from the original list.
- */
- void remove(int index);
-
- /**
- * Set the specified object in the original list.
- */
- void set(int index, T o);
-
-
- final class ReadOnly<S>
- implements Mutator<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Mutator INSTANCE = new ReadOnly();
- @SuppressWarnings("unchecked")
- public static <R> Mutator<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private ReadOnly() {
- super();
- }
- // add is not supported
- public void add(int index, Object o) {
- throw new UnsupportedOperationException();
- }
- // remove is not supported
- public void remove(int index) {
- throw new UnsupportedOperationException();
- }
- // set is not supported
- public void set(int index, Object o) {
- throw new UnsupportedOperationException();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CompositeIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CompositeIterator.java
deleted file mode 100644
index 02ad76d9d0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CompositeIterator.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-
-/**
- * A <code>CompositeIterator</code> wraps a collection
- * of {@link Iterator}s and makes them appear to be a single
- * {@link Iterator}.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable
- */
-public class CompositeIterator<E>
- implements Iterator<E>
-{
- private final Iterator<? extends Iterator<? extends E>> iterators;
- private Iterator<? extends E> currentIterator;
- private Iterator<? extends E> lastIteratorToReturnNext;
-
-
- // ********** constructors **********
-
- /**
- * Construct an iterator that returns all the elements held by the
- * specified iterables.
- */
- public CompositeIterator(Iterable<? extends Iterable<? extends E>> iterables) {
- this(
- new TransformationIterator<Iterable<? extends E>, Iterator<? extends E>>(iterables.iterator()) {
- @Override
- protected Iterator<? extends E> transform(Iterable<? extends E> iterable) {
- return iterable.iterator();
- }
- }
- );
- }
-
- /**
- * Construct an iterator with the specified collection of iterators.
- */
- public CompositeIterator(Iterator<? extends Iterator<? extends E>> iterators) {
- super();
- this.iterators = iterators;
- }
-
- /**
- * Construct an iterator with the specified object prepended
- * to the specified iterable.
- */
- public CompositeIterator(E object, Iterable<? extends E> iterable) {
- this(object, iterable.iterator());
- }
-
- /**
- * Construct an iterator with the specified object prepended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public CompositeIterator(E object, Iterator<? extends E> iterator) {
- this(new SingleElementIterator<E>(object), iterator);
- }
-
- /**
- * Construct an iterator with the specified object appended
- * to the specified iterable.
- */
- public CompositeIterator(Iterable<? extends E> iterable, E object) {
- this(iterable.iterator(), object);
- }
-
- /**
- * Construct an iterator with the specified object appended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public CompositeIterator(Iterator<? extends E> iterator, E object) {
- this(iterator, new SingleElementIterator<E>(object));
- }
-
- /**
- * Construct an iterator with the specified iterables.
- */
- public CompositeIterator(Iterable<? extends E>... iterables) {
- this(new ArrayIterable<Iterable<? extends E>>(iterables));
- }
-
- /**
- * Construct an iterator with the specified iterators.
- */
- public CompositeIterator(Iterator<? extends E>... iterators) {
- this(new ArrayIterator<Iterator<? extends E>>(iterators));
- }
-
-
- // ********** Iterator implementation **********
-
- public boolean hasNext() {
- try {
- this.loadCurrentIterator();
- } catch (NoSuchElementException ex) {
- // this occurs if there are no iterators at all
- return false;
- }
- return this.currentIterator.hasNext();
- }
-
- public E next() {
- this.loadCurrentIterator();
- E result = this.currentIterator.next();
-
- // the statement above will throw a NoSuchElementException
- // if the current iterator is at the end of the line;
- // so if we get here, we can set 'lastIteratorToReturnNext'
- this.lastIteratorToReturnNext = this.currentIterator;
-
- return result;
- }
-
- public void remove() {
- if (this.lastIteratorToReturnNext == null) {
- // CompositeIterator#next() has never been called
- throw new IllegalStateException();
- }
- this.lastIteratorToReturnNext.remove();
- }
-
- /**
- * Load {@link #currentIterator} with the first iterator that {@link Iterator#hasNext()}
- * or the final iterator if all the elements have already been retrieved.
- */
- private void loadCurrentIterator() {
- if (this.currentIterator == null) {
- this.currentIterator = this.iterators.next();
- }
- while (( ! this.currentIterator.hasNext()) && this.iterators.hasNext()) {
- this.currentIterator = this.iterators.next();
- }
- }
-
-
- // ********** overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterators);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CompositeListIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CompositeListIterator.java
deleted file mode 100644
index 3111451a92..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/CompositeListIterator.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-/**
- * A <code>CompositeListIterator</code> wraps a list
- * of {@link ListIterator}s and makes them appear to be a single
- * {@link ListIterator}.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.CompositeListIterable
- */
-public class CompositeListIterator<E>
- implements ListIterator<E>
-{
- private final ListIterator<? extends ListIterator<E>> iterators;
- private ListIterator<E> nextIterator;
- private int nextIndex;
- /**
- * <code>true</code> if "next" was last returned;
- * <code>false</code> if "previous" was last returned;
- * this determines the effect of {@link #remove()} on {@link #nextIndex}
- */
- private boolean nextReturned;
- private ListIterator<E> lastIteratorToReturnElement;
-
-
- /**
- * Construct a list iterator on the elements in the specified list of lists.
- */
- public CompositeListIterator(List<? extends List<E>> lists) {
- this(
- new TransformationListIterator<List<E>, ListIterator<E>>(lists.listIterator()) {
- @Override
- protected ListIterator<E> transform(List<E> list) {
- return list.listIterator();
- }
- }
- );
- }
-
- /**
- * Construct a list iterator on the elements in the specified list of lists.
- */
- public CompositeListIterator(ListIterable<? extends ListIterable<E>> listIterables) {
- this(
- new TransformationListIterator<ListIterable<E>, ListIterator<E>>(listIterables.iterator()) {
- @Override
- protected ListIterator<E> transform(ListIterable<E> list) {
- return list.iterator();
- }
- }
- );
- }
-
- /**
- * Construct a list iterator with the specified list of list iterators.
- */
- public CompositeListIterator(ListIterator<? extends ListIterator<E>> iterators) {
- super();
- this.iterators = iterators;
- this.nextIndex = 0;
- this.nextReturned = false;
- }
-
- /**
- * Construct a list iterator with the specified object prepended
- * to the specified list.
- */
- public CompositeListIterator(E object, List<E> list) {
- this(object, list.listIterator());
- }
-
- /**
- * Construct a list iterator with the specified object prepended
- * to the specified list.
- */
- public CompositeListIterator(E object, ListIterable<E> listIterable) {
- this(object, listIterable.iterator());
- }
-
- /**
- * Construct a list iterator with the specified object prepended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public CompositeListIterator(E object, ListIterator<E> iterator) {
- this(new SingleElementListIterator<E>(object), iterator);
- }
-
- /**
- * Construct a list iterator with the specified object appended
- * to the specified list.
- */
- public CompositeListIterator(List<E> list, E object) {
- this(list.listIterator(), object);
- }
-
- /**
- * Construct a list iterator with the specified object appended
- * to the specified list.
- */
- public CompositeListIterator(ListIterable<E> listIterable, E object) {
- this(listIterable.iterator(), object);
- }
-
- /**
- * Construct a list iterator with the specified object appended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public CompositeListIterator(ListIterator<E> iterator, E object) {
- this(iterator, new SingleElementListIterator<E>(object));
- }
-
- /**
- * Construct a list iterator with the specified lists.
- */
- public CompositeListIterator(List<E>... lists) {
- this(Arrays.asList(lists));
- }
-
- /**
- * Construct a list iterator with the specified lists.
- */
- public CompositeListIterator(ListIterable<E>... listIterables) {
- this(new ArrayListIterable<ListIterable<E>>(listIterables));
- }
-
- /**
- * Construct a list iterator with the specified list iterators.
- */
- public CompositeListIterator(ListIterator<E>... iterators) {
- this(new ArrayListIterator<ListIterator<E>>(iterators));
- }
-
- public void add(E o) {
- this.checkNextIterator();
- this.nextIterator.add(o);
- this.nextIndex++;
- }
-
- public boolean hasNext() {
- try {
- this.loadNextIterator();
- } catch (NoSuchElementException ex) {
- // this occurs if there are no iterators at all
- return false;
- }
- return this.nextIterator.hasNext();
- }
-
- public boolean hasPrevious() {
- try {
- this.loadPreviousIterator();
- } catch (NoSuchElementException ex) {
- // this occurs if there are no iterators at all
- return false;
- }
- return this.nextIterator.hasPrevious();
- }
-
- public E next() {
- this.loadNextIterator();
- E result = this.nextIterator.next();
-
- // the statement above will throw a NoSuchElementException
- // if the current iterator is at the end of the line;
- // so if we get here, we can set the 'lastIteratorToReturnElement'
- this.lastIteratorToReturnElement = this.nextIterator;
- this.nextIndex++;
- this.nextReturned = true;
-
- return result;
- }
-
- public int nextIndex() {
- return this.nextIndex;
- }
-
- public E previous() {
- this.loadPreviousIterator();
- E result = this.nextIterator.previous();
-
- // the statement above will throw a NoSuchElementException
- // if the current iterator is at the end of the line;
- // so if we get here, we can set the 'lastIteratorToReturnElement'
- this.lastIteratorToReturnElement = this.nextIterator;
- this.nextIndex--;
- this.nextReturned = false;
-
- return result;
- }
-
- public int previousIndex() {
- return this.nextIndex - 1;
- }
-
- public void remove() {
- if (this.lastIteratorToReturnElement == null) {
- throw new IllegalStateException();
- }
- this.lastIteratorToReturnElement.remove();
- if (this.nextReturned) {
- // decrement the index because the "next" element has moved forward in the list
- this.nextIndex--;
- }
- }
-
- public void set(E e) {
- if (this.lastIteratorToReturnElement == null) {
- throw new IllegalStateException();
- }
- this.lastIteratorToReturnElement.set(e);
- }
-
- /**
- * Load 'nextIterator' with the first iterator that <code>hasNext()</code>
- * or the final iterator if all the elements have already been retrieved.
- */
- private void loadNextIterator() {
- this.checkNextIterator();
- while (( ! this.nextIterator.hasNext()) && this.iterators.hasNext()) {
- this.nextIterator = this.iterators.next();
- }
- }
-
- /**
- * Load 'nextIterator' with the first iterator that <code>hasPrevious()</code>
- * or the first iterator if all the elements have already been retrieved.
- */
- private void loadPreviousIterator() {
- this.checkNextIterator();
- while (( ! this.nextIterator.hasPrevious()) && this.iterators.hasPrevious()) {
- this.nextIterator = this.iterators.previous();
- }
- }
-
- /**
- * If 'nextIterator' is null, load it with the first iterator.
- */
- private void checkNextIterator() {
- if (this.nextIterator == null) {
- this.nextIterator = this.iterators.next();
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterators);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EmptyIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EmptyIterator.java
deleted file mode 100644
index 89d38f0d34..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EmptyIterator.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-/**
- * An <code>EmptyIterator</code> is just that.
- *
- * @param <E> the type of elements (not) returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable
- */
-public final class EmptyIterator<E>
- implements Iterator<E>, Serializable
-{
- // singleton
- @SuppressWarnings("rawtypes")
- private static final EmptyIterator INSTANCE = new EmptyIterator();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <T> Iterator<T> instance() {
- return INSTANCE;
- }
-
-
- /**
- * Ensure single instance.
- */
- private EmptyIterator() {
- super();
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public E next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EmptyListIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EmptyListIterator.java
deleted file mode 100644
index cd8f7edb06..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EmptyListIterator.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.io.Serializable;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-/**
- * An <code>EmptyListIterator</code> is just that.
- *
- * @param <E> the type of elements (not) returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable
- */
-public final class EmptyListIterator<E>
- implements ListIterator<E>, Serializable
-{
- // singleton
- @SuppressWarnings("rawtypes")
- private static final EmptyListIterator INSTANCE = new EmptyListIterator();
-
- /**
- * Return the singleton.
- */
- @SuppressWarnings("unchecked")
- public static <T> ListIterator<T> instance() {
- return INSTANCE;
- }
-
-
- /**
- * Ensure single instance.
- */
- private EmptyListIterator() {
- super();
- }
-
- public void add(E e) {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public boolean hasPrevious() {
- return false;
- }
-
- public E next() {
- throw new NoSuchElementException();
- }
-
- public int nextIndex() {
- return 0;
- }
-
- public E previous() {
- throw new NoSuchElementException();
- }
-
- public int previousIndex() {
- return -1;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public void set(E e) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EnumerationIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EnumerationIterator.java
deleted file mode 100644
index d8e9d38e25..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/EnumerationIterator.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * An <code>EnumerationIterator</code> wraps an
- * {@link Enumeration} so that it can be treated like an
- * {@link Iterator}.
- *
- * @param <E> the type of elements returned by the iterator
- */
-public class EnumerationIterator<E>
- implements Iterator<E>
-{
- private final Enumeration<? extends E> enumeration;
-
- /**
- * Construct an iterator that wraps the specified enumeration.
- */
- public EnumerationIterator(Enumeration<? extends E> enumeration) {
- this.enumeration = enumeration;
- }
-
- public boolean hasNext() {
- return this.enumeration.hasMoreElements();
- }
-
- public E next() {
- return this.enumeration.nextElement();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.enumeration);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/FilteringIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/FilteringIterator.java
deleted file mode 100644
index 4c3176c9d4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/FilteringIterator.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>FilteringIterator</code> wraps another {@link Iterator}
- * and uses a {@link Filter} to determine which elements in the
- * nested iterator are to be returned by calls to {@link #next()}.
- * <p>
- * As an alternative to building a {@link Filter}, a subclass
- * of <code>FilteringIterator</code> can override the
- * {@link #accept(Object)} method.
- * <p>
- * One, possibly undesirable, side-effect of using this iterator is that
- * the nested iterator's <code>next()</code> method will be invoked
- * <em>before</em> the filtered iterator's {@link #next()}
- * method is invoked. This is because the "next" element must be
- * checked for whether it is to be accepted before the filtered iterator
- * can determine whether it has a "next" element (i.e. that the
- * {@link #hasNext()} method should return <code>true</code>).
- * This also prevents a filtered iterator from supporting the optional
- * <code>remove()</code> method.
- *
- * @param <E> the type of elements to be filtered
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable
- */
-public class FilteringIterator<E>
- implements Iterator<E>
-{
- private final Iterator<? extends E> iterator;
- private final Filter<E> filter;
- private E next;
- private boolean done;
-
-
- /**
- * Construct an iterator with the specified
- * iterable and a disabled filter.
- * Use this constructor if you want to override the
- * {@link #accept(Object)} method instead of building
- * a {@link Filter}.
- */
- public FilteringIterator(Iterable<? extends E> iterable) {
- this(iterable.iterator());
- }
-
- /**
- * Construct an iterator with the specified nested
- * iterator and a disabled filter.
- * Use this constructor if you want to override the
- * {@link #accept(Object)} method instead of building
- * a {@link Filter}.
- */
- public FilteringIterator(Iterator<? extends E> iterator) {
- this(iterator, Filter.Disabled.<E>instance());
- }
-
- /**
- * Construct an iterator with the specified
- * iterable and filter.
- */
- public FilteringIterator(Iterable<? extends E> iterable, Filter<E> filter) {
- this(iterable.iterator(), filter);
- }
-
- /**
- * Construct an iterator with the specified nested
- * iterator and filter.
- */
- public FilteringIterator(Iterator<? extends E> iterator, Filter<E> filter) {
- super();
- this.iterator = iterator;
- this.filter = filter;
- this.loadNext();
- }
-
- public boolean hasNext() {
- return ! this.done;
- }
-
- public E next() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- E result = this.next;
- this.loadNext();
- return result;
- }
-
- /**
- * Because we need to pre-load the next element
- * to be returned, we cannot support the <code>remove()</code>
- * method.
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Load next with the next valid entry from the nested
- * iterator. If there are none, next is set to <code>END</code>.
- */
- private void loadNext() {
- this.done = true;
- while (this.iterator.hasNext() && (this.done)) {
- E temp = this.iterator.next();
- if (this.accept(temp)) {
- // assume that if the object was accepted it is of type E
- this.next = temp;
- this.done = false;
- } else {
- this.next = null;
- this.done = true;
- }
- }
- }
-
- /**
- * Return whether the {@link FilteringIterator}
- * should return the specified next element from a call to the
- * {@link #next()} method.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link Filter}.
- */
- protected boolean accept(E o) {
- return this.filter.accept(o);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterator);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/GraphIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/GraphIterator.java
deleted file mode 100644
index 3add6cbd4d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/GraphIterator.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>GraphIterator</code> is similar to a {@link TreeIterator}
- * except that it cannot be assumed that all nodes assume a strict tree
- * structure. For instance, in a tree, a node cannot be a descendent of
- * itself, but a graph may have a cyclical structure.
- *
- * A <code>GraphIterator</code> simplifies the traversal of a
- * graph of objects, where the objects' protocol(s) provides
- * a method for getting the next collection of nodes in the graph,
- * (or <em>neighbors</em>), but does not provide a method for
- * getting <em>all</em> of the nodes in the graph.
- * (e.g. a neighbor can return his neighbors, and those neighbors
- * can return their neighbors, which might also include the original
- * neighbor, but you only want to visit the original neighbor once.)
- * <p>
- * If a neighbor has already been visited (determined by using
- * {@link #equals(Object)}), that neighbor is not visited again,
- * nor are the neighbors of that object.
- * <p>
- * It is up to the user of this class to ensure a <em>complete</em> graph.
- * <p>
- * To use, supply:<ul>
- * <li> either the initial node of the graph or an {@link Iterator}
- * over an initial collection of graph nodes
- * <li> a {@link MisterRogers} that tells who the neighbors are
- * of each node
- * (alternatively, subclass <code>GraphIterator</code>
- * and override the {@link #neighbors(Object)} method)
- * </ul>
- * {@link #remove()} is not supported. This behavior, if
- * desired, must be implemented by the user of this class.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.GraphIterable
- */
-public class GraphIterator<E>
- implements Iterator<E>
-{
- // use a LinkedList since we will be pulling off the front and adding to the end
- private final LinkedList<Iterator<? extends E>> iterators = new LinkedList<Iterator<? extends E>>();
- private final HashSet<E> visitedNeighbors = new HashSet<E>();
- private final MisterRogers<E> misterRogers;
-
- private Iterator<? extends E> currentIterator;
-
- private E nextNeighbor;
- private boolean done;
-
-
- /**
- * Construct an iterator that returns the nodes of a graph
- * with the specified collection of roots
- * and a disabled Mr. Rogers.
- * Use this constructor if you want to override the
- * {@link #neighbors(Object)} method instead of building
- * a {@link MisterRogers}.
- */
- public GraphIterator(E... roots) {
- this(new ArrayIterator<E>(roots));
- }
-
- /**
- * Construct an iterator that returns the nodes of a graph
- * with the specified collection of roots
- * and a disabled Mr. Rogers.
- * Use this constructor if you want to override the
- * {@link #neighbors(Object)} method instead of building
- * a {@link MisterRogers}.
- */
- public GraphIterator(Iterable<? extends E> roots) {
- this(roots.iterator());
- }
-
- /**
- * Construct an iterator that returns the nodes of a graph
- * with the specified collection of roots
- * and a disabled Mr. Rogers.
- * Use this constructor if you want to override the
- * {@link #neighbors(Object)} method instead of building
- * a {@link MisterRogers}.
- */
- public GraphIterator(Iterator<? extends E> roots) {
- this(roots, MisterRogers.Disabled.<E>instance());
- }
-
- /**
- * Construct an iterator that returns the nodes of a graph
- * with the specified root
- * and a disabled Mr. Rogers.
- * Use this constructor if you want to override the
- * <code>neighbors(Object)</code> method instead of building
- * a <code>MisterRogers</code>.
- */
- public GraphIterator(E root) {
- this(root, MisterRogers.Disabled.<E>instance());
- }
-
- /**
- * Construct an iterator that returns the nodes of a graph
- * with the specified root and Mr. Rogers.
- */
- public GraphIterator(E root, MisterRogers<E> misterRogers) {
- this(new SingleElementIterator<E>(root), misterRogers);
- }
-
- /**
- * Construct an iterator that returns the nodes of a graph
- * with the specified collection of roots and Mr. Rogers.
- */
- public GraphIterator(E[] roots, MisterRogers<E> misterRogers) {
- this(new ArrayIterator<E>(roots), misterRogers);
- }
-
- /**
- * Construct an iterator that returns the nodes of a graph
- * with the specified roots and Mr. Rogers.
- */
- public GraphIterator(Iterable<? extends E> roots, MisterRogers<E> misterRogers) {
- this(roots.iterator(), misterRogers);
- }
-
- /**
- * Construct an iterator that returns the nodes of a graph
- * with the specified roots and Mr. Rogers.
- */
- public GraphIterator(Iterator<? extends E> roots, MisterRogers<E> misterRogers) {
- super();
- this.currentIterator = roots;
- this.misterRogers = misterRogers;
- this.loadNextNeighbor();
- }
-
- /**
- * Load next neighbor with the next entry from the current iterator.
- * If the current iterator has none, load the next iterator.
- * If there are no more, the {@link #done} flag is set.
- */
- private void loadNextNeighbor() {
- if (this.currentIterator == EmptyIterator.instance()) {
- this.done = true;
- }
- else if (this.currentIterator.hasNext()) {
- E nextPossibleNeighbor = this.currentIterator.next();
- if (this.visitedNeighbors.contains(nextPossibleNeighbor)) {
- this.loadNextNeighbor(); // recurse
- } else {
- this.nextNeighbor = nextPossibleNeighbor;
- this.visitedNeighbors.add(nextPossibleNeighbor);
- this.iterators.add(this.neighbors(nextPossibleNeighbor));
- }
- }
- else {
- for (Iterator<? extends Iterator<? extends E>> stream = this.iterators.iterator(); ! this.currentIterator.hasNext() && stream.hasNext(); ) {
- this.currentIterator = stream.next();
- stream.remove();
- }
- if ( ! this.currentIterator.hasNext()) {
- this.currentIterator = EmptyIterator.instance();
- }
- this.loadNextNeighbor(); // recurse
- }
- }
-
- public boolean hasNext() {
- return ! this.done;
- }
-
- public E next() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- E next = this.nextNeighbor;
- this.loadNextNeighbor();
- return next;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Return the immediate neighbors of the specified object.
- */
- protected Iterator<? extends E> neighbors(E next) {
- return this.misterRogers.neighbors(next);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.currentIterator);
- }
-
-
- //********** inner classes **********
-
- /**
- * Used by {@link GraphIterator} to retrieve
- * the immediate neighbors of a node in the graph.
- * "These are the people in your neighborhood..."
- */
- public interface MisterRogers<T> {
-
- /**
- * Return the immediate neighbors of the specified object.
- */
- Iterator<? extends T> neighbors(T next);
-
-
- final class Null<S>
- implements MisterRogers<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final MisterRogers INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R> MisterRogers<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // return no neighbors
- public Iterator<S> neighbors(S next) {
- return EmptyIterator.instance();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- /** The Mr. Rogers used when the {@link GraphIterator#neighbors(Object)} method is overridden. */
- final class Disabled<S>
- implements MisterRogers<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final MisterRogers INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> MisterRogers<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public Iterator<S> neighbors(S next) {
- throw new UnsupportedOperationException(); // GraphIterator.neighbors(Object) was not implemented
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/LateralIteratorWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/LateralIteratorWrapper.java
deleted file mode 100644
index f5c67ceda2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/LateralIteratorWrapper.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Wrap an iterator on elements of type <code>E1</code>, converting it into an
- * iterator on elements of type <code>E2</code>. <em>Assume</em> the wrapped
- * iterator returns only elements of type <code>E2</code>. The result is a
- * {@link ClassCastException} if this assumption is false.
- *
- * @param <E1> input: the type of elements returned by the wrapped iterator
- * @param <E2> output: the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.LateralIterableWrapper
- * @see SubIteratorWrapper
- */
-public class LateralIteratorWrapper<E1, E2>
- implements Iterator<E2>
-{
- private final Iterator<E1> iterator;
-
-
- public LateralIteratorWrapper(Iterable<E1> iterable) {
- this(iterable.iterator());
- }
-
- public LateralIteratorWrapper(Iterator<E1> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasNext() {
- return this.iterator.hasNext();
- }
-
- @SuppressWarnings("unchecked")
- public E2 next() {
- return (E2) this.iterator.next();
- }
-
- public void remove() {
- this.iterator.remove();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterator);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/LateralListIteratorWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/LateralListIteratorWrapper.java
deleted file mode 100644
index f34b8eff5d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/LateralListIteratorWrapper.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-/**
- * Wrap a list iterator on elements of type <code>E1</code>, converting it into
- * a list iterator on elements of type <code>E2</code>. <em>Assume</em> the
- * wrapped list iterator returns only elements of type <code>E2</code>.
- * The result is a {@link ClassCastException} if this assumption is false.
- *
- * @param <E1> input: the type of elements returned by the wrapped list iterator
- * @param <E2> output: the type of elements returned by the list iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.LateralIterableWrapper
- * @see SubListIteratorWrapper
- */
-public class LateralListIteratorWrapper<E1, E2>
- implements ListIterator<E2>
-{
- final ListIterator<E1> listIterator;
-
-
- public LateralListIteratorWrapper(List<E1> list) {
- this(list.listIterator());
- }
-
- public LateralListIteratorWrapper(ListIterable<E1> listIterable) {
- this(listIterable.iterator());
- }
-
- public LateralListIteratorWrapper(ListIterator<E1> iterator) {
- super();
- this.listIterator = iterator;
- }
-
- public boolean hasNext() {
- return this.listIterator.hasNext();
- }
-
- @SuppressWarnings("unchecked")
- public E2 next() {
- return (E2) this.listIterator.next();
- }
-
- public int nextIndex() {
- return this.listIterator.nextIndex();
- }
-
- public boolean hasPrevious() {
- return this.listIterator.hasPrevious();
- }
-
- @SuppressWarnings("unchecked")
- public E2 previous() {
- return (E2) this.listIterator.previous();
- }
-
- public int previousIndex() {
- return this.listIterator.previousIndex();
- }
-
- public void remove() {
- this.listIterator.remove();
- }
-
- @SuppressWarnings("unchecked")
- public void set(E2 e) {
- this.listIterator.set((E1) e);
- }
-
- @SuppressWarnings("unchecked")
- public void add(E2 e) {
- this.listIterator.add((E1) e);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listIterator);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/PeekableIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/PeekableIterator.java
deleted file mode 100644
index 1a1f6284ae..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/PeekableIterator.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>PeekableIterator</code> wraps another {@link Iterator}
- * and allows a {@link #peek()} at the next element to be
- * returned by {@link #next()}.
- * <p>
- * One, possibly undesirable, side-effect of using this iterator is that
- * the nested iterator's <code>next()</code> method will be invoked
- * <em>before</em> the peekable iterator's {@link #next()}
- * method is invoked. This is because the "next" element must be
- * pre-loaded for the {@link #peek()} method.
- * This also prevents a peekable iterator from supporting the optional
- * {@link #remove()} method.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.PeekableIterable
- */
-public class PeekableIterator<E>
- implements Iterator<E>
-{
- private final Iterator<? extends E> iterator;
- private E next;
- private boolean done;
-
-
- /**
- * Construct a peekable iterator that wraps the specified
- * iterable.
- */
- public PeekableIterator(Iterable<? extends E> iterable) {
- this(iterable.iterator());
- }
-
- /**
- * Construct a peekable iterator that wraps the specified nested
- * iterator.
- */
- public PeekableIterator(Iterator<? extends E> iterator) {
- super();
- this.iterator = iterator;
- this.done = false;
- this.loadNext();
- }
-
- public boolean hasNext() {
- return ! this.done;
- }
-
- public E next() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- E result = this.next;
- this.loadNext();
- return result;
- }
-
- /**
- * Return the element that will be returned by the next call to the
- * {@link #next()} method, without advancing past it.
- */
- public E peek() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- return this.next;
- }
-
- /**
- * Because we need to pre-load the next element
- * to be returned, we cannot support the {@link #remove()}
- * method.
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Load next with the next entry from the nested
- * iterator. If there are none, {@link #next} is set to <code>null</code>
- * and {@link #done} is set to <code>true</code>.
- */
- private void loadNext() {
- if (this.iterator.hasNext()) {
- this.next = this.iterator.next();
- } else {
- this.next = null;
- this.done = true;
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterator);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/QueueIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/QueueIterator.java
deleted file mode 100644
index 4f946237b0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/QueueIterator.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.Queue;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>QueueIterator</code> provides an {@link Iterator}
- * for a {@link Queue} of objects of type <code>E</code>. The queue's elements
- * are {@link Queue#dequeue() dequeue}d" as the iterator returns them with
- * calls to {@link #next()}.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see Queue
- * @see org.eclipse.jpt.common.utility.internal.iterables.QueueIterable
- */
-public class QueueIterator<E>
- implements Iterator<E>
-{
- private final Queue<E> queue;
-
-
- /**
- * Construct an iterator for the specified queue.
- */
- public QueueIterator(Queue<E> queue) {
- super();
- this.queue = queue;
- }
-
- public boolean hasNext() {
- return ! this.queue.isEmpty();
- }
-
- public E next() {
- return this.queue.dequeue();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.queue);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyCompositeListIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyCompositeListIterator.java
deleted file mode 100644
index 425788548e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyCompositeListIterator.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-/**
- * A <code>ReadOnlyCompositeListIterator</code> wraps a list
- * of {@link ListIterator}s and makes them appear to be a single
- * read-only {@link ListIterator}. A read-only composite list
- * iterator is more flexible than a normal composite list iterator when it
- * comes to the element types of the nested iterators.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.ReadOnlyCompositeListIterable
- */
-public class ReadOnlyCompositeListIterator<E>
- implements ListIterator<E>
-{
- private final ListIterator<? extends ListIterator<? extends E>> iterators;
- private ListIterator<? extends E> nextIterator;
- private int nextIndex;
-
-
- /**
- * Construct a read-only list iterator with the specified list of lists.
- */
- public ReadOnlyCompositeListIterator(List<? extends List<? extends E>> lists) {
- this(
- new TransformationListIterator<List<? extends E>, ListIterator<? extends E>>(lists.listIterator()) {
- @Override
- protected ListIterator<? extends E> transform(List<? extends E> list) {
- return list.listIterator();
- }
- }
- );
- }
-
- /**
- * Construct a read-only list iterator with the specified list of lists.
- */
- public ReadOnlyCompositeListIterator(ListIterable<? extends ListIterable<? extends E>> listIterables) {
- this(
- new TransformationListIterator<ListIterable<? extends E>, ListIterator<? extends E>>(listIterables.iterator()) {
- @Override
- protected ListIterator<? extends E> transform(ListIterable<? extends E> listIterable) {
- return listIterable.iterator();
- }
- }
- );
- }
-
- /**
- * Construct a read-only list iterator with the specified list of
- * list iterators.
- */
- public ReadOnlyCompositeListIterator(ListIterator<? extends ListIterator<? extends E>> iterators) {
- super();
- this.iterators = iterators;
- this.nextIndex = 0;
- }
-
- /**
- * Construct a read-only list iterator with the specified object prepended
- * to the specified list.
- */
- public ReadOnlyCompositeListIterator(E object, List<? extends E> list) {
- this(object, list.listIterator());
- }
-
- /**
- * Construct a read-only list iterator with the specified object prepended
- * to the specified list.
- */
- public ReadOnlyCompositeListIterator(E object, ListIterable<? extends E> listIterable) {
- this(object, listIterable.iterator());
- }
-
- /**
- * Construct a read-only list iterator with the specified object prepended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public ReadOnlyCompositeListIterator(E object, ListIterator<? extends E> iterator) {
- this(new SingleElementListIterator<E>(object), iterator);
- }
-
- /**
- * Construct a read-only list iterator with the specified object appended
- * to the specified list.
- */
- public ReadOnlyCompositeListIterator(List<? extends E> list, E object) {
- this(list.listIterator(), object);
- }
-
- /**
- * Construct a read-only list iterator with the specified object appended
- * to the specified list.
- */
- public ReadOnlyCompositeListIterator(ListIterable<? extends E> listIterable, E object) {
- this(listIterable.iterator(), object);
- }
-
- /**
- * Construct a read-only list iterator with the specified object appended
- * to the specified iterator.
- */
- @SuppressWarnings("unchecked")
- public ReadOnlyCompositeListIterator(ListIterator<? extends E> iterator, E object) {
- this(iterator, new SingleElementListIterator<E>(object));
- }
-
- /**
- * Construct a read-only list iterator with the specified lists.
- */
- public ReadOnlyCompositeListIterator(List<? extends E>... lists) {
- this(Arrays.asList(lists));
- }
-
- /**
- * Construct a read-only list iterator with the specified lists.
- */
- public ReadOnlyCompositeListIterator(ListIterable<? extends E>... listIterables) {
- this(new ArrayListIterable<ListIterable<? extends E>>(listIterables));
- }
-
- /**
- * Construct a read-only list iterator with the specified list iterators.
- */
- public ReadOnlyCompositeListIterator(ListIterator<? extends E>... iterators) {
- this(new ArrayListIterator<ListIterator<? extends E>>(iterators));
- }
-
- public boolean hasNext() {
- try {
- this.loadNextIterator();
- } catch (NoSuchElementException ex) {
- // this occurs if there are no iterators at all
- return false;
- }
- return this.nextIterator.hasNext();
- }
-
- public boolean hasPrevious() {
- try {
- this.loadPreviousIterator();
- } catch (NoSuchElementException ex) {
- // this occurs if there are no iterators at all
- return false;
- }
- return this.nextIterator.hasPrevious();
- }
-
- public E next() {
- this.loadNextIterator();
- E result = this.nextIterator.next();
-
- // the statement above will throw a NoSuchElementException
- // if the current iterator is at the end of the line;
- // so if we get here, we can increment 'nextIndex'
- this.nextIndex++;
-
- return result;
- }
-
- public int nextIndex() {
- return this.nextIndex;
- }
-
- public E previous() {
- this.loadPreviousIterator();
- E result = this.nextIterator.previous();
-
- // the statement above will throw a NoSuchElementException
- // if the current iterator is at the end of the line;
- // so if we get here, we can decrement 'nextIndex'
- this.nextIndex--;
-
- return result;
- }
-
- public int previousIndex() {
- return this.nextIndex - 1;
- }
-
- public void add(E o) {
- // the list iterator is read-only
- throw new UnsupportedOperationException();
- }
-
- public void remove() {
- // the list iterator is read-only
- throw new UnsupportedOperationException();
- }
-
- public void set(E e) {
- // the list iterator is read-only
- throw new UnsupportedOperationException();
- }
-
- /**
- * Load {@link #nextIterator} with the first iterator that {@link #hasNext()}
- * or the final iterator if all the elements have already been retrieved.
- */
- private void loadNextIterator() {
- this.checkNextIterator();
- while (( ! this.nextIterator.hasNext()) && this.iterators.hasNext()) {
- this.nextIterator = this.iterators.next();
- }
- }
-
- /**
- * Load {@link #nextIterator} with the first iterator that {@link #hasPrevious()}
- * or the first iterator if all the elements have already been retrieved.
- */
- private void loadPreviousIterator() {
- this.checkNextIterator();
- while (( ! this.nextIterator.hasPrevious()) && this.iterators.hasPrevious()) {
- this.nextIterator = this.iterators.previous();
- }
- }
-
- /**
- * If {@link #nextIterator} is null, load it with the first iterator.
- */
- private void checkNextIterator() {
- if (this.nextIterator == null) {
- this.nextIterator = this.iterators.next();
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterators);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyIterator.java
deleted file mode 100644
index 5673d3d190..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyIterator.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>ReadOnlyIterator</code> wraps another {@link Iterator}
- * and removes support for {@link #remove()}.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.ReadOnlyIterable
- */
-public class ReadOnlyIterator<E>
- implements Iterator<E>
-{
- private final Iterator<? extends E> iterator;
-
- /**
- * Construct an iterator on the specified collection that
- * disallows removes.
- */
- public ReadOnlyIterator(Iterable<? extends E> c) {
- this(c.iterator());
- }
-
- /**
- * Construct an iterator with the specified nested iterator
- * and disallow removes.
- */
- public ReadOnlyIterator(Iterator<? extends E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasNext() {
- // delegate to the nested iterator
- return this.iterator.hasNext();
- }
-
- public E next() {
- // delegate to the nested iterator
- return this.iterator.next();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterator);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyListIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyListIterator.java
deleted file mode 100644
index ac09133a5d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReadOnlyListIterator.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-/**
- * A <code>ReadOnlyListIterator</code> wraps another
- * {@link ListIterator} and removes support for:<ul>
- * <li>{@link #remove()}
- * <li>{@link #set(Object)}
- * <li>{@link #add(Object)}
- * </ul>
- *
- * @param <E> the type of elements returned by the list iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.ReadOnlyListIterable
- */
-public class ReadOnlyListIterator<E>
- implements ListIterator<E>
-{
- private final ListIterator<? extends E> listIterator;
-
-
- /**
- * Construct a list iterator on the specified list that
- * disallows removes, sets, and adds.
- */
- public ReadOnlyListIterator(List<? extends E> list) {
- this(list.listIterator());
- }
-
- /**
- * Construct a list iterator on the specified list that
- * disallows removes, sets, and adds.
- */
- public ReadOnlyListIterator(ListIterable<? extends E> listIterable) {
- this(listIterable.iterator());
- }
-
- /**
- * Construct a list iterator on the specified list iterator that
- * disallows removes, sets, and adds.
- */
- public ReadOnlyListIterator(ListIterator<? extends E> listIterator) {
- super();
- this.listIterator = listIterator;
- }
-
- public boolean hasNext() {
- // delegate to the nested iterator
- return this.listIterator.hasNext();
- }
-
- public E next() {
- // delegate to the nested iterator
- return this.listIterator.next();
- }
-
- public boolean hasPrevious() {
- // delegate to the nested iterator
- return this.listIterator.hasPrevious();
- }
-
- public E previous() {
- // delegate to the nested iterator
- return this.listIterator.previous();
- }
-
- public int nextIndex() {
- // delegate to the nested iterator
- return this.listIterator.nextIndex();
- }
-
- public int previousIndex() {
- // delegate to the nested iterator
- return this.listIterator.previousIndex();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public void set(E o) {
- throw new UnsupportedOperationException();
- }
-
- public void add(E o) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listIterator);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ResultSetIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ResultSetIterator.java
deleted file mode 100644
index f75089a639..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ResultSetIterator.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.io.Serializable;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>ResultSetIterator</code> wraps an SQL {@link ResultSet}
- * and transforms its rows for client consumption. Subclasses can override
- * {@link #buildNext(ResultSet)} to build the expected object from
- * the current row of the result set.
- * <p>
- * To use, supply:<ul>
- * <li> a {@link ResultSet}
- * <li> an {@link Adapter} that converts a row in the {@link ResultSet}
- * into the desired object
- * (alternatively, subclass <code>ResultSetIterator</code>
- * and override the {@link #buildNext(ResultSet)} method)
- * </ul>
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see java.sql.ResultSet
- */
-public class ResultSetIterator<E>
- implements Iterator<E>
-{
- private final ResultSet resultSet;
- private final Adapter<E> adapter;
- private E next;
- private boolean done;
-
-
- /**
- * Construct an iterator on the specified result set that returns
- * the objects produced by the specified adapter.
- */
- public ResultSetIterator(ResultSet resultSet, Adapter<E> adapter) {
- super();
- this.resultSet = resultSet;
- this.adapter = adapter;
- this.done = false;
- this.next = this.buildNext();
- }
-
- /**
- * Construct an iterator on the specified result set that returns
- * the first object in each row of the result set.
- */
- public ResultSetIterator(ResultSet resultSet) {
- this(resultSet, Adapter.Default.<E>instance());
- }
-
- /**
- * Build the next object for the iterator to return.
- * Close the result set when we reach the end.
- */
- private E buildNext() {
- try {
- if (this.resultSet.next()) {
- return this.buildNext(this.resultSet);
- }
- this.resultSet.close();
- this.done = true;
- return null;
- } catch (SQLException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * By default, return the first object in the current row
- * of the result set. Any {@link SQLException}s will
- * be caught and wrapped in a {@link RuntimeException}.
- */
- protected E buildNext(ResultSet rs) throws SQLException {
- return this.adapter.buildNext(rs);
- }
-
- public boolean hasNext() {
- return ! this.done;
- }
-
- public E next() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- E temp = this.next;
- this.next = this.buildNext();
- return temp;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.resultSet);
- }
-
-
- // ********** interface **********
-
- /**
- * Used by {@link ResultSetIterator} to convert a
- * {@link ResultSet}'s current row into the next object
- * to be returned by the {@link Iterator}.
- */
- public interface Adapter<T> {
-
- /**
- * Return an object corresponding to the result set's
- * "current" row. Any {@link SQLException}s will
- * be caught and wrapped in a {@link RuntimeException}.
- * @see java.sql.ResultSet
- */
- T buildNext(ResultSet rs) throws SQLException;
-
-
- final class Default<S>
- implements Adapter<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Adapter INSTANCE = new Default();
- @SuppressWarnings("unchecked")
- public static <R> Adapter<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Default() {
- super();
- }
- // return the first object in the current row of the result set
- @SuppressWarnings("unchecked")
- public S buildNext(ResultSet rs) throws SQLException {
- // result set columns are indexed starting with 1
- return (S) rs.getObject(1);
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReverseIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReverseIterator.java
deleted file mode 100644
index 7b8bfb4a07..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/ReverseIterator.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>ReverseIterator</code> wraps another {@link Iterator} and returns
- * its elements in the reverse order in which the wrapped {@link Iterator}
- * returns the elements.
- *
- * @param <E> the type of elements returned by the iterator
- */
-public class ReverseIterator<E>
- implements Iterator<E>
-{
- /**
- * The elements in this iterator are already reversed.
- */
- private final Iterator<E> iterator;
-
-
- /**
- * Construct a reverse iterator for the specified iterator.
- */
- public ReverseIterator(Iterator<E> iterator) {
- this(CollectionTools.reverseList(iterator));
- }
-
- /**
- * Construct a reverse iterator for the specified iterator.
- */
- public ReverseIterator(Iterator<E> iterator, int size) {
- this(CollectionTools.reverseList(iterator, size));
- }
-
- /**
- * Construct a reverse iterator for the specified iterable.
- */
- public ReverseIterator(Iterable<E> iterable) {
- this(CollectionTools.reverseList(iterable));
- }
-
- /**
- * Construct a reverse iterator for the specified iterable.
- */
- public ReverseIterator(Iterable<E> iterable, int size) {
- this(CollectionTools.reverseList(iterable, size));
- }
-
- private ReverseIterator(ArrayList<E> reverseList) {
- super();
- this.iterator = reverseList.iterator();
- }
-
- public boolean hasNext() {
- return this.iterator.hasNext();
- }
-
- public E next() {
- return this.iterator.next();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SingleElementIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SingleElementIterator.java
deleted file mode 100644
index a6a743d1c7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SingleElementIterator.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>SingleElementIterator</code> holds a single element
- * and returns it with the first call to {@link #next()}, at
- * which point it will return <code>false</code> to any subsequent
- * call to {@link #hasNext()}.
- * <p>
- * A <code>SingleElementIterator</code> is equivalent to the
- * {@link Iterator} returned by:
- * {@link java.util.Collections#singleton(Object element)}<code>.iterator()</code>
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable
- */
-public class SingleElementIterator<E>
- implements Iterator<E>
-{
- private final E element;
- private boolean done;
-
-
- /**
- * Construct an iterator that returns only the specified element.
- */
- public SingleElementIterator(E element) {
- super();
- this.element = element;
- this.done = false;
- }
-
- public boolean hasNext() {
- return ! this.done;
- }
-
- public E next() {
- if (this.done) {
- throw new NoSuchElementException();
- }
- this.done = true;
- return this.element;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.element);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SingleElementListIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SingleElementListIterator.java
deleted file mode 100644
index 9363cd0be7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SingleElementListIterator.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>SingleElementListIterator</code> holds a single element
- * and returns it with the first call to {@link #next()}, at
- * which point it will return <code>false</code> to any subsequent
- * call to {@link #hasNext()}. Likewise, it will return <code>false</code>
- * to a call to {@link #hasPrevious()} until a call to {@link #next()},
- * at which point a call to {@link #previous()} will return the
- * single element.
- * <p>
- * A <code>SingleElementListIterator</code> is equivalent to the
- * {@link ListIterator} returned by:
- * {@link java.util.Collections#singletonList(Object element)}<code>.listIterator()</code>
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable
- */
-public class SingleElementListIterator<E>
- implements ListIterator<E>
-{
- private final E element;
- private boolean hasNext;
-
-
- /**
- * Construct a list iterator that returns only the specified element.
- */
- public SingleElementListIterator(E element) {
- super();
- this.element = element;
- this.hasNext = true;
- }
-
- public boolean hasNext() {
- return this.hasNext;
- }
-
- public E next() {
- if (this.hasNext) {
- this.hasNext = false;
- return this.element;
- }
- throw new NoSuchElementException();
- }
-
- public int nextIndex() {
- return this.hasNext ? 0 : 1;
- }
-
- public boolean hasPrevious() {
- return ! this.hasNext;
- }
-
- public E previous() {
- if (this.hasNext) {
- throw new NoSuchElementException();
- }
- this.hasNext = true;
- return this.element;
- }
-
- public int previousIndex() {
- return this.hasNext ? -1 : 0;
- }
-
- public void add(E e) {
- throw new UnsupportedOperationException();
- }
-
- public void set(E e) {
- throw new UnsupportedOperationException();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.element);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/StackIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/StackIterator.java
deleted file mode 100644
index d8106d037a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/StackIterator.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.Stack;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>StackIterator</code> provides an {@link Iterator}
- * for a {@link Stack} of objects of type <code>E</code>. The stack's elements
- * are {@link Stack#pop() pop}ped" as the iterator returns them with
- * calls to {@link #next()}.
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see Stack
- * @see org.eclipse.jpt.common.utility.internal.iterables.StackIterable
- */
-public class StackIterator<E>
- implements Iterator<E>
-{
- private final Stack<E> stack;
-
-
- /**
- * Construct an iterator for the specified stack.
- */
- public StackIterator(Stack<E> stack) {
- super();
- this.stack = stack;
- }
-
- public boolean hasNext() {
- return ! this.stack.isEmpty();
- }
-
- public E next() {
- return this.stack.pop();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.stack);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SubIteratorWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SubIteratorWrapper.java
deleted file mode 100644
index 4faf788ad1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SubIteratorWrapper.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-
-/**
- * Wrap an iterator on elements of type <code>E1</code>, converting it into an
- * iterator on elements of type <code>E2</code>. <em>Assume</em> the wrapped
- * iterator returns only elements of type <code>E2</code>. The result is a
- * {@link ClassCastException} if this assumption is false.
- * <p>
- * This is a {@link LateralIteratorWrapper} with more restrictive type
- * parameters.
- *
- * @param <E1> input: the type of elements returned by the wrapped iterator
- * @param <E2> output: the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper
- */
-public class SubIteratorWrapper<E1, E2 extends E1>
- extends LateralIteratorWrapper<E1, E2>
-{
- public SubIteratorWrapper(Iterable<E1> iterable) {
- super(iterable);
- }
-
- public SubIteratorWrapper(Iterator<E1> iterator) {
- super(iterator);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SubListIteratorWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SubListIteratorWrapper.java
deleted file mode 100644
index 6225d851a0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SubListIteratorWrapper.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-/**
- * Wrap a list iterator on elements of type <code>E1</code>, converting it into
- * a list iterator on elements of type <code>E2</code>. <em>Assume</em> the
- * wrapped list iterator returns only elements of type <code>E2</code>.
- * The result is a {@link ClassCastException} if this assumption is false.
- * <p>
- * This is a {@link LateralListIteratorWrapper} with more restrictive type
- * parameters.
- *
- * @param <E1> input: the type of elements returned by the wrapped list iterator
- * @param <E2> output: the type of elements returned by the list iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.SubListIterableWrapper
- */
-public class SubListIteratorWrapper<E1, E2 extends E1>
- extends LateralListIteratorWrapper<E1, E2>
-{
- public SubListIteratorWrapper(List<E1> list) {
- super(list);
- }
-
- public SubListIteratorWrapper(ListIterable<E1> listIterable) {
- super(listIterable);
- }
-
- public SubListIteratorWrapper(ListIterator<E1> iterator) {
- super(iterator);
- }
-
- @Override
- public void set(E2 e) {
- // no explicit cast necessary
- this.listIterator.set(e);
- }
-
- @Override
- public void add(E2 e) {
- // no explicit cast necessary
- this.listIterator.add(e);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SuperIteratorWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SuperIteratorWrapper.java
deleted file mode 100644
index 9e420fc57c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SuperIteratorWrapper.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Wrap an iterator on elements of any sub-type of <code>E</code>, converting
- * it into a iterator on elements of type <code>E</code>. This shouldn't be a
- * problem since there is no way to add invalid elements to the iterator's
- * backing collection. (Note the lack of compiler warnings, suppressed or
- * otherwise.)
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.SuperIterableWrapper
- */
-public class SuperIteratorWrapper<E>
- implements Iterator<E>
-{
- private final Iterator<? extends E> iterator;
-
-
- public SuperIteratorWrapper(Iterable<? extends E> iterable) {
- this(iterable.iterator());
- }
-
- public SuperIteratorWrapper(Iterator<? extends E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasNext() {
- return this.iterator.hasNext();
- }
-
- public E next() {
- return this.iterator.next();
- }
-
- public void remove() {
- this.iterator.remove();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterator);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SuperListIteratorWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SuperListIteratorWrapper.java
deleted file mode 100644
index 21bc8e5326..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SuperListIteratorWrapper.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-/**
- * Wrap a list iterator on elements of any sub-type of <code>E</code>,
- * converting it into a <em>non-writable</em> list iterator on elements of type
- * <code>E</code>. This shouldn't be a problem since the
- * resulting list iterator disables the methods that would put invalid elements
- * in the iterator's backing list (i.e. {@link #set(Object)} and {@link #add(Object)}).
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.SuperListIterableWrapper
- */
-public class SuperListIteratorWrapper<E>
- implements ListIterator<E>
-{
- private final ListIterator<? extends E> listIterator;
-
-
- public SuperListIteratorWrapper(List<? extends E> list) {
- this(list.listIterator());
- }
-
- public SuperListIteratorWrapper(ListIterable<? extends E> listIterable) {
- this(listIterable.iterator());
- }
-
- public SuperListIteratorWrapper(ListIterator<? extends E> listIterator) {
- super();
- this.listIterator = listIterator;
- }
-
- public boolean hasNext() {
- return this.listIterator.hasNext();
- }
-
- public E next() {
- return this.listIterator.next();
- }
-
- public int nextIndex() {
- return this.listIterator.nextIndex();
- }
-
- public boolean hasPrevious() {
- return this.listIterator.hasPrevious();
- }
-
- public E previous() {
- return this.listIterator.previous();
- }
-
- public int previousIndex() {
- return this.listIterator.previousIndex();
- }
-
- public void remove() {
- this.listIterator.remove();
- }
-
- public void set(E e) {
- throw new UnsupportedOperationException();
- }
-
- public void add(E e) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listIterator);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SynchronizedIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SynchronizedIterator.java
deleted file mode 100644
index 8efef7eb2e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SynchronizedIterator.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Wrap an iterator and synchronize all its methods so it can be safely shared
- * among multiple threads.
- *
- * @param <E> the type of elements returned by the iterator
- */
-public class SynchronizedIterator<E>
- implements Iterator<E>
-{
- private final Iterator<? extends E> iterator;
-
- /** Object to synchronize on. */
- private final Object mutex;
-
-
- public SynchronizedIterator(Iterable<? extends E> iterable) {
- this(iterable.iterator());
- }
-
- public SynchronizedIterator(Iterable<? extends E> iterable, Object mutex) {
- this(iterable.iterator(), mutex);
- }
-
- public SynchronizedIterator(Iterator<? extends E> iterator) {
- super();
- this.iterator = iterator;
- this.mutex = this;
- }
-
- public SynchronizedIterator(Iterator<? extends E> iterator, Object mutex) {
- super();
- this.iterator = iterator;
- this.mutex = mutex;
- }
-
- public synchronized boolean hasNext() {
- synchronized (this.mutex) {
- return this.iterator.hasNext();
- }
- }
-
- public synchronized E next() {
- synchronized (this.mutex) {
- return this.iterator.next();
- }
- }
-
- public synchronized void remove() {
- synchronized (this.mutex) {
- this.iterator.remove();
- }
- }
-
- @Override
- public String toString() {
- synchronized (this.mutex) {
- return StringTools.buildToStringFor(this, this.iterator);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SynchronizedListIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SynchronizedListIterator.java
deleted file mode 100644
index 87e6384bf5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/SynchronizedListIterator.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-/**
- * Wrap a list iterator and synchronize all its methods so it can be safely shared
- * among multiple threads.
- *
- * @param <E> the type of elements returned by the iterator
- */
-public class SynchronizedListIterator<E>
- implements ListIterator<E>
-{
- private final ListIterator<E> listIterator;
-
- /** Object to synchronize on. */
- private final Object mutex;
-
-
- public SynchronizedListIterator(List<E> list) {
- this(list.listIterator());
- }
-
- public SynchronizedListIterator(List<E> list, Object mutex) {
- this(list.listIterator(), mutex);
- }
-
- public SynchronizedListIterator(ListIterable<E> listIterable) {
- this(listIterable.iterator());
- }
-
- public SynchronizedListIterator(ListIterable<E> listIterable, Object mutex) {
- this(listIterable.iterator(), mutex);
- }
-
- public SynchronizedListIterator(ListIterator<E> listIterator) {
- super();
- this.listIterator = listIterator;
- this.mutex = this;
- }
-
- public SynchronizedListIterator(ListIterator<E> listIterator, Object mutex) {
- super();
- this.listIterator = listIterator;
- this.mutex = mutex;
- }
-
- public synchronized boolean hasNext() {
- synchronized (this.mutex) {
- return this.listIterator.hasNext();
- }
- }
-
- public synchronized E next() {
- synchronized (this.mutex) {
- return this.listIterator.next();
- }
- }
-
- public synchronized int nextIndex() {
- synchronized (this.mutex) {
- return this.listIterator.nextIndex();
- }
- }
-
- public synchronized boolean hasPrevious() {
- synchronized (this.mutex) {
- return this.listIterator.hasPrevious();
- }
- }
-
- public synchronized E previous() {
- synchronized (this.mutex) {
- return this.listIterator.previous();
- }
- }
-
- public synchronized int previousIndex() {
- synchronized (this.mutex) {
- return this.listIterator.previousIndex();
- }
- }
-
- public synchronized void remove() {
- synchronized (this.mutex) {
- this.listIterator.remove();
- }
- }
-
- public synchronized void add(E e) {
- synchronized (this.mutex) {
- this.listIterator.add(e);
- }
- }
-
- public synchronized void set(E e) {
- synchronized (this.mutex) {
- this.listIterator.set(e);
- }
- }
-
- @Override
- public String toString() {
- synchronized (this.mutex) {
- return StringTools.buildToStringFor(this, this.listIterator);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TransformationIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TransformationIterator.java
deleted file mode 100644
index 7b6aa41bd2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TransformationIterator.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-
-
-/**
- * A <code>TransformationIterator</code> wraps another {@link Iterator}
- * and transforms its results for client consumption. To use, supply a
- * {@link Transformer} or subclass <code>TransformationIterator</code>
- * and override the {@link #transform(Object)} method.
- * Objects of type <code>E1</code> are transformed into objects of type <code>E2</code>;
- * i.e. the iterator returns objects of type <code>E2</code>.
- *
- * @param <E1> input: the type of elements to be transformed
- * @param <E2> output: the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable
- */
-public class TransformationIterator<E1, E2>
- implements Iterator<E2>
-{
- private final Iterator<? extends E1> iterator;
- private final Transformer<E1, ? extends E2> transformer;
-
-
- /**
- * Construct an iterator with the specified iterable
- * and a disabled transformer.
- * Use this constructor if you want to override the
- * {@link #transform(Object)} method instead of building
- * a {@link Transformer}.
- */
- public TransformationIterator(Iterable<? extends E1> iterable) {
- this(iterable.iterator());
- }
-
- /**
- * Construct an iterator with the specified nested iterator
- * and a disabled transformer.
- * Use this constructor if you want to override the
- * {@link #transform(Object)} method instead of building
- * a {@link Transformer}.
- */
- public TransformationIterator(Iterator<? extends E1> iterator) {
- this(iterator, Transformer.Disabled.<E1, E2>instance());
- }
-
- /**
- * Construct an iterator with the specified iterable and transformer.
- */
- public TransformationIterator(Iterable<? extends E1> iterable, Transformer<E1, ? extends E2> transformer) {
- this(iterable.iterator(), transformer);
- }
-
- /**
- * Construct an iterator with the specified nested iterator
- * and transformer.
- */
- public TransformationIterator(Iterator<? extends E1> iterator, Transformer<E1, ? extends E2> transformer) {
- super();
- this.iterator = iterator;
- this.transformer = transformer;
- }
-
- public boolean hasNext() {
- // delegate to the nested iterator
- return this.iterator.hasNext();
- }
-
- public E2 next() {
- // transform the object returned by the nested iterator before returning it
- return this.transform(this.iterator.next());
- }
-
- public void remove() {
- // delegate to the nested iterator
- this.iterator.remove();
- }
-
- /**
- * Transform the specified object and return the result.
- */
- protected E2 transform(E1 next) {
- return this.transformer.transform(next);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.iterator);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TransformationListIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TransformationListIterator.java
deleted file mode 100644
index 01455cd3d2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TransformationListIterator.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-/**
- * A <code>TransformationListIterator</code> wraps another {@link ListIterator}
- * and transforms its results for client consumption. To use, supply a
- * {@link Transformer} or subclass <code>TransformationIterator</code>
- * and override the {@link #transform(Object)} method.
- * <p>
- * The methods {@link #set(Object)} and {@link #add(Object)}
- * are left unsupported in this class.
- *
- * @param <E1> input: the type of elements to be transformed
- * @param <E2> output: the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.TransformationListIterable
- */
-public class TransformationListIterator<E1, E2>
- implements ListIterator<E2>
-{
- private final ListIterator<? extends E1> listIterator;
- private final Transformer<E1, ? extends E2> transformer;
-
-
- /**
- * Construct an iterator with the specified list
- * and a disabled transformer.
- * Use this constructor if you want to override the
- * {@link #transform(Object)} method instead of building
- * a {@link Transformer}.
- */
- public TransformationListIterator(List<? extends E1> list) {
- this(list.listIterator());
- }
-
- /**
- * Construct an iterator with the specified nested listed iterator
- * and a disabled transformer.
- * Use this constructor if you want to override the
- * {@link #transform(Object)} method instead of building
- * a {@link Transformer}.
- */
- public TransformationListIterator(ListIterator<? extends E1> listIterator) {
- this(listIterator, Transformer.Disabled.<E1, E2>instance());
- }
-
- /**
- * Construct an iterator with the specified list
- * and a disabled transformer.
- * Use this constructor if you want to override the
- * {@link #transform(Object)} method instead of building
- * a {@link Transformer}.
- */
- public TransformationListIterator(ListIterable<? extends E1> listIterable) {
- this(listIterable.iterator());
- }
-
- /**
- * Construct an iterator with the specified list and transformer.
- */
- public TransformationListIterator(List<? extends E1> list, Transformer<E1, ? extends E2> transformer) {
- this(list.listIterator(), transformer);
- }
-
- /**
- * Construct an iterator with the specified list and transformer.
- */
- public TransformationListIterator(ListIterable<? extends E1> listIterable, Transformer<E1, ? extends E2> transformer) {
- this(listIterable.iterator(), transformer);
- }
-
- /**
- * Construct an iterator with the specified nested iterator
- * and transformer.
- */
- public TransformationListIterator(ListIterator<? extends E1> listIterator, Transformer<E1, ? extends E2> transformer) {
- super();
- this.listIterator = listIterator;
- this.transformer = transformer;
- }
-
- public boolean hasNext() {
- // delegate to the nested iterator
- return this.listIterator.hasNext();
- }
-
- public E2 next() {
- // transform the object returned by the nested iterator before returning it
- return this.transform(this.listIterator.next());
- }
-
- public int nextIndex() {
- // delegate to the nested iterator
- return this.listIterator.nextIndex();
- }
-
- public boolean hasPrevious() {
- // delegate to the nested iterator
- return this.listIterator.hasPrevious();
- }
-
- public E2 previous() {
- // transform the object returned by the nested iterator before returning it
- return this.transform(this.listIterator.previous());
- }
-
- public int previousIndex() {
- // delegate to the nested iterator
- return this.listIterator.previousIndex();
- }
-
- public void add(E2 o) {
- throw new UnsupportedOperationException();
- }
-
- public void set(E2 o) {
- throw new UnsupportedOperationException();
- }
-
- public void remove() {
- // delegate to the nested iterator
- this.listIterator.remove();
- }
-
- /**
- * Transform the specified object and return the result.
- */
- protected E2 transform(E1 next) {
- return this.transformer.transform(next);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listIterator);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TreeIterator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TreeIterator.java
deleted file mode 100644
index 8be76ab07b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/iterators/TreeIterator.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.iterators;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.LinkedList;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * A <code>TreeIterator</code> simplifies the traversal of a
- * tree of objects, where the objects' protocol(s) provides
- * a method for getting the immediate children of the given
- * node but does not provide a method for getting all the
- * descendants (children, grandchildren, etc.) of the given node.
- * <p>
- * To use, supply:<ul>
- * <li> either the root element of the tree or, if the tree has
- * multiple roots, an {@link Iterator} over the set of roots
- * <li> a {@link Midwife} that delivers the children
- * of each child
- * (alternatively, subclass <code>TreeIterator</code>
- * and override the {@link #children(Object)} method)
- * </ul>
- *
- * @param <E> the type of elements returned by the iterator
- *
- * @see org.eclipse.jpt.common.utility.internal.iterables.TreeIterable
- */
-public class TreeIterator<E>
- implements Iterator<E>
-{
- private final LinkedList<Iterator<? extends E>> iterators;
- private final Midwife<E> midwife;
- private Iterator<? extends E> currentIterator;
-
-
- /**
- * Construct an iterator that returns the nodes of a tree
- * with the specified collection of roots
- * and a disabled midwife.
- * Use this constructor if you want to override the
- * {@link #children(Object)} method instead of building
- * a {@link Midwife}.
- */
- public TreeIterator(E... roots) {
- this(new ArrayIterator<E>(roots));
- }
-
- /**
- * Construct an iterator that returns the nodes of a tree
- * with the specified collection of roots
- * and a disabled midwife.
- * Use this constructor if you want to override the
- * {@link #children(Object)} method instead of building
- * a {@link Midwife}.
- */
- public TreeIterator(Iterable<? extends E> roots) {
- this(roots.iterator());
- }
-
- /**
- * Construct an iterator that returns the nodes of a tree
- * with the specified collection of roots
- * and a disabled midwife.
- * Use this constructor if you want to override the
- * {@link #children(Object)} method instead of building
- * a {@link Midwife}.
- */
- public TreeIterator(Iterator<? extends E> roots) {
- this(roots, Midwife.Disabled.<E>instance());
- }
-
- /**
- * Construct an iterator that returns the nodes of a tree
- * with the specified root and a disabled midwife.
- * Use this constructor if you want to override the
- * {@link #children(Object)} method instead of building
- * a {@link Midwife}.
- */
- public TreeIterator(E root) {
- this(root, Midwife.Disabled.<E>instance());
- }
-
- /**
- * Construct an iterator that returns the nodes of a tree
- * with the specified root and midwife.
- */
- public TreeIterator(E root, Midwife<E> midwife) {
- this(new SingleElementIterator<E>(root), midwife);
- }
-
- /**
- * Construct an iterator that returns the nodes of a tree
- * with the specified roots and midwife.
- */
- public TreeIterator(E[] roots, Midwife<E> midwife) {
- this(new ArrayIterator<E>(roots), midwife);
- }
-
- /**
- * Construct an iterator that returns the nodes of a tree
- * with the specified roots and midwife.
- */
- public TreeIterator(Iterable<? extends E> roots, Midwife<E> midwife) {
- this(roots.iterator(), midwife);
- }
-
- /**
- * Construct an iterator that returns the nodes of a tree
- * with the specified roots and midwife.
- */
- public TreeIterator(Iterator<? extends E> roots, Midwife<E> midwife) {
- super();
- this.currentIterator = roots;
- // use a LinkedList since we will be pulling off the front and adding to the end
- this.iterators = new LinkedList<Iterator<? extends E>>();
- this.midwife = midwife;
- }
-
- public boolean hasNext() {
- if (this.currentIterator.hasNext()) {
- return true;
- }
- for (Iterator<? extends E> iterator : this.iterators) {
- if (iterator.hasNext()) {
- return true;
- }
- }
- return false;
- }
-
- public E next() {
- if (this.currentIterator.hasNext()) {
- return this.nextInternal();
- }
- for (Iterator<Iterator<? extends E>> stream = this.iterators.iterator(); stream.hasNext(); ) {
- this.currentIterator = stream.next();
- if (this.currentIterator.hasNext()) {
- break;
- }
- stream.remove();
- }
- return this.nextInternal();
- }
-
- /**
- * Fetch the children of the next node before returning it.
- */
- private E nextInternal() {
- E next = this.currentIterator.next();
- this.iterators.add(this.children(next));
- return next;
- }
-
- public void remove() {
- this.currentIterator.remove();
- }
-
- /**
- * Return the immediate children of the specified object.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link Midwife}.
- */
- protected Iterator<? extends E> children(E next) {
- return this.midwife.children(next);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.currentIterator);
- }
-
-
- //********** inner classes **********
-
- /**
- * Used by {@link TreeIterator} to retrieve
- * the immediate children of a node in the tree.
- */
- public interface Midwife<T> {
-
- /**
- * Return the immediate children of the specified object.
- */
- Iterator<? extends T> children(T o);
-
-
- final class Null<S> implements
- Midwife<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Midwife INSTANCE = new Null();
- @SuppressWarnings("unchecked")
- public static <R> Midwife<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- // return no neighbors
- public Iterator<S> children(S next) {
- return EmptyIterator.instance();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-
- /**
- * The midwife used when the {@link TreeIterator#children(Object)}
- * method is overridden.
- */
- final class Disabled<S>
- implements Midwife<S>, Serializable
- {
- @SuppressWarnings("rawtypes")
- public static final Midwife INSTANCE = new Disabled();
- @SuppressWarnings("unchecked")
- public static <R> Midwife<R> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Disabled() {
- super();
- }
- // throw an exception
- public Iterator<S> children(S next) {
- throw new UnsupportedOperationException(); // TreeIterator.children(Object) was not implemented
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AbstractModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AbstractModel.java
deleted file mode 100644
index c8d1dc690b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AbstractModel.java
+++ /dev/null
@@ -1,1007 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.TreeChangeListener;
-
-/**
- * Reasonable implementation of the {@link Model} protocol
- * with numerous convenience methods.
- *
- * @see ChangeSupport
- */
-public abstract class AbstractModel
- implements Model
-{
- /**
- * Delegate state/property/collection/list/tree change support to this
- * helper object. The change support object is <em>lazily-initialized</em>;
- * so it may be <code>null</code>. The method {@link #getChangeSupport()}
- * will initialize this field if it is <code>null</code>.
- * <p>
- * <strong>NB:</strong> We instantiate this when we fire events, even when
- * we do not have any listeners (which is be implied if this is <code>null</code>).
- * This allows the change support to have behavior tied to events even when
- * we have no listeners.
- *
- * @see AspectChangeSupport#aspectChanged(String)
- */
- protected ChangeSupport changeSupport;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Default constructor.
- */
- protected AbstractModel() {
- super();
- }
-
- /**
- * This accessor will build the change support when required.
- * This only helps reduce the footprint of a model that neither has any
- * listeners added to it nor ever changes (fires any events).
- */
- protected synchronized ChangeSupport getChangeSupport() {
- if (this.changeSupport == null) {
- this.changeSupport = this.buildChangeSupport();
- }
- return this.changeSupport;
- }
-
- /**
- * Allow subclasses to tweak the change support used.
- */
- protected ChangeSupport buildChangeSupport() {
- return new ChangeSupport(this);
- }
-
-
- // ********** change support **********
-
- /**
- * @see ChangeSupport#addChangeListener(ChangeListener)
- */
- public void addChangeListener(ChangeListener listener) {
- this.getChangeSupport().addChangeListener(listener);
- }
-
- /**
- * @see ChangeSupport#removeChangeListener(ChangeListener)
- */
- public void removeChangeListener(ChangeListener listener) {
- this.getChangeSupport().removeChangeListener(listener);
- }
-
- /**
- * @see ChangeSupport#hasAnyChangeListeners()
- */
- public boolean hasAnyChangeListeners() {
- return (this.changeSupport != null) && this.changeSupport.hasAnyChangeListeners();
- }
-
- /**
- * Return whether the model has no change listeners.
- */
- public boolean hasNoChangeListeners() {
- return ! this.hasAnyChangeListeners();
- }
-
-
- // ********** state change support **********
-
- /**
- * @see ChangeSupport#addStateChangeListener(StateChangeListener)
- */
- public void addStateChangeListener(StateChangeListener listener) {
- this.getChangeSupport().addStateChangeListener(listener);
- }
-
- /**
- * @see ChangeSupport#removeStateChangeListener(StateChangeListener)
- */
- public void removeStateChangeListener(StateChangeListener listener) {
- this.getChangeSupport().removeStateChangeListener(listener);
- }
-
- /**
- * @see ChangeSupport#hasAnyStateChangeListeners()
- */
- public boolean hasAnyStateChangeListeners() {
- return (this.changeSupport != null) && this.changeSupport.hasAnyStateChangeListeners();
- }
-
- /**
- * Return whether the model has no state change listeners.
- */
- public boolean hasNoStateChangeListeners() {
- return ! this.hasAnyStateChangeListeners();
- }
-
- /**
- * @see ChangeSupport#fireStateChanged(StateChangeEvent)
- */
- protected final void fireStateChanged(StateChangeEvent event) {
- this.getChangeSupport().fireStateChanged(event);
- }
-
- /**
- * @see ChangeSupport#fireStateChanged()
- */
- protected final void fireStateChanged() {
- this.getChangeSupport().fireStateChanged();
- }
-
-
- // ********** property change support **********
-
- /**
- * @see ChangeSupport#addPropertyChangeListener(String, PropertyChangeListener)
- */
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- this.getChangeSupport().addPropertyChangeListener(propertyName, listener);
- }
-
- /**
- * @see ChangeSupport#removePropertyChangeListener(String, PropertyChangeListener)
- */
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- this.getChangeSupport().removePropertyChangeListener(propertyName, listener);
- }
-
- /**
- * @see ChangeSupport#hasAnyPropertyChangeListeners(String)
- */
- public boolean hasAnyPropertyChangeListeners(String propertyName) {
- return (this.changeSupport != null) && this.changeSupport.hasAnyPropertyChangeListeners(propertyName);
- }
-
- /**
- * Return whether the model has no property change listeners that will
- * be notified when the specified property has changed.
- */
- public boolean hasNoPropertyChangeListeners(String propertyName) {
- return ! this.hasAnyPropertyChangeListeners(propertyName);
- }
-
- /**
- * @see ChangeSupport#firePropertyChanged(PropertyChangeEvent)
- */
- protected final boolean firePropertyChanged(PropertyChangeEvent event) {
- return this.getChangeSupport().firePropertyChanged(event);
- }
-
- /**
- * @see ChangeSupport#firePropertyChanged(String, Object, Object)
- */
- protected final boolean firePropertyChanged(String propertyName, Object oldValue, Object newValue) {
- return this.getChangeSupport().firePropertyChanged(propertyName, oldValue, newValue);
- }
-
- /**
- * @see ChangeSupport#firePropertyChanged(String, int, int)
- */
- protected final boolean firePropertyChanged(String propertyName, int oldValue, int newValue) {
- return this.getChangeSupport().firePropertyChanged(propertyName, oldValue, newValue);
- }
-
- /**
- * @see ChangeSupport#firePropertyChanged(String, boolean, boolean)
- */
- protected final boolean firePropertyChanged(String propertyName, boolean oldValue, boolean newValue) {
- return this.getChangeSupport().firePropertyChanged(propertyName, oldValue, newValue);
- }
-
- /**
- * Implied <code>null</code> "old" value.
- * @see #firePropertyChanged(String, Object, Object)
- */
- protected final boolean firePropertyChanged(String propertyName, Object newValue) {
- return this.firePropertyChanged(propertyName, null, newValue);
- }
-
-
- // ********** collection change support **********
-
- /**
- * @see ChangeSupport#addCollectionChangeListener(String, CollectionChangeListener)
- */
- public void addCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- this.getChangeSupport().addCollectionChangeListener(collectionName, listener);
- }
-
- /**
- * @see ChangeSupport#removeCollectionChangeListener(String, CollectionChangeListener)
- */
- public void removeCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- this.getChangeSupport().removeCollectionChangeListener(collectionName, listener);
- }
-
- /**
- * @see ChangeSupport#hasAnyCollectionChangeListeners(String)
- */
- public boolean hasAnyCollectionChangeListeners(String collectionName) {
- return (this.changeSupport != null) && this.changeSupport.hasAnyCollectionChangeListeners(collectionName);
- }
-
- /**
- * Return whether the model has no collection change listeners that will
- * be notified when the specified collection has changed.
- */
- public boolean hasNoCollectionChangeListeners(String collectionName) {
- return ! this.hasAnyCollectionChangeListeners(collectionName);
- }
-
- /**
- * @see ChangeSupport#fireItemsAdded(CollectionAddEvent)
- */
- protected final boolean fireItemsAdded(CollectionAddEvent event) {
- return this.getChangeSupport().fireItemsAdded(event);
- }
-
- /**
- * @see ChangeSupport#fireItemsAdded(String, Collection)
- */
- protected final boolean fireItemsAdded(String collectionName, Collection<?> addedItems) {
- return this.getChangeSupport().fireItemsAdded(collectionName, addedItems);
- }
-
- /**
- * @see ChangeSupport#fireItemAdded(String, Object)
- */
- protected final void fireItemAdded(String collectionName, Object addedItem) {
- this.getChangeSupport().fireItemAdded(collectionName, addedItem);
- }
-
- /**
- * @see ChangeSupport#fireItemsRemoved(CollectionRemoveEvent)
- */
- protected final boolean fireItemsRemoved(CollectionRemoveEvent event) {
- return this.getChangeSupport().fireItemsRemoved(event);
- }
-
- /**
- * @see ChangeSupport#fireItemsRemoved(String, Collection)
- */
- protected final boolean fireItemsRemoved(String collectionName, Collection<?> removedItems) {
- return this.getChangeSupport().fireItemsRemoved(collectionName, removedItems);
- }
-
- /**
- * @see ChangeSupport#fireItemRemoved(String, Object)
- */
- protected final void fireItemRemoved(String collectionName, Object removedItem) {
- this.getChangeSupport().fireItemRemoved(collectionName, removedItem);
- }
-
- /**
- * @see ChangeSupport#fireCollectionCleared(CollectionClearEvent)
- */
- protected final void fireCollectionCleared(CollectionClearEvent event) {
- this.getChangeSupport().fireCollectionCleared(event);
- }
-
- /**
- * @see ChangeSupport#fireCollectionCleared(String)
- */
- protected final void fireCollectionCleared(String collectionName) {
- this.getChangeSupport().fireCollectionCleared(collectionName);
- }
-
- protected final void fireCollectionChanged(CollectionChangeEvent event) {
- this.getChangeSupport().fireCollectionChanged(event);
- }
-
- protected final void fireCollectionChanged(String collectionName, Collection<?> collection) {
- this.getChangeSupport().fireCollectionChanged(collectionName, collection);
- }
-
- /**
- * @see ChangeSupport#addItemToCollection(Object, Collection, String)
- */
- protected <E> boolean addItemToCollection(E item, Collection<E> collection, String collectionName) {
- return this.getChangeSupport().addItemToCollection(item, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#addItemsToCollection(Object[], Collection, String)
- */
- protected <E> boolean addItemsToCollection(E[] items, Collection<E> collection, String collectionName) {
- return this.getChangeSupport().addItemsToCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#addItemsToCollection(Collection, Collection, String)
- */
- protected <E> boolean addItemsToCollection(Collection<? extends E> items, Collection<E> collection, String collectionName) {
- return this.getChangeSupport().addItemsToCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#addItemsToCollection(Iterable, Collection, String)
- */
- protected <E> boolean addItemsToCollection(Iterable<? extends E> items, Collection<E> collection, String collectionName) {
- return this.getChangeSupport().addItemsToCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#addItemsToCollection(Iterator, Collection, String)
- */
- protected <E> boolean addItemsToCollection(Iterator<? extends E> items, Collection<E> collection, String collectionName) {
- return this.getChangeSupport().addItemsToCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#removeItemFromCollection(Object, Collection, String)
- */
- protected boolean removeItemFromCollection(Object item, Collection<?> collection, String collectionName) {
- return this.getChangeSupport().removeItemFromCollection(item, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#removeItemsFromCollection(Object[], Collection, String)
- */
- protected boolean removeItemsFromCollection(Object[] items, Collection<?> collection, String collectionName) {
- return this.getChangeSupport().removeItemsFromCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#removeItemsFromCollection(Collection, Collection, String)
- */
- protected boolean removeItemsFromCollection(Collection<?> items, Collection<?> collection, String collectionName) {
- return this.getChangeSupport().removeItemsFromCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#removeItemsFromCollection(Iterable, Collection, String)
- */
- protected boolean removeItemsFromCollection(Iterable<?> items, Collection<?> collection, String collectionName) {
- return this.getChangeSupport().removeItemsFromCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#removeItemsFromCollection(Iterator, Collection, String)
- */
- protected boolean removeItemsFromCollection(Iterator<?> items, Collection<?> collection, String collectionName) {
- return this.getChangeSupport().removeItemsFromCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#retainItemsInCollection(Object[], Collection, String)
- */
- protected boolean retainItemsInCollection(Object[] items, Collection<?> collection, String collectionName) {
- return this.getChangeSupport().retainItemsInCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#retainItemsInCollection(Collection, Collection, String)
- */
- protected boolean retainItemsInCollection(Collection<?> items, Collection<?> collection, String collectionName) {
- return this.getChangeSupport().retainItemsInCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#retainItemsInCollection(Iterable, Collection, String)
- */
- protected boolean retainItemsInCollection(Iterable<?> items, Collection<?> collection, String collectionName) {
- return this.getChangeSupport().retainItemsInCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#retainItemsInCollection(Iterator, Collection, String)
- */
- protected boolean retainItemsInCollection(Iterator<?> items, Collection<?> collection, String collectionName) {
- return this.getChangeSupport().retainItemsInCollection(items, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#clearCollection(Collection, String)
- */
- protected boolean clearCollection(Collection<?> collection, String collectionName) {
- return this.getChangeSupport().clearCollection(collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#synchronizeCollection(Collection, Collection, String)
- */
- protected <E> boolean synchronizeCollection(Collection<E> newCollection, Collection<E> collection, String collectionName) {
- return this.getChangeSupport().synchronizeCollection(newCollection, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#synchronizeCollection(Iterable, Collection, String)
- */
- protected <E> boolean synchronizeCollection(Iterable<E> newCollection, Collection<E> collection, String collectionName) {
- return this.getChangeSupport().synchronizeCollection(newCollection, collection, collectionName);
- }
-
- /**
- * @see ChangeSupport#synchronizeCollection(Iterator, Collection, String)
- */
- protected <E> boolean synchronizeCollection(Iterator<E> newCollection, Collection<E> collection, String collectionName) {
- return this.getChangeSupport().synchronizeCollection(newCollection, collection, collectionName);
- }
-
-
- // ********** list change support **********
-
- /**
- * @see ChangeSupport#addListChangeListener(String, ListChangeListener)
- */
- public void addListChangeListener(String listName, ListChangeListener listener) {
- this.getChangeSupport().addListChangeListener(listName, listener);
- }
-
- /**
- * @see ChangeSupport#removeListChangeListener(String, ListChangeListener)
- */
- public void removeListChangeListener(String listName, ListChangeListener listener) {
- this.getChangeSupport().removeListChangeListener(listName, listener);
- }
-
- /**
- * @see ChangeSupport#hasAnyListChangeListeners(String)
- */
- public boolean hasAnyListChangeListeners(String listName) {
- return (this.changeSupport != null) && this.changeSupport.hasAnyListChangeListeners(listName);
- }
-
- /**
- * Return whether the model has no list change listeners that will
- * be notified when the specified list has changed.
- */
- public boolean hasNoListChangeListeners(String listName) {
- return ! this.hasAnyListChangeListeners(listName);
- }
-
- /**
- * @see ChangeSupport#fireItemsAdded(ListAddEvent)
- */
- protected final boolean fireItemsAdded(ListAddEvent event) {
- return this.getChangeSupport().fireItemsAdded(event);
- }
-
- /**
- * @see ChangeSupport#fireItemsAdded(String, int, List)
- */
- protected final boolean fireItemsAdded(String listName, int index, List<?> addedItems) {
- return this.getChangeSupport().fireItemsAdded(listName, index, addedItems);
- }
-
- /**
- * @see ChangeSupport#fireItemAdded(String, int, Object)
- */
- protected final void fireItemAdded(String listName, int index, Object addedItem) {
- this.getChangeSupport().fireItemAdded(listName, index, addedItem);
- }
-
- /**
- * @see ChangeSupport#fireItemsRemoved(ListRemoveEvent)
- */
- protected final boolean fireItemsRemoved(ListRemoveEvent event) {
- return this.getChangeSupport().fireItemsRemoved(event);
- }
-
- /**
- * @see ChangeSupport#fireItemsRemoved(String, int, List)
- */
- protected final boolean fireItemsRemoved(String listName, int index, List<?> removedItems) {
- return this.getChangeSupport().fireItemsRemoved(listName, index, removedItems);
- }
-
- /**
- * @see ChangeSupport#fireItemRemoved(String, int, Object)
- */
- protected final void fireItemRemoved(String listName, int index, Object removedItem) {
- this.getChangeSupport().fireItemRemoved(listName, index, removedItem);
- }
-
- /**
- * @see ChangeSupport#fireItemsReplaced(ListReplaceEvent)
- */
- protected final boolean fireItemsReplaced(ListReplaceEvent event) {
- return this.getChangeSupport().fireItemsReplaced(event);
- }
-
- /**
- * @see ChangeSupport#fireItemsReplaced(String, int, List, List)
- */
- protected final <E> boolean fireItemsReplaced(String listName, int index, List<? extends E> newItems, List<E> replacedItems) {
- return this.getChangeSupport().fireItemsReplaced(listName, index, newItems, replacedItems);
- }
-
- /**
- * @see ChangeSupport#fireItemReplaced(String, int, Object, Object)
- */
- protected final boolean fireItemReplaced(String listName, int index, Object newItem, Object replacedItem) {
- return this.getChangeSupport().fireItemReplaced(listName, index, newItem, replacedItem);
- }
-
- /**
- * @see ChangeSupport#fireItemsMoved(ListMoveEvent)
- */
- protected final boolean fireItemsMoved(ListMoveEvent event) {
- return this.getChangeSupport().fireItemsMoved(event);
- }
-
- /**
- * @see ChangeSupport#fireItemsMoved(String, int, int, int)
- */
- protected final <E> boolean fireItemsMoved(String listName, int targetIndex, int sourceIndex, int length) {
- return this.getChangeSupport().fireItemsMoved(listName, targetIndex, sourceIndex, length);
- }
-
- /**
- * @see ChangeSupport#fireItemMoved(String, int, int)
- */
- protected final boolean fireItemMoved(String listName, int targetIndex, int sourceIndex) {
- return this.getChangeSupport().fireItemMoved(listName, targetIndex, sourceIndex);
- }
-
- /**
- * @see ChangeSupport#fireListCleared(ListClearEvent)
- */
- protected final void fireListCleared(ListClearEvent event) {
- this.getChangeSupport().fireListCleared(event);
- }
-
- /**
- * @see ChangeSupport#fireListCleared(String)
- */
- protected final void fireListCleared(String listName) {
- this.getChangeSupport().fireListCleared(listName);
- }
-
- protected final void fireListChanged(ListChangeEvent event) {
- this.getChangeSupport().fireListChanged(event);
- }
-
- protected final void fireListChanged(String listName, List<?> list) {
- this.getChangeSupport().fireListChanged(listName, list);
- }
-
- /**
- * @see ChangeSupport#addItemToList(int, Object, List, String)
- */
- protected <E> void addItemToList(int index, E item, List<E> list, String listName) {
- this.getChangeSupport().addItemToList(index, item, list, listName);
- }
-
- /**
- * @see ChangeSupport#addItemToList(Object, List, String)
- */
- protected <E> boolean addItemToList(E item, List<E> list, String listName) {
- return this.getChangeSupport().addItemToList(item, list, listName);
- }
-
- /**
- * @see ChangeSupport#addItemsToList(int, Object[], List, String)
- */
- protected <E> boolean addItemsToList(int index, E[] items, List<E> list, String listName) {
- return this.getChangeSupport().addItemsToList(index, items, list, listName);
- }
-
- /**
- * @see ChangeSupport#addItemsToList(int, Collection, List, String)
- */
- protected <E> boolean addItemsToList(int index, Collection<? extends E> items, List<E> list, String listName) {
- return this.getChangeSupport().addItemsToList(index, items, list, listName);
- }
-
- /**
- * @see ChangeSupport#addItemsToList(int, Iterable, List, String)
- */
- protected <E> boolean addItemsToList(int index, Iterable<? extends E> items, List<E> list, String listName) {
- return this.getChangeSupport().addItemsToList(index, items, list, listName);
- }
-
- /**
- * @see ChangeSupport#addItemsToList(int, Iterator, List, String)
- */
- protected <E> boolean addItemsToList(int index, Iterator<? extends E> items, List<E> list, String listName) {
- return this.getChangeSupport().addItemsToList(index, items, list, listName);
- }
-
- /**
- * @see ChangeSupport#addItemsToList(Object[], List, String)
- */
- protected <E> boolean addItemsToList(E[] items, List<E> list, String listName) {
- return this.getChangeSupport().addItemsToList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#addItemsToList(Collection, List, String)
- */
- protected <E> boolean addItemsToList(Collection<? extends E> items, List<E> list, String listName) {
- return this.getChangeSupport().addItemsToList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#addItemsToList(Iterable, List, String)
- */
- protected <E> boolean addItemsToList(Iterable<? extends E> items, List<E> list, String listName) {
- return this.getChangeSupport().addItemsToList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#addItemsToList(Iterator, List, String)
- */
- protected <E> boolean addItemsToList(Iterator<? extends E> items, List<E> list, String listName) {
- return this.getChangeSupport().addItemsToList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#removeItemFromList(int, List, String)
- */
- protected <E> E removeItemFromList(int index, List<E> list, String listName) {
- return this.getChangeSupport().removeItemFromList(index, list, listName);
- }
-
- /**
- * @see ChangeSupport#removeItemFromList(Object, List, String)
- */
- protected boolean removeItemFromList(Object item, List<?> list, String listName) {
- return this.getChangeSupport().removeItemFromList(item, list, listName);
- }
-
- /**
- * @see ChangeSupport#removeRangeFromList(int, int, List, String)
- */
- protected <E> List<E> removeRangeFromList(int beginIndex, int endIndex, List<E> list, String listName) {
- return this.getChangeSupport().removeRangeFromList(beginIndex, endIndex, list, listName);
- }
-
- /**
- * @see ChangeSupport#removeItemsFromList(int, List, String)
- */
- protected <E> List<E> removeItemsFromList(int index, List<E> list, String listName) {
- return this.getChangeSupport().removeItemsFromList(index, list, listName);
- }
-
- /**
- * @see ChangeSupport#removeItemsFromList(int, int, List, String)
- */
- protected <E> List<E> removeItemsFromList(int index, int length, List<E> list, String listName) {
- return this.getChangeSupport().removeItemsFromList(index, length, list, listName);
- }
-
- /**
- * @see ChangeSupport#removeItemsFromList(Object[], List, String)
- */
- protected boolean removeItemsFromList(Object[] items, List<?> list, String listName) {
- return this.getChangeSupport().removeItemsFromList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#removeItemsFromList(Collection, List, String)
- */
- protected boolean removeItemsFromList(Collection<?> items, List<?> list, String listName) {
- return this.getChangeSupport().removeItemsFromList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#removeItemsFromList(Iterable, List, String)
- */
- protected boolean removeItemsFromList(Iterable<?> items, List<?> list, String listName) {
- return this.getChangeSupport().removeItemsFromList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#removeItemsFromList(Iterator, List, String)
- */
- protected boolean removeItemsFromList(Iterator<?> items, List<?> list, String listName) {
- return this.getChangeSupport().removeItemsFromList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#retainItemsInList(Object[], List, String)
- */
- protected boolean retainItemsInList(Object[] items, List<?> list, String listName) {
- return this.getChangeSupport().retainItemsInList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#retainItemsInList(Collection, List, String)
- */
- protected boolean retainItemsInList(Collection<?> items, List<?> list, String listName) {
- return this.getChangeSupport().retainItemsInList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#retainItemsInList(Iterable, List, String)
- */
- protected boolean retainItemsInList(Iterable<?> items, List<?> list, String listName) {
- return this.getChangeSupport().retainItemsInList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#retainItemsInList(Iterator, List, String)
- */
- protected boolean retainItemsInList(Iterator<?> items, List<?> list, String listName) {
- return this.getChangeSupport().retainItemsInList(items, list, listName);
- }
-
- /**
- * @see ChangeSupport#setItemInList(int, Object, List, String)
- */
- protected <E> E setItemInList(int index, E item, List<E> list, String listName) {
- return this.getChangeSupport().setItemInList(index, item, list, listName);
- }
-
- /**
- * @see ChangeSupport#replaceItemInList(Object, Object, List, String)
- */
- protected <E> int replaceItemInList(E oldItem, E newItem, List<E> list, String listName) {
- return this.getChangeSupport().replaceItemInList(oldItem, newItem, list, listName);
- }
-
- /**
- * @see ChangeSupport#setItemsInList(int, Object[], List, String)
- */
- protected <E> List<E> setItemsInList(int index, E[] items, List<E> list, String listName) {
- return this.getChangeSupport().setItemsInList(index, items, list, listName);
- }
-
- /**
- * @see ChangeSupport#setItemsInList(int, List, List, String)
- */
- protected <E> List<E> setItemsInList(int index, List<? extends E> items, List<E> list, String listName) {
- return this.getChangeSupport().setItemsInList(index, items, list, listName);
- }
-
- /**
- * @see ChangeSupport#moveItemsInList(int, int, int, List, String)
- */
- protected <E> void moveItemsInList(int targetIndex, int sourceIndex, int length, List<E> list, String listName) {
- this.getChangeSupport().moveItemsInList(targetIndex, sourceIndex, length, list, listName);
- }
-
- /**
- * @see ChangeSupport#moveItemInList(int, int, List, String)
- */
- protected <E> void moveItemInList(int targetIndex, int sourceIndex, List<E> list, String listName) {
- this.getChangeSupport().moveItemInList(targetIndex, sourceIndex, list, listName);
- }
-
- /**
- * @see ChangeSupport#moveItemInList(int, Object, List, String)
- */
- protected <E> void moveItemInList(int targetIndex, E item, List<E> list, String listName) {
- this.getChangeSupport().moveItemInList(targetIndex, item, list, listName);
- }
-
- /**
- * @see ChangeSupport#clearList(List, String)
- */
- protected boolean clearList(List<?> list, String listName) {
- return this.getChangeSupport().clearList(list, listName);
- }
-
- /**
- * @see ChangeSupport#synchronizeList(List, List, String)
- */
- protected <E> boolean synchronizeList(List<? extends E> newList, List<E> list, String listName) {
- return this.getChangeSupport().synchronizeList(newList, list, listName);
- }
-
- /**
- * @see ChangeSupport#synchronizeList(Iterable, List, String)
- */
- protected <E> boolean synchronizeList(Iterable<? extends E> newList, List<E> list, String listName) {
- return this.getChangeSupport().synchronizeList(newList, list, listName);
- }
-
- /**
- * @see ChangeSupport#synchronizeList(Iterator, List, String)
- */
- protected <E> boolean synchronizeList(Iterator<? extends E> newList, List<E> list, String listName) {
- return this.getChangeSupport().synchronizeList(newList, list, listName);
- }
-
-
- // ********** tree change support **********
-
- /**
- * @see ChangeSupport#addTreeChangeListener(String, TreeChangeListener)
- */
- public void addTreeChangeListener(String treeName, TreeChangeListener listener) {
- this.getChangeSupport().addTreeChangeListener(treeName, listener);
- }
-
- /**
- * @see ChangeSupport#removeTreeChangeListener(String, TreeChangeListener)
- */
- public void removeTreeChangeListener(String treeName, TreeChangeListener listener) {
- this.getChangeSupport().removeTreeChangeListener(treeName, listener);
- }
-
- /**
- * @see ChangeSupport#hasAnyTreeChangeListeners(String)
- */
- public boolean hasAnyTreeChangeListeners(String treeName) {
- return (this.changeSupport != null) && this.changeSupport.hasAnyTreeChangeListeners(treeName);
- }
-
- /**
- * Return whether the model has no tree change listeners that will
- * be notified when the specified tree has changed.
- */
- public boolean hasNoTreeChangeListeners(String treeName) {
- return ! this.hasAnyTreeChangeListeners(treeName);
- }
-
- /**
- * @see ChangeSupport#fireNodeAdded(TreeAddEvent)
- */
- protected final void fireNodeAdded(TreeAddEvent event) {
- this.getChangeSupport().fireNodeAdded(event);
- }
-
- /**
- * @see ChangeSupport#fireNodeAdded(String, List)
- */
- protected final void fireNodeAdded(String treeName, List<?> path) {
- this.getChangeSupport().fireNodeAdded(treeName, path);
- }
-
- /**
- * @see ChangeSupport#fireNodeRemoved(TreeRemoveEvent)
- */
- protected final void fireNodeRemoved(TreeRemoveEvent event) {
- this.getChangeSupport().fireNodeRemoved(event);
- }
-
- /**
- * @see ChangeSupport#fireNodeRemoved(String, List)
- */
- protected final void fireNodeRemoved(String treeName, List<?> path) {
- this.getChangeSupport().fireNodeRemoved(treeName, path);
- }
-
- /**
- * @see ChangeSupport#fireTreeCleared(TreeClearEvent)
- */
- protected final void fireTreeCleared(TreeClearEvent event) {
- this.getChangeSupport().fireTreeCleared(event);
- }
-
- /**
- * @see ChangeSupport#fireTreeCleared(String)
- */
- protected final void fireTreeCleared(String treeName) {
- this.getChangeSupport().fireTreeCleared(treeName);
- }
-
- /**
- * @see ChangeSupport#fireTreeChanged(TreeChangeEvent)
- */
- protected final void fireTreeChanged(TreeChangeEvent event) {
- this.getChangeSupport().fireTreeChanged(event);
- }
-
- /**
- * @see ChangeSupport#fireTreeChanged(String, Collection)
- */
- protected final void fireTreeChanged(String treeName, Collection<?> nodes) {
- this.getChangeSupport().fireTreeChanged(treeName, nodes);
- }
-
-
- // ********** convenience methods **********
-
- /**
- * Return whether the specified values are equal, with the appropriate <code>null</code> checks.
- * Convenience method for checking whether an attribute value has changed.
- * <p>
- * <em>Do not</em> use this to determine whether to fire a change notification,
- * {@link ChangeSupport} already does that.
- */
- protected final boolean valuesAreEqual(Object value1, Object value2) {
- return this.getChangeSupport().valuesAreEqual(value1, value2);
- }
-
- /**
- * @see #valuesAreEqual(Object, Object)
- */
- protected final boolean attributeValueHasNotChanged(Object oldValue, Object newValue) {
- return this.valuesAreEqual(oldValue, newValue);
- }
-
-
- /**
- * <em>Do not</em> use this to determine whether to fire a change notification,
- * {@link ChangeSupport} already does that.
- * <p>
- * For example, after firing the change notification, you can use this method
- * to decide if some other, related, piece of state needs to be synchronized
- * with the state that just changed.
- *
- * @see ChangeSupport#valuesAreDifferent(Object, Object)
- */
- protected final boolean valuesAreDifferent(Object value1, Object value2) {
- return this.getChangeSupport().valuesAreDifferent(value1, value2);
- }
-
- /**
- * @see #valuesAreDifferent(Object, Object)
- */
- protected final boolean attributeValueHasChanged(Object oldValue, Object newValue) {
- return this.valuesAreDifferent(oldValue, newValue);
- }
-
-
- // ********** Object overrides **********
-
- /**
- * Although cloning models is usually not a Good Idea,
- * we should at least support it properly.
- */
- @Override
- protected AbstractModel clone() throws CloneNotSupportedException {
- AbstractModel clone = (AbstractModel) super.clone();
- // clear out change support - models do not share listeners
- clone.changeSupport = null;
- return clone;
- }
-
- /**
- * e.g. <code>"ClassName[00-F3-EE-42](add'l info)"</code>
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- StringTools.appendSimpleToString(sb, this);
- sb.append('(');
- int len = sb.length();
- this.toString(sb);
- if (sb.length() == len) {
- sb.deleteCharAt(len - 1);
- } else {
- sb.append(')');
- }
- return sb.toString();
- }
-
- /**
- * This method is public so one model can call a nested abstract model's
- * <code>#toString(StringBuilder)</code>.
- */
- public void toString(@SuppressWarnings("unused") StringBuilder sb) {
- // subclasses should override this to do something a bit more helpful
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AspectChangeSupport.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AspectChangeSupport.java
deleted file mode 100644
index d98f4438fd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/AspectChangeSupport.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model;
-
-import java.util.Collection;
-import java.util.EventListener;
-import java.util.List;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-
-/**
- * This change support class will notify listeners whenever one of the source's
- * aspects has changed. Only the aspect name is passed to the listener; no
- * event is generated. This allows the listeners to delegate to the change
- * support object verification that an aspect as actually changed. This is
- * useful for simple things like setting dirty flags, blanket validation, and
- * blanket sychronization; i.e. things that might be interested in the <em>name</em>
- * of the aspect that changed but not so much <em>how</em> the aspect changed.
- */
-public class AspectChangeSupport
- extends ChangeSupport
-{
- private static final long serialVersionUID = 1L;
- protected static final Class<Listener> LISTENER_CLASS = Listener.class;
-
-
- public AspectChangeSupport(Model source, Listener listener) {
- this(source);
- this.addListener(listener);
- }
-
- public AspectChangeSupport(Model source) {
- super(source);
- }
-
- protected void aspectChanged(String aspectName) {
- Iterable<Listener> listeners = this.getListeners();
- if (listeners != null) {
- for (Listener listener : listeners) {
- listener.aspectChanged(aspectName);
- }
- }
- }
-
- public void addListener(Listener listener) {
- this.addListener(LISTENER_CLASS, listener);
- }
-
- public void removeListener(Listener listener) {
- this.removeListener(LISTENER_CLASS, listener);
- }
-
- private Iterable<Listener> getListeners() {
- ListenerList<Listener> listenerList = this.getListenerList();
- return (listenerList == null) ? null : listenerList.getListeners();
- }
-
- private ListenerList<Listener> getListenerList() {
- return this.getListenerList(LISTENER_CLASS);
- }
-
-
- // ********** listener interface **********
-
- /**
- * Listener that will be notified of any aspect changes.
- */
- public interface Listener extends EventListener {
-
- /**
- * The specified aspect changed.
- */
- void aspectChanged(String aspectName);
-
- }
-
-
- // ********** state change support **********
-
- @Override
- public void fireStateChanged(StateChangeEvent event) {
- super.fireStateChanged(event);
- this.aspectChanged(null);
- }
-
- @Override
- public void fireStateChanged() {
- super.fireStateChanged();
- this.aspectChanged(null);
- }
-
-
- // ********** property change support **********
-
- @Override
- protected void firePropertyChanged_(PropertyChangeEvent event) {
- super.firePropertyChanged_(event);
- this.aspectChanged(event.getPropertyName());
- }
-
- @Override
- protected void firePropertyChanged_(String propertyName, Object oldValue, Object newValue) {
- super.firePropertyChanged_(propertyName, oldValue, newValue);
- this.aspectChanged(propertyName);
- }
-
- @Override
- protected void firePropertyChanged_(String propertyName, int oldValue, int newValue) {
- super.firePropertyChanged_(propertyName, oldValue, newValue);
- this.aspectChanged(propertyName);
- }
-
- @Override
- protected void firePropertyChanged_(String propertyName, boolean oldValue, boolean newValue) {
- super.firePropertyChanged_(propertyName, oldValue, newValue);
- this.aspectChanged(propertyName);
- }
-
-
- // ********** collection change support **********
-
- @Override
- protected void fireItemsAdded_(CollectionAddEvent event) {
- super.fireItemsAdded_(event);
- this.aspectChanged(event.getCollectionName());
- }
-
- @Override
- protected void fireItemsAdded_(String collectionName, Collection<?> addedItems) {
- super.fireItemsAdded_(collectionName, addedItems);
- this.aspectChanged(collectionName);
- }
-
- @Override
- public void fireItemAdded(String collectionName, Object addedItem) {
- super.fireItemAdded(collectionName, addedItem);
- this.aspectChanged(collectionName);
- }
-
- @Override
- protected void fireItemsRemoved_(CollectionRemoveEvent event) {
- super.fireItemsRemoved_(event);
- this.aspectChanged(event.getCollectionName());
- }
-
- @Override
- protected void fireItemsRemoved_(String collectionName, Collection<?> removedItems) {
- super.fireItemsRemoved_(collectionName, removedItems);
- this.aspectChanged(collectionName);
- }
-
- @Override
- public void fireItemRemoved(String collectionName, Object removedItem) {
- super.fireItemRemoved(collectionName, removedItem);
- this.aspectChanged(collectionName);
- }
-
- @Override
- public void fireCollectionCleared(CollectionClearEvent event) {
- super.fireCollectionCleared(event);
- this.aspectChanged(event.getCollectionName());
- }
-
- @Override
- public void fireCollectionCleared(String collectionName) {
- super.fireCollectionCleared(collectionName);
- this.aspectChanged(collectionName);
- }
-
- @Override
- public void fireCollectionChanged(CollectionChangeEvent event) {
- super.fireCollectionChanged(event);
- this.aspectChanged(event.getCollectionName());
- }
-
- @Override
- public void fireCollectionChanged(String collectionName, Collection<?> collection) {
- super.fireCollectionChanged(collectionName, collection);
- this.aspectChanged(collectionName);
- }
-
-
- // ********** list change support **********
-
- @Override
- protected void fireItemsAdded_(ListAddEvent event) {
- super.fireItemsAdded_(event);
- this.aspectChanged(event.getListName());
- }
-
- @Override
- protected void fireItemsAdded_(String listName, int index, List<?> addedItems) {
- super.fireItemsAdded_(listName, index, addedItems);
- this.aspectChanged(listName);
- }
-
- @Override
- public void fireItemAdded(String listName, int index, Object addedItem) {
- super.fireItemAdded(listName, index, addedItem);
- this.aspectChanged(listName);
- }
-
- @Override
- protected void fireItemsRemoved_(ListRemoveEvent event) {
- super.fireItemsRemoved_(event);
- this.aspectChanged(event.getListName());
- }
-
- @Override
- protected void fireItemsRemoved_(String listName, int index, List<?> removedItems) {
- super.fireItemsRemoved_(listName, index, removedItems);
- this.aspectChanged(listName);
- }
-
- @Override
- public void fireItemRemoved(String listName, int index, Object removedItem) {
- super.fireItemRemoved(listName, index, removedItem);
- this.aspectChanged(listName);
- }
-
- @Override
- protected void fireItemsReplaced_(ListReplaceEvent event) {
- super.fireItemsReplaced_(event);
- this.aspectChanged(event.getListName());
- }
-
- @Override
- protected void fireItemsReplaced_(String listName, int index, List<?> newItems, List<?> replacedItems) {
- super.fireItemsReplaced_(listName, index, newItems, replacedItems);
- this.aspectChanged(listName);
- }
-
- @Override
- protected void fireItemReplaced_(String listName, int index, Object newItem, Object replacedItem) {
- super.fireItemReplaced_(listName, index, newItem, replacedItem);
- this.aspectChanged(listName);
- }
-
- @Override
- protected void fireItemsMoved_(ListMoveEvent event) {
- super.fireItemsMoved_(event);
- this.aspectChanged(event.getListName());
- }
-
- @Override
- protected void fireItemsMoved_(String listName, int targetIndex, int sourceIndex, int length) {
- super.fireItemsMoved_(listName, targetIndex, sourceIndex, length);
- this.aspectChanged(listName);
- }
-
- @Override
- public void fireListCleared(ListClearEvent event) {
- super.fireListCleared(event);
- this.aspectChanged(event.getListName());
- }
-
- @Override
- public void fireListCleared(String listName) {
- super.fireListCleared(listName);
- this.aspectChanged(listName);
- }
-
- @Override
- public void fireListChanged(ListChangeEvent event) {
- super.fireListChanged(event);
- this.aspectChanged(event.getListName());
- }
-
- @Override
- public void fireListChanged(String listName, List<?> list) {
- super.fireListChanged(listName, list);
- this.aspectChanged(listName);
- }
-
-
- // ********** tree change support **********
-
- @Override
- public void fireNodeAdded(TreeAddEvent event) {
- super.fireNodeAdded(event);
- this.aspectChanged(event.getTreeName());
- }
-
- @Override
- public void fireNodeAdded(String treeName, List<?> path) {
- super.fireNodeAdded(treeName, path);
- this.aspectChanged(treeName);
- }
-
- @Override
- public void fireNodeRemoved(TreeRemoveEvent event) {
- super.fireNodeRemoved(event);
- this.aspectChanged(event.getTreeName());
- }
-
- @Override
- public void fireNodeRemoved(String treeName, List<?> path) {
- super.fireNodeRemoved(treeName, path);
- this.aspectChanged(treeName);
- }
-
- @Override
- public void fireTreeCleared(TreeClearEvent event) {
- super.fireTreeCleared(event);
- this.aspectChanged(event.getTreeName());
- }
-
- @Override
- public void fireTreeCleared(String treeName) {
- super.fireTreeCleared(treeName);
- this.aspectChanged(treeName);
- }
-
- @Override
- public void fireTreeChanged(TreeChangeEvent event) {
- super.fireTreeChanged(event);
- this.aspectChanged(event.getTreeName());
- }
-
- @Override
- public void fireTreeChanged(String treeName, Collection<?> nodes) {
- super.fireTreeChanged(treeName, nodes);
- this.aspectChanged(treeName);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/ChangeSupport.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/ChangeSupport.java
deleted file mode 100644
index 6774ac4b6d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/ChangeSupport.java
+++ /dev/null
@@ -1,2844 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EventListener;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.TreeChangeListener;
-
-/**
- * Support object that can be used by implementors of the {@link Model} interface.
- * It provides for state, property, collection, list, and tree change notifications to
- * listeners.
- * <p>
- * <strong>NB1:</strong> There is lots of copy-n-paste code in this class. Nearly all of this duplication
- * is an effort to prevent the unnecessary creation of new objects (typically event
- * objects). Since many events are fired when there are no listeners, we postpone
- * the creation of event objects until we know we have interested listeners.
- * Most methods have the "non-duplicated" version of the method body commented
- * out at the top of the current method body.
- * The hope was that this class would prove to be fairly static and the duplicated
- * code would not prove onerous; but that has not proven to be
- * the case, as we have added support for "state" changes, "dirty" notification,
- * and custom "notifiers", with more to come, I'm sure.... ~bjv
- * <p>
- * <strong>NB2:</strong> This class will check to see if, during the firing of events, a listener
- * on the original, cloned, list of listeners has been removed from the master
- * list of listeners <em>before</em> it is notified. If the listener has been removed
- * "concurrently" it will <em>not</em> be notified.
- * <p>
- * <strong>NB3:</strong> Any listener that is added during the firing of events will <em>not</em> be
- * also notified. This is a bit inconsistent with NB2, but seems reasonable
- * since any added listener should already be in sync with the model.
- * <p>
- * <strong>NB4:</strong> This class is serializable, but it will only write out listeners that
- * are also serializable while silently leaving behind listeners that are not.
- *
- * @see Model
- * @see AbstractModel
- */
-public class ChangeSupport
- implements Serializable
-{
- /** The object to be provided as the "source" for any generated events. */
- protected final Model source;
-
- /** Associate aspect names to class-specific listener lists. */
- private AspectListenerListPair<?>[] aspectListenerListPairs = EMPTY_ASPECT_LISTENER_LIST_PAIR_ARRAY;
- private static final AspectListenerListPair<?>[] EMPTY_ASPECT_LISTENER_LIST_PAIR_ARRAY = new AspectListenerListPair[0];
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructor **********
-
- /**
- * Construct support for the specified source of change events.
- * The source cannot be <code>null</code>.
- */
- public ChangeSupport(Model source) {
- super();
- if (source == null) {
- throw new NullPointerException();
- }
- this.source = source;
- }
-
-
- // ********** internal implementation **********
-
- /**
- * Add a listener that listens to all the events of the specified type and
- * carrying the specified aspect name.
- * Neither the aspect name nor the listener can be <code>null</code>.
- */
- protected synchronized <L extends EventListener> void addListener(Class<L> listenerClass, String aspectName, L listener) {
- ListenerList<L> aspectListenerList = this.getListenerList(listenerClass, aspectName);
- if (aspectListenerList == null) {
- this.aspectListenerListPairs = ArrayTools.add(this.aspectListenerListPairs, new SimpleAspectListenerListPair<L>(listenerClass, aspectName, listener));
- } else {
- aspectListenerList.add(listener);
- }
- }
-
- /**
- * Add a listener that listens to all the events of the specified type.
- * The listener cannot be <code>null</code>.
- */
- protected synchronized <L extends EventListener> void addListener(Class<L> listenerClass, L listener) {
- ListenerList<L> listenerList = this.getListenerList(listenerClass);
- if (listenerList == null) {
- this.aspectListenerListPairs = ArrayTools.add(this.aspectListenerListPairs, new NullAspectListenerListPair<L>(listenerClass, listener));
- } else {
- listenerList.add(listener);
- }
- }
-
- /**
- * Remove a listener that has been registered for all the
- * events of the specified type and carrying the specified aspect name.
- * Neither the aspect name nor the listener can be <code>null</code>.
- */
- protected synchronized <L extends EventListener> void removeListener(Class<L> listenerClass, String aspectName, L listener) {
- ListenerList<L> aspectListenerList = this.getListenerList(listenerClass, aspectName);
- if (aspectListenerList == null) {
- throw new IllegalArgumentException("unregistered listener: " + listener); //$NON-NLS-1$
- }
- aspectListenerList.remove(listener); // leave the pair, even if the listener list is empty?
- }
-
- /**
- * Remove a listener that has been registered for all the events of the specified type.
- * The listener cannot be <code>null</code>.
- */
- protected synchronized <L extends EventListener> void removeListener(Class<L> listenerClass, L listener) {
- ListenerList<L> listenerList = this.getListenerList(listenerClass);
- if (listenerList == null) {
- throw new IllegalArgumentException("unregistered listener: " + listener); //$NON-NLS-1$
- }
- listenerList.remove(listener); // leave the pair, even if the listener list is empty?
- }
-
- /**
- * Return the listener list for the specified listener class and aspect name.
- * Return <code>null</code> if the listener list is not present.
- * The aspect name cannot be <code>null</code>.
- */
- protected <L extends EventListener> ListenerList<L> getListenerList(Class<L> listenerClass, String aspectName) {
- // put in a null check to simplify calling code
- if (aspectName == null) {
- throw new NullPointerException();
- }
- return this.getListenerList_(listenerClass, aspectName);
- }
-
- /**
- * Return the listener list for the specified listener class.
- * Return <code>null</code> if the listener list is not present.
- */
- protected <L extends EventListener> ListenerList<L> getListenerList(Class<L> listenerClass) {
- return this.getListenerList_(listenerClass, null);
- }
-
- /**
- * Return the listener list for the specified listener class and aspect name.
- * Return <code>null</code> if the listener list is not present.
- */
- protected synchronized <L extends EventListener> ListenerList<L> getListenerList_(Class<L> listenerClass, String aspectName) {
- for (AspectListenerListPair<?> pair : this.aspectListenerListPairs) {
- if (pair.matches(listenerClass, aspectName)) {
- @SuppressWarnings("unchecked") ListenerList<L> aspectListenerList = (ListenerList<L>) pair.listenerList;
- return aspectListenerList;
- }
- }
- return null;
- }
-
- /**
- * Return whether there are any listeners for the specified listener class
- * and aspect name.
- */
- protected <L extends EventListener> boolean hasAnyListeners(Class<L> listenerClass, String aspectName) {
- ListenerList<L> aspectListenerList = this.getListenerList(listenerClass, aspectName);
- if ((aspectListenerList != null) && ! aspectListenerList.isEmpty()) {
- return true;
- }
- return this.hasAnyChangeListeners(); // check for any general purpose listeners
- }
-
- /**
- * Return whether there are no listeners for the specified listener class
- * and aspect name.
- */
- protected <L extends EventListener> boolean hasNoListeners(Class<L> listenerClass, String aspectName) {
- return ! this.hasAnyListeners(listenerClass, aspectName);
- }
-
- /**
- * Return whether there are any listeners for the specified listener class.
- */
- protected <L extends EventListener> boolean hasAnyListeners(Class<L> listenerClass) {
- ListenerList<L> aspectListenerList = this.getListenerList(listenerClass);
- if ((aspectListenerList != null) && ! aspectListenerList.isEmpty()) {
- return true;
- }
- // check for any general purpose listeners (unless that's what we're already doing)
- return (listenerClass == this.getChangeListenerClass()) ? false : this.hasAnyChangeListeners();
- }
-
- /**
- * Return whether there are no listeners for the specified listener class.
- */
- protected <L extends EventListener> boolean hasNoListeners(Class<L> listenerClass) {
- return ! this.hasAnyListeners(listenerClass);
- }
-
-
- // ********** general purpose change support **********
-
- /**
- * Subclasses that add other types of listeners should override this method
- * to return the extension to ChangeListener that also extends whatever new
- * listener types are supported.
- */
- @SuppressWarnings("unchecked")
- protected <L extends ChangeListener> Class<L> getChangeListenerClass() {
- // not sure why I need to cast here...
- return (Class<L>) CHANGE_LISTENER_CLASS;
- }
-
- protected static final Class<ChangeListener> CHANGE_LISTENER_CLASS = ChangeListener.class;
-
- /**
- * Add a general purpose listener that listens to all events,
- * regardless of the aspect name associated with that event.
- * The listener cannot be null.
- */
- public void addChangeListener(ChangeListener listener) {
- this.addListener(this.getChangeListenerClass(), listener);
- }
-
- /**
- * Remove a general purpose listener.
- * The listener cannot be null.
- */
- public void removeChangeListener(ChangeListener listener) {
- this.removeListener(this.getChangeListenerClass(), listener);
- }
-
- /**
- * Return whether there are any general purpose listeners that will be
- * notified of any changes.
- */
- public boolean hasAnyChangeListeners() {
- return this.hasAnyListeners(this.getChangeListenerClass());
- }
-
- private ListenerList<ChangeListener> getChangeListenerList() {
- return this.getListenerList(CHANGE_LISTENER_CLASS);
- }
-
- private Iterable<ChangeListener> getChangeListeners() {
- ListenerList<ChangeListener> listenerList = this.getChangeListenerList();
- return (listenerList == null) ? null : listenerList.getListeners();
- }
-
- private boolean hasChangeListener(ChangeListener listener) {
- return CollectionTools.contains(this.getChangeListeners(), listener);
- }
-
-
- // ********** state change support **********
-
- protected static final Class<StateChangeListener> STATE_CHANGE_LISTENER_CLASS = StateChangeListener.class;
-
- /**
- * Add a state change listener.
- */
- public void addStateChangeListener(StateChangeListener listener) {
- this.addListener(STATE_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Remove a state change listener.
- */
- public void removeStateChangeListener(StateChangeListener listener) {
- this.removeListener(STATE_CHANGE_LISTENER_CLASS, listener);
- }
-
- /**
- * Return whether there are any state change listeners.
- */
- public boolean hasAnyStateChangeListeners() {
- return this.hasAnyListeners(STATE_CHANGE_LISTENER_CLASS);
- }
-
- private ListenerList<StateChangeListener> getStateChangeListenerList() {
- return this.getListenerList(STATE_CHANGE_LISTENER_CLASS);
- }
-
- private Iterable<StateChangeListener> getStateChangeListeners() {
- ListenerList<StateChangeListener> listenerList = this.getStateChangeListenerList();
- return (listenerList == null) ? null : listenerList.getListeners();
- }
-
- private boolean hasStateChangeListener(StateChangeListener listener) {
- return CollectionTools.contains(this.getStateChangeListeners(), listener);
- }
-
- /**
- * Fire the specified state change event to any registered listeners.
- */
- public void fireStateChanged(StateChangeEvent event) {
- Iterable<StateChangeListener> listeners = this.getStateChangeListeners();
- if (listeners != null) {
- for (StateChangeListener listener : listeners) {
- if (this.hasStateChangeListener(listener)) { // verify listener is still listening
- listener.stateChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.stateChanged(event);
- }
- }
- }
- }
-
- /**
- * Report a generic state change event to any registered state change
- * listeners.
- */
- public void fireStateChanged() {
-// this.fireStateChanged(new StateChangeEvent(this.source));
- StateChangeEvent event = null;
- Iterable<StateChangeListener> listeners = this.getStateChangeListeners();
- if (listeners != null) {
- for (StateChangeListener listener : listeners) {
- if (this.hasStateChangeListener(listener)) { // verify listener is still listening
- if (event == null) {
- event = new StateChangeEvent(this.source);
- }
- listener.stateChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new StateChangeEvent(this.source);
- }
- changeListener.stateChanged(event);
- }
- }
- }
- }
-
-
- // ********** property change support **********
-
- protected static final Class<PropertyChangeListener> PROPERTY_CHANGE_LISTENER_CLASS = PropertyChangeListener.class;
-
- /**
- * Add a property change listener for the specified property. The listener
- * will be notified only for changes to the specified property.
- */
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- this.addListener(PROPERTY_CHANGE_LISTENER_CLASS, propertyName, listener);
- }
-
- /**
- * Remove a property change listener that was registered for a specific property.
- */
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- this.removeListener(PROPERTY_CHANGE_LISTENER_CLASS, propertyName, listener);
- }
-
- /**
- * Return whether there are any property change listeners that will
- * be notified when the specified property has changed.
- */
- public boolean hasAnyPropertyChangeListeners(String propertyName) {
- return this.hasAnyListeners(PROPERTY_CHANGE_LISTENER_CLASS, propertyName);
- }
-
- private ListenerList<PropertyChangeListener> getPropertyChangeListenerList(String propertyName) {
- return this.getListenerList(PROPERTY_CHANGE_LISTENER_CLASS, propertyName);
- }
-
- private Iterable<PropertyChangeListener> getPropertyChangeListeners(String propertyName) {
- ListenerList<PropertyChangeListener> listenerList = this.getPropertyChangeListenerList(propertyName);
- return (listenerList == null) ? null : listenerList.getListeners();
- }
-
- private boolean hasPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- return CollectionTools.contains(this.getPropertyChangeListeners(propertyName), listener);
- }
-
- /**
- * Fire the specified property change event to any registered listeners.
- * No event is fired if the specified event's old and new values are the same;
- * this includes when both values are null. Use a state change event
- * for general purpose notification of changes.
- * Return whether the old and new values are different.
- */
- public boolean firePropertyChanged(PropertyChangeEvent event) {
- if (this.valuesAreDifferent(event.getOldValue(), event.getNewValue())) {
- this.firePropertyChanged_(event);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified event's old and new values are different
- */
- protected void firePropertyChanged_(PropertyChangeEvent event) {
- String propertyName = event.getPropertyName();
- Iterable<PropertyChangeListener> listeners = this.getPropertyChangeListeners(propertyName);
- if (listeners != null) {
- for (PropertyChangeListener listener : listeners) {
- if (this.hasPropertyChangeListener(propertyName, listener)) { // verify listener is still listening
- listener.propertyChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.propertyChanged(event);
- }
- }
- }
- }
-
- /**
- * Report a bound property update to any registered property change listeners.
- * No event is fired if the specified old and new values are the same;
- * this includes when both values are null. Use a state change event
- * for general purpose notification of changes.
- * Return whether the old and new values are different.
- */
- public boolean firePropertyChanged(String propertyName, Object oldValue, Object newValue) {
-// return this.firePropertyChanged(new PropertyChangeEvent(this.source, propertyName, oldValue, newValue));
- if (this.valuesAreDifferent(oldValue, newValue)) {
- this.firePropertyChanged_(propertyName, oldValue, newValue);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified old and new values are different
- */
- protected void firePropertyChanged_(String propertyName, Object oldValue, Object newValue) {
- PropertyChangeEvent event = null;
- Iterable<PropertyChangeListener> listeners = this.getPropertyChangeListeners(propertyName);
- if (listeners != null) {
- for (PropertyChangeListener listener : listeners) {
- if (this.hasPropertyChangeListener(propertyName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new PropertyChangeEvent(this.source, propertyName, oldValue, newValue);
- }
- listener.propertyChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new PropertyChangeEvent(this.source, propertyName, oldValue, newValue);
- }
- changeListener.propertyChanged(event);
- }
- }
- }
- }
-
- /**
- * Report an <code>int</code> bound property update to any registered listeners.
- * No event is fired if the specified old and new values are equal.
- * Return whether the old and new values are different.
- * <p>
- * This is merely a convenience wrapper around the more general method
- * {@link #firePropertyChanged(String, Object, Object)}.
- */
- public boolean firePropertyChanged(String propertyName, int oldValue, int newValue) {
-// return this.firePropertyChanged(propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue));
- if (oldValue != newValue) {
- this.firePropertyChanged_(propertyName, oldValue, newValue);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified old and new values are different
- */
- protected void firePropertyChanged_(String propertyName, int oldValue, int newValue) {
- PropertyChangeEvent event = null;
- Iterable<PropertyChangeListener> listeners = this.getPropertyChangeListeners(propertyName);
- if (listeners != null) {
- for (PropertyChangeListener listener : listeners) {
- if (this.hasPropertyChangeListener(propertyName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new PropertyChangeEvent(this.source, propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue));
- }
- listener.propertyChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new PropertyChangeEvent(this.source, propertyName, Integer.valueOf(oldValue), Integer.valueOf(newValue));
- }
- changeListener.propertyChanged(event);
- }
- }
- }
- }
-
- /**
- * Report a <code>boolean</code> bound property update to any registered listeners.
- * No event is fired if the specified old and new values are equal.
- * Return whether the old and new values are different.
- * <p>
- * This is merely a convenience wrapper around the more general method
- * {@link #firePropertyChanged(String, Object, Object)}.
- */
- public boolean firePropertyChanged(String propertyName, boolean oldValue, boolean newValue) {
-// return this.firePropertyChanged(propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
- if (oldValue != newValue) {
- this.firePropertyChanged_(propertyName, oldValue, newValue);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified old and new values are different
- */
- protected void firePropertyChanged_(String propertyName, boolean oldValue, boolean newValue) {
- PropertyChangeEvent event = null;
- Iterable<PropertyChangeListener> listeners = this.getPropertyChangeListeners(propertyName);
- if (listeners != null) {
- for (PropertyChangeListener listener : listeners) {
- if (this.hasPropertyChangeListener(propertyName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new PropertyChangeEvent(this.source, propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
- }
- listener.propertyChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new PropertyChangeEvent(this.source, propertyName, Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
- }
- changeListener.propertyChanged(event);
- }
- }
- }
- }
-
-
- // ********** collection change support **********
-
- protected static final Class<CollectionChangeListener> COLLECTION_CHANGE_LISTENER_CLASS = CollectionChangeListener.class;
-
- /**
- * Add a collection change listener for the specified collection. The listener
- * will be notified only for changes to the specified collection.
- */
- public void addCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- this.addListener(COLLECTION_CHANGE_LISTENER_CLASS, collectionName, listener);
- }
-
- /**
- * Remove a collection change listener that was registered for a specific collection.
- */
- public void removeCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- this.removeListener(COLLECTION_CHANGE_LISTENER_CLASS, collectionName, listener);
- }
-
- /**
- * Return whether there are any collection change listeners that will
- * be notified when the specified collection has changed.
- */
- public boolean hasAnyCollectionChangeListeners(String collectionName) {
- return this.hasAnyListeners(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- }
-
- private ListenerList<CollectionChangeListener> getCollectionChangeListenerList(String collectionName) {
- return this.getListenerList(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- }
-
- private Iterable<CollectionChangeListener> getCollectionChangeListeners(String collectionName) {
- ListenerList<CollectionChangeListener> listenerList = this.getCollectionChangeListenerList(collectionName);
- return (listenerList == null) ? null : listenerList.getListeners();
- }
-
- private boolean hasCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- return CollectionTools.contains(this.getCollectionChangeListeners(collectionName), listener);
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- * Return whether the event has any items.
- */
- public boolean fireItemsAdded(CollectionAddEvent event) {
- if (event.getItemsSize() != 0) {
- this.fireItemsAdded_(event);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified event contains items
- */
- protected void fireItemsAdded_(CollectionAddEvent event) {
- String collectionName = event.getCollectionName();
- Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
- if (listeners != null) {
- for (CollectionChangeListener listener : listeners) {
- if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
- listener.itemsAdded(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.itemsAdded(event);
- }
- }
- }
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- * Return whether there are any added items.
- */
- public boolean fireItemsAdded(String collectionName, Collection<?> addedItems) {
-// return this.fireItemsAdded(new CollectionAddEvent(this.source, collectionName, addedItems));
- if ( ! addedItems.isEmpty()) {
- this.fireItemsAdded_(collectionName, addedItems);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: 'addedItems' is not empty
- */
- protected void fireItemsAdded_(String collectionName, Collection<?> addedItems) {
- CollectionAddEvent event = null;
- Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
- if (listeners != null) {
- for (CollectionChangeListener listener : listeners) {
- if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionAddEvent(this.source, collectionName, addedItems);
- }
- listener.itemsAdded(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionAddEvent(this.source, collectionName, addedItems);
- }
- changeListener.itemsAdded(event);
- }
- }
- }
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireItemAdded(String collectionName, Object addedItem) {
-// this.fireItemsAdded(collectionName, Collections.singleton(addedItem));
-
- CollectionAddEvent event = null;
- Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
- if (listeners != null) {
- for (CollectionChangeListener listener : listeners) {
- if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionAddEvent(this.source, collectionName, addedItem);
- }
- listener.itemsAdded(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionAddEvent(this.source, collectionName, addedItem);
- }
- changeListener.itemsAdded(event);
- }
- }
- }
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- * Return whether the event has any items.
- */
- public boolean fireItemsRemoved(CollectionRemoveEvent event) {
- if (event.getItemsSize() != 0) {
- this.fireItemsRemoved_(event);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified event contains items
- */
- protected void fireItemsRemoved_(CollectionRemoveEvent event) {
- String collectionName = event.getCollectionName();
- Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
- if (listeners != null) {
- for (CollectionChangeListener listener : listeners) {
- if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
- listener.itemsRemoved(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.itemsRemoved(event);
- }
- }
- }
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- * Return whether there are any removed items.
- */
- public boolean fireItemsRemoved(String collectionName, Collection<?> removedItems) {
-// return this.fireItemsRemoved(new CollectionRemoveEvent(this.source, collectionName, removedItems));
- if ( ! removedItems.isEmpty()) {
- this.fireItemsRemoved_(collectionName, removedItems);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: 'removedItems' is not empty
- */
- protected void fireItemsRemoved_(String collectionName, Collection<?> removedItems) {
- CollectionRemoveEvent event = null;
- Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
- if (listeners != null) {
- for (CollectionChangeListener listener : listeners) {
- if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionRemoveEvent(this.source, collectionName, removedItems);
- }
- listener.itemsRemoved(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionRemoveEvent(this.source, collectionName, removedItems);
- }
- changeListener.itemsRemoved(event);
- }
- }
- }
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireItemRemoved(String collectionName, Object removedItem) {
-// this.fireItemsRemoved(collectionName, Collections.singleton(removedItem));
-
- CollectionRemoveEvent event = null;
- Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
- if (listeners != null) {
- for (CollectionChangeListener listener : listeners) {
- if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionRemoveEvent(this.source, collectionName, removedItem);
- }
- listener.itemsRemoved(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionRemoveEvent(this.source, collectionName, removedItem);
- }
- changeListener.itemsRemoved(event);
- }
- }
- }
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireCollectionCleared(CollectionClearEvent event) {
- String collectionName = event.getCollectionName();
- Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
- if (listeners != null) {
- for (CollectionChangeListener listener : listeners) {
- if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
- listener.collectionCleared(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.collectionCleared(event);
- }
- }
- }
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireCollectionCleared(String collectionName) {
-// this.fireCollectionCleared(new CollectionClearEvent(this.source, collectionName));
-
- CollectionClearEvent event = null;
- Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
- if (listeners != null) {
- for (CollectionChangeListener listener : listeners) {
- if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionClearEvent(this.source, collectionName);
- }
- listener.collectionCleared(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionClearEvent(this.source, collectionName);
- }
- changeListener.collectionCleared(event);
- }
- }
- }
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireCollectionChanged(CollectionChangeEvent event) {
- String collectionName = event.getCollectionName();
- Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
- if (listeners != null) {
- for (CollectionChangeListener listener : listeners) {
- if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
- listener.collectionChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.collectionChanged(event);
- }
- }
- }
- }
-
- /**
- * Report a bound collection update to any registered listeners.
- */
- public void fireCollectionChanged(String collectionName, Collection<?> collection) {
-// this.fireCollectionChanged(new CollectionChangeEvent(this.source, collectionName, collection));
-
- CollectionChangeEvent event = null;
- Iterable<CollectionChangeListener> listeners = this.getCollectionChangeListeners(collectionName);
- if (listeners != null) {
- for (CollectionChangeListener listener : listeners) {
- if (this.hasCollectionChangeListener(collectionName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionChangeEvent(this.source, collectionName, collection);
- }
- listener.collectionChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new CollectionChangeEvent(this.source, collectionName, collection);
- }
- changeListener.collectionChanged(event);
- }
- }
- }
- }
-
- /**
- * Add the specified item to the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see Collection#add(Object)
- */
- public <E> boolean addItemToCollection(E item, Collection<E> collection, String collectionName) {
- if (collection.add(item)) {
- this.fireItemAdded(collectionName, item);
- return true;
- }
- return false;
- }
-
- /**
- * Add the specified items to the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether collection changed.
- * @see Collection#addAll(Collection)
- */
- public <E> boolean addItemsToCollection(E[] items, Collection<E> collection, String collectionName) {
- return (items.length != 0)
- && this.addItemsToCollection_(new ArrayIterator<E>(items), collection, collectionName);
- }
-
- /**
- * Add the specified items to the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether collection changed.
- * @see Collection#addAll(Collection)
- */
- public <E> boolean addItemsToCollection(Collection<? extends E> items, Collection<E> collection, String collectionName) {
- return ( ! items.isEmpty())
- && this.addItemsToCollection_(items.iterator(), collection, collectionName);
- }
-
- /**
- * Add the specified items to the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether collection changed.
- * @see Collection#addAll(Collection)
- */
- public <E> boolean addItemsToCollection(Iterable<? extends E> items, Collection<E> collection, String collectionName) {
- return this.addItemsToCollection(items.iterator(), collection, collectionName);
- }
-
- /**
- * Add the specified items to the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether collection changed.
- * @see Collection#addAll(Collection)
- */
- public <E> boolean addItemsToCollection(Iterator<? extends E> items, Collection<E> collection, String collectionName) {
- return items.hasNext()
- && this.addItemsToCollection_(items, collection, collectionName);
- }
-
- /**
- * no empty check
- */
- protected <E> boolean addItemsToCollection_(Iterator<? extends E> items, Collection<E> collection, String collectionName) {
- Collection<E> addedItems = null;
- while (items.hasNext()) {
- E item = items.next();
- if (collection.add(item)) {
- if (addedItems == null) {
- addedItems = new ArrayList<E>();
- }
- addedItems.add(item);
- }
- }
- if (addedItems != null) {
- this.fireItemsAdded_(collectionName, addedItems);
- return true;
- }
- return false;
- }
-
- /**
- * Remove the specified item from the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see Collection#remove(Object)
- */
- public boolean removeItemFromCollection(Object item, Collection<?> collection, String collectionName) {
- if (collection.remove(item)) {
- this.fireItemRemoved(collectionName, item);
- return true;
- }
- return false;
- }
-
- /**
- * Remove the specified items from the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see Collection#removeAll(Collection)
- */
- public boolean removeItemsFromCollection(Object[] items, Collection<?> collection, String collectionName) {
- return (items.length != 0)
- && ( ! collection.isEmpty())
- && this.removeItemsFromCollection_(new ArrayIterator<Object>(items), collection, collectionName);
- }
-
- /**
- * Remove the specified items from the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see Collection#removeAll(Collection)
- */
- public boolean removeItemsFromCollection(Collection<?> items, Collection<?> collection, String collectionName) {
- return ( ! items.isEmpty())
- && ( ! collection.isEmpty())
- && this.removeItemsFromCollection_(items.iterator(), collection, collectionName);
- }
-
- /**
- * Remove the specified items from the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see Collection#removeAll(Collection)
- */
- public boolean removeItemsFromCollection(Iterable<?> items, Collection<?> collection, String collectionName) {
- return this.removeItemsFromCollection(items.iterator(), collection, collectionName);
- }
-
- /**
- * Remove the specified items from the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see Collection#removeAll(Collection)
- */
- public boolean removeItemsFromCollection(Iterator<?> items, Collection<?> collection, String collectionName) {
- return items.hasNext()
- && ( ! collection.isEmpty())
- && this.removeItemsFromCollection_(items, collection, collectionName);
- }
-
- /**
- * no empty checks
- */
- protected boolean removeItemsFromCollection_(Iterator<?> items, Collection<?> collection, String collectionName) {
- HashBag<?> removedItems = CollectionTools.collection(items);
- removedItems.retainAll(collection);
- boolean changed = collection.removeAll(removedItems);
-
- if ( ! removedItems.isEmpty()) {
- this.fireItemsRemoved_(collectionName, removedItems);
- }
- return changed;
- }
-
- /**
- * Retain the specified items in the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see Collection#retainAll(Collection)
- */
- public boolean retainItemsInCollection(Object[] items, Collection<?> collection, String collectionName) {
- if (collection.isEmpty()) {
- return false;
- }
- if (items.length == 0) {
- return this.clearCollection_(collection, collectionName);
- }
- return this.retainItemsInCollection_(new ArrayIterator<Object>(items), collection, collectionName);
- }
-
- /**
- * Retain the specified items in the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see Collection#retainAll(Collection)
- */
- public boolean retainItemsInCollection(Collection<?> items, Collection<?> collection, String collectionName) {
- if (collection.isEmpty()) {
- return false;
- }
- if (items.isEmpty()) {
- return this.clearCollection_(collection, collectionName);
- }
- return this.retainItemsInCollection_(items.iterator(), collection, collectionName);
- }
-
- /**
- * Retain the specified items in the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see Collection#retainAll(Collection)
- */
- public boolean retainItemsInCollection(Iterable<?> items, Collection<?> collection, String collectionName) {
- return this.retainItemsInCollection(items.iterator(), collection, collectionName);
- }
-
- /**
- * Retain the specified items in the specified bound collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see Collection#retainAll(Collection)
- */
- public boolean retainItemsInCollection(Iterator<?> items, Collection<?> collection, String collectionName) {
- if (collection.isEmpty()) {
- return false;
- }
- if ( ! items.hasNext()) {
- return this.clearCollection_(collection, collectionName);
- }
- return this.retainItemsInCollection_(items, collection, collectionName);
- }
-
- /**
- * no empty checks
- */
- protected boolean retainItemsInCollection_(Iterator<?> items, Collection<?> collection, String collectionName) {
- HashBag<?> retainedItems = CollectionTools.collection(items);
- HashBag<?> removedItems = CollectionTools.collection(collection);
- removedItems.removeAll(retainedItems);
- boolean changed = collection.retainAll(retainedItems);
-
- if ( ! removedItems.isEmpty()) {
- this.fireItemsRemoved_(collectionName, removedItems);
- }
- return changed;
- }
-
- /**
- * Clear the entire collection
- * and fire the appropriate event if necessary.
- * Return whether the collection changed.
- * @see Collection#clear()
- */
- public boolean clearCollection(Collection<?> collection, String collectionName) {
- if (collection.isEmpty()) {
- return false;
- }
- return this.clearCollection_(collection, collectionName);
- }
-
- /**
- * no empty check
- */
- protected boolean clearCollection_(Collection<?> collection, String collectionName) {
- collection.clear();
- this.fireCollectionCleared(collectionName);
- return true;
- }
-
- /**
- * Synchronize the collection with the specified new collection,
- * making a minimum number of removes and adds.
- * Return whether the collection changed.
- */
- public <E> boolean synchronizeCollection(Collection<E> newCollection, Collection<E> collection, String collectionName) {
- if (newCollection.isEmpty()) {
- return this.clearCollection(collection, collectionName);
- }
-
- if (collection.isEmpty()) {
- return this.addItemsToCollection_(newCollection.iterator(), collection, collectionName);
- }
-
- return this.synchronizeCollection_(newCollection, collection, collectionName);
- }
-
- /**
- * Synchronize the collection with the specified new collection,
- * making a minimum number of removes and adds.
- * Return whether the collection changed.
- */
- public <E> boolean synchronizeCollection(Iterable<E> newCollection, Collection<E> collection, String collectionName) {
- return this.synchronizeCollection(newCollection.iterator(), collection, collectionName);
- }
-
- /**
- * Synchronize the collection with the specified new collection,
- * making a minimum number of removes and adds.
- * Return whether the collection changed.
- */
- public <E> boolean synchronizeCollection(Iterator<E> newCollection, Collection<E> collection, String collectionName) {
- if ( ! newCollection.hasNext()) {
- return this.clearCollection(collection, collectionName);
- }
-
- if (collection.isEmpty()) {
- return this.addItemsToCollection_(newCollection, collection, collectionName);
- }
-
- return this.synchronizeCollection_(CollectionTools.collection(newCollection), collection, collectionName);
- }
-
- /**
- * no empty checks
- */
- protected <E> boolean synchronizeCollection_(Collection<E> newCollection, Collection<E> collection, String collectionName) {
- boolean changed = false;
- Collection<E> removeItems = new HashBag<E>(collection);
- removeItems.removeAll(newCollection);
- changed |= this.removeItemsFromCollection(removeItems, collection, collectionName);
-
- Collection<E> addItems = new HashBag<E>(newCollection);
- addItems.removeAll(collection);
- changed |= this.addItemsToCollection(addItems, collection, collectionName);
-
- return changed;
- }
-
-
- // ********** list change support **********
-
- protected static final Class<ListChangeListener> LIST_CHANGE_LISTENER_CLASS = ListChangeListener.class;
-
- /**
- * Add a list change listener for the specified list. The listener
- * will be notified only for changes to the specified list.
- */
- public void addListChangeListener(String listName, ListChangeListener listener) {
- this.addListener(LIST_CHANGE_LISTENER_CLASS, listName, listener);
- }
-
- /**
- * Remove a list change listener that was registered for a specific list.
- */
- public void removeListChangeListener(String listName, ListChangeListener listener) {
- this.removeListener(LIST_CHANGE_LISTENER_CLASS, listName, listener);
- }
-
- /**
- * Return whether there are any list change listeners that will
- * be notified when the specified list has changed.
- */
- public boolean hasAnyListChangeListeners(String listName) {
- return this.hasAnyListeners(LIST_CHANGE_LISTENER_CLASS, listName);
- }
-
- private ListenerList<ListChangeListener> getListChangeListenerList(String listName) {
- return this.getListenerList(LIST_CHANGE_LISTENER_CLASS, listName);
- }
-
- private Iterable<ListChangeListener> getListChangeListeners(String listName) {
- ListenerList<ListChangeListener> listenerList = this.getListChangeListenerList(listName);
- return (listenerList == null) ? null : listenerList.getListeners();
- }
-
- private boolean hasListChangeListener(String listName, ListChangeListener listener) {
- return CollectionTools.contains(this.getListChangeListeners(listName), listener);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- * Return whether there are any added items.
- */
- public boolean fireItemsAdded(ListAddEvent event) {
- if (event.getItemsSize() != 0) {
- this.fireItemsAdded_(event);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified event contains items
- */
- protected void fireItemsAdded_(ListAddEvent event) {
- String listName = event.getListName();
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- listener.itemsAdded(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.itemsAdded(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- * Return whether there are any added items.
- */
- public boolean fireItemsAdded(String listName, int index, List<?> addedItems) {
-// return this.fireItemsAdded(new ListAddEvent(this.source, listName, index, addedItems));
- if ( ! addedItems.isEmpty()) {
- this.fireItemsAdded_(listName, index, addedItems);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: 'addedItems' is not empty
- */
- protected void fireItemsAdded_(String listName, int index, List<?> addedItems) {
- ListAddEvent event = null;
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new ListAddEvent(this.source, listName, index, addedItems);
- }
- listener.itemsAdded(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new ListAddEvent(this.source, listName, index, addedItems);
- }
- changeListener.itemsAdded(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemAdded(String listName, int index, Object addedItem) {
-// this.fireItemsAdded(listName, index, Collections.singletonList(addedItem));
-
- ListAddEvent event = null;
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new ListAddEvent(this.source, listName, index, addedItem);
- }
- listener.itemsAdded(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new ListAddEvent(this.source, listName, index, addedItem);
- }
- changeListener.itemsAdded(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- * Return whether there are any removed items.
- */
- public boolean fireItemsRemoved(ListRemoveEvent event) {
- if (event.getItemsSize() != 0) {
- this.fireItemsRemoved_(event);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified event contains items
- */
- protected void fireItemsRemoved_(ListRemoveEvent event) {
- String listName = event.getListName();
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- listener.itemsRemoved(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.itemsRemoved(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- * Return whether there are any removed items.
- */
- public boolean fireItemsRemoved(String listName, int index, List<?> removedItems) {
-// return this.fireItemsRemoved(new ListRemoveEvent(this.source, listName, index, removedItems));
- if ( ! removedItems.isEmpty()) {
- this.fireItemsRemoved_(listName, index, removedItems);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: 'removedItems' is not empty
- */
- protected void fireItemsRemoved_(String listName, int index, List<?> removedItems) {
- ListRemoveEvent event = null;
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new ListRemoveEvent(this.source, listName, index, removedItems);
- }
- listener.itemsRemoved(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new ListRemoveEvent(this.source, listName, index, removedItems);
- }
- changeListener.itemsRemoved(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireItemRemoved(String listName, int index, Object removedItem) {
-// this.fireItemsRemoved(listName, index, Collections.singletonList(removedItem));
-
- ListRemoveEvent event = null;
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new ListRemoveEvent(this.source, listName, index, removedItem);
- }
- listener.itemsRemoved(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new ListRemoveEvent(this.source, listName, index, removedItem);
- }
- changeListener.itemsRemoved(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- * Return whether there are any replaced items.
- */
- public boolean fireItemsReplaced(ListReplaceEvent event) {
- if ((event.getItemsSize() != 0) && this.elementsAreDifferent(event.getNewItems(), event.getOldItems())) {
- this.fireItemsReplaced_(event);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified event contains new items
- */
- protected void fireItemsReplaced_(ListReplaceEvent event) {
- String listName = event.getListName();
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- listener.itemsReplaced(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.itemsReplaced(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- * Return whether there are any replaced items.
- */
- public boolean fireItemsReplaced(String listName, int index, List<?> newItems, List<?> oldItems) {
-// return this.fireItemsReplaced(new ListReplaceEvent(this.source, listName, index, newItems, oldItems));
- if (( ! newItems.isEmpty()) && this.elementsAreDifferent(newItems, oldItems)) {
- this.fireItemsReplaced_(listName, index, newItems, oldItems);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: 'newItems' is not empty and unequal to 'oldItems'
- */
- protected void fireItemsReplaced_(String listName, int index, List<?> newItems, List<?> oldItems) {
- ListReplaceEvent event = null;
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new ListReplaceEvent(this.source, listName, index, newItems, oldItems);
- }
- listener.itemsReplaced(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new ListReplaceEvent(this.source, listName, index, newItems, oldItems);
- }
- changeListener.itemsReplaced(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- * Return whether the item changed.
- */
- public boolean fireItemReplaced(String listName, int index, Object newItem, Object oldItem) {
-// return this.fireItemsReplaced(listName, index, Collections.singletonList(newItem), Collections.singletonList(oldItem));
- if (this.valuesAreDifferent(newItem, oldItem)) {
- this.fireItemReplaced_(listName, index, newItem, oldItem);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified old and new items are different
- */
- protected void fireItemReplaced_(String listName, int index, Object newItem, Object oldItem) {
- ListReplaceEvent event = null;
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new ListReplaceEvent(this.source, listName, index, newItem, oldItem);
- }
- listener.itemsReplaced(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new ListReplaceEvent(this.source, listName, index, newItem, oldItem);
- }
- changeListener.itemsReplaced(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- * Return whether there are any moved items.
- */
- // it's unlikely but possible the list is unchanged by the move...
- // e.g. any moves within ["foo", "foo", "foo"]
- public boolean fireItemsMoved(ListMoveEvent event) {
- if (event.getTargetIndex() != event.getSourceIndex()) {
- this.fireItemsMoved_(event);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified event indicates a move
- */
- protected void fireItemsMoved_(ListMoveEvent event) {
- String listName = event.getListName();
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- listener.itemsMoved(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.itemsMoved(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- * Return whether there are any moved items.
- */
- // it's unlikely but possible the list is unchanged by the move...
- // e.g. any moves within ["foo", "foo", "foo"]
- public boolean fireItemsMoved(String listName, int targetIndex, int sourceIndex, int length) {
-// return this.fireItemsMoved(new ListMoveEvent(this.source, listName, targetIndex, sourceIndex, length));
- if (targetIndex != sourceIndex) {
- this.fireItemsMoved_(listName, targetIndex, sourceIndex, length);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified indices indicate a move
- */
- protected void fireItemsMoved_(String listName, int targetIndex, int sourceIndex, int length) {
- ListMoveEvent event = null;
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new ListMoveEvent(this.source, listName, targetIndex, sourceIndex, length);
- }
- listener.itemsMoved(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new ListMoveEvent(this.source, listName, targetIndex, sourceIndex, length);
- }
- changeListener.itemsMoved(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- * Return whether there are any moved items.
- */
- // it's unlikely but possible the list is unchanged by the move...
- // e.g. any moves within ["foo", "foo", "foo"]
- public boolean fireItemMoved(String listName, int targetIndex, int sourceIndex) {
- if (targetIndex != sourceIndex) {
- this.fireItemMoved_(listName, targetIndex, sourceIndex);
- return true;
- }
- return false;
- }
-
- /**
- * pre-condition: the specified indices indicate a move
- */
- protected void fireItemMoved_(String listName, int targetIndex, int sourceIndex) {
- this.fireItemsMoved_(listName, targetIndex, sourceIndex, 1);
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireListCleared(ListClearEvent event) {
- String listName = event.getListName();
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- listener.listCleared(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.listCleared(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireListCleared(String listName) {
-// this.fireListCleared(new ListClearEvent(this.source, listName));
-
- ListClearEvent event = null;
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new ListClearEvent(this.source, listName);
- }
- listener.listCleared(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new ListClearEvent(this.source, listName);
- }
- changeListener.listCleared(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireListChanged(ListChangeEvent event) {
- String listName = event.getListName();
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- listener.listChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.listChanged(event);
- }
- }
- }
- }
-
- /**
- * Report a bound list update to any registered listeners.
- */
- public void fireListChanged(String listName, List<?> list) {
-// this.fireListChanged(new ListChangeEvent(this.source, listName));
-
- ListChangeEvent event = null;
- Iterable<ListChangeListener> listeners = this.getListChangeListeners(listName);
- if (listeners != null) {
- for (ListChangeListener listener : listeners) {
- if (this.hasListChangeListener(listName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new ListChangeEvent(this.source, listName, list);
- }
- listener.listChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new ListChangeEvent(this.source, listName, list);
- }
- changeListener.listChanged(event);
- }
- }
- }
- }
-
- /**
- * Add the specified item to the specified bound list at the specified index
- * and fire the appropriate event.
- * @see List#add(int, Object)
- */
- public <E> void addItemToList(int index, E item, List<E> list, String listName) {
- list.add(index, item);
- this.fireItemAdded(listName, index, item);
- }
-
- /**
- * Add the specified item to the end of the specified bound list
- * and fire the appropriate event.
- * Return whether the list changed (i.e. 'true').
- * @see List#add(Object)
- */
- public <E> boolean addItemToList(E item, List<E> list, String listName) {
- if (list.add(item)) {
- this.fireItemAdded(listName, list.size() - 1, item);
- return true;
- }
- return false; // List#add(Object) should always return 'true', so we should never get here...
- }
-
- /**
- * Add the specified items to the specified bound list at the specified index
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see List#addAll(int, Collection)
- */
- public <E> boolean addItemsToList(int index, E[] items, List<E> list, String listName) {
- return (items.length != 0)
- && this.addItemsToList_(index, Arrays.asList(items), list, listName);
- }
-
- /**
- * Add the specified items to the specified bound list at the specified index
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see List#addAll(int, Collection)
- */
- public <E> boolean addItemsToList(int index, Collection<? extends E> items, List<E> list, String listName) {
- return ( ! items.isEmpty())
- && this.addItemsToList_(index, this.convertToList(items), list, listName);
- }
-
- /**
- * no empty check
- */
- protected <E> boolean addItemsToList_(int index, List<? extends E> items, List<E> list, String listName) {
- if (list.addAll(index, items)) {
- this.fireItemsAdded(listName, index, items);
- return true;
- }
- return false; // 'items' should not be empty, so we should never get here...
- }
-
- /**
- * Add the specified items to the specified bound list
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see List#addAll(int, Collection)
- */
- public <E> boolean addItemsToList(int index, Iterable<? extends E> items, List<E> list, String listName) {
- return this.addItemsToList(index, items.iterator(), list, listName);
- }
-
- /**
- * Add the specified items to the specified bound list
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see List#addAll(int, Collection)
- */
- public <E> boolean addItemsToList(int index, Iterator<? extends E> items, List<E> list, String listName) {
- if ( ! items.hasNext()) {
- return false;
- }
-
- ArrayList<E> addedItems = CollectionTools.list(items);
- if (list.addAll(index, addedItems)) {
- this.fireItemsAdded(listName, index, addedItems);
- return true;
- }
- return false; // 'items' should not be empty, so we should never get here...
- }
-
- /**
- * Add the specified items to the end of to the specified bound list
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see List#addAll(Collection)
- */
- public <E> boolean addItemsToList(E[] items, List<E> list, String listName) {
- return (items.length != 0)
- && this.addItemsToList_(Arrays.asList(items), list, listName);
- }
-
- /**
- * Add the specified items to the end of the specified bound list
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see List#addAll(int, Collection)
- */
- public <E> boolean addItemsToList(Collection<? extends E> items, List<E> list, String listName) {
- return ( ! items.isEmpty())
- && this.addItemsToList_(this.convertToList(items), list, listName);
- }
-
- protected <E> List<? extends E> convertToList(Collection<? extends E> collection) {
- return (collection instanceof List<?>) ? (List<? extends E>) collection : new ArrayList<E>(collection);
- }
-
- /**
- * no empty check
- */
- protected <E> boolean addItemsToList_(List<? extends E> items, List<E> list, String listName) {
- int index = list.size();
- if (list.addAll(items)) {
- this.fireItemsAdded(listName, index, items);
- return true;
- }
- return false; // 'items' should not be empty, so we should never get here...
- }
-
- /**
- * Add the specified items to the end of to the specified bound list
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see List#addAll(Collection)
- */
- public <E> boolean addItemsToList(Iterable<? extends E> items, List<E> list, String listName) {
- return this.addItemsToList(items.iterator(), list, listName);
- }
-
- /**
- * Add the specified items to the end of to the specified bound list
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see List#addAll(Collection)
- */
- public <E> boolean addItemsToList(Iterator<? extends E> items, List<E> list, String listName) {
- if ( ! items.hasNext()) {
- return false;
- }
- return this.addItemsToList_(items, list, listName);
- }
-
- /**
- * no empty check
- */
- protected <E> boolean addItemsToList_(Iterator<? extends E> items, List<E> list, String listName) {
- ArrayList<E> addedItems = CollectionTools.list(items);
- int index = list.size();
- if (list.addAll(addedItems)) {
- this.fireItemsAdded(listName, index, addedItems);
- return true;
- }
- return false; // 'items' should not be empty, so we should never get here...
- }
-
- /**
- * Remove the specified item from the specified bound list
- * and fire the appropriate event if necessary.
- * Return the removed item.
- * @see List#remove(int)
- */
- public <E> E removeItemFromList(int index, List<E> list, String listName) {
- E item = list.remove(index);
- this.fireItemRemoved(listName, index, item);
- return item;
- }
-
- /**
- * Remove the specified item from the specified bound list
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see List#remove(Object)
- */
- public boolean removeItemFromList(Object item, List<?> list, String listName) {
- int index = list.indexOf(item);
- if (index == -1) {
- return false;
- }
- list.remove(index);
- this.fireItemRemoved(listName, index, item);
- return true;
- }
-
- /**
- * Remove the items from the specified index to the end of the list
- * from the specified bound list
- * and fire the appropriate event if necessary.
- * Return the removed items.
- * @see List#remove(int)
- */
- public <E> List<E> removeItemsFromList(int index, List<E> list, String listName) {
- return this.removeRangeFromList(index, list.size(), list, listName);
- }
-
- /**
- * Remove the specified items from the specified bound list
- * and fire the appropriate event if necessary.
- * Return the removed items.
- * @see List#remove(int)
- */
- public <E> List<E> removeItemsFromList(int index, int length, List<E> list, String listName) {
- return this.removeRangeFromList(index, index + length, list, listName);
- }
-
- /**
- * Remove the specified items from the specified bound list
- * and fire the appropriate event if necessary. The begin index
- * is inclusive, while the end index is exclusive.
- * Return the removed items.
- * @see List#remove(int)
- * @see List#subList(int, int)
- */
- public <E> List<E> removeRangeFromList(int beginIndex, int endIndex, List<E> list, String listName) {
- if (beginIndex == endIndex) {
- return Collections.emptyList();
- }
- return this.removeRangeFromList_(beginIndex, endIndex, list, listName);
- }
-
- /**
- * no empty check
- */
- protected <E> List<E> removeRangeFromList_(int beginIndex, int endIndex, List<E> list, String listName) {
- List<E> subList = list.subList(beginIndex, endIndex);
- List<E> removedItems = new ArrayList<E>(subList);
- subList.clear();
- this.fireItemsRemoved(listName, beginIndex, removedItems);
- return removedItems;
- }
-
- /**
- * Remove the specified items from the specified bound list
- * and fire the appropriate event(s) if necessary.
- * Return whether the list changed.
- * @see List#removeAll(Collection)
- */
- public boolean removeItemsFromList(Object[] items, List<?> list, String listName) {
- return (items.length != 0)
- && ( ! list.isEmpty())
- && this.removeItemsFromList_(new ArrayIterator<Object>(items), list, listName);
- }
-
- /**
- * Remove the specified items from the specified bound list
- * and fire the appropriate event(s) if necessary.
- * Return whether the list changed.
- * @see List#removeAll(Collection)
- */
- public boolean removeItemsFromList(Collection<?> items, List<?> list, String listName) {
- return ( ! items.isEmpty())
- && ( ! list.isEmpty())
- && this.removeItemsFromList_(items.iterator(), list, listName);
- }
-
- /**
- * Remove the specified items from the specified bound list
- * and fire the appropriate event(s) if necessary.
- * Return whether the list changed.
- * @see List#removeAll(Collection)
- */
- public boolean removeItemsFromList(Iterable<?> items, List<?> list, String listName) {
- return this.removeItemsFromList(items.iterator(), list, listName);
- }
-
- /**
- * Remove the specified items from the specified bound list
- * and fire the appropriate event(s) if necessary.
- * Return whether the list changed.
- * @see List#removeAll(Collection)
- */
- public boolean removeItemsFromList(Iterator<?> items, List<?> list, String listName) {
- return (items.hasNext())
- && ( ! list.isEmpty())
- && this.removeItemsFromList_(items, list, listName);
- }
-
- /**
- * no empty checks
- */
- protected boolean removeItemsFromList_(Iterator<?> items, List<?> list, String listName) {
- boolean changed = false;
- while (items.hasNext()) {
- changed |= this.removeItemFromList(items.next(), list, listName);
- }
- return changed;
- }
-
- /**
- * Retain the specified items in the specified bound list
- * and fire the appropriate event(s) if necessary.
- * Return whether the list changed.
- * @see List#retainAll(Collection)
- */
- public boolean retainItemsInList(Object[] items, List<?> list, String listName) {
- if (list.isEmpty()) {
- return false;
- }
- if (items.length == 0) {
- return this.clearList_(list, listName);
- }
- return this.retainItemsInList_(new ArrayIterator<Object>(items), list, listName);
- }
-
- /**
- * Retain the specified items in the specified bound list
- * and fire the appropriate event(s) if necessary.
- * Return whether the list changed.
- * @see List#retainAll(Collection)
- */
- public boolean retainItemsInList(Collection<?> items, List<?> list, String listName) {
- if (list.isEmpty()) {
- return false;
- }
- if (items.isEmpty()) {
- return this.clearList_(list, listName);
- }
- return this.retainItemsInList_(items.iterator(), list, listName);
- }
-
- /**
- * Retain the specified items in the specified bound list
- * and fire the appropriate event(s) if necessary.
- * Return whether the list changed.
- * @see List#retainAll(Collection)
- */
- public boolean retainItemsInList(Iterable<?> items, List<?> list, String listName) {
- return this.retainItemsInList(items.iterator(), list, listName);
- }
-
- /**
- * Retain the specified items in the specified bound list
- * and fire the appropriate event(s) if necessary.
- * Return whether the list changed.
- * @see List#retainAll(Collection)
- */
- public boolean retainItemsInList(Iterator<?> items, List<?> list, String listName) {
- if (list.isEmpty()) {
- return false;
- }
- if ( ! items.hasNext()) {
- return this.clearList_(list, listName);
- }
- return this.retainItemsInList_(items, list, listName);
- }
-
- /**
- * no empty checks
- */
- protected boolean retainItemsInList_(Iterator<?> items, List<?> list, String listName) {
- HashBag<?> retainedItems = CollectionTools.collection(items);
- HashBag<?> removedItems = CollectionTools.collection(list);
- removedItems.removeAll(retainedItems);
- return this.removeItemsFromList(removedItems, list, listName);
- }
-
- /**
- * Set the specified item in the specified bound list
- * and fire the appropriate event if necessary.
- * Return the replaced item.
- * @see List#set(int, Object)
- */
- public <E> E setItemInList(int index, E item, List<E> list, String listName) {
- E oldItem = list.set(index, item);
- this.fireItemReplaced(listName, index, item, oldItem);
- return oldItem;
- }
-
- /**
- * Replace the first occurrence of the specified item
- * in the specified bound list
- * and fire the appropriate event if necessary.
- * Return the index of the replaced item.
- * Return -1 if the item was not found in the list.
- * @see List#set(int, Object)
- */
- public <E> int replaceItemInList(E oldItem, E newItem, List<E> list, String listName) {
- if (list.isEmpty()) {
- return -1;
- }
-
- int index = list.indexOf(oldItem);
- if ((index != -1) && this.valuesAreDifferent(oldItem, newItem)) {
- list.set(index, newItem);
- this.fireItemReplaced_(listName, index, newItem, oldItem);
- }
- return index;
- }
-
- /**
- * Set the specified items in the specified bound list
- * and fire the appropriate event if necessary.
- * Return the replaced items.
- * @see List#set(int, Object)
- */
- public <E> List<E> setItemsInList(int index, E[] items, List<E> list, String listName) {
- if (items.length == 0) {
- return Collections.emptyList();
- }
- return this.setItemsInList_(index, Arrays.asList(items), list, listName);
- }
-
- /**
- * Set the specified items in the specified bound list
- * and fire the appropriate event if necessary.
- * Return the replaced items.
- * @see List#set(int, Object)
- */
- public <E> List<E> setItemsInList(int index, List<? extends E> items, List<E> list, String listName) {
- if (items.isEmpty()) {
- return Collections.emptyList();
- }
- return this.setItemsInList_(index, items, list, listName);
- }
-
- /**
- * no empty check
- */
- protected <E> List<E> setItemsInList_(int index, List<? extends E> items, List<E> list, String listName) {
- List<E> subList = list.subList(index, index + items.size());
- List<E> oldItems = new ArrayList<E>(subList);
- for (int i = 0; i < items.size(); i++) {
- E newItem = items.get(i);
- E oldItem = subList.set(i, newItem);
- this.fireItemReplaced(listName, index + i, newItem, oldItem);
- }
- return oldItems;
- }
-
- /**
- * Move items in the specified list from the specified source index to the
- * specified target index for the specified length.
- * Return whether the list changed.
- */
- public <E> boolean moveItemsInList(int targetIndex, int sourceIndex, int length, List<E> list, String listName) {
- if ((targetIndex == sourceIndex) || (length == 0)) {
- return false;
- }
- // it's unlikely but possible the list is unchanged by the move... (e.g. any moves within ["foo", "foo", "foo"]...)
- CollectionTools.move(list, targetIndex, sourceIndex, length);
- this.fireItemsMoved(listName, targetIndex, sourceIndex, length);
- return true;
- }
-
- /**
- * Move the specified item in the specified list to the
- * specified target index.
- * Return whether the list changed.
- */
- public <E> boolean moveItemInList(int targetIndex, E item, List<E> list, String listName) {
- return this.moveItemInList(targetIndex, list.indexOf(item), list, listName);
- }
-
- /**
- * Move an item in the specified list from the specified source index to the
- * specified target index.
- * Return whether the list changed.
- */
- public <E> boolean moveItemInList(int targetIndex, int sourceIndex, List<E> list, String listName) {
- if (targetIndex == sourceIndex) {
- return false;
- }
- if (this.valuesAreEqual(list.get(targetIndex), list.get(sourceIndex))) {
- return false;
- }
- CollectionTools.move(list, targetIndex, sourceIndex);
- this.fireItemMoved_(listName, targetIndex, sourceIndex);
- return true;
- }
-
- /**
- * Clear the entire list
- * and fire the appropriate event if necessary.
- * Return whether the list changed.
- * @see List#clear()
- */
- public boolean clearList(List<?> list, String listName) {
- return ( ! list.isEmpty()) && this.clearList_(list, listName);
- }
-
- /**
- * no empty check
- */
- protected boolean clearList_(List<?> list, String listName) {
- list.clear();
- this.fireListCleared(listName);
- return true;
- }
-
- /**
- * Synchronize the list with the specified new list,
- * making a minimum number of sets, removes, and/or adds.
- * Return whether the list changed.
- */
- public <E> boolean synchronizeList(List<E> newList, List<E> list, String listName) {
- if (newList.isEmpty()) {
- return this.clearList(list, listName);
- }
- if (list.isEmpty()) {
- return this.addItemsToList_(newList, list, listName);
- }
- return this.synchronizeList_(newList, list, listName);
- }
-
- /**
- * Synchronize the list with the specified new list,
- * making a minimum number of sets, removes, and/or adds.
- * Return whether the list changed.
- */
- public <E> boolean synchronizeList(Iterable<? extends E> newList, List<E> list, String listName) {
- return this.synchronizeList(newList.iterator(), list, listName);
- }
-
- /**
- * Synchronize the list with the specified new list,
- * making a minimum number of sets, removes, and/or adds.
- * Return whether the list changed.
- */
- public <E> boolean synchronizeList(Iterator<? extends E> newList, List<E> list, String listName) {
- if ( ! newList.hasNext()) {
- return this.clearList(list, listName);
- }
- if (list.isEmpty()) {
- return this.addItemsToList_(newList, list, listName);
- }
- return this.synchronizeList_(CollectionTools.list(newList), list, listName);
- }
-
- /**
- * no empty checks
- */
- protected <E> boolean synchronizeList_(List<? extends E> newList, List<E> oldList, String listName) {
- int newSize = newList.size();
- int oldSize = oldList.size();
-
- boolean changed = false;
- // TODO check for RandomAccess
- int min = Math.min(newSize, oldSize);
- for (int i = 0; i < min; i++) {
- E newItem = newList.get(i);
- E oldItem = oldList.set(i, newItem);
- if (this.valuesAreDifferent(newItem, oldItem)) {
- changed = true;
- this.fireItemReplaced_(listName, i, newItem, oldItem);
- }
- }
-
- if (newSize == oldSize) {
- return changed;
- }
-
- if (newSize < oldSize) {
- this.removeRangeFromList_(newSize, oldSize, oldList, listName);
- return true;
- }
-
- // newSize > oldSize
- this.addItemsToList_(newList.subList(oldSize, newSize), oldList, listName);
- return true;
- }
-
-
- // ********** tree change support **********
-
- protected static final Class<TreeChangeListener> TREE_CHANGE_LISTENER_CLASS = TreeChangeListener.class;
-
- /**
- * Add a tree change listener for the specified tree. The listener
- * will be notified only for changes to the specified tree.
- */
- public void addTreeChangeListener(String treeName, TreeChangeListener listener) {
- this.addListener(TREE_CHANGE_LISTENER_CLASS, treeName, listener);
- }
-
- /**
- * Remove a tree change listener that was registered for a specific tree.
- */
- public void removeTreeChangeListener(String treeName, TreeChangeListener listener) {
- this.removeListener(TREE_CHANGE_LISTENER_CLASS, treeName, listener);
- }
-
- /**
- * Return whether there are any tree change listeners that will
- * be notified when the specified tree has changed.
- */
- public boolean hasAnyTreeChangeListeners(String treeName) {
- return this.hasAnyListeners(TREE_CHANGE_LISTENER_CLASS, treeName);
- }
-
- private ListenerList<TreeChangeListener> getTreeChangeListenerList(String treeName) {
- return this.getListenerList(TREE_CHANGE_LISTENER_CLASS, treeName);
- }
-
- private Iterable<TreeChangeListener> getTreeChangeListeners(String treeName) {
- ListenerList<TreeChangeListener> listenerList = this.getTreeChangeListenerList(treeName);
- return (listenerList == null) ? null : listenerList.getListeners();
- }
-
- private boolean hasTreeChangeListener(String treeName, TreeChangeListener listener) {
- return CollectionTools.contains(this.getTreeChangeListeners(treeName), listener);
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireNodeAdded(TreeAddEvent event) {
- String treeName = event.getTreeName();
- Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
- if (listeners != null) {
- for (TreeChangeListener listener : listeners) {
- if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
- listener.nodeAdded(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.nodeAdded(event);
- }
- }
- }
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireNodeAdded(String treeName, List<?> path) {
-// this.fireNodeAdded(new TreeAddEvent(this.source, treeName, path));
- TreeAddEvent event = null;
- Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
- if (listeners != null) {
- for (TreeChangeListener listener : listeners) {
- if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new TreeAddEvent(this.source, treeName, path);
- }
- listener.nodeAdded(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new TreeAddEvent(this.source, treeName, path);
- }
- changeListener.nodeAdded(event);
- }
- }
- }
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireNodeRemoved(TreeRemoveEvent event) {
- String treeName = event.getTreeName();
- Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
- if (listeners != null) {
- for (TreeChangeListener listener : listeners) {
- if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
- listener.nodeRemoved(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.nodeRemoved(event);
- }
- }
- }
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireNodeRemoved(String treeName, List<?> path) {
-// this.fireNodeRemoved(new TreeRemoveEvent(this.source, treeName, path));
-
- TreeRemoveEvent event = null;
- Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
- if (listeners != null) {
- for (TreeChangeListener listener : listeners) {
- if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new TreeRemoveEvent(this.source, treeName, path);
- }
- listener.nodeRemoved(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new TreeRemoveEvent(this.source, treeName, path);
- }
- changeListener.nodeRemoved(event);
- }
- }
- }
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireTreeCleared(TreeClearEvent event) {
- String treeName = event.getTreeName();
- Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
- if (listeners != null) {
- for (TreeChangeListener listener : listeners) {
- if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
- listener.treeCleared(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.treeCleared(event);
- }
- }
- }
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireTreeCleared(String treeName) {
-// this.fireTreeCleared(new TreeClearEvent(this.source, treeName));
-
- TreeClearEvent event = null;
- Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
- if (listeners != null) {
- for (TreeChangeListener listener : listeners) {
- if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new TreeClearEvent(this.source, treeName);
- }
- listener.treeCleared(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new TreeClearEvent(this.source, treeName);
- }
- changeListener.treeCleared(event);
- }
- }
- }
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireTreeChanged(TreeChangeEvent event) {
- String treeName = event.getTreeName();
- Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
- if (listeners != null) {
- for (TreeChangeListener listener : listeners) {
- if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
- listener.treeChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- changeListener.treeChanged(event);
- }
- }
- }
- }
-
- /**
- * Report a bound tree update to any registered listeners.
- */
- public void fireTreeChanged(String treeName, Collection<?> nodes) {
-// this.fireTreeChanged(new TreeChangeEvent(this.source, treeName, nodes));
-
- TreeChangeEvent event = null;
- Iterable<TreeChangeListener> listeners = this.getTreeChangeListeners(treeName);
- if (listeners != null) {
- for (TreeChangeListener listener : listeners) {
- if (this.hasTreeChangeListener(treeName, listener)) { // verify listener is still listening
- if (event == null) {
- event = new TreeChangeEvent(this.source, treeName, nodes);
- }
- listener.treeChanged(event);
- }
- }
- }
-
- Iterable<ChangeListener> changeListeners = this.getChangeListeners();
- if (changeListeners != null) {
- for (ChangeListener changeListener : changeListeners) {
- if (this.hasChangeListener(changeListener)) { // verify listener is still listening
- if (event == null) {
- event = new TreeChangeEvent(this.source, treeName, nodes);
- }
- changeListener.treeChanged(event);
- }
- }
- }
- }
-
-
- // ********** misc **********
-
- /**
- * Convenience method for checking whether an attribute value has changed.
- * @see Tools#valuesAreEqual(Object, Object)
- */
- public boolean valuesAreEqual(Object value1, Object value2) {
- return Tools.valuesAreEqual(value1, value2);
- }
-
- /**
- * Convenience method for checking whether an attribute value has changed.
- * @see Tools#valuesAreDifferent(Object, Object)
- */
- public boolean valuesAreDifferent(Object value1, Object value2) {
- return Tools.valuesAreDifferent(value1, value2);
- }
-
- /**
- * @see CollectionTools#elementsAreEqual(Iterable, Iterable)
- */
- public boolean elementsAreEqual(Iterable<?> iterable1, Iterable<?> iterable2) {
- return CollectionTools.elementsAreEqual(iterable1, iterable2);
- }
-
- /**
- * @see CollectionTools#elementsAreDifferent(Iterable, Iterable)
- */
- public boolean elementsAreDifferent(Iterable<?> iterable1, Iterable<?> iterable2) {
- return CollectionTools.elementsAreDifferent(iterable1, iterable2);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.source);
- }
-
-
- // ********** member classes **********
-
- /**
- * Pair a possibly <code>null</code> aspect name with its associated
- * listeners.
- */
- static abstract class AspectListenerListPair<L extends EventListener>
- implements Serializable
- {
- final ListenerList<L> listenerList;
-
- private static final long serialVersionUID = 1L;
-
- AspectListenerListPair(Class<L> listenerClass, L listener) {
- super();
- this.listenerList = new ListenerList<L>(listenerClass, listener);
- }
-
- boolean matches(Class<? extends EventListener> listenerClass, @SuppressWarnings("unused") String aspectName) {
- return this.listenerList.getListenerType() == listenerClass;
- }
-
- boolean matches(Class<? extends EventListener> listenerClass) {
- return this.matches(listenerClass, null);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.getAspectName());
- }
-
- abstract String getAspectName();
- }
-
- /**
- * Pair a non-<code>null</code> aspect name with its associated listeners.
- */
- static class SimpleAspectListenerListPair<L extends EventListener>
- extends AspectListenerListPair<L>
- {
- final String aspectName;
-
- private static final long serialVersionUID = 1L;
-
- SimpleAspectListenerListPair(Class<L> listenerClass, String aspectName, L listener) {
- super(listenerClass, listener);
- if (aspectName == null) {
- throw new NullPointerException();
- }
- this.aspectName = aspectName;
- }
-
- @Override
- boolean matches(Class<? extends EventListener> listenerClass, @SuppressWarnings("hiding") String aspectName) {
- return this.aspectName.equals(aspectName)
- && super.matches(listenerClass, aspectName);
- }
-
- @Override
- String getAspectName() {
- return this.aspectName;
- }
- }
-
- /**
- * Pair a <code>null</code> aspect name with its associated listeners.
- */
- static class NullAspectListenerListPair<L extends EventListener>
- extends AspectListenerListPair<L>
- {
- private static final long serialVersionUID = 1L;
-
- NullAspectListenerListPair(Class<L> listenerClass, L listener) {
- super(listenerClass, listener);
- }
-
- @Override
- boolean matches(Class<? extends EventListener> listenerClass, String aspectName) {
- return (aspectName == null)
- && super.matches(listenerClass, null);
- }
-
- @Override
- String getAspectName() {
- return null;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/SingleAspectChangeSupport.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/SingleAspectChangeSupport.java
deleted file mode 100644
index f4641d1253..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/SingleAspectChangeSupport.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model;
-
-import java.util.Collection;
-import java.util.EventListener;
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-
-/**
- * This change support class changes the behavior of the standard
- * change support in several ways:<ul>
- * <li>All events fired by the source must specify the single aspect.
- * <li>Listeners are required to be either "general purpose" listeners or
- * listeners of the single aspect.
- * </ul>
- */
-public class SingleAspectChangeSupport
- extends ChangeSupport
-{
- protected final Class<? extends EventListener> validListenerClass;
- protected final String validAspectName;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructor **********
-
- public SingleAspectChangeSupport(Model source, Class<? extends EventListener> validListenerClass, String validAspectName) {
- super(source);
- if ( ! validListenerClass.isAssignableFrom(this.getChangeListenerClass())) {
- throw new IllegalArgumentException("The change support's change listener class (" + this.getChangeListenerClass().getName() + //$NON-NLS-1$
- ") does not extend the valid listener class: " + validListenerClass.getName()); //$NON-NLS-1$
- }
- this.validListenerClass = validListenerClass;
- this.validAspectName = validAspectName;
- }
-
-
- // ********** internal implementation **********
-
- private UnsupportedOperationException buildUnsupportedOperationException() {
- return new UnsupportedOperationException(
- "This Model supports only changes for the listener type \"" + this.validListenerClass.getName() //$NON-NLS-1$
- + "\" and the aspect \"" + this.validAspectName + '"' //$NON-NLS-1$
- );
- }
-
- /**
- * The listener can be either an instance of the valid listener class or
- * the "general-purpose" change listener class (which should extend the
- * the valid listener class).
- */
- private void check(Class<? extends EventListener> listenerClass) {
- if ((listenerClass != this.getChangeListenerClass()) && (listenerClass != this.validListenerClass)) {
- throw new IllegalArgumentException(
- "This Model supports only changes for the listener type \"" + this.validListenerClass.getName() //$NON-NLS-1$
- + "\" : \"" + listenerClass.getName() + '"' //$NON-NLS-1$
- );
- }
- }
-
- protected void check(Class<? extends EventListener> listenerClass, String aspectName) {
- this.check(listenerClass);
- if ( ! aspectName.equals(this.validAspectName)) {
- throw new IllegalArgumentException(
- "This Model supports only changes for the aspect \"" + this.validAspectName //$NON-NLS-1$
- + "\" : \"" + aspectName + '"' //$NON-NLS-1$
- );
- }
- }
-
- @Override
- protected synchronized <L extends EventListener> void addListener(Class<L> listenerClass, String aspectName, L listener) {
- this.check(listenerClass, aspectName);
- super.addListener(listenerClass, aspectName, listener);
- }
-
- @Override
- protected synchronized <L extends EventListener> void addListener(Class<L> listenerClass, L listener) {
- this.check(listenerClass);
- super.addListener(listenerClass, listener);
- }
-
- @Override
- protected synchronized <L extends EventListener> void removeListener(Class<L> listenerClass, String aspectName, L listener) {
- this.check(listenerClass, aspectName);
- super.removeListener(listenerClass, aspectName, listener);
- }
-
- @Override
- protected synchronized <L extends EventListener> void removeListener(Class<L> listenerClass, L listener) {
- this.check(listenerClass);
- super.removeListener(listenerClass, listener);
- }
-
- @Override
- protected <L extends EventListener> boolean hasAnyListeners(Class<L> listenerClass, String aspectName) {
- this.check(listenerClass, aspectName);
- return super.hasAnyListeners(listenerClass, aspectName);
- }
-
- @Override
- protected <L extends EventListener> boolean hasAnyListeners(Class<L> listenerClass) {
- this.check(listenerClass);
- return super.hasAnyListeners(listenerClass);
- }
-
-
- // ********** state change support **********
-
- @Override
- public void fireStateChanged(StateChangeEvent event) {
- throw this.buildUnsupportedOperationException();
- }
-
- @Override
- public void fireStateChanged() {
- throw this.buildUnsupportedOperationException();
- }
-
-
- // ********** property change support **********
-
- @Override
- public boolean firePropertyChanged(PropertyChangeEvent event) {
- this.check(PROPERTY_CHANGE_LISTENER_CLASS, event.getPropertyName());
- return super.firePropertyChanged(event);
- }
-
- @Override
- public boolean firePropertyChanged(String propertyName, Object oldValue, Object newValue) {
- this.check(PROPERTY_CHANGE_LISTENER_CLASS, propertyName);
- return super.firePropertyChanged(propertyName, oldValue, newValue);
- }
-
- @Override
- public boolean firePropertyChanged(String propertyName, int oldValue, int newValue) {
- this.check(PROPERTY_CHANGE_LISTENER_CLASS, propertyName);
- return super.firePropertyChanged(propertyName, oldValue, newValue);
- }
-
- @Override
- public boolean firePropertyChanged(String propertyName, boolean oldValue, boolean newValue) {
- this.check(PROPERTY_CHANGE_LISTENER_CLASS, propertyName);
- return super.firePropertyChanged(propertyName, oldValue, newValue);
- }
-
-
- // ********** collection change support **********
-
- @Override
- public boolean fireItemsAdded(CollectionAddEvent event) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, event.getCollectionName());
- return super.fireItemsAdded(event);
- }
-
- @Override
- public boolean fireItemsAdded(String collectionName, Collection<?> addedItems) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- return super.fireItemsAdded(collectionName, addedItems);
- }
-
- @Override
- public void fireItemAdded(String collectionName, Object addedItem) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- super.fireItemAdded(collectionName, addedItem);
- }
-
- @Override
- public boolean fireItemsRemoved(CollectionRemoveEvent event) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, event.getCollectionName());
- return super.fireItemsRemoved(event);
- }
-
- @Override
- public boolean fireItemsRemoved(String collectionName, Collection<?> removedItems) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- return super.fireItemsRemoved(collectionName, removedItems);
- }
-
- @Override
- public void fireItemRemoved(String collectionName, Object removedItem) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- super.fireItemRemoved(collectionName, removedItem);
- }
-
- @Override
- public void fireCollectionCleared(CollectionClearEvent event) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, event.getCollectionName());
- super.fireCollectionCleared(event);
- }
-
- @Override
- public void fireCollectionCleared(String collectionName) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- super.fireCollectionCleared(collectionName);
- }
-
- @Override
- public void fireCollectionChanged(CollectionChangeEvent event) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, event.getCollectionName());
- super.fireCollectionChanged(event);
- }
-
- @Override
- public void fireCollectionChanged(String collectionName, Collection<?> collection) {
- this.check(COLLECTION_CHANGE_LISTENER_CLASS, collectionName);
- super.fireCollectionChanged(collectionName, collection);
- }
-
-
- // ********** list change support **********
-
- @Override
- public boolean fireItemsAdded(ListAddEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- return super.fireItemsAdded(event);
- }
-
- @Override
- public boolean fireItemsAdded(String listName, int index, List<?> addedItems) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- return super.fireItemsAdded(listName, index, addedItems);
- }
-
- @Override
- public void fireItemAdded(String listName, int index, Object addedItem) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireItemAdded(listName, index, addedItem);
- }
-
- @Override
- public boolean fireItemsRemoved(ListRemoveEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- return super.fireItemsRemoved(event);
- }
-
- @Override
- public boolean fireItemsRemoved(String listName, int index, List<?> removedItems) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- return super.fireItemsRemoved(listName, index, removedItems);
- }
-
- @Override
- public void fireItemRemoved(String listName, int index, Object removedItem) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireItemRemoved(listName, index, removedItem);
- }
-
- @Override
- public boolean fireItemsReplaced(ListReplaceEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- return super.fireItemsReplaced(event);
- }
-
- @Override
- public boolean fireItemsReplaced(String listName, int index, List<?> newItems, List<?> replacedItems) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- return super.fireItemsReplaced(listName, index, newItems, replacedItems);
- }
-
- @Override
- public boolean fireItemReplaced(String listName, int index, Object newItem, Object replacedItem) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- return super.fireItemReplaced(listName, index, newItem, replacedItem);
- }
-
- @Override
- public boolean fireItemsMoved(ListMoveEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- return super.fireItemsMoved(event);
- }
-
- @Override
- public boolean fireItemsMoved(String listName, int targetIndex, int sourceIndex, int length) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- return super.fireItemsMoved(listName, targetIndex, sourceIndex, length);
- }
-
- @Override
- public void fireListCleared(ListClearEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- super.fireListCleared(event);
- }
-
- @Override
- public void fireListCleared(String listName) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireListCleared(listName);
- }
-
- @Override
- public void fireListChanged(ListChangeEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- super.fireListChanged(event);
- }
-
- @Override
- public void fireListChanged(String listName, List<?> list) {
- this.check(LIST_CHANGE_LISTENER_CLASS, listName);
- super.fireListChanged(listName, list);
- }
-
-
- // ********** tree change support **********
-
- @Override
- public void fireNodeAdded(TreeAddEvent event) {
- this.check(TREE_CHANGE_LISTENER_CLASS, event.getTreeName());
- super.fireNodeAdded(event);
- }
-
- @Override
- public void fireNodeAdded(String treeName, List<?> path) {
- this.check(TREE_CHANGE_LISTENER_CLASS, treeName);
- super.fireNodeAdded(treeName, path);
- }
-
- @Override
- public void fireNodeRemoved(TreeRemoveEvent event) {
- this.check(TREE_CHANGE_LISTENER_CLASS, event.getTreeName());
- super.fireNodeRemoved(event);
- }
-
- @Override
- public void fireNodeRemoved(String treeName, List<?> path) {
- this.check(TREE_CHANGE_LISTENER_CLASS, treeName);
- super.fireNodeRemoved(treeName, path);
- }
-
- @Override
- public void fireTreeCleared(TreeClearEvent event) {
- this.check(TREE_CHANGE_LISTENER_CLASS, event.getTreeName());
- super.fireTreeCleared(event);
- }
-
- @Override
- public void fireTreeCleared(String treeName) {
- this.check(TREE_CHANGE_LISTENER_CLASS, treeName);
- super.fireTreeCleared(treeName);
- }
-
- @Override
- public void fireTreeChanged(TreeChangeEvent event) {
- this.check(TREE_CHANGE_LISTENER_CLASS, event.getTreeName());
- super.fireTreeChanged(event);
- }
-
- @Override
- public void fireTreeChanged(String treeName, Collection<?> nodes) {
- this.check(TREE_CHANGE_LISTENER_CLASS, treeName);
- super.fireTreeChanged(treeName, nodes);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTChangeListenerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTChangeListenerWrapper.java
deleted file mode 100644
index 5f16ea4650..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTChangeListenerWrapper.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.listener.awt;
-
-import java.awt.EventQueue;
-
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-
-/**
- * Wrap another change listener and forward events to it on the AWT
- * event queue, asynchronously if necessary. If the event arrived on the UI
- * thread that is probably because it was initiated by a UI widget; as a
- * result, we want to loop back synchronously so the events can be
- * short-circuited.
- */
-public final class AWTChangeListenerWrapper
- implements ChangeListener
-{
- private final ChangeListener listener;
-
-
- public AWTChangeListenerWrapper(ChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void stateChanged(StateChangeEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.stateChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildStateChangedRunnable(event));
- }
- }
-
- public void propertyChanged(PropertyChangeEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.propertyChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildPropertyChangedRunnable(event));
- }
- }
-
- public void itemsAdded(CollectionAddEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsAdded_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsAddedRunnable(event));
- }
- }
-
- public void itemsRemoved(CollectionRemoveEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsRemoved_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsRemovedRunnable(event));
- }
- }
-
- public void collectionCleared(CollectionClearEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.collectionCleared_(event);
- } else {
- this.executeOnEventQueue(this.buildCollectionClearedRunnable(event));
- }
- }
-
- public void collectionChanged(CollectionChangeEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.collectionChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildCollectionChangedRunnable(event));
- }
- }
-
- public void itemsAdded(ListAddEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsAdded_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsAddedRunnable(event));
- }
- }
-
- public void itemsRemoved(ListRemoveEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsRemoved_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsRemovedRunnable(event));
- }
- }
-
- public void itemsMoved(ListMoveEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsMoved_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsMovedRunnable(event));
- }
- }
-
- public void itemsReplaced(ListReplaceEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsReplaced_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsReplacedRunnable(event));
- }
- }
-
- public void listCleared(ListClearEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.listCleared_(event);
- } else {
- this.executeOnEventQueue(this.buildListClearedRunnable(event));
- }
- }
-
- public void listChanged(ListChangeEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.listChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildListChangedRunnable(event));
- }
- }
-
- public void nodeAdded(TreeAddEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.nodeAdded_(event);
- } else {
- this.executeOnEventQueue(this.buildNodeAddedRunnable(event));
- }
- }
-
- public void nodeRemoved(TreeRemoveEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.nodeRemoved_(event);
- } else {
- this.executeOnEventQueue(this.buildNodeRemovedRunnable(event));
- }
- }
-
- public void treeCleared(TreeClearEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.treeCleared_(event);
- } else {
- this.executeOnEventQueue(this.buildTreeClearedRunnable(event));
- }
- }
-
- public void treeChanged(TreeChangeEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.treeChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildTreeChangedRunnable(event));
- }
- }
-
- private Runnable buildStateChangedRunnable(final StateChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.stateChanged_(event);
- }
- };
- }
-
- private Runnable buildPropertyChangedRunnable(final PropertyChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.propertyChanged_(event);
- }
- };
- }
-
- private Runnable buildItemsAddedRunnable(final CollectionAddEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.itemsAdded_(event);
- }
- @Override
- public String toString() {
- return "items added runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildItemsRemovedRunnable(final CollectionRemoveEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.itemsRemoved_(event);
- }
- @Override
- public String toString() {
- return "items removed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildCollectionClearedRunnable(final CollectionClearEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.collectionCleared_(event);
- }
- @Override
- public String toString() {
- return "collection cleared runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildCollectionChangedRunnable(final CollectionChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.collectionChanged_(event);
- }
- @Override
- public String toString() {
- return "collection changed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildItemsAddedRunnable(final ListAddEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.itemsAdded_(event);
- }
- @Override
- public String toString() {
- return "items added runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildItemsRemovedRunnable(final ListRemoveEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.itemsRemoved_(event);
- }
- @Override
- public String toString() {
- return "items removed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildItemsMovedRunnable(final ListMoveEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.itemsMoved_(event);
- }
- @Override
- public String toString() {
- return "items moved runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildItemsReplacedRunnable(final ListReplaceEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.itemsReplaced_(event);
- }
- @Override
- public String toString() {
- return "items replaced runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildListClearedRunnable(final ListClearEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.listCleared_(event);
- }
- @Override
- public String toString() {
- return "list cleared runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildListChangedRunnable(final ListChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.listChanged_(event);
- }
- @Override
- public String toString() {
- return "list changed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildNodeAddedRunnable(final TreeAddEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.nodeAdded_(event);
- }
- @Override
- public String toString() {
- return "node added runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildNodeRemovedRunnable(final TreeRemoveEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.nodeRemoved_(event);
- }
- @Override
- public String toString() {
- return "node removed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildTreeClearedRunnable(final TreeClearEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.treeCleared_(event);
- }
- @Override
- public String toString() {
- return "tree cleared runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildTreeChangedRunnable(final TreeChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTChangeListenerWrapper.this.treeChanged_(event);
- }
- @Override
- public String toString() {
- return "tree changed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private boolean isExecutingOnUIThread() {
- return EventQueue.isDispatchThread();
- }
-
- /**
- * {@link EventQueue#invokeLater(Runnable)} seems to work OK;
- * but using {@link EventQueue#invokeAndWait(Runnable)} can sometimes make
- * things more predictable when debugging, at the risk of deadlocks.
- */
- private void executeOnEventQueue(Runnable r) {
- EventQueue.invokeLater(r);
-// try {
-// EventQueue.invokeAndWait(r);
-// } catch (InterruptedException ex) {
-// throw new RuntimeException(ex);
-// } catch (java.lang.reflect.InvocationTargetException ex) {
-// throw new RuntimeException(ex);
-// }
- }
-
- void stateChanged_(StateChangeEvent event) {
- this.listener.stateChanged(event);
- }
-
- void propertyChanged_(PropertyChangeEvent event) {
- this.listener.propertyChanged(event);
- }
-
- void itemsAdded_(CollectionAddEvent event) {
- this.listener.itemsAdded(event);
- }
-
- void itemsRemoved_(CollectionRemoveEvent event) {
- this.listener.itemsRemoved(event);
- }
-
- void collectionCleared_(CollectionClearEvent event) {
- this.listener.collectionCleared(event);
- }
-
- void collectionChanged_(CollectionChangeEvent event) {
- this.listener.collectionChanged(event);
- }
-
- void itemsAdded_(ListAddEvent event) {
- this.listener.itemsAdded(event);
- }
-
- void itemsRemoved_(ListRemoveEvent event) {
- this.listener.itemsRemoved(event);
- }
-
- void itemsMoved_(ListMoveEvent event) {
- this.listener.itemsMoved(event);
- }
-
- void itemsReplaced_(ListReplaceEvent event) {
- this.listener.itemsReplaced(event);
- }
-
- void listCleared_(ListClearEvent event) {
- this.listener.listCleared(event);
- }
-
- void listChanged_(ListChangeEvent event) {
- this.listener.listChanged(event);
- }
-
- void nodeAdded_(TreeAddEvent event) {
- this.listener.nodeAdded(event);
- }
-
- void nodeRemoved_(TreeRemoveEvent event) {
- this.listener.nodeRemoved(event);
- }
-
- void treeCleared_(TreeClearEvent event) {
- this.listener.treeCleared(event);
- }
-
- void treeChanged_(TreeChangeEvent event) {
- this.listener.treeChanged(event);
- }
-
- @Override
- public String toString() {
- return "AWT(" + this.listener.toString() + ')'; //$NON-NLS-1$
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java
deleted file mode 100644
index b8af52a34e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTCollectionChangeListenerWrapper.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.listener.awt;
-
-import java.awt.EventQueue;
-
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-
-/**
- * Wrap another collection change listener and forward events to it on the AWT
- * event queue, asynchronously if necessary. If the event arrived on the UI
- * thread that is probably because it was initiated by a UI widget; as a
- * result, we want to loop back synchronously so the events can be
- * short-circuited.
- */
-public final class AWTCollectionChangeListenerWrapper
- implements CollectionChangeListener
-{
- private final CollectionChangeListener listener;
-
- public AWTCollectionChangeListenerWrapper(CollectionChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void itemsAdded(CollectionAddEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsAdded_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsAddedRunnable(event));
- }
- }
-
- public void itemsRemoved(CollectionRemoveEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsRemoved_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsRemovedRunnable(event));
- }
- }
-
- public void collectionCleared(CollectionClearEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.collectionCleared_(event);
- } else {
- this.executeOnEventQueue(this.buildCollectionClearedRunnable(event));
- }
- }
-
- public void collectionChanged(CollectionChangeEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.collectionChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildCollectionChangedRunnable(event));
- }
- }
-
- private Runnable buildItemsAddedRunnable(final CollectionAddEvent event) {
- return new Runnable() {
- public void run() {
- AWTCollectionChangeListenerWrapper.this.itemsAdded_(event);
- }
- @Override
- public String toString() {
- return "items added runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildItemsRemovedRunnable(final CollectionRemoveEvent event) {
- return new Runnable() {
- public void run() {
- AWTCollectionChangeListenerWrapper.this.itemsRemoved_(event);
- }
- @Override
- public String toString() {
- return "items removed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildCollectionClearedRunnable(final CollectionClearEvent event) {
- return new Runnable() {
- public void run() {
- AWTCollectionChangeListenerWrapper.this.collectionCleared_(event);
- }
- @Override
- public String toString() {
- return "collection cleared runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildCollectionChangedRunnable(final CollectionChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTCollectionChangeListenerWrapper.this.collectionChanged_(event);
- }
- @Override
- public String toString() {
- return "collection changed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private boolean isExecutingOnUIThread() {
- return EventQueue.isDispatchThread();
- }
-
- /**
- * {@link EventQueue#invokeLater(Runnable)} seems to work OK;
- * but using {@link EventQueue#invokeAndWait(Runnable)} can sometimes make
- * things more predictable when debugging, at the risk of deadlocks.
- */
- private void executeOnEventQueue(Runnable r) {
- EventQueue.invokeLater(r);
-// try {
-// EventQueue.invokeAndWait(r);
-// } catch (InterruptedException ex) {
-// throw new RuntimeException(ex);
-// } catch (java.lang.reflect.InvocationTargetException ex) {
-// throw new RuntimeException(ex);
-// }
- }
-
- void itemsAdded_(CollectionAddEvent event) {
- this.listener.itemsAdded(event);
- }
-
- void itemsRemoved_(CollectionRemoveEvent event) {
- this.listener.itemsRemoved(event);
- }
-
- void collectionCleared_(CollectionClearEvent event) {
- this.listener.collectionCleared(event);
- }
-
- void collectionChanged_(CollectionChangeEvent event) {
- this.listener.collectionChanged(event);
- }
-
- @Override
- public String toString() {
- return "AWT(" + this.listener.toString() + ')'; //$NON-NLS-1$
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java
deleted file mode 100644
index bc477f4f7a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTListChangeListenerWrapper.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.listener.awt;
-
-import java.awt.EventQueue;
-
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-
-/**
- * Wrap another list change listener and forward events to it on the AWT
- * event queue, asynchronously if necessary. If the event arrived on the UI
- * thread that is probably because it was initiated by a UI widget; as a
- * result, we want to loop back synchronously so the events can be
- * short-circuited.
- */
-public final class AWTListChangeListenerWrapper
- implements ListChangeListener
-{
- private final ListChangeListener listener;
-
- public AWTListChangeListenerWrapper(ListChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void itemsAdded(ListAddEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsAdded_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsAddedRunnable(event));
- }
- }
-
- public void itemsRemoved(ListRemoveEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsRemoved_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsRemovedRunnable(event));
- }
- }
-
- public void itemsMoved(ListMoveEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsMoved_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsMovedRunnable(event));
- }
- }
-
- public void itemsReplaced(ListReplaceEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.itemsReplaced_(event);
- } else {
- this.executeOnEventQueue(this.buildItemsReplacedRunnable(event));
- }
- }
-
- public void listCleared(ListClearEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.listCleared_(event);
- } else {
- this.executeOnEventQueue(this.buildListClearedRunnable(event));
- }
- }
-
- public void listChanged(ListChangeEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.listChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildListChangedRunnable(event));
- }
- }
-
- private Runnable buildItemsAddedRunnable(final ListAddEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.itemsAdded_(event);
- }
- @Override
- public String toString() {
- return "items added runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildItemsRemovedRunnable(final ListRemoveEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.itemsRemoved_(event);
- }
- @Override
- public String toString() {
- return "items removed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildItemsMovedRunnable(final ListMoveEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.itemsMoved_(event);
- }
- @Override
- public String toString() {
- return "items moved runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildItemsReplacedRunnable(final ListReplaceEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.itemsReplaced_(event);
- }
- @Override
- public String toString() {
- return "items replaced runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildListClearedRunnable(final ListClearEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.listCleared_(event);
- }
- @Override
- public String toString() {
- return "list cleared runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildListChangedRunnable(final ListChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTListChangeListenerWrapper.this.listChanged_(event);
- }
- @Override
- public String toString() {
- return "list changed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private boolean isExecutingOnUIThread() {
- return EventQueue.isDispatchThread();
- }
-
- /**
- * {@link EventQueue#invokeLater(Runnable)} seems to work OK;
- * but using {@link EventQueue#invokeAndWait(Runnable)} can sometimes make
- * things more predictable when debugging, at the risk of deadlocks.
- */
- private void executeOnEventQueue(Runnable r) {
- EventQueue.invokeLater(r);
-// try {
-// EventQueue.invokeAndWait(r);
-// } catch (InterruptedException ex) {
-// throw new RuntimeException(ex);
-// } catch (java.lang.reflect.InvocationTargetException ex) {
-// throw new RuntimeException(ex);
-// }
- }
-
- void itemsAdded_(ListAddEvent event) {
- this.listener.itemsAdded(event);
- }
-
- void itemsRemoved_(ListRemoveEvent event) {
- this.listener.itemsRemoved(event);
- }
-
- void itemsMoved_(ListMoveEvent event) {
- this.listener.itemsMoved(event);
- }
-
- void itemsReplaced_(ListReplaceEvent event) {
- this.listener.itemsReplaced(event);
- }
-
- void listCleared_(ListClearEvent event) {
- this.listener.listCleared(event);
- }
-
- void listChanged_(ListChangeEvent event) {
- this.listener.listChanged(event);
- }
-
- @Override
- public String toString() {
- return "AWT(" + this.listener.toString() + ')'; //$NON-NLS-1$
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java
deleted file mode 100644
index a46bd8bc64..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTPropertyChangeListenerWrapper.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.listener.awt;
-
-import java.awt.EventQueue;
-
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-
-/**
- * Wrap another property change listener and forward events to it on the AWT
- * event queue, asynchronously if necessary. If the event arrived on the UI
- * thread that is probably because it was initiated by a UI widget; as a
- * result, we want to loop back synchronously so the events can be
- * short-circuited.
- */
-public final class AWTPropertyChangeListenerWrapper
- implements PropertyChangeListener
-{
- private final PropertyChangeListener listener;
-
-
- public AWTPropertyChangeListenerWrapper(PropertyChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void propertyChanged(PropertyChangeEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.propertyChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildPropertyChangedRunnable(event));
- }
- }
-
- private Runnable buildPropertyChangedRunnable(final PropertyChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTPropertyChangeListenerWrapper.this.propertyChanged_(event);
- }
- @Override
- public String toString() {
- return "property changed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private boolean isExecutingOnUIThread() {
- return EventQueue.isDispatchThread();
- }
-
- /**
- * {@link EventQueue#invokeLater(Runnable)} seems to work OK;
- * but using {@link EventQueue#invokeAndWait(Runnable)} can sometimes make
- * things more predictable when debugging, at the risk of deadlocks.
- */
- private void executeOnEventQueue(Runnable r) {
- EventQueue.invokeLater(r);
-// try {
-// EventQueue.invokeAndWait(r);
-// } catch (InterruptedException ex) {
-// throw new RuntimeException(ex);
-// } catch (java.lang.reflect.InvocationTargetException ex) {
-// throw new RuntimeException(ex);
-// }
- }
-
- void propertyChanged_(PropertyChangeEvent event) {
- this.listener.propertyChanged(event);
- }
-
- @Override
- public String toString() {
- return "AWT(" + this.listener.toString() + ')'; //$NON-NLS-1$
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java
deleted file mode 100644
index c1ecf2b2ee..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTStateChangeListenerWrapper.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.listener.awt;
-
-import java.awt.EventQueue;
-
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-
-/**
- * Wrap another state change listener and forward events to it on the AWT
- * event queue, asynchronously if necessary. If the event arrived on the UI
- * thread that is probably because it was initiated by a UI widget; as a
- * result, we want to loop back synchronously so the events can be
- * short-circuited.
- */
-public final class AWTStateChangeListenerWrapper
- implements StateChangeListener
-{
- private final StateChangeListener listener;
-
- public AWTStateChangeListenerWrapper(StateChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void stateChanged(StateChangeEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.stateChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildStateChangedRunnable(event));
- }
- }
-
- private Runnable buildStateChangedRunnable(final StateChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTStateChangeListenerWrapper.this.stateChanged_(event);
- }
- @Override
- public String toString() {
- return "state changed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private boolean isExecutingOnUIThread() {
- return EventQueue.isDispatchThread();
- }
-
- /**
- * {@link EventQueue#invokeLater(Runnable)} seems to work OK;
- * but using {@link EventQueue#invokeAndWait(Runnable)} can sometimes make
- * things more predictable when debugging, at the risk of deadlocks.
- */
- private void executeOnEventQueue(Runnable r) {
- EventQueue.invokeLater(r);
-// try {
-// EventQueue.invokeAndWait(r);
-// } catch (InterruptedException ex) {
-// throw new RuntimeException(ex);
-// } catch (java.lang.reflect.InvocationTargetException ex) {
-// throw new RuntimeException(ex);
-// }
- }
-
- void stateChanged_(StateChangeEvent event) {
- this.listener.stateChanged(event);
- }
-
- @Override
- public String toString() {
- return "AWT(" + this.listener.toString() + ')'; //$NON-NLS-1$
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java
deleted file mode 100644
index ea60469d1a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/listener/awt/AWTTreeChangeListenerWrapper.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.listener.awt;
-
-import java.awt.EventQueue;
-
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.TreeChangeListener;
-
-/**
- * Wrap another tree change listener and forward events to it on the AWT
- * event queue, asynchronously if necessary. If the event arrived on the UI
- * thread that is probably because it was initiated by a UI widget; as a
- * result, we want to loop back synchronously so the events can be
- * short-circuited.
- */
-public final class AWTTreeChangeListenerWrapper
- implements TreeChangeListener
-{
- private final TreeChangeListener listener;
-
- public AWTTreeChangeListenerWrapper(TreeChangeListener listener) {
- super();
- if (listener == null) {
- throw new NullPointerException();
- }
- this.listener = listener;
- }
-
- public void nodeAdded(TreeAddEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.nodeAdded_(event);
- } else {
- this.executeOnEventQueue(this.buildNodeAddedRunnable(event));
- }
- }
-
- public void nodeRemoved(TreeRemoveEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.nodeRemoved_(event);
- } else {
- this.executeOnEventQueue(this.buildNodeRemovedRunnable(event));
- }
- }
-
- public void treeCleared(TreeClearEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.treeCleared_(event);
- } else {
- this.executeOnEventQueue(this.buildTreeClearedRunnable(event));
- }
- }
-
- public void treeChanged(TreeChangeEvent event) {
- if (this.isExecutingOnUIThread()) {
- this.treeChanged_(event);
- } else {
- this.executeOnEventQueue(this.buildTreeChangedRunnable(event));
- }
- }
-
- private Runnable buildNodeAddedRunnable(final TreeAddEvent event) {
- return new Runnable() {
- public void run() {
- AWTTreeChangeListenerWrapper.this.nodeAdded_(event);
- }
- @Override
- public String toString() {
- return "node added runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildNodeRemovedRunnable(final TreeRemoveEvent event) {
- return new Runnable() {
- public void run() {
- AWTTreeChangeListenerWrapper.this.nodeRemoved_(event);
- }
- @Override
- public String toString() {
- return "node removed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildTreeClearedRunnable(final TreeClearEvent event) {
- return new Runnable() {
- public void run() {
- AWTTreeChangeListenerWrapper.this.treeCleared_(event);
- }
- @Override
- public String toString() {
- return "tree cleared runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private Runnable buildTreeChangedRunnable(final TreeChangeEvent event) {
- return new Runnable() {
- public void run() {
- AWTTreeChangeListenerWrapper.this.treeChanged_(event);
- }
- @Override
- public String toString() {
- return "tree changed runnable"; //$NON-NLS-1$
- }
- };
- }
-
- private boolean isExecutingOnUIThread() {
- return EventQueue.isDispatchThread();
- }
-
- /**
- * {@link EventQueue#invokeLater(Runnable)} seems to work OK;
- * but using {@link EventQueue#invokeAndWait(Runnable)} can sometimes make
- * things more predictable when debugging, at the risk of deadlocks.
- */
- private void executeOnEventQueue(Runnable r) {
- EventQueue.invokeLater(r);
-// try {
-// EventQueue.invokeAndWait(r);
-// } catch (InterruptedException ex) {
-// throw new RuntimeException(ex);
-// } catch (java.lang.reflect.InvocationTargetException ex) {
-// throw new RuntimeException(ex);
-// }
- }
-
- void nodeAdded_(TreeAddEvent event) {
- this.listener.nodeAdded(event);
- }
-
- void nodeRemoved_(TreeRemoveEvent event) {
- this.listener.nodeRemoved(event);
- }
-
- void treeCleared_(TreeClearEvent event) {
- this.listener.treeCleared(event);
- }
-
- void treeChanged_(TreeChangeEvent event) {
- this.listener.treeChanged(event);
- }
-
- @Override
- public String toString() {
- return "AWT(" + this.listener.toString() + ')'; //$NON-NLS-1$
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractCollectionValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractCollectionValueModel.java
deleted file mode 100644
index 31aad85651..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractCollectionValueModel.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-
-/**
- * This abstract class provides the infrastructure for "lazily" adding listeners
- * to an underlying model as necessary. Subclasses will need to engage and
- * disegage the underlying model and fire the appropriate collection change
- * events. Subclasses must implement the appropriate {@link CollectionValueModel}.
- * <p>
- * Subclasses must implement the following methods:<ul>
- * <li>{@link #engageModel()}<p>
- * implement this method to add the appropriate listener to the underlying model
- * <li>{@link #disengageModel()}<p>
- * implement this method to remove the appropriate listener from the underlying model
- * </ul>
- */
-public abstract class AbstractCollectionValueModel
- extends AbstractModel
-{
-
- // ********** constructor/initialization **********
-
- protected AbstractCollectionValueModel() {
- super();
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, CollectionChangeListener.class, CollectionValueModel.VALUES);
- }
-
-
- // ********** extend change support **********
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public synchronized void addChangeListener(ChangeListener listener) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addChangeListener(listener);
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public synchronized void addCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- if (collectionName.equals(CollectionValueModel.VALUES) && this.hasNoListeners()) {
- this.engageModel();
- }
- super.addCollectionChangeListener(collectionName, listener);
- }
-
- /**
- * Extend to stop listening to the underlying model if necessary.
- */
- @Override
- public synchronized void removeChangeListener(ChangeListener listener) {
- super.removeChangeListener(listener);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Extend to stop listening to the underlying model if necessary.
- */
- @Override
- public synchronized void removeCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- super.removeCollectionChangeListener(collectionName, listener);
- if (collectionName.equals(CollectionValueModel.VALUES) && this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether the model has no collection value listeners.
- */
- protected boolean hasNoListeners() {
- return ! this.hasListeners();
- }
-
- /**
- * Return whether the model has any collection value listeners.
- */
- protected boolean hasListeners() {
- return this.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES);
- }
-
-
- // ********** behavior **********
-
- /**
- * Engage the underlying model.
- */
- protected abstract void engageModel();
-
- /**
- * Stop listening to the underlying model.
- */
- protected abstract void disengageModel();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractListValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractListValueModel.java
deleted file mode 100644
index b182a52764..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractListValueModel.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * This abstract class provides the infrastructure for "lazily" adding listeners
- * to an underlying model as necessary. Subclasses will need to engage and
- * disegage the underlying model and fire the appropriate list change
- * events. Subclasses must implement the appropriate {@link ListValueModel}.
- * <p>
- * Subclasses must implement the following methods:<ul>
- * <li>{@link #engageModel()}<p>
- * implement this method to add the appropriate listener to the underlying model
- * <li>{@link #disengageModel()}<p>
- * implement this method to remove the appropriate listener from the underlying model
- * </ul>
- */
-public abstract class AbstractListValueModel
- extends AbstractModel
-{
-
- // ********** constructor/initialization **********
-
- protected AbstractListValueModel() {
- super();
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, ListChangeListener.class, ListValueModel.LIST_VALUES);
- }
-
-
- // ********** extend change support **********
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addChangeListener(ChangeListener listener) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addChangeListener(listener);
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addListChangeListener(String listName, ListChangeListener listener) {
- if (listName.equals(ListValueModel.LIST_VALUES) && this.hasNoListeners()) {
- this.engageModel();
- }
- super.addListChangeListener(listName, listener);
- }
-
- /**
- * Extend to stop listening to the underlying model if necessary.
- */
- @Override
- public void removeChangeListener(ChangeListener listener) {
- super.removeChangeListener(listener);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Extend to stop listening to the underlying model if necessary.
- */
- @Override
- public void removeListChangeListener(String listName, ListChangeListener listener) {
- super.removeListChangeListener(listName, listener);
- if (listName.equals(ListValueModel.LIST_VALUES) && this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether the model has no collection value listeners.
- */
- protected boolean hasNoListeners() {
- return ! this.hasListeners();
- }
-
- /**
- * Return whether the model has any collection value listeners.
- */
- protected boolean hasListeners() {
- return this.hasAnyListChangeListeners(ListValueModel.LIST_VALUES);
- }
-
-
- // ********** behavior **********
-
- /**
- * Engage the underlying model.
- */
- protected abstract void engageModel();
-
- /**
- * Stop listening to the underlying model.
- */
- protected abstract void disengageModel();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractPropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractPropertyValueModel.java
deleted file mode 100644
index 27e31c28b1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractPropertyValueModel.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This abstract class provides the infrastructure for "lazily" adding/removing
- * listeners to/from an underlying model as <em>property</em> change
- * listeners are added to/removed from itself.
- * Subclasses will need to engage and disengage the underlying model
- * appropriately and fire the appropriate <em>property</em>
- * change events.
- * <p>
- * Subclasses must implement the appropriate {@link PropertyValueModel}.
- * <p>
- * Subclasses must implement the following methods:<ul>
- * <li>{@link #engageModel()}<p>
- * implement this method to add the appropriate listener(s) to the
- * underlying model
- * <li>{@link #disengageModel()}<p>
- * implement this method to remove the appropriate listener(s) from the
- * underlying model
- * </ul>
- */
-public abstract class AbstractPropertyValueModel
- extends AbstractModel
-{
- // ********** constructor/initialization **********
-
- protected AbstractPropertyValueModel() {
- super();
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, PropertyChangeListener.class, PropertyValueModel.VALUE);
- }
-
-
- // ********** listeners **********
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public synchronized void addChangeListener(ChangeListener listener) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addChangeListener(listener);
- }
-
- /**
- * Extend to stop listening to the underlying model if necessary.
- */
- @Override
- public synchronized void removeChangeListener(ChangeListener listener) {
- super.removeChangeListener(listener);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- if (propertyName.equals(PropertyValueModel.VALUE) && this.hasNoListeners()) {
- this.engageModel();
- }
- super.addPropertyChangeListener(propertyName, listener);
- }
-
- /**
- * Extend to stop listening to the underlying model if necessary.
- */
- @Override
- public synchronized void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- super.removePropertyChangeListener(propertyName, listener);
- if (propertyName.equals(PropertyValueModel.VALUE) && this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Return whether the model has no property value listeners.
- */
- protected boolean hasNoListeners() {
- return ! this.hasListeners();
- }
-
- /**
- * Return whether the model has any property value listeners.
- */
- protected boolean hasListeners() {
- return this.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE);
- }
-
-
- // ********** subclass implementation **********
-
- /**
- * Engage the underlying model.
- */
- protected abstract void engageModel();
-
- /**
- * Stop listening to the underlying model.
- */
- protected abstract void disengageModel();
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractPropertyValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractPropertyValueModelAdapter.java
deleted file mode 100644
index a77b11b6cf..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractPropertyValueModelAdapter.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * a model, "lazily" listen to it, and convert
- * its change notifications into <em>property</em> value model change
- * notifications.
- * <p>
- * Subclasses must implement:<ul>
- * <li>{@link #buildValue()}<p>
- * to return the current property value, as derived from the
- * current state of the underlying model
- * <li>{@link #engageModel_()}<p>
- * to start listening to the underlying (adapted) model
- * <li>{@link #disengageModel_()}<p>
- * to stop listening to the underlying (adapted) model
- * </ul>
- * Subclasses can call {@link #propertyChanged()} whenever the calculated
- * value of the property changes (as determined by the subclass).
- *
- * @param <V> the type of the model's value
- */
-public abstract class AbstractPropertyValueModelAdapter<V>
- extends AbstractPropertyValueModel
- implements PropertyValueModel<V>
-{
- /**
- * Cache the current value so we can pass an "old value" when
- * we fire a property change event.
- * We need this because the value may be calculated and we may
- * not able to derive the "old value" from any fired events.
- */
- protected volatile V value;
-
-
- // ********** constructor/initialization **********
-
- protected AbstractPropertyValueModelAdapter() {
- super();
- // our value is null when we are not listening to the model
- this.value = null;
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- /**
- * Return the cached value.
- */
- public V getValue() {
- return this.value;
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the underlying model and build the value.
- */
- @Override
- protected void engageModel() {
- this.engageModel_();
- // sync our value *after* we start listening to the model,
- // since the model's value might change when a listener is added
- this.value = this.buildValue();
- }
-
- /**
- * Start listening to the underlying model.
- */
- protected abstract void engageModel_();
-
- /**
- * Build and return the current value, as derived from the
- * current state of the underlying model.
- */
- protected abstract V buildValue();
-
- /**
- * Stop listening to the underlying model and clear the value.
- */
- @Override
- protected void disengageModel() {
- this.disengageModel_();
- // clear out our value when we are not listening to the model
- this.value = null;
- }
-
- /**
- * Stop listening to the underlying model.
- */
- protected abstract void disengageModel_();
-
- /**
- * The underlying model changed in some fashion.
- * Recalculate the model's value and notify listeners.
- */
- protected void propertyChanged() {
- Object old = this.value;
- this.firePropertyChanged(VALUE, old, this.value = this.buildValue());
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.value);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractTreeNodeValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractTreeNodeValueModel.java
deleted file mode 100644
index 657676e34d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AbstractTreeNodeValueModel.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ChainIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.TreeNodeValueModel;
-
-/**
- * Subclasses need only implement the following methods:
- *
- * #value()
- * return the user-determined "value" of the node,
- * i.e. the object "wrapped" by the node
- *
- * #setValue(Object)
- * set the user-determined "value" of the node,
- * i.e. the object "wrapped" by the node;
- * typically only overridden for nodes with "primitive" values
- *
- * #parent()
- * return the parent of the node, which should be another
- * TreeNodeValueModel
- *
- * #childrenModel()
- * return a ListValueModel for the node's children
- *
- * #engageValue() and #disengageValue()
- * override these methods to listen to the node's value if
- * it can change in a way that should be reflected in the tree
- */
-public abstract class AbstractTreeNodeValueModel<T>
- extends AbstractModel
- implements TreeNodeValueModel<T>
-{
-
-
- // ********** constructors **********
-
- /**
- * Default constructor.
- */
- protected AbstractTreeNodeValueModel() {
- super();
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- // this model fires *both* "value property change" and "state change" events...
-// return new SingleAspectChangeSupport(this, PropertyChangeListener.class, PropertyValueModel.VALUE);
- return super.buildChangeSupport();
- }
-
-
- // ********** extend AbstractModel implementation **********
-
- /**
- * Clients should be adding both "state change" and "value property change"
- * listeners.
- */
- @Override
- public void addStateChangeListener(StateChangeListener listener) {
- if (this.hasNoStateChangeListeners()) {
- this.engageValue();
- }
- super.addStateChangeListener(listener);
- }
-
- /**
- * Begin listening to the node's value's state. If the state of the node changes
- * in a way that should be reflected in the tree, fire a "state change" event.
- */
- protected abstract void engageValue();
-
- /**
- * @see #addStateChangeListener(StateChangeListener)
- */
- @Override
- public void removeStateChangeListener(StateChangeListener listener) {
- super.removeStateChangeListener(listener);
- if (this.hasNoStateChangeListeners()) {
- this.disengageValue();
- }
- }
-
- /**
- * Stop listening to the node's value.
- * @see #engageValue()
- */
- protected abstract void disengageValue();
-
-
- // ********** WritablePropertyValueModel implementation **********
-
- public void setValue(T value) {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** TreeNodeValueModel implementation **********
-
- @SuppressWarnings("unchecked")
- public TreeNodeValueModel<T>[] path() {
- List<TreeNodeValueModel<T>> path = CollectionTools.reverseList(this.backPath());
- return path.toArray(new TreeNodeValueModel[path.size()]);
- }
-
- /**
- * Return an iterator that climbs up the node's path,
- * starting with, and including, the node
- * and up to, and including, the root node.
- */
- protected Iterator<TreeNodeValueModel<T>> backPath() {
- return new ChainIterator<TreeNodeValueModel<T>>(this) {
- @Override
- protected TreeNodeValueModel<T> nextLink(TreeNodeValueModel<T> currentLink) {
- return currentLink.parent();
- }
- };
- }
-
- public TreeNodeValueModel<T> child(int index) {
- return this.childrenModel().get(index);
- }
-
- public int childrenSize() {
- return this.childrenModel().size();
- }
-
- public int indexOfChild(TreeNodeValueModel<T> child) {
- ListValueModel<TreeNodeValueModel<T>> children = this.childrenModel();
- int size = children.size();
- for (int i = 0; i < size; i++) {
- if (children.get(i) == child) {
- return i;
- }
- }
- return -1;
- }
-
- public boolean isLeaf() {
- return this.childrenModel().size() == 0;
- }
-
-
- // ********** standard methods **********
-
- /**
- * We implement #equals(Object) so that TreePaths containing these nodes
- * will resolve properly when the nodes contain the same values. This is
- * necessary because nodes are dropped and rebuilt willy-nilly when dealing
- * with a sorted list of children; and this allows us to save and restore
- * a tree's expanded paths. The nodes in the expanded paths that are
- * saved before any modification (e.g. renaming a node) will be different
- * from the nodes in the tree's paths after the modification, if the modification
- * results in a possible change in the node sort order. ~bjv
- */
- @Override
- public boolean equals(Object o) {
- if (o == null) {
- return false;
- }
- if (o.getClass() != this.getClass()) {
- return false;
- }
- @SuppressWarnings("unchecked")
- AbstractTreeNodeValueModel<T> other = (AbstractTreeNodeValueModel<T>) o;
- return this.getValue().equals(other.getValue());
- }
-
- @Override
- public int hashCode() {
- return this.getValue().hashCode();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getValue());
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectAdapter.java
deleted file mode 100644
index 9dd8d46bd8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectAdapter.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.EventListener;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This abstract extension of {@link AbstractModel} provides a base for adding
- * change listeners (property change, collection change, list change, tree change)
- * to a subject and converting the subject's change notifications into a single
- * set of change notifications for a common aspect
- * (e.g. {@link PropertyValueModel#VALUE}).
- * <p>
- * The adapter will only listen to the subject (and subject model) when the
- * adapter itself actually has listeners. This will allow the adapter to be
- * garbage collected when appropriate.
- *
- * @param <S> the type of the model's subject
- * @param <A> the type of the subject's aspect
- */
-public abstract class AspectAdapter<S, A>
- extends AbstractModel
-{
- /**
- * The subject that holds the aspect and fires
- * change notification when the aspect changes.
- * We need to hold on to this directly so we can
- * disengage it when it changes.
- */
- protected volatile S subject;
-
- /**
- * A value model that holds the {@link #subject}
- * that holds the aspect and provides change notification.
- * This is useful when there are a number of aspect adapters
- * that have the same subject and that subject can change.
- * All the aspect adapters can share the same subject model.
- * For now, this is can only be set upon construction and is
- * immutable.
- */
- protected final PropertyValueModel<? extends S> subjectHolder;
-
- /** A listener that keeps us in sync with the subject model. */
- protected final PropertyChangeListener subjectListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an aspect adapter for the specified subject.
- */
- protected AspectAdapter(S subject) {
- this(new StaticPropertyValueModel<S>(subject));
- }
-
- /**
- * Construct an aspect adapter for the specified subject model.
- * The subject model cannot be <code>null</code>.
- */
- protected AspectAdapter(PropertyValueModel<? extends S> subjectModel) {
- super();
- if (subjectModel == null) {
- throw new NullPointerException();
- }
- this.subjectHolder = subjectModel;
- this.subjectListener = this.buildSubjectListener();
- // the subject is null when we are not listening to it
- // this will typically result in our value being null
- this.subject = null;
- }
-
-
- // ********** initialization **********
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new LocalChangeSupport(this, this.getListenerClass(), this.getListenerAspectName());
- }
-
- protected PropertyChangeListener buildSubjectListener() {
- return new SubjectListener();
- }
-
- protected class SubjectListener
- extends PropertyChangeAdapter
- {
- /**
- * The subject model's value has changed, keep our subject in sync.
- */
- @Override
- public void propertyChanged(PropertyChangeEvent event) {
- AspectAdapter.this.subjectChanged();
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * The subject has changed.
- * Move our subject listener and
- * notify listeners that the value has changed.
- */
- protected synchronized void subjectChanged() {
- A old = this.getAspectValue();
- boolean hasListeners = this.hasListeners();
- if (hasListeners) {
- this.disengageSubject();
- }
- this.subject = this.subjectHolder.getValue();
- if (hasListeners) {
- this.engageSubject();
- this.fireAspectChanged(old, this.getAspectValue());
- }
- }
-
- /**
- * Return the aspect's current value.
- */
- protected abstract A getAspectValue();
-
- /**
- * Return the class of listener that is interested in the aspect adapter's
- * changes.
- */
- protected abstract Class<? extends EventListener> getListenerClass();
-
- /**
- * Return the name of the aspect adapter's aspect
- * (e.g. {@link PropertyValueModel#VALUE}).
- * This is the name of the aspect adapter's single aspect, not the
- * name of the subject's aspect(s) the aspect adapter is adapting.
- */
- protected abstract String getListenerAspectName();
-
- /**
- * Return whether there are any listeners for the aspect.
- */
- protected abstract boolean hasListeners();
-
- /**
- * Return whether there are no listeners for the aspect.
- */
- protected boolean hasNoListeners() {
- return ! this.hasListeners();
- }
-
- /**
- * The aspect has changed, notify listeners appropriately.
- */
- protected abstract void fireAspectChanged(A oldValue, A newValue);
-
-
- // ********** engage/disengage models **********
-
- /**
- * Called by {@link LocalChangeSupport}
- */
- protected void engageModels() {
- this.engageSubjectHolder();
- this.engageSubject();
- }
-
- protected void engageSubjectHolder() {
- this.subjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.subjectListener);
- // sync our subject *after* we start listening to the subject holder,
- // since its value might change when a listener is added
- this.subject = this.subjectHolder.getValue();
- }
-
- protected void engageSubject() {
- // check for nothing to listen to
- if (this.subject != null) {
- this.engageSubject_();
- }
- }
-
- /**
- * The {@link #subject} is not <code>null</code> - add our listener.
- */
- protected abstract void engageSubject_();
-
- /**
- * Called by {@link LocalChangeSupport}
- */
- protected void disengageModels() {
- this.disengageSubject();
- this.disengageSubjectHolder();
- }
-
- protected void disengageSubject() {
- // check for nothing to listen to
- if (this.subject != null) {
- this.disengageSubject_();
- }
- }
-
- /**
- * The {@link #subject} is not <code>null</code> - remove our listener.
- */
- protected abstract void disengageSubject_();
-
- protected void disengageSubjectHolder() {
- this.subjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.subjectListener);
- // clear out the subject when we are not listening to its holder
- this.subject = null;
- }
-
-
- // ********** local change support **********
-
- /**
- * Extend change support to start listening to the aspect adapter's
- * models (the subject holder and the subject itself) when the first
- * relevant listener is added.
- * Conversely, stop listening to the aspect adapter's models when the
- * last relevant listener is removed.
- * A relevant listener is a listener of the relevant type and aspect or a
- * general-purpose listener.
- */
- protected class LocalChangeSupport
- extends SingleAspectChangeSupport
- {
- private static final long serialVersionUID = 1L;
-
- public LocalChangeSupport(AspectAdapter<S, A> source, Class<? extends EventListener> validListenerClass, String validAspectName) {
- super(source, validListenerClass, validAspectName);
- }
-
- protected boolean hasNoListeners() {
- return this.hasNoListeners(this.validListenerClass, this.validAspectName);
- }
-
-
- // ********** overrides **********
-
- @Override
- protected synchronized <T extends EventListener> void addListener(Class<T> listenerClass, T listener) {
- if (this.hasNoListeners()) {
- AspectAdapter.this.engageModels();
- }
- super.addListener(listenerClass, listener);
- }
-
- @Override
- protected synchronized <T extends EventListener> void addListener(Class<T> listenerClass, String aspectName, T listener) {
- if (this.hasNoListeners()) {
- AspectAdapter.this.engageModels();
- }
- super.addListener(listenerClass, aspectName, listener);
- }
-
- @Override
- protected synchronized <T extends EventListener> void removeListener(Class<T> listenerClass, T listener) {
- super.removeListener(listenerClass, listener);
- if (this.hasNoListeners()) {
- AspectAdapter.this.disengageModels();
- }
- }
-
- @Override
- protected synchronized <T extends EventListener> void removeListener(Class<T> listenerClass, String aspectName, T listener) {
- super.removeListener(listenerClass, aspectName, listener);
- if (this.hasNoListeners()) {
- AspectAdapter.this.disengageModels();
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectCollectionValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectCollectionValueModelAdapter.java
deleted file mode 100644
index ec46773400..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectCollectionValueModelAdapter.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Collection;
-import java.util.EventListener;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This {@link AspectAdapter} provides basic collection change support.
- * This converts an "aspect" (as defined by subclasses) into
- * a single {@link #VALUES} collection.
- * <p>
- * The typical subclass will override the following methods:<ul>
- * <li>{@link #engageSubject_()}<p>
- * implement this method to add the appropriate listener to the subject
- * <li>{@link #disengageSubject_()}<p>
- * implement this method to remove the appropriate listener from the subject
- * <li>{@link #getIterable()}<p>
- * at the very minimum, override this method to return an iterable containing the
- * subject's collection aspect; it does not need to be overridden if either
- * {@link #iterator_()} or {@link #iterator()} is overridden and its behavior changed
- * <li>{@link #size_()}<p>
- * override this method to improve performance; it does not need to be overridden if
- * {@link #size()} is overridden and its behavior changed
- * <li>{@link #iterator_()}<p>
- * override this method to return an iterator on the
- * subject's collection aspect if it is not possible to implement {@link #getIterable()};
- * it does not need to be overridden if
- * {@link #iterator()} is overridden and its behavior changed
- * <li>{@link #iterator()}<p>
- * override this method only if returning an empty iterator when the
- * subject is null is unacceptable
- * <li>{@link #size()}<p>
- * override this method only if returning a zero when the
- * subject is null is unacceptable
- * </ul>
- * To notify listeners, subclasses can call {@link #aspectChanged()}
- * whenever the aspect has changed.
- *
- * @param <S> the type of the model's subject
- * @param <E> the type of the subject's collection aspect's elements
- */
-public abstract class AspectCollectionValueModelAdapter<S, E>
- extends AspectAdapter<S, Collection<E>>
- implements CollectionValueModel<E>
-{
- /**
- * Construct a collection value model adapter for an aspect of the
- * specified subject.
- */
- protected AspectCollectionValueModelAdapter(PropertyValueModel<? extends S> subjectModel) {
- super(subjectModel);
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- /**
- * Return the elements of the subject's collection aspect.
- */
- public Iterator<E> iterator() {
- return (this.subject == null) ? EmptyIterator.<E>instance() : this.iterator_();
- }
-
- /**
- * Return the elements of the subject's collection aspect.
- * At this point we can be sure the {@link #subject} is
- * <em>not</em> <code>null</code>.
- * @see #iterator()
- */
- protected Iterator<E> iterator_() {
- return this.getIterable().iterator();
- }
-
- /**
- * Return the elements of the subject's collection aspect.
- * At this point we can be sure the {@link #subject} is
- * <em>not</em> <code>null</code>.
- * @see #iterator_()
- */
- protected Iterable<E> getIterable() {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- /**
- * Return the size of the subject's collection aspect.
- */
- public int size() {
- return (this.subject == null) ? 0 : this.size_();
- }
-
- /**
- * Return the size of the subject's collection aspect.
- * At this point we can be sure the {@link #subject} is
- * <em>not</em> <code>null</code>.
- * @see #size()
- */
- protected int size_() {
- return CollectionTools.size(this.iterator());
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected Collection<E> getAspectValue() {
- return this.buildValueCollection();
- }
-
- @Override
- protected Class<? extends EventListener> getListenerClass() {
- return CollectionChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return VALUES;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyCollectionChangeListeners(VALUES);
- }
-
- @Override
- protected void fireAspectChanged(Collection<E> oldValue, Collection<E> newValue) {
- this.fireCollectionChanged(VALUES, newValue);
- }
-
- protected void aspectChanged() {
- this.fireCollectionChanged(VALUES, this.buildValueCollection());
- }
-
- protected Collection<E> buildValueCollection() {
- return CollectionTools.collection(this.iterator());
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.buildValueCollection());
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectListValueModelAdapter.java
deleted file mode 100644
index da7db5c4f4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectListValueModelAdapter.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.EventListener;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This {@link AspectAdapter} provides basic list change support.
- * This converts an "aspect" (as defined by subclasses) into
- * a single {@link #LIST_VALUES} list.
- * <p>
- * The typical subclass will override the following methods:<ul>
- * <li>{@link #engageSubject_()}<p>
- * implement this method to add the appropriate listener to the subject
- * <li>{@link #disengageSubject_()}<p>
- * implement this method to remove the appropriate listener from the subject
- * <li>{@link #getListIterable()}<p>
- * at the very minimum, override this method to return a list iterable containing the
- * subject's list aspect; it does not need to be overridden if either
- * {@link #listIterator_()} or {@link #listIterator()} is overridden and its behavior changed
- * <li>{@link #get(int)}<p>
- * override this method to improve performance
- * <li>{@link #size_()}<p>
- * override this method to improve performance; it does not need to be overridden if
- * {@link #size()} is overridden and its behavior changed
- * <li>{@link #toArray_()}<p>
- * override this method to improve performance; it does not need to be overridden if
- * {@link #toArray()} is overridden and its behavior changed
- * <li>{@link #listIterator_()}<p>
- * override this method to return a list iterator on the subject's list
- * aspect if it is not possible to implement {@link #getListIterable()};
- * it does not need to be overridden if
- * {@link #listIterator()} is overridden and its behavior changed
- * <li>{@link #listIterator()}<p>
- * override this method only if returning an empty list iterator when the
- * subject is null is unacceptable
- * <li>{@link #size()}<p>
- * override this method only if returning a zero when the
- * subject is null is unacceptable
- * <li>{@link #toArray()}<p>
- * override this method only if returning an empty array when the
- * subject is null is unacceptable
- * </ul>
- * To notify listeners, subclasses can call {@link #aspectChanged()}
- * whenever the aspect has changed.
- *
- * @param <S> the type of the model's subject
- * @param <E> the type of the subject's list aspect's elements
- */
-public abstract class AspectListValueModelAdapter<S, E>
- extends AspectAdapter<S, List<E>>
- implements ListValueModel<E>
-{
- private static final Object[] EMPTY_ARRAY = new Object[0];
-
-
- // ********** constructors **********
-
- /**
- * Construct a list value model adapter for an aspect of the
- * specified subject.
- */
- protected AspectListValueModelAdapter(PropertyValueModel<? extends S> subjectModel) {
- super(subjectModel);
- }
-
-
- // ********** ListValueModel implementation **********
-
- /**
- * Return the elements of the subject's list aspect.
- */
- public ListIterator<E> iterator() {
- return this.listIterator();
- }
-
- /**
- * Return the elements of the subject's list aspect.
- */
- public ListIterator<E> listIterator() {
- return (this.subject == null) ? EmptyListIterator.<E>instance() : this.listIterator_();
- }
-
- /**
- * Return the elements of the subject's list aspect.
- * At this point we can be sure the {@link #subject} is
- * <em>not</em> <code>null</code>.
- * @see #listIterator()
- */
- protected ListIterator<E> listIterator_() {
- return this.getListIterable().iterator();
- }
-
- /**
- * Return the elements of the subject's list aspect.
- * At this point we can be sure the {@link #subject} is
- * <em>not</em> <code>null</code>.
- * @see #listIterator_()
- */
- protected ListIterable<E> getListIterable() {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- /**
- * Return the element at the specified index of the subject's list aspect.
- */
- public E get(int index) {
- return CollectionTools.get(this.listIterator(), index);
- }
-
- /**
- * Return the size of the subject's list aspect.
- */
- public int size() {
- return this.subject == null ? 0 : this.size_();
- }
-
- /**
- * Return the size of the subject's list aspect.
- * At this point we can be sure the {@link #subject} is
- * <em>not</em> <code>null</code>.
- * @see #size()
- */
- protected int size_() {
- return CollectionTools.size(this.listIterator());
- }
-
- /**
- * Return an array manifestation of the subject's list aspect.
- */
- public Object[] toArray() {
- return this.subject == null ? EMPTY_ARRAY : this.toArray_();
- }
-
- /**
- * Return an array manifestation of the subject's list aspect.
- * At this point we can be sure the subject is not null.
- * @see #toArray()
- */
- protected Object[] toArray_() {
- return ArrayTools.array(this.listIterator(), this.size());
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected List<E> getAspectValue() {
- return this.buildValueList();
- }
-
- @Override
- protected Class<? extends EventListener> getListenerClass() {
- return ListChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return LIST_VALUES;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyListChangeListeners(LIST_VALUES);
- }
-
- @Override
- protected void fireAspectChanged(List<E> oldValue, List<E> newValue) {
- this.fireListChanged(LIST_VALUES, newValue);
- }
-
- protected void aspectChanged() {
- this.fireListChanged(LIST_VALUES, this.buildValueList());
- }
-
- protected List<E> buildValueList() {
- return CollectionTools.list(this.iterator());
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.buildValueList());
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectPropertyValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectPropertyValueModelAdapter.java
deleted file mode 100644
index a7629e2494..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/AspectPropertyValueModelAdapter.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.EventListener;
-
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This {@link AspectAdapter} provides basic property change support.
- * This converts an "aspect" (as defined by subclasses) into
- * a single {@link #VALUE} property.
- * <p>
- * The typical subclass will override the following methods:<ul>
- * <li>{@link #engageSubject_()}<p>
- * implement this method to add the appropriate listener to the subject
- * <li>{@link #disengageSubject_()}<p>
- * implement this method to remove the appropriate listener from the subject
- * <li>{@link #buildValue_()}<p>
- * at the very minimum, override this method to return the value of the
- * subject's aspect (or "virtual" aspect); it does not need to be
- * overridden if {@link #buildValue()} is overridden and its behavior changed
- * <li>{@link #setValue_(Object)}<p>
- * override this method if the client code needs to <em>set</em> the value of
- * the subject's aspect; oftentimes, though, the client code (e.g. UI)
- * will need only to <em>get</em> the value; it does not need to be
- * overridden if {@link #setValue(Object)} is overridden and its behavior changed
- * <li>{@link #buildValue()}<p>
- * override this method only if returning a <code>null</code> value when
- * the subject is <code>null</code> is unacceptable
- * <li>{@link #setValue(Object)}<p>
- * override this method only if something must be done when the subject
- * is <code>null</code> (e.g. throw an exception)
- * </ul>
- * To notify listeners, subclasses can call {@link #aspectChanged()}
- * whenever the aspect has changed.
- *
- * @param <S> the type of the model's subject
- * @param <V> the type of the subject's property aspect
- */
-public abstract class AspectPropertyValueModelAdapter<S, V>
- extends AspectAdapter<S, V>
- implements ModifiablePropertyValueModel<V>
-{
- /**
- * Cache the current value of the aspect so we
- * can pass an "old value" when we fire a property change event.
- * We need this because the value may be calculated and may
- * not be in the property change event fired by the subject,
- * especially when dealing with multiple aspects.
- */
- protected volatile V value;
-
-
- // ********** constructor **********
-
- /**
- * Construct a property value model adapter for an aspect of the
- * specified subject.
- * The subject model cannot be <code>null</code>.
- */
- protected AspectPropertyValueModelAdapter(PropertyValueModel<? extends S> subjectModel) {
- super(subjectModel);
- // our value is null when we are not listening to the subject
- this.value = null;
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- /**
- * Return the value of the subject's aspect.
- */
- public final V getValue() {
- return this.value;
- }
-
-
- // ********** WritablePropertyValueModel implementation **********
-
- /**
- * Set the value of the subject's aspect.
- */
- public void setValue(V value) {
- if (this.subject != null) {
- this.setValue_(value);
- }
- }
-
- /**
- * Set the value of the subject's aspect.
- * At this point we can be sure the {@link #subject} is
- * <em>not</em> <code>null</code>.
- * @see #setValue(Object)
- */
- protected void setValue_(@SuppressWarnings("unused") V value) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected V getAspectValue() {
- return this.value;
- }
-
- @Override
- protected Class<? extends EventListener> getListenerClass() {
- return PropertyChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return VALUE;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyPropertyChangeListeners(VALUE);
- }
-
- @Override
- protected void fireAspectChanged(V oldValue, V newValue) {
- this.firePropertyChanged(VALUE, oldValue, newValue);
- }
-
- @Override
- protected void engageSubject() {
- super.engageSubject();
- // sync our value *after* we start listening to the subject,
- // since its value might change when a listener is added
- this.value = this.buildValue();
- }
-
- @Override
- protected void disengageSubject() {
- super.disengageSubject();
- // clear out our value when we are not listening to the subject
- this.value = null;
- }
-
-
- // ********** behavior **********
-
- /**
- * Return the aspect's value.
- * At this point the subject may be <code>null</code>.
- */
- protected V buildValue() {
- return (this.subject == null) ? null : this.buildValue_();
- }
-
- /**
- * Return the value of the subject's aspect.
- * At this point we can be sure the {@link #subject} is
- * <em>not</em> <code>null</code>.
- * @see #buildValue()
- */
- protected V buildValue_() {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- /**
- * This method can be called by subclasses whenever the subject's aspect
- * has changed; listeners will be notified appropriately.
- */
- protected void aspectChanged() {
- V old = this.value;
- this.fireAspectChanged(old, this.value = this.buildValue());
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.value);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/BufferedWritablePropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/BufferedWritablePropertyValueModel.java
deleted file mode 100644
index 2f292b8c53..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/BufferedWritablePropertyValueModel.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * A <code>BufferedWritablePropertyValueModel</code> is used to hold a temporary
- * copy of the value
- * in another property value model (the "wrapped" value model). The application
- * can modify this temporary copy, ad nauseam; but the temporary copy is only
- * passed through to the "wrapped" value model when the trigger "accepts" the
- * buffered value. Alternatively, the application can "reset" the buffered value
- * to the original, "wrapped" value.
- * <p>
- * The trigger is another {@link PropertyValueModel} that holds a
- * {@link Boolean} and the application changes the trigger's value to
- * <code>true</code> on "accept", <code>false</code> on "reset".
- * <p>
- * Typically, in a dialog:<ul>
- * <li>pressing the "OK" button will trigger an "accept" and close the dialog
- * <li>pressing the "Cancel" button will simply close the dialog,
- * dropping the "buffered" values into the bit bucket
- * <li>pressing the "Apply" button will trigger an "accept" and leave the
- * dialog open
- * <li>pressing the "Restore" button will trigger a "reset" and leave the
- * dialog open
- * </ul>
- * A number of buffered property value models can wrap another set of
- * property aspect adapters that adapt the various aspects of a single
- * domain model. All the buffered property value models can be hooked to the
- * same trigger, and that trigger is controlled by the application, typically
- * via the "OK" button in a dialog.
- *
- * @param <V> the type of the model's value
- * @see PropertyAspectAdapter
- */
-public class BufferedWritablePropertyValueModel<V>
- extends PropertyValueModelWrapper<V>
- implements ModifiablePropertyValueModel<V>
-{
- /**
- * We cache the value here until it is accepted and passed
- * through to the wrapped value model.
- */
- protected volatile V bufferedValue;
-
- /**
- * This is set to true when we are "accepting" the buffered value
- * and passing it through to the wrapped value model. This allows
- * us to ignore the property change event fired by the wrapped
- * value model.
- * (We can't stop listening to the wrapped value model, because
- * if we are the only listener that could "deactivate" the wrapped
- * value model.)
- */
- protected volatile boolean accepting;
-
- /**
- * This is the trigger that indicates whether the buffered value
- * should be accepted or reset.
- */
- protected final PropertyValueModel<Boolean> triggerModel;
-
- /** This listens to the trigger model. */
- protected final PropertyChangeListener triggerListener;
-
- /**
- * This flag indicates whether our buffered value has been assigned
- * a value and is possibly out of sync with the wrapped value.
- */
- protected volatile boolean buffering;
-
-
- // ********** constructor/initialization **********
-
- /**
- * Construct a buffered property value model with the specified wrapped
- * property value model and trigger model.
- */
- // TODO wrap the value model in a CachingPVMWrapper and get rid of accepting flag
- public BufferedWritablePropertyValueModel(ModifiablePropertyValueModel<V> valueModel, PropertyValueModel<Boolean> triggerModel) {
- super(valueModel);
- if (triggerModel == null) {
- throw new NullPointerException();
- }
- this.triggerModel = triggerModel;
- this.bufferedValue = null;
- this.buffering = false;
- this.accepting = false;
- this.triggerListener = this.buildTriggerListener();
- }
-
- protected PropertyChangeListener buildTriggerListener() {
- return new TriggerListener();
- }
-
- protected class TriggerListener
- extends PropertyChangeAdapter
- {
- @Override
- public void propertyChanged(PropertyChangeEvent event) {
- BufferedWritablePropertyValueModel.this.triggerChanged(event);
- }
- }
-
-
- // ********** value **********
-
- /**
- * If we are currently "buffering" a value, return that;
- * otherwise, return the wrapped value.
- */
- public V getValue() {
- return this.buffering ? this.bufferedValue : this.valueModel.getValue();
- }
-
- /**
- * Assign the new value to our "buffered" value.
- * It will be pushed to the wrapped value model
- * when the trigger is "accepted".
- */
- public void setValue(V value) {
- if (this.buffering) {
- if (this.valuesAreEqual(value, this.valueModel.getValue())) {
- // the buffered value is being set back to the original value
- this.reset();
- } else {
- // the buffered value is being changed
- Object old = this.bufferedValue;
- this.bufferedValue = value;
- this.firePropertyChanged(VALUE, old, value);
- }
- } else {
- if (this.valuesAreEqual(value, this.valueModel.getValue())) {
- // the buffered value is being set to the same value as the original value - ignore
- } else {
- // the buffered value is being set for the first time
- Object old = this.valueModel.getValue();
- this.bufferedValue = value;
- this.buffering = true;
- this.firePropertyChanged(VALUE, old, value);
- }
- }
- }
-
-
- // ********** PropertyValueModelWrapper extensions **********
-
- /**
- * Extend to engage the trigger model also.
- */
- @Override
- protected void engageModel() {
- super.engageModel();
- this.triggerModel.addPropertyChangeListener(VALUE, this.triggerListener);
- }
-
- /**
- * Extend to disengage the trigger model also.
- */
- @Override
- protected void disengageModel() {
- this.triggerModel.removePropertyChangeListener(VALUE, this.triggerListener);
- super.disengageModel();
- }
-
-
- // ********** behavior **********
-
- /**
- * If we are currently "accepting" the value (i.e passing it on to the
- * "wrapped" model), ignore change notifications, since we caused
- * them and our own listeners are already aware of the change.
- */
- @Override
- protected void wrappedValueChanged(PropertyChangeEvent event) {
- if ( ! this.accepting) {
- this.wrappedValueChanged_(event);
- }
- }
-
- /**
- * If we have a "buffered" value, check whether the "wrapped" value has
- * changed to be the same as the "buffered" value. If it has, stop "buffering";
- * if not, do nothing.
- * If we do not yet have a "buffered" value, simply propagate the
- * change notification with the buffered model as the source.
- */
- protected void wrappedValueChanged_(PropertyChangeEvent event) {
- if (this.buffering) {
- if (this.valuesAreEqual(event.getNewValue(), this.bufferedValue)) {
- // the buffered value is being set back to the original value
- this.reset();
- } else {
- this.handleChangeConflict(event);
- }
- } else {
- this.firePropertyChanged(event.clone(this));
- }
- }
-
- /**
- * By default, if we have a "buffered" value and the "wrapped" value changes,
- * we simply ignore the new "wrapped" value and simply overlay it with the
- * "buffered" value if it is "accepted". ("Last One In Wins" concurrency model)
- * Subclasses can override this method to change that behavior with a
- * different concurrency model. For example, you could drop the "buffered" value
- * and replace it with the new "wrapped" value, or you could throw an
- * exception.
- */
- protected void handleChangeConflict(@SuppressWarnings("unused") PropertyChangeEvent event) {
- // the default is to do nothing
- }
-
- protected void triggerChanged(PropertyChangeEvent event) {
- this.triggerChanged(((Boolean) event.getNewValue()).booleanValue());
- }
-
- /**
- * The trigger changed:<ul>
- * <li>If it is now <code>true</code>, "accept" the buffered value and push
- * it to the wrapped value model.
- * <li>If it is now <code>false</code>, "reset" the buffered value to its
- * original value.
- * </ul>
- */
- protected void triggerChanged(boolean triggerValue) {
- // if nothing has been "buffered", we don't need to do anything:
- // nothing needs to be passed through; nothing needs to be reset;
- if (this.buffering) {
- if (triggerValue) {
- this.accept();
- } else {
- this.reset();
- }
- }
- }
-
- protected void accept() {
- // set the accepting flag so we ignore any events
- // fired by the wrapped value model
- this.accepting = true;
- try {
- this.getValueModel().setValue(this.bufferedValue);
- } finally {
- this.bufferedValue = null;
- this.buffering = false;
- // clear the flag once the "accept" is complete
- this.accepting = false;
- }
- }
-
- protected void reset() {
- // notify our listeners that our value has been reset
- Object old = this.bufferedValue;
- this.bufferedValue = null;
- this.buffering = false;
- this.firePropertyChanged(VALUE, old, this.valueModel.getValue());
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getValue());
- }
-
-
- // ********** misc **********
-
- /**
- * Return whether the buffered model is currently "buffering"
- * a value.
- */
- public boolean isBuffering() {
- return this.buffering;
- }
-
- /**
- * Our constructor accepts only a {@link ModifiablePropertyValueModel}{@code<T>}.
- */
- @SuppressWarnings("unchecked")
- protected ModifiablePropertyValueModel<V> getValueModel() {
- return (ModifiablePropertyValueModel<V>) this.valueModel;
- }
-
-
- // ********** trigger **********
-
- /**
- * <code>Trigger</code> is a special property value model that only maintains its
- * value (of <code>true</code> or <code>false</code>) during the change notification caused by
- * {@link #setValue(Object)}. In other words, a <code>Trigger</code>
- * only has a valid value when it is being set.
- */
- public static class Trigger
- extends SimplePropertyValueModel<Boolean>
- {
- /**
- * Construct a trigger with a null value.
- */
- public Trigger() {
- super();
- }
-
-
- // ********** ValueModel implementation **********
-
- /**
- * Extend so that this method can only be invoked during
- * change notification triggered by {@link #setValue(Object)}.
- */
- @Override
- public Boolean getValue() {
- if (this.value == null) {
- throw new IllegalStateException("The method Trigger.getValue() may only be called during change notification."); //$NON-NLS-1$
- }
- return this.value;
- }
-
- /**
- * Extend to reset the value to <code>null</code> once all the
- * listeners have been notified.
- */
- @Override
- public void setValue(Boolean value) {
- super.setValue(value);
- this.value = null;
- }
-
-
- // ********** convenience methods **********
-
- /**
- * Set the trigger's value:<ul>
- * <li><code>true</code> indicates "accept"
- * <li><code>false</code> indicates "reset"
- * </ul>
- */
- public void setValue(boolean value) {
- this.setValue(Boolean.valueOf(value));
- }
-
- /**
- * Return the trigger's value:<ul>
- * <li><code>true</code> indicates "accept"
- * <li><code>false</code> indicates "reset"
- * </ul>
- * This method can only be invoked during change notification.
- */
- public boolean booleanValue() {
- return this.getValue().booleanValue();
- }
-
- /**
- * Accept the trigger (i.e. set its value to <code>true</code>).
- */
- public void accept() {
- this.setValue(true);
- }
-
- /**
- * Return whether the trigger has been accepted
- * (i.e. its value was changed to <code>true</code>).
- * This method can only be invoked during change notification.
- */
- public boolean isAccepted() {
- return this.booleanValue();
- }
-
- /**
- * Reset the trigger (i.e. set its value to <code>false</code>).
- */
- public void reset() {
- this.setValue(false);
- }
-
- /**
- * Return whether the trigger has been reset
- * (i.e. its value was changed to <code>false</code>).
- * This method can only be invoked during change notification.
- */
- public boolean isReset() {
- return ! this.booleanValue();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CachingPropertyValueModelWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CachingPropertyValueModelWrapper.java
deleted file mode 100644
index fa23022d81..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CachingPropertyValueModelWrapper.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Wrap a writable property value model and cache its value so any changes
- * made via the wrapper model will not fire any events to its listeners.
- * Thus, a client can modify and listen to the wrapper model and not receive
- * a change event when the client modifies the wrapper model; but any changes
- * made by other clients (directly to the original model) will fire events
- * to the client.
- *
- * @param <V> the type of the model's value
- */
-public class CachingPropertyValueModelWrapper<V>
- extends PropertyValueModelWrapper<V>
- implements ModifiablePropertyValueModel<V>
-{
- /**
- * Cache the value so we ignore any property change events
- * we ourselves trigger.
- */
- protected volatile V value;
-
-
- /**
- * Construct a caching writable property value model with the specified
- * nested writable property value model.
- */
- public CachingPropertyValueModelWrapper(ModifiablePropertyValueModel<V> valueModel) {
- super(valueModel);
- }
-
- /**
- * Return the cached value, since it is up-to-date.
- */
- public V getValue() {
- return this.value;
- }
-
- /**
- * Cache the new value so we ignore the resulting property change event.
- */
- public void setValue(V value) {
- this.value = value;
- this.getValueModel().setValue(value);
- }
-
- @Override
- protected void wrappedValueChanged(V oldValue, V newValue) {
- V old = this.value;
- // the new event will be suppressed if it is the result of a new value
- // forwarded from this wrapper (i.e. 'old' and 'newValue' are equal)
- this.firePropertyChanged(VALUE, old, this.value = newValue);
- }
-
- /**
- * Our constructors accept only a
- * {@link ModifiablePropertyValueModel}{@code<V>},
- * so this cast should be safe.
- */
- @SuppressWarnings("unchecked")
- protected ModifiablePropertyValueModel<V> getValueModel() {
- return (ModifiablePropertyValueModel<V>) this.valueModel;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.value);
- }
-
-
- // ********** listeners **********
-
- /**
- * We have listeners, cache the nested value.
- */
- @Override
- protected void engageModel() {
- super.engageModel();
- this.value = this.valueModel.getValue();
- }
-
- /**
- * We have no more listeners, clear the cached value.
- */
- @Override
- protected void disengageModel() {
- this.value = null;
- super.disengageModel();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ChangePropertyValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ChangePropertyValueModelAdapter.java
deleted file mode 100644
index 3dcf14af6a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ChangePropertyValueModelAdapter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.AbstractChangeListener;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * a model, "lazily" listen to it, and convert
- * its change notifications into property value model change
- * notifications.
- * <p>
- * Subclasses must implement:<ul>
- * <li>{@link #buildValue()}<p>
- * to return the current property value, as derived from the
- * current model
- * </ul>
- * Subclasses might want to override the following methods
- * to improve performance (by not recalculating the value, if possible):<ul>
- * <li>{@link #modelChanged(ChangeEvent event)}
- * <li>{@link #buildChangeListener()}
- * </ul>
- */
-public abstract class ChangePropertyValueModelAdapter<T>
- extends AbstractPropertyValueModelAdapter<T>
-{
- /** The wrapped model. */
- protected final Model model;
-
- /** A listener that allows us to sync with changes to the wrapped collection model. */
- protected final ChangeListener modelListener;
-
-
- // ********** constructor/initialization **********
-
- /**
- * Construct a property value model with the specified wrapped model.
- */
- protected ChangePropertyValueModelAdapter(Model model) {
- super();
- if (model == null) {
- throw new NullPointerException();
- }
- this.model = model;
- this.modelListener = this.buildChangeListener();
- }
-
- protected ChangeListener buildChangeListener() {
- return new ModelListener();
- }
-
- protected class ModelListener
- extends AbstractChangeListener
- {
- @Override
- protected void modelChanged(ChangeEvent event) {
- ChangePropertyValueModelAdapter.this.modelChanged(event);
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the model.
- */
- @Override
- protected void engageModel_() {
- this.model.addChangeListener(this.modelListener);
- }
-
- /**
- * Stop listening to the model.
- */
- @Override
- protected void disengageModel_() {
- this.model.removeChangeListener(this.modelListener);
- }
-
-
- // ********** change support **********
-
- /**
- * The wrapped model has changed;
- * propagate the change notification appropriately.
- */
- protected void modelChanged(@SuppressWarnings("unused") ChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionAspectAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionAspectAdapter.java
deleted file mode 100644
index c84c33eb0e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionAspectAdapter.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Collection;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This extension of {@link AspectCollectionValueModelAdapter} provides
- * basic collection change support.
- * This converts a set of one or more collections into
- * a single {@link #VALUES} collection.
- * <p>
- * The typical subclass will override the following methods (see the descriptions
- * in {@link AspectCollectionValueModelAdapter}):<ul>
- * <li>{@link #getIterable()} - preferred
- * <li>{@link #size_()} - semi-preferred
- * <li>{@link #iterator_()}
- * <li>{@link #iterator()}
- * <li>{@link #size()}
- * </ul>
- *
- * @param <S> the type of the adapter's subject
- * @param <E> the type of the adapter's collection's elements
- */
-public abstract class CollectionAspectAdapter<S extends Model, E>
- extends AspectCollectionValueModelAdapter<S, E>
-{
- /**
- * The name of the subject's collections that we use for the value.
- */
- protected final String[] aspectNames;
- protected static final String[] EMPTY_ASPECT_NAMES = new String[0];
-
- /** A listener that listens to the subject's collection aspects. */
- protected final CollectionChangeListener aspectChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a collection aspect adapter for the specified subject
- * and collection aspect.
- */
- protected CollectionAspectAdapter(String aspectName, S subject) {
- this(new String[] {aspectName}, subject);
- }
-
- /**
- * Construct a collection aspect adapter for the specified subject
- * and collection aspects.
- */
- protected CollectionAspectAdapter(String[] aspectNames, S subject) {
- this(new StaticPropertyValueModel<S>(subject), aspectNames);
- }
-
- /**
- * Construct a collection aspect adapter for the specified subject model
- * and collection apects.
- */
- protected CollectionAspectAdapter(PropertyValueModel<? extends S> subjectModel, String... aspectNames) {
- super(subjectModel);
- this.aspectNames = aspectNames;
- this.aspectChangeListener = this.buildAspectChangeListener();
- }
-
- /**
- * Construct a collection aspect adapter for the specified subject holder
- * and collection aspects.
- */
- protected CollectionAspectAdapter(PropertyValueModel<? extends S> subjectModel, Collection<String> aspectNames) {
- this(subjectModel, aspectNames.toArray(new String[aspectNames.size()]));
- }
-
- /**
- * Construct a collection aspect adapter for an "unchanging" collection in
- * the specified subject. This is useful for a collection aspect that does not
- * change for a particular subject; but the subject will change, resulting in
- * a new collection.
- */
- protected CollectionAspectAdapter(PropertyValueModel<? extends S> subjectModel) {
- this(subjectModel, EMPTY_ASPECT_NAMES);
- }
-
-
- // ********** initialization **********
-
- protected CollectionChangeListener buildAspectChangeListener() {
- return new AspectChangeListener();
- }
-
- /**
- * Transform the subject's collection change events into {@link #VALUES}
- * collection change events
- */
- protected class AspectChangeListener
- extends CollectionChangeAdapter
- {
- @Override
- public void itemsAdded(CollectionAddEvent event) {
- CollectionAspectAdapter.this.aspectItemsAdded(event);
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent event) {
- CollectionAspectAdapter.this.aspectItemsRemoved(event);
- }
- @Override
- public void collectionCleared(CollectionClearEvent event) {
- CollectionAspectAdapter.this.aspectCollectionCleared(event);
- }
- @Override
- public void collectionChanged(CollectionChangeEvent event) {
- CollectionAspectAdapter.this.aspectCollectionChanged(event);
- }
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected void engageSubject_() {
- for (String collectionName : this.aspectNames) {
- this.subject.addCollectionChangeListener(collectionName, this.aspectChangeListener);
- }
- }
-
- @Override
- protected void disengageSubject_() {
- for (String collectionName : this.aspectNames) {
- this.subject.removeCollectionChangeListener(collectionName, this.aspectChangeListener);
- }
- }
-
-
- // ********** events **********
-
- protected void aspectItemsAdded(CollectionAddEvent event) {
- this.fireItemsAdded(event.clone(this, VALUES));
- }
-
- protected void aspectItemsRemoved(CollectionRemoveEvent event) {
- this.fireItemsRemoved(event.clone(this, VALUES));
- }
-
- protected void aspectCollectionCleared(CollectionClearEvent event) {
- this.fireCollectionCleared(event.clone(this, VALUES));
- }
-
- protected void aspectCollectionChanged(CollectionChangeEvent event) {
- this.fireCollectionChanged(event.clone(this, VALUES));
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionListValueModelAdapter.java
deleted file mode 100644
index 8ae33d53e9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionListValueModelAdapter.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * An adapter that allows us to make a {@link CollectionValueModel} behave like
- * a read-only {@link ListValueModel}, sorta.
- * <p>
- * To maintain a reasonably consistent appearance to client code, we
- * keep an internal list somewhat in sync with the wrapped collection.
- * <p>
- * <strong>NB:</strong> Since we only listen to the wrapped collection when we have
- * listeners ourselves and we can only stay in sync with the wrapped
- * collection while we are listening to it, results to various methods
- * (e.g. {@link #size()}, {@link #get(int)}) will be unpredictable whenever
- * we do not have any listeners. This should not be too painful since,
- * most likely, clients will also be listeners.
- */
-public class CollectionListValueModelAdapter<E>
- extends AbstractListValueModel
- implements ListValueModel<E>
-{
- /** The wrapped collection value model. */
- protected final CollectionValueModel<? extends E> collectionHolder;
-
- /** A listener that forwards any events fired by the collection holder. */
- protected final CollectionChangeListener collectionChangeListener;
-
- /**
- * Our internal list, which holds the same elements as
- * the wrapped collection, but keeps them in order.
- */
- // we declare this an ArrayList so we can use #clone() and #ensureCapacity(int)
- protected final ArrayList<E> list;
-
-
- // ********** constructors **********
-
- /**
- * Wrap the specified collection value model.
- */
- public CollectionListValueModelAdapter(CollectionValueModel<? extends E> collectionHolder) {
- super();
- if (collectionHolder == null) {
- throw new NullPointerException();
- }
- this.collectionHolder = collectionHolder;
- this.collectionChangeListener = this.buildCollectionChangeListener();
- this.list = new ArrayList<E>(collectionHolder.size());
- // postpone building the list and listening to the underlying collection
- // until we have listeners ourselves...
- }
-
-
- // ********** initialization **********
-
- /**
- * The wrapped collection has changed, forward an equivalent
- * list change event to our listeners.
- */
- protected CollectionChangeListener buildCollectionChangeListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent event) {
- CollectionListValueModelAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(CollectionRemoveEvent event) {
- CollectionListValueModelAdapter.this.itemsRemoved(event);
- }
- public void collectionCleared(CollectionClearEvent event) {
- CollectionListValueModelAdapter.this.collectionCleared(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- CollectionListValueModelAdapter.this.collectionChanged(event);
- }
- @Override
- public String toString() {
- return "collection change listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E> listIterator() {
- return new ReadOnlyListIterator<E>(this.list);
- }
-
- public E get(int index) {
- return this.list.get(index);
- }
-
- public int size() {
- return this.list.size();
- }
-
- public Object[] toArray() {
- return this.list.toArray();
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void engageModel() {
- this.collectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
- // sync our list *after* we start listening to the collection model,
- // since its value might change when a listener is added
- this.buildList();
- }
-
- @Override
- protected void disengageModel() {
- this.collectionHolder.removeCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
- // clear out the list when we are not listening to the collection holder
- this.list.clear();
- }
-
- protected void buildList() {
- // if the new collection is empty, do nothing
- int size = this.collectionHolder.size();
- if (size != 0) {
- this.buildList(size);
- }
- }
-
- protected void buildList(int size) {
- this.list.ensureCapacity(size);
- for (E each : this.collectionHolder) {
- this.list.add(each);
- }
- }
-
- protected void itemsAdded(CollectionAddEvent event) {
- this.addItemsToList(this.indexToAddItems(), this.getItems(event), this.list, LIST_VALUES);
- }
-
- protected int indexToAddItems() {
- return this.list.size();
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(CollectionAddEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- protected void itemsRemoved(CollectionRemoveEvent event) {
- this.removeItemsFromList(this.getItems(event), this.list, LIST_VALUES);
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(CollectionRemoveEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- protected void collectionCleared(@SuppressWarnings("unused") CollectionClearEvent event) {
- this.clearList(this.list, LIST_VALUES);
- }
-
- /**
- * synchronize our internal list with the wrapped collection
- * and fire the appropriate events
- */
- protected void collectionChanged(@SuppressWarnings("unused") CollectionChangeEvent event) {
- int size = this.collectionHolder.size();
- if (size == 0) {
- if (this.list.isEmpty()) {
- // no change
- } else {
- this.clearList(this.list, LIST_VALUES);
- }
- } else {
- if (this.list.isEmpty()) {
- this.buildList(size);
- this.fireItemsAdded(LIST_VALUES, 0, this.list);
- } else {
- this.synchronizeList(this.buildSyncList(), this.list, LIST_VALUES);
- }
- }
- }
-
- protected Iterable<? extends E> buildSyncList() {
- return this.collectionHolder;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.list);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionPropertyValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionPropertyValueModelAdapter.java
deleted file mode 100644
index 1f636e5fd1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionPropertyValueModelAdapter.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * a collection value model, "lazily" listen to it, and convert
- * its change notifications into property value model change
- * notifications.
- * <p>
- * Subclasses must override:<ul>
- * <li>{@link #buildValue()}<p>
- * to return the current property value, as derived from the
- * current collection value
- * </ul>
- * Subclasses might want to override the following methods
- * to improve performance (by not recalculating the value, if possible):<ul>
- * <li>{@link #itemsAdded(CollectionAddEvent event)}
- * <li>{@link #itemsAdded(Iterable)}
- * <li>{@link #itemsRemoved(CollectionRemoveEvent event)}
- * <li>{@link #itemsRemoved(Iterable)}
- * <li>{@link #collectionCleared(CollectionClearEvent event)}
- * <li>{@link #collectionChanged(CollectionChangeEvent event)}
- * </ul>
- *
- * @param <V> the type of the model's value
- * @param <E> the type of the wrapped collection value model's elements
- */
-public abstract class CollectionPropertyValueModelAdapter<V, E>
- extends AbstractPropertyValueModelAdapter<V>
-{
- /** The wrapped collection value model. */
- protected final CollectionValueModel<? extends E> collectionModel;
-
- /** A listener that allows us to sync with changes to the wrapped collection model. */
- protected final CollectionChangeListener collectionListener;
-
-
- // ********** constructor/initialization **********
-
- /**
- * Construct a property value model with the specified wrapped
- * collection value model.
- */
- protected CollectionPropertyValueModelAdapter(CollectionValueModel<? extends E> collectionModel) {
- super();
- if (collectionModel == null) {
- throw new NullPointerException();
- }
- this.collectionModel = collectionModel;
- this.collectionListener = this.buildCollectionListener();
- }
-
- protected CollectionChangeListener buildCollectionListener() {
- return new CollectionListener();
- }
-
- /**
- * Straightforward callbacks to the adapter.
- */
- protected class CollectionListener
- extends CollectionChangeAdapter
- {
- @Override
- public void itemsAdded(CollectionAddEvent event) {
- CollectionPropertyValueModelAdapter.this.itemsAdded(event);
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent event) {
- CollectionPropertyValueModelAdapter.this.itemsRemoved(event);
- }
- @Override
- public void collectionCleared(CollectionClearEvent event) {
- CollectionPropertyValueModelAdapter.this.collectionCleared(event);
- }
- @Override
- public void collectionChanged(CollectionChangeEvent event) {
- CollectionPropertyValueModelAdapter.this.collectionChanged(event);
- }
- }
-
-
- // ********** listener **********
-
- /**
- * Start listening to the collection holder.
- */
- @Override
- protected void engageModel_() {
- this.collectionModel.addCollectionChangeListener(CollectionValueModel.VALUES, this.collectionListener);
- }
-
- /**
- * Stop listening to the collection holder.
- */
- @Override
- protected void disengageModel_() {
- this.collectionModel.removeCollectionChangeListener(CollectionValueModel.VALUES, this.collectionListener);
- }
-
-
- // ********** collection change support **********
-
- /**
- * Items were added to the wrapped collection holder;
- * propagate the change notification appropriately.
- */
- protected void itemsAdded(CollectionAddEvent event) {
- @SuppressWarnings("unchecked")
- Iterable<E> items = (Iterable<E>) event.getItems();
- this.itemsAdded(items);
- }
-
- /**
- * The specified items were added to the wrapped collection holder;
- * propagate the change notification appropriately.
- */
- protected void itemsAdded(@SuppressWarnings("unused") Iterable<E> items) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * Items were removed from the wrapped collection holder;
- * propagate the change notification appropriately.
- */
- protected void itemsRemoved(CollectionRemoveEvent event) {
- @SuppressWarnings("unchecked")
- Iterable<E> items = (Iterable<E>) event.getItems();
- this.itemsRemoved(items);
- }
-
- /**
- * The specified items were removed from the wrapped collection holder;
- * propagate the change notification appropriately.
- */
- protected void itemsRemoved(@SuppressWarnings("unused") Iterable<E> items) {
- // by default, simply recalculate the value and fire an event if necessary
- this.propertyChanged();
- }
-
- /**
- * The wrapped collection holder was cleared;
- * propagate the change notification appropriately.
- */
- protected void collectionCleared(@SuppressWarnings("unused") CollectionClearEvent event) {
- // by default, simply recalculate the value and fire an event if necessary
- this.propertyChanged();
- }
-
- /**
- * The value of the wrapped collection holder has changed;
- * propagate the change notification appropriately.
- */
- protected void collectionChanged(@SuppressWarnings("unused") CollectionChangeEvent event) {
- // by default, simply recalculate the value and fire an event if necessary
- this.propertyChanged();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionValueModelWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionValueModelWrapper.java
deleted file mode 100644
index a3417a13b1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CollectionValueModelWrapper.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * another collection value model, "lazily" listen to it, and propagate
- * its change notifications. Subclasses must implement the appropriate
- * {@link CollectionValueModel}.
- */
-public abstract class CollectionValueModelWrapper<E>
- extends AbstractCollectionValueModel
-{
- /** The wrapped collection value model. */
- protected final CollectionValueModel<? extends E> collectionHolder;
-
- /** A listener that allows us to sync with changes to the wrapped collection model. */
- protected final CollectionChangeListener collectionChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a collection value model with the specified wrapped
- * collection value model.
- */
- protected CollectionValueModelWrapper(CollectionValueModel<? extends E> collectionHolder) {
- super();
- this.collectionHolder = collectionHolder;
- this.collectionChangeListener = this.buildCollectionChangeListener();
- }
-
-
- // ********** initialization **********
-
- protected CollectionChangeListener buildCollectionChangeListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent event) {
- CollectionValueModelWrapper.this.itemsAdded(event);
- }
- public void itemsRemoved(CollectionRemoveEvent event) {
- CollectionValueModelWrapper.this.itemsRemoved(event);
- }
- public void collectionCleared(CollectionClearEvent event) {
- CollectionValueModelWrapper.this.collectionCleared(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- CollectionValueModelWrapper.this.collectionChanged(event);
- }
- @Override
- public String toString() {
- return "collection change listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** AbstractCollectionValueModel implementation **********
-
- /**
- * Start listening to the collection holder.
- */
- @Override
- protected void engageModel() {
- this.collectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
- }
-
- /**
- * Stop listening to the collection holder.
- */
- @Override
- protected void disengageModel() {
- this.collectionHolder.removeCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
- }
-
-
- // ********** helper methods **********
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(CollectionAddEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(CollectionRemoveEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
-
- // ********** collection change support **********
-
- /**
- * Items were added to the wrapped collection holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsAdded(CollectionAddEvent event);
-
- /**
- * Items were removed from the wrapped collection holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsRemoved(CollectionRemoveEvent event);
-
- /**
- * The wrapped collection holder was cleared;
- * propagate the change notification appropriately.
- */
- protected abstract void collectionCleared(CollectionClearEvent event);
-
- /**
- * The value of the wrapped collection holder has changed;
- * propagate the change notification appropriately.
- */
- protected abstract void collectionChanged(CollectionChangeEvent event);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeBooleanPropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeBooleanPropertyValueModel.java
deleted file mode 100644
index a08ef48875..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeBooleanPropertyValueModel.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Collection;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * A <code>CompositeBooleanPropertyValueModel</code> adapts a
- * {@link CollectionValueModel} holding boolean {@link PropertyValueModel}s
- * to a single boolean {@link PropertyValueModel}. The composite value is
- * determined by the {@link CompositeBooleanPropertyValueModel.Adapter} provided
- * at construction. Typically the composite will be either an AND or an OR of
- * all the boolean values.
- * <p>
- * If there are <em>no</em> boolean {@link PropertyValueModel}s, the composite
- * will return its default value; which, by default, is <code>null</code>.
- * <p>
- * <strong>NB:</strong> None of the wrapped boolean models can return a
- * <code>null</code> value or this class will throw an exception. The assumption
- * is that all the wrapped boolean models are configured with "default" values
- * that determine the model's value (TRUE or FALSE) when <code>null</code>.
- */
-public class CompositeBooleanPropertyValueModel
- extends CompositePropertyValueModel<Boolean, Boolean>
-{
- /**
- * Calculation of the model's value is delegated to this adapter.
- */
- protected final Adapter adapter;
-
- /**
- * The default setting for the composite boolean property value model;
- * for when the underlying collection model is empty.
- * The default [default value] is <code>null</code>.
- */
- private final Boolean defaultValue;
-
-
- // ********** AND factory methods **********
-
- /**
- * Construct a boolean property value model that is a composite AND of the
- * specified boolean property value models; i.e. the model's value is true
- * if all the contained models are true, otherwise its value is false.
- * The model's default value, when it contains no nested models, is
- * <code>null</code>.
- */
- public static CompositeBooleanPropertyValueModel and(PropertyValueModel<Boolean>... array) {
- return new CompositeBooleanPropertyValueModel(AND_ADAPTER, array);
- }
-
- /**
- * Construct a boolean property value model that is a composite AND of the
- * specified boolean property value models; i.e. the model's value is true
- * if all the contained models are true, otherwise its value is false.
- * When the model contains no nested models, its value will be the
- * specified default.
- */
- public static CompositeBooleanPropertyValueModel and(Boolean defaultValue, PropertyValueModel<Boolean>... array) {
- return new CompositeBooleanPropertyValueModel(AND_ADAPTER, defaultValue, array);
- }
-
- /**
- * Construct a boolean property value model that is a composite AND of the
- * specified boolean property value models; i.e. the model's value is true
- * if all the contained models are true, otherwise its value is false.
- * The model's default value, when it contains no nested models, is
- * <code>null</code>.
- */
- public static <E extends PropertyValueModel<Boolean>> CompositeBooleanPropertyValueModel and(Collection<E> collection) {
- return new CompositeBooleanPropertyValueModel(AND_ADAPTER, collection);
- }
-
- /**
- * Construct a boolean property value model that is a composite AND of the
- * specified boolean property value models; i.e. the model's value is true
- * if all the contained models are true, otherwise its value is false.
- * When the model contains no nested models, its value will be the
- * specified default.
- */
- public static <E extends PropertyValueModel<Boolean>> CompositeBooleanPropertyValueModel and(Boolean defaultValue, Collection<E> collection) {
- return new CompositeBooleanPropertyValueModel(AND_ADAPTER, defaultValue, collection);
- }
-
- /**
- * Construct a boolean property value model that is a composite AND of the
- * specified boolean property value models; i.e. the model's value is true
- * if all the contained models are true, otherwise its value is false.
- * The model's default value, when it contains no nested models, is
- * <code>null</code>.
- */
- public static CompositeBooleanPropertyValueModel and(CollectionValueModel<? extends PropertyValueModel<Boolean>> collectionModel) {
- return new CompositeBooleanPropertyValueModel(AND_ADAPTER, collectionModel);
- }
-
- /**
- * Construct a boolean property value model that is a composite AND of the
- * specified boolean property value models; i.e. the model's value is true
- * if all the contained models are true, otherwise its value is false.
- * When the model contains no nested models, its value will be the
- * specified default.
- */
- public static CompositeBooleanPropertyValueModel and(Boolean defaultValue, CollectionValueModel<? extends PropertyValueModel<Boolean>> collectionModel) {
- return new CompositeBooleanPropertyValueModel(AND_ADAPTER, defaultValue, collectionModel);
- }
-
-
- // ********** OR factory methods **********
-
- /**
- * Construct a boolean property value model that is a composite OR of the
- * specified boolean property value models; i.e. the model's value is false
- * if all the contained models are false, otherwise its value is true.
- * The model's default value, when it contains no nested models, is
- * <code>null</code>.
- */
- public static CompositeBooleanPropertyValueModel or(PropertyValueModel<Boolean>... array) {
- return new CompositeBooleanPropertyValueModel(OR_ADAPTER, array);
- }
-
- /**
- * Construct a boolean property value model that is a composite OR of the
- * specified boolean property value models; i.e. the model's value is false
- * if all the contained models are false, otherwise its value is true.
- * When the model contains no nested models, its value will be the
- * specified default.
- */
- public static CompositeBooleanPropertyValueModel or(Boolean defaultValue, PropertyValueModel<Boolean>... array) {
- return new CompositeBooleanPropertyValueModel(OR_ADAPTER, defaultValue, array);
- }
-
- /**
- * Construct a boolean property value model that is a composite OR of the
- * specified boolean property value models; i.e. the model's value is false
- * if all the contained models are false, otherwise its value is true.
- * The model's default value, when it contains no nested models, is
- * <code>null</code>.
- */
- public static <E extends PropertyValueModel<Boolean>> CompositeBooleanPropertyValueModel or(Collection<E> collection) {
- return new CompositeBooleanPropertyValueModel(OR_ADAPTER, collection);
- }
-
- /**
- * Construct a boolean property value model that is a composite OR of the
- * specified boolean property value models; i.e. the model's value is false
- * if all the contained models are false, otherwise its value is true.
- * When the model contains no nested models, its value will be the
- * specified default.
- */
- public static <E extends PropertyValueModel<Boolean>> CompositeBooleanPropertyValueModel or(Boolean defaultValue, Collection<E> collection) {
- return new CompositeBooleanPropertyValueModel(OR_ADAPTER, defaultValue, collection);
- }
-
- /**
- * Construct a boolean property value model that is a composite OR of the
- * specified boolean property value models; i.e. the model's value is false
- * if all the contained models are false, otherwise its value is true.
- * The model's default value, when it contains no nested models, is
- * <code>null</code>.
- */
- public static CompositeBooleanPropertyValueModel or(CollectionValueModel<? extends PropertyValueModel<Boolean>> collectionModel) {
- return new CompositeBooleanPropertyValueModel(OR_ADAPTER, collectionModel);
- }
-
- /**
- * Construct a boolean property value model that is a composite OR of the
- * specified boolean property value models; i.e. the model's value is false
- * if all the contained models are false, otherwise its value is true.
- * When the model contains no nested models, its value will be the
- * specified default.
- */
- public static CompositeBooleanPropertyValueModel or(Boolean defaultValue, CollectionValueModel<? extends PropertyValueModel<Boolean>> collectionModel) {
- return new CompositeBooleanPropertyValueModel(OR_ADAPTER, defaultValue, collectionModel);
- }
-
-
- // ********** constructors **********
-
- /**
- * Construct a boolean property value model that is a composite of the specified
- * boolean property value models, as defined by the specified adapter.
- * The model's default value, when it contains no nested models, is
- * <code>null</code>.
- */
- public CompositeBooleanPropertyValueModel(Adapter adapter, PropertyValueModel<Boolean>... array) {
- this(adapter, null, array);
- }
-
- /**
- * Construct a boolean property value model that is a composite of the specified
- * boolean property value models, as defined by the specified adapter.
- * When the model contains no nested models, its value will be the
- * specified default.
- */
- public CompositeBooleanPropertyValueModel(Adapter adapter, Boolean defaultValue, PropertyValueModel<Boolean>... array) {
- super(array);
- if (adapter == null) {
- throw new NullPointerException();
- }
- this.adapter = adapter;
- this.defaultValue = defaultValue;
- }
-
- /**
- * Construct a boolean property value model that is a composite of the specified
- * boolean property value models, as defined by the specified adapter.
- * The model's default value, when it contains no nested models, is
- * <code>null</code>.
- */
- public <E extends PropertyValueModel<Boolean>> CompositeBooleanPropertyValueModel(Adapter adapter, Collection<E> collection) {
- this(adapter, null, collection);
- }
-
- /**
- * Construct a boolean property value model that is a composite of the specified
- * boolean property value models, as defined by the specified adapter.
- * When the model contains no nested models, its value will be the
- * specified default.
- */
- public <E extends PropertyValueModel<Boolean>> CompositeBooleanPropertyValueModel(Adapter adapter, Boolean defaultValue, Collection<E> collection) {
- super(collection);
- if (adapter == null) {
- throw new NullPointerException();
- }
- this.adapter = adapter;
- this.defaultValue = defaultValue;
- }
-
- /**
- * Construct a boolean property value model that is a composite of the specified
- * boolean property value models, as defined by the specified adapter.
- * The model's default value, when it contains no nested models, is
- * <code>null</code>.
- */
- public CompositeBooleanPropertyValueModel(Adapter adapter, CollectionValueModel<? extends PropertyValueModel<Boolean>> collectionModel) {
- this(adapter, null, collectionModel);
- }
-
- /**
- * Construct a boolean property value model that is a composite of the specified
- * boolean property value models, as defined by the specified adapter.
- * When the model contains no nested models, its value will be the
- * specified default.
- */
- public CompositeBooleanPropertyValueModel(Adapter adapter, Boolean defaultValue, CollectionValueModel<? extends PropertyValueModel<Boolean>> collectionModel) {
- super(collectionModel);
- if (adapter == null) {
- throw new NullPointerException();
- }
- this.adapter = adapter;
- this.defaultValue = defaultValue;
- }
-
-
- // ********** implementation **********
-
- /**
- * Return the {@link #defaultValue} if the collection is empty;
- * otherwise delegate to the {@link #adapter}.
- */
- @Override
- protected Boolean buildValue() {
- return (this.collectionModel.size() == 0) ? this.defaultValue : this.buildValue_();
- }
-
- protected Boolean buildValue_() {
- return this.adapter.buildValue(this.getBooleans());
- }
-
- protected Iterable<Boolean> getBooleans() {
- return new TransformationIterable<PropertyValueModel<? extends Boolean>, Boolean>(this.collectionModel, BOOLEAN_TRANSFORMER);
- }
-
- protected static final Transformer<PropertyValueModel<? extends Boolean>, Boolean> BOOLEAN_TRANSFORMER = new BooleanTransformer();
-
- protected static class BooleanTransformer
- implements Transformer<PropertyValueModel<? extends Boolean>, Boolean>
- {
- public Boolean transform(PropertyValueModel<? extends Boolean> booleanModel) {
- return booleanModel.getValue();
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- }
-
-
- // ********** adapter **********
-
- /**
- * This adapter allows the {@link CompositeBooleanPropertyValueModel} to be
- * pluggable.
- */
- public interface Adapter {
- /**
- * Return the composite boolean value of the specified collection
- * of booleans.
- */
- Boolean buildValue(Iterable<Boolean> booleans);
- }
-
- /**
- * Return <code>true</code> if all the booleans are <code>true</code>;
- * otherwise return <code>false</code>.
- */
- public static final Adapter AND_ADAPTER = new Adapter() {
- public Boolean buildValue(Iterable<Boolean> booleans) {
- for (Boolean b : booleans) {
- if ( ! b.booleanValue()) {
- return Boolean.FALSE;
- }
- }
- return Boolean.TRUE;
- }
- @Override
- public String toString() {
- return "AND_ADAPTER"; //$NON-NLS-1$
- }
- };
-
- /**
- * Return <code>false</code> if all the booleans are <code>false</code>;
- * otherwise return <code>true</code>.
- */
- public static final Adapter OR_ADAPTER = new Adapter() {
- public Boolean buildValue(Iterable<Boolean> booleans) {
- for (Boolean b : booleans) {
- if (b.booleanValue()) {
- return Boolean.TRUE;
- }
- }
- return Boolean.FALSE;
- }
- @Override
- public String toString() {
- return "OR_ADAPTER"; //$NON-NLS-1$
- }
- };
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeCollectionValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeCollectionValueModel.java
deleted file mode 100644
index 8e979626be..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeCollectionValueModel.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.NullList;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * A <code>CompositeCollectionValueModel</code> wraps another
- * {@link CollectionValueModel} and uses a {@link Transformer}
- * to convert each item in the wrapped collection to yet another
- * {@link CollectionValueModel}. This composite collection contains
- * the combined items from all these component collections.
- * <p>
- * <strong>NB:</strong> The wrapped collection must be an "identity set" that does not
- * contain the same item twice or this class will throw an exception.
- * <p>
- * Terminology:<ul>
- * <li><em>sources</em> - the items in the wrapped collection value model; these
- * are converted into component CVMs by the transformer
- * <li><em>component CVMs</em> - the component collection value models that are combined
- * by this composite collection value model
- * <li><em>items</em> - the items held by the component CVMs
- * </ul>
- */
-public class CompositeCollectionValueModel<E1, E2>
- extends CollectionValueModelWrapper<E1>
- implements CollectionValueModel<E2>
-{
- /**
- * This is the (optional) user-supplied object that transforms
- * the items in the wrapped collection to collection value models.
- */
- private final Transformer<E1, CollectionValueModel<E2>> transformer;
-
- /**
- * Cache of the component collection value models that
- * were generated by the transformer; keyed by the item
- * in the wrapped collection that was passed to the transformer.
- */
- private final IdentityHashMap<E1, CollectionValueModel<E2>> componentCVMs =
- new IdentityHashMap<E1, CollectionValueModel<E2>>();
-
- /**
- * Cache of the collections corresponding to the component
- * collection value models above; keyed by the component
- * collection value models.
- * Use {@link ArrayList}s so we can use {@link ArrayList}-specific methods
- * (e.g. {@link ArrayList#clone()} and {@link ArrayList#ensureCapacity(int)}).
- */
- private final IdentityHashMap<CollectionValueModel<E2>, ArrayList<E2>> collections =
- new IdentityHashMap<CollectionValueModel<E2>, ArrayList<E2>>();
-
- /** Listener that listens to all the component collection value models. */
- private final CollectionChangeListener componentCVMListener;
-
- /** Cache the size of the composite collection. */
- private int size;
-
-
- // ********** constructors **********
-
- /**
- * Construct a collection value model with the specified wrapped
- * collection value model. Use this constructor if<ul>
- * <li> the wrapped collection value model already contains other
- * collection value models, or
- * <li> you want to override {@link #transform(Object) transform(E1)}
- * instead of building a {@link Transformer}
- * </ul>
- */
- public CompositeCollectionValueModel(CollectionValueModel<? extends E1> collectionHolder) {
- this(collectionHolder, Transformer.Null.<E1, CollectionValueModel<E2>>instance());
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * collection value model and transformer.
- */
- public CompositeCollectionValueModel(CollectionValueModel<? extends E1> collectionHolder, Transformer<E1, CollectionValueModel<E2>> transformer) {
- super(collectionHolder);
- this.transformer = transformer;
- this.componentCVMListener = this.buildComponentListener();
- this.size = 0;
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * list value model. Use this constructor if<ul>
- * <li> the wrapped collection value model already contains other
- * collection value models, or
- * <li> you want to override {@link #transform(Object) transform(E1)}
- * instead of building a {@link Transformer}
- * </ul>
- */
- public CompositeCollectionValueModel(ListValueModel<? extends E1> listHolder) {
- this(new ListCollectionValueModelAdapter<E1>(listHolder));
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * list value model and transformer.
- */
- public CompositeCollectionValueModel(ListValueModel<? extends E1> listHolder, Transformer<E1, CollectionValueModel<E2>> transformer) {
- this(new ListCollectionValueModelAdapter<E1>(listHolder), transformer);
- }
-
- /**
- * Construct a collection value model with the specified, unchanging, wrapped
- * collection. Use this constructor if<ul>
- * <li> the wrapped collection value model already contains other
- * collection value models, or
- * <li> you want to override {@link #transform(Object) transform(E1)}
- * instead of building a {@link Transformer}
- * </ul>
- */
- public CompositeCollectionValueModel(Collection<? extends E1> collection) {
- this(new StaticCollectionValueModel<E1>(collection));
- }
-
- /**
- * Construct a collection value model with the specified, unchanging, wrapped
- * collection and transformer.
- */
- public CompositeCollectionValueModel(Collection<? extends E1> collection, Transformer<E1, CollectionValueModel<E2>> transformer) {
- this(new StaticCollectionValueModel<E1>(collection), transformer);
- }
-
- /**
- * Construct a collection value model with the specified, unchanging, wrapped
- * collection. Use this constructor if<ul>
- * <li> the wrapped collection value model already contains other
- * collection value models, or
- * <li> you want to override {@link #transform(Object) transform(E1)}
- * instead of building a {@link Transformer}
- * </ul>
- */
- public CompositeCollectionValueModel(E1... collection) {
- this(new StaticCollectionValueModel<E1>(collection));
- }
-
- /**
- * Construct a collection value model with the specified, unchanging, wrapped
- * collection and transformer.
- */
- public CompositeCollectionValueModel(E1[] collection, Transformer<E1, CollectionValueModel<E2>> transformer) {
- this(new StaticCollectionValueModel<E1>(collection), transformer);
- }
-
-
- // ********** initialization **********
-
- protected CollectionChangeListener buildComponentListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent event) {
- CompositeCollectionValueModel.this.componentItemsAdded(event);
- }
- public void itemsRemoved(CollectionRemoveEvent event) {
- CompositeCollectionValueModel.this.componentItemsRemoved(event);
- }
- public void collectionCleared(CollectionClearEvent event) {
- CompositeCollectionValueModel.this.componentCollectionCleared(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- CompositeCollectionValueModel.this.componentCollectionChanged(event);
- }
- @Override
- public String toString() {
- return "component listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public Iterator<E2> iterator() {
- return new CompositeIterator<E2>(this.buildCollectionsIterators());
- }
-
- protected Iterator<Iterator<E2>> buildCollectionsIterators() {
- return new TransformationIterator<ArrayList<E2>, Iterator<E2>>(this.collections.values().iterator()) {
- @Override
- protected Iterator<E2> transform(ArrayList<E2> next) {
- return next.iterator();
- }
- };
- }
-
- public int size() {
- return this.size;
- }
-
-
- // ********** CollectionValueModelWrapper overrides/implementation **********
-
- @Override
- protected void engageModel() {
- super.engageModel();
- // sync our cache *after* we start listening to the wrapped collection,
- // since its value might change when a listener is added
- this.addAllComponentSources();
- }
-
- /**
- * Transform all the sources to collection value models
- * and add their items to our cache, with no event notification.
- */
- protected void addAllComponentSources() {
- for (E1 source : this.collectionHolder) {
- this.addComponentSource(source, NullList.<E2>instance());
- }
- }
-
- @Override
- protected void disengageModel() {
- super.disengageModel();
- // stop listening to the components...
- for (CollectionValueModel<E2> componentCVM : this.componentCVMs.values()) {
- componentCVM.removeCollectionChangeListener(VALUES, this.componentCVMListener);
- }
- // ...and clear the cache
- this.componentCVMs.clear();
- this.collections.clear();
- this.size = 0;
- }
-
- /**
- * Some component sources were added;
- * add their corresponding items to our cache.
- */
- @Override
- protected void itemsAdded(CollectionAddEvent event) {
- ArrayList<E2> addedItems = new ArrayList<E2>();
- for (E1 item : this.getItems(event)) {
- this.addComponentSource(item, addedItems);
- }
- this.fireItemsAdded(VALUES, addedItems);
- }
-
- /**
- * Transform the specified source to a collection value model
- * and add its items to our cache and the "collecting parameter".
- */
- protected void addComponentSource(E1 source, List<E2> addedItems) {
- CollectionValueModel<E2> componentCVM = this.transform(source);
- if (this.componentCVMs.put(source, componentCVM) != null) {
- throw new IllegalStateException("duplicate component: " + source); //$NON-NLS-1$
- }
- componentCVM.addCollectionChangeListener(VALUES, this.componentCVMListener);
- ArrayList<E2> componentCollection = new ArrayList<E2>(componentCVM.size());
- if (this.collections.put(componentCVM, componentCollection) != null) {
- throw new IllegalStateException("duplicate collection: " + source); //$NON-NLS-1$
- }
- this.addComponentItems(componentCVM, componentCollection);
- addedItems.addAll(componentCollection);
- }
-
- /**
- * Add the items in the specified component CVM to the specified component
- * collection.
- */
- protected void addComponentItems(CollectionValueModel<E2> componentCVM, ArrayList<E2> componentCollection) {
- int itemsSize = componentCVM.size();
- this.size += itemsSize;
- componentCollection.ensureCapacity(componentCollection.size() + itemsSize);
- CollectionTools.addAll(componentCollection, componentCVM);
- }
-
- /**
- * Some component sources were removed;
- * remove their corresponding items from our cache.
- */
- @Override
- protected void itemsRemoved(CollectionRemoveEvent event) {
- ArrayList<E2> removedItems = new ArrayList<E2>();
- for (E1 item : this.getItems(event)) {
- this.removeComponentSource(item, removedItems);
- }
- this.fireItemsRemoved(VALUES, removedItems);
- }
-
- /**
- * Remove the items corresponding to the specified source
- * from our cache.
- */
- protected void removeComponentSource(E1 source, List<E2> removedItems) {
- CollectionValueModel<E2> componentCVM = this.componentCVMs.remove(source);
- if (componentCVM == null) {
- throw new IllegalStateException("missing component: " + source); //$NON-NLS-1$
- }
- componentCVM.removeCollectionChangeListener(VALUES, this.componentCVMListener);
- ArrayList<E2> componentCollection = this.collections.remove(componentCVM);
- if (componentCollection == null) {
- throw new IllegalStateException("missing collection: " + source); //$NON-NLS-1$
- }
- removedItems.addAll(componentCollection);
- this.removeComponentItems(componentCollection);
- }
-
- /**
- * Update our size and collection cache.
- */
- protected void removeComponentItems(ArrayList<E2> componentCollection) {
- this.size -= componentCollection.size();
- componentCollection.clear();
- }
-
- /**
- * The component sources cleared;
- * clear our cache.
- */
- @Override
- protected void collectionCleared(CollectionClearEvent event) {
- this.removeAllComponentSources();
- this.fireCollectionCleared(VALUES);
- }
-
- protected void removeAllComponentSources() {
- // copy the keys so we don't eat our own tail
- ArrayList<E1> copy = new ArrayList<E1>(this.componentCVMs.keySet());
- for (E1 source : copy) {
- this.removeComponentSource(source, NullList.<E2>instance());
- }
- }
-
- /**
- * The component sources changed;
- * rebuild our cache.
- */
- @Override
- protected void collectionChanged(CollectionChangeEvent event) {
- this.removeAllComponentSources();
- this.addAllComponentSources();
- this.fireCollectionChanged(VALUES, CollectionTools.collection(this.iterator()));
- }
-
-
- // ********** internal methods **********
-
- /**
- * Transform the specified object into a collection value model.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link Transformer}.
- */
- protected CollectionValueModel<E2> transform(E1 value) {
- return this.transformer.transform(value);
- }
-
- /**
- * One of the component collections had items added;
- * synchronize our caches.
- */
- protected void componentItemsAdded(CollectionAddEvent event) {
- int itemsSize = event.getItemsSize();
- this.size += itemsSize;
-
- ArrayList<E2> componentCollection = this.collections.get(this.componentCVM(event));
- componentCollection.ensureCapacity(componentCollection.size() + itemsSize);
-
- this.addItemsToCollection(this.getComponentItems(event), componentCollection, VALUES);
- }
-
- /**
- * One of the component collections had items removed;
- * synchronize our caches.
- */
- protected void componentItemsRemoved(CollectionRemoveEvent event) {
- this.size -= event.getItemsSize();
- ArrayList<E2> componentCollection = this.collections.get(this.componentCVM(event));
- this.removeItemsFromCollection(this.getComponentItems(event), componentCollection, VALUES);
- }
-
- /**
- * One of the component collections was cleared;
- * synchronize our caches by clearing out the appropriate
- * collection.
- */
- protected void componentCollectionCleared(CollectionClearEvent event) {
- ArrayList<E2> componentCollection = this.collections.get(this.componentCVM(event));
- ArrayList<E2> removedItems = new ArrayList<E2>(componentCollection);
- this.removeComponentItems(componentCollection);
- this.fireItemsRemoved(VALUES, removedItems);
- }
-
- /**
- * One of the component collections changed;
- * synchronize our caches by clearing out the appropriate
- * collection and then rebuilding it.
- */
- protected void componentCollectionChanged(CollectionChangeEvent event) {
- CollectionValueModel<E2> componentCVM = this.componentCVM(event);
- ArrayList<E2> componentCollection = this.collections.get(componentCVM);
- this.removeComponentItems(componentCollection);
- this.addComponentItems(componentCVM, componentCollection);
- this.fireCollectionChanged(VALUES, CollectionTools.collection(this.iterator()));
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E2> getComponentItems(CollectionAddEvent event) {
- return (Iterable<E2>) event.getItems();
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E2> getComponentItems(CollectionRemoveEvent event) {
- return (Iterable<E2>) event.getItems();
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected CollectionValueModel<E2> componentCVM(CollectionEvent event) {
- return (CollectionValueModel<E2>) event.getSource();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- StringTools.append(sb, this);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeListValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeListValueModel.java
deleted file mode 100644
index 2fe04c401c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositeListValueModel.java
+++ /dev/null
@@ -1,682 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 20124 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyCompositeListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationListIterator;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * A <code>CompositeListValueModel</code> wraps another
- * {@link ListValueModel} and uses a {@link Transformer}
- * to convert each item in the wrapped list to yet another
- * {@link ListValueModel}. This composite list contains
- * the combined items from all these component lists.
- * <p>
- * Terminology:<ul>
- * <li><em>sources</em> - the items in the wrapped list value model; these
- * are converted into component LVMs by the transformer
- * <li><em>component LVMs</em> - the component list value models that are combined
- * by this composite list value model
- * <li><em>items</em> - the items held by the component LVMs
- * </ul>
- */
-public class CompositeListValueModel<E1, E2>
- extends ListValueModelWrapper<E1>
- implements ListValueModel<E2>
-{
- /**
- * This is the (optional) user-supplied object that transforms
- * the items in the wrapped list to list value models.
- */
- private final Transformer<E1, ListValueModel<E2>> transformer;
-
- /**
- * Cache of the sources, component LVMs, lists.
- */
- private final ArrayList<Info> infoList = new ArrayList<Info>();
- protected class Info {
- // the object passed to the transformer
- final E1 source;
- // the list value model generated by the transformer
- final ListValueModel<E2> componentLVM;
- // cache of the items held by the component LVM
- final ArrayList<E2> items;
- // the component LVM's beginning index within the composite LVM
- int begin;
- protected Info(E1 source, ListValueModel<E2> componentLVM, ArrayList<E2> items, int begin) {
- super();
- this.source = source;
- this.componentLVM = componentLVM;
- this.items = items;
- this.begin = begin;
- }
- }
-
- /** Listener that listens to all the component list value models. */
- private final ListChangeListener componentLVMListener;
-
- /** Cache the size of the composite list. */
- private int size;
-
-
- // ********** constructors **********
-
- /**
- * Construct a list value model with the specified wrapped
- * list value model. Use this constructor if<ul>
- * <li> the wrapped list value model already contains other
- * list value models, or
- * <li> you want to override {@link #transform(Object) transform(E1)}
- * instead of building a {@link Transformer}
- * </ul>
- */
- public CompositeListValueModel(ListValueModel<? extends E1> listHolder) {
- this(listHolder, Transformer.Null.<E1, ListValueModel<E2>>instance());
- }
-
- /**
- * Construct a list value model with the specified wrapped
- * list value model and transformer.
- */
- public CompositeListValueModel(ListValueModel<? extends E1> listHolder, Transformer<E1, ListValueModel<E2>> transformer) {
- super(listHolder);
- this.transformer = transformer;
- this.componentLVMListener = this.buildComponentLVMListener();
- this.size = 0;
- }
-
- /**
- * Construct a list value model with the specified, unchanging, wrapped
- * list. Use this constructor if<ul>
- * <li> the wrapped list value model already contains other
- * list value models, or
- * <li> you want to override {@link #transform(Object) transform(E1)}
- * instead of building a {@link Transformer}
- * </ul>
- */
- public CompositeListValueModel(List<? extends E1> list) {
- this(new StaticListValueModel<E1>(list));
- }
-
- /**
- * Construct a list value model with the specified, unchanging, wrapped
- * list and transformer.
- */
- public CompositeListValueModel(List<? extends E1> list, Transformer<E1, ListValueModel<E2>> transformer) {
- this(new StaticListValueModel<E1>(list), transformer);
- }
-
- /**
- * Construct a list value model with the specified, unchanging, wrapped
- * list. Use this constructor if<ul>
- * <li> the wrapped list value model already contains other
- * list value models, or
- * <li> you want to override {@link #transform(Object) transform(E1)}
- * instead of building a {@link Transformer}
- * </ul>
- */
- public CompositeListValueModel(E1... list) {
- this(new StaticListValueModel<E1>(list));
- }
-
- /**
- * Construct a list value model with the specified, unchanging, wrapped
- * list and transformer.
- */
- public CompositeListValueModel(E1[] list, Transformer<E1, ListValueModel<E2>> transformer) {
- this(new StaticListValueModel<E1>(list), transformer);
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildComponentLVMListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent event) {
- CompositeListValueModel.this.componentItemsAdded(event);
- }
- public void itemsRemoved(ListRemoveEvent event) {
- CompositeListValueModel.this.componentItemsRemoved(event);
- }
- public void itemsReplaced(ListReplaceEvent event) {
- CompositeListValueModel.this.componentItemsReplaced(event);
- }
- public void itemsMoved(ListMoveEvent event) {
- CompositeListValueModel.this.componentItemsMoved(event);
- }
- public void listCleared(ListClearEvent event) {
- CompositeListValueModel.this.componentListCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- CompositeListValueModel.this.componentListChanged(event);
- }
- @Override
- public String toString() {
- return "component LVM listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ListValueModel implementation **********
-
- public E2 get(int index) {
- if ((index < 0) || (index >= this.size)) {
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + this.size); //$NON-NLS-1$ //$NON-NLS-2$
- }
- // move backwards through the info list
- for (int i = this.infoList.size(); i-- > 0; ) {
- Info info = this.infoList.get(i);
- if (index >= info.begin) {
- return info.items.get(index - info.begin);
- }
- }
- throw new IllegalStateException(); // something is wack
- }
-
- public Iterator<E2> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E2> listIterator() {
- return new ReadOnlyCompositeListIterator<E2>(this.buildListsIterators());
- }
-
- protected ListIterator<ListIterator<E2>> buildListsIterators() {
- return new TransformationListIterator<Info, ListIterator<E2>>(this.infoList.listIterator()) {
- @Override
- protected ListIterator<E2> transform(Info info) {
- return info.items.listIterator();
- }
- };
- }
-
- public int size() {
- return this.size;
- }
-
- public Object[] toArray() {
- return ArrayTools.array(this.listIterator(), this.size);
- }
-
-
- // ********** ListValueModelWrapper overrides/implementation **********
-
- @Override
- protected void engageModel() {
- super.engageModel();
- // sync our cache *after* we start listening to the wrapped list,
- // since its value might change when a listener is added
- this.addComponentSources(0, this.listHolder, this.listHolder.size(), false); // false = do not fire event
- }
-
- @Override
- protected void disengageModel() {
- super.disengageModel();
- // stop listening to the component LVMs...
- for (Info info : this.infoList) {
- info.componentLVM.removeListChangeListener(LIST_VALUES, this.componentLVMListener);
- }
- // ...and clear the cache
- this.infoList.clear();
- this.size = 0;
- }
-
- /**
- * Some component sources were added; update our cache.
- */
- @Override
- protected void itemsAdded(ListAddEvent event) {
- this.addComponentSources(event.getIndex(), this.getItems(event), event.getItemsSize(), true); // true = fire event
- }
-
- /**
- * Add infos corresponding to the specified sources to our cache.
- * Fire the appropriate event if requested.
- */
- protected void addComponentSources(int addedSourcesIndex, Iterable<? extends E1> addedSources, int addedSourcesSize, boolean fireEvent) {
- ArrayList<Info> newInfoList = new ArrayList<Info>(addedSourcesSize);
- // the 'items' are either tacked on to the end or
- // at the 'begin' index of the first 'info' that is being pushed back
- int newItemsIndex = (addedSourcesIndex == this.infoList.size()) ? this.size : this.infoList.get(addedSourcesIndex).begin;
-
- int begin = newItemsIndex;
- for (E1 source : addedSources) {
- ListValueModel<E2> componentLVM = this.transform(source);
- componentLVM.addListChangeListener(LIST_VALUES, this.componentLVMListener);
- ArrayList<E2> items = new ArrayList<E2>(componentLVM.size());
- CollectionTools.addAll(items, componentLVM.listIterator());
- newInfoList.add(new Info(source, componentLVM, items, begin));
- begin += items.size();
- }
- this.infoList.addAll(addedSourcesIndex, newInfoList);
- int newItemsSize = begin - newItemsIndex;
- this.size += newItemsSize;
-
- // bump the 'begin' index for all the infos that were pushed back by the insert
- int movedInfosIndex = addedSourcesIndex + addedSourcesSize;
- for (int i = movedInfosIndex; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin += newItemsSize;
- }
-
- if (fireEvent) {
- ArrayList<E2> newItems = new ArrayList<E2>(newItemsSize);
- for (int i = addedSourcesIndex; i < movedInfosIndex; i++) {
- newItems.addAll(this.infoList.get(i).items);
- }
- this.fireItemsAdded(LIST_VALUES, newItemsIndex, newItems);
- }
- }
-
- /**
- * Some component sources were removed; update our cache.
- */
- @Override
- protected void itemsRemoved(ListRemoveEvent event) {
- this.removeComponentSources(event.getIndex(), event.getItemsSize(), true); // true = fire event
- }
-
- /**
- * Remove the infos corresponding to the specified sources from our cache.
- */
- protected void removeComponentSources(int removedSourcesIndex, int removedSourcesSize, boolean fireEvent) {
- int removedItemsIndex = this.infoList.get(removedSourcesIndex).begin;
- int movedSourcesIndex = removedSourcesIndex + removedSourcesSize;
- int movedItemsIndex = (movedSourcesIndex == this.infoList.size()) ? this.size : this.infoList.get(movedSourcesIndex).begin;
- int removedItemsSize = movedItemsIndex - removedItemsIndex;
- this.size -= removedItemsSize;
-
- List<Info> subList = this.infoList.subList(removedSourcesIndex, removedSourcesIndex + removedSourcesSize);
- ArrayList<Info> removedInfoList = new ArrayList<Info>(subList); // make a copy
- subList.clear();
-
- // decrement the 'begin' index for all the infos that were moved forward by the deletes
- for (int i = removedSourcesIndex; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin -= removedItemsSize;
- }
-
- for (Info removedInfo : removedInfoList) {
- removedInfo.componentLVM.removeListChangeListener(LIST_VALUES, this.componentLVMListener);
- }
-
- if (fireEvent) {
- ArrayList<E2> removedItems = new ArrayList<E2>(removedItemsSize);
- for (Info removedInfo : removedInfoList) {
- removedItems.addAll(removedInfo.items);
- }
- this.fireItemsRemoved(LIST_VALUES, removedItemsIndex, removedItems);
- }
- }
-
- /**
- * Some component sources were replaced; update our cache.
- */
- @Override
- protected void itemsReplaced(ListReplaceEvent event) {
- this.replaceComponentSources(event.getIndex(), this.getNewItems(event), event.getItemsSize(), true); // true = fire event
- }
-
- /**
- * Replaced component sources will not (typically) map to a set of replaced
- * items, so we remove and add the corresponding lists of items, resulting in
- * two events.
- */
- protected void replaceComponentSources(int replacedSourcesIndex, Iterable<? extends E1> newSources, int replacedSourcesSize, boolean fireEvent) {
- this.removeComponentSources(replacedSourcesIndex, replacedSourcesSize, fireEvent);
- this.addComponentSources(replacedSourcesIndex, newSources, replacedSourcesSize, fireEvent);
- }
-
- /**
- * Some component sources were moved; update our cache.
- */
- @Override
- protected void itemsMoved(ListMoveEvent event) {
- this.moveComponentSources(event.getTargetIndex(), event.getSourceIndex(), event.getLength(), true); // true = fire event
- }
-
- protected void moveComponentSources(int targetSourcesIndex, int sourceSourcesIndex, int movedSourcesLength, boolean fireEvent) {
- int sourceItemsIndex = this.infoList.get(sourceSourcesIndex).begin;
-
- int nextSourceSourceIndex = sourceSourcesIndex + movedSourcesLength;
- int nextSourceItemIndex = (nextSourceSourceIndex == this.infoList.size()) ? this.size : this.infoList.get(nextSourceSourceIndex).begin;
- int moveItemsLength = nextSourceItemIndex - sourceItemsIndex;
-
- int targetItemsIndex = -1;
- if (sourceSourcesIndex > targetSourcesIndex) {
- // move from high to low index
- targetItemsIndex = this.infoList.get(targetSourcesIndex).begin;
- } else {
- // move from low to high index (higher items move down during move)
- int nextTargetSourceIndex = targetSourcesIndex + movedSourcesLength;
- targetItemsIndex = (nextTargetSourceIndex == this.infoList.size()) ? this.size : this.infoList.get(nextTargetSourceIndex).begin;
- targetItemsIndex = targetItemsIndex - moveItemsLength;
- }
-
- CollectionTools.move(this.infoList, targetSourcesIndex, sourceSourcesIndex, movedSourcesLength);
-
- // update the 'begin' indexes of all the affected 'infos'
- int min = Math.min(targetSourcesIndex, sourceSourcesIndex);
- int max = Math.max(targetSourcesIndex, sourceSourcesIndex) + movedSourcesLength;
- int begin = Math.min(targetItemsIndex, sourceItemsIndex);
- for (int i = min; i < max; i++) {
- Info info = this.infoList.get(i);
- info.begin = begin;
- begin += info.componentLVM.size();
- }
-
- if (fireEvent) {
- this.fireItemsMoved(LIST_VALUES, targetItemsIndex, sourceItemsIndex, moveItemsLength);
- }
- }
-
- /**
- * The component sources were cleared; clear our cache.
- */
- @Override
- protected void listCleared(ListClearEvent event) {
- this.clearComponentSources();
- }
-
- protected void clearComponentSources() {
- this.removeComponentSources(0, this.infoList.size(), false); // false = do not fire event
- this.fireListCleared(LIST_VALUES);
- }
-
- /**
- * The component sources changed; rebuild our cache.
- */
- @Override
- protected void listChanged(ListChangeEvent event) {
- int newSize = this.listHolder.size();
- if (newSize == 0) {
- this.clearComponentSources();
- return;
- }
-
- int oldSize = this.infoList.size();
- if (oldSize == 0) {
- this.addComponentSources(0, this.listHolder, newSize, true); // true = fire event
- return;
- }
-
- int min = Math.min(newSize, oldSize);
- // handle replaced sources individually so we don't fire events for unchanged sources
- for (int i = 0; i < min; i++) {
- E1 newSource = this.listHolder.get(i);
- E1 oldSource = this.infoList.get(i).source;
- if (this.valuesAreDifferent(newSource, oldSource)) {
- this.replaceComponentSources(i, new SingleElementIterable<E1>(newSource), 1, true); // true = fire event
- }
- }
-
- if (newSize == oldSize) {
- return;
- }
-
- if (newSize < oldSize) {
- this.removeComponentSources(min, oldSize - newSize, true); // true = fire event
- return;
- }
-
- // newSize > oldSize
- this.addComponentSources(min, this.buildSubListHolder(min), newSize - oldSize, true); // true = fire event
- }
-
- protected Iterable<? extends E1> buildSubListHolder(int fromIndex) {
- int listHolderSize = this.listHolder.size();
- return CollectionTools.list(this.listHolder, listHolderSize).subList(fromIndex, listHolderSize);
- }
-
- protected Iterable<? extends E1> buildSubListHolder(int fromIndex, int toIndex) {
- int listHolderSize = this.listHolder.size();
- return ((fromIndex == 0) && (toIndex == listHolderSize)) ?
- this.listHolder :
- CollectionTools.list(this.listHolder, listHolderSize).subList(fromIndex, toIndex);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- StringTools.append(sb, this);
- }
-
-
- // ********** internal methods **********
-
- /**
- * Transform the specified object into a list value model.
- * <p>
- * This method can be overridden by a subclass as an
- * alternative to building a {@link Transformer}.
- */
- protected ListValueModel<E2> transform(E1 value) {
- return this.transformer.transform(value);
- }
-
- /**
- * Return the index of the specified component LVM.
- */
- protected int indexOf(ListValueModel<E2> componentLVM) {
- for (int i = 0; i < this.infoList.size(); i++) {
- if (this.infoList.get(i).componentLVM == componentLVM) {
- return i;
- }
- }
- throw new IllegalArgumentException("invalid component LVM: " + componentLVM); //$NON-NLS-1$
- }
-
- /**
- * Return the index of the specified event's component LVM.
- */
- protected int indexFor(ListEvent event) {
- return this.indexOf(this.getComponentLVM(event));
- }
-
- /**
- * Items were added to one of the component lists;
- * synchronize our cache.
- */
- protected void componentItemsAdded(ListAddEvent event) {
- int componentLVMIndex = this.indexFor(event);
- this.addComponentItems(componentLVMIndex, this.infoList.get(componentLVMIndex), event.getIndex(), this.getComponentItems(event), event.getItemsSize());
- }
-
- protected void addComponentItems(int componentLVMIndex, Info info, int addedItemsIndex, Iterable<E2> addedItems, int addedItemsSize) {
- // update the affected 'begin' indices
- for (int i = componentLVMIndex + 1; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin += addedItemsSize;
- }
- this.size += addedItemsSize;
-
- // synchronize the cached list
- CollectionTools.addAll(info.items, addedItemsIndex, addedItems, addedItemsSize);
-
- // translate the event
- this.fireItemsAdded(LIST_VALUES, info.begin + addedItemsIndex, info.items.subList(addedItemsIndex, addedItemsIndex + addedItemsSize));
- }
-
- /**
- * Items were removed from one of the component lists;
- * synchronize our cache.
- */
- protected void componentItemsRemoved(ListRemoveEvent event) {
- // update the affected 'begin' indices
- int componentLVMIndex = this.indexFor(event);
- int removedItemsSize = event.getItemsSize();
- for (int i = componentLVMIndex + 1; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin -= removedItemsSize;
- }
- this.size -= removedItemsSize;
-
- // synchronize the cached list
- Info info = this.infoList.get(componentLVMIndex);
- int itemIndex = event.getIndex();
- info.items.subList(itemIndex, itemIndex + event.getItemsSize()).clear();
-
- // translate the event
- this.fireItemsRemoved(event.clone(this, LIST_VALUES, info.begin));
- }
-
- /**
- * Items were replaced in one of the component lists;
- * synchronize our cache.
- */
- protected void componentItemsReplaced(ListReplaceEvent event) {
- // no changes to the 'begin' indices or size
-
- // synchronize the cached list
- int componentLVMIndex = this.indexFor(event);
- Info info = this.infoList.get(componentLVMIndex);
- int i = event.getIndex();
- for (E2 item : this.getComponentItems(event)) {
- info.items.set(i++, item);
- }
-
- // translate the event
- this.fireItemsReplaced(event.clone(this, LIST_VALUES, info.begin));
- }
-
- /**
- * Items were moved in one of the component lists;
- * synchronize our cache.
- */
- protected void componentItemsMoved(ListMoveEvent event) {
- // no changes to the 'begin' indices or size
-
- // synchronize the cached list
- int componentLVMIndex = this.indexFor(event);
- Info info = this.infoList.get(componentLVMIndex);
- CollectionTools.move(info.items, event.getTargetIndex(), event.getSourceIndex(), event.getLength());
-
- // translate the event
- this.fireItemsMoved(event.clone(this, LIST_VALUES, info.begin));
- }
-
- /**
- * One of the component lists was cleared;
- * synchronize our cache.
- */
- protected void componentListCleared(ListClearEvent event) {
- int componentLVMIndex = this.indexFor(event);
- this.clearComponentList(componentLVMIndex, this.infoList.get(componentLVMIndex));
- }
-
- protected void clearComponentList(int componentLVMIndex, Info info) {
- // update the affected 'begin' indices
- int removedItemsSize = info.items.size();
- if (removedItemsSize == 0) {
- return;
- }
-
- for (int i = componentLVMIndex + 1; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin -= removedItemsSize;
- }
- this.size -= removedItemsSize;
-
- // synchronize the cached list
- ArrayList<E2> items = new ArrayList<E2>(info.items); // make a copy
- info.items.clear();
-
- // translate the event
- this.fireItemsRemoved(LIST_VALUES, info.begin, items);
- }
-
- /**
- * One of the component lists changed;
- * synchronize our cache by synchronizing the appropriate
- * list and firing the appropriate events.
- */
- protected void componentListChanged(ListChangeEvent event) {
- int componentLVMIndex = this.indexFor(event);
- Info info = this.infoList.get(componentLVMIndex);
-
- int newItemsSize = info.componentLVM.size();
- if (newItemsSize == 0) {
- this.clearComponentList(componentLVMIndex, info);
- return;
- }
-
- int oldItemsSize = info.items.size();
- if (oldItemsSize == 0) {
- this.addComponentItems(componentLVMIndex, info, 0, info.componentLVM, newItemsSize);
- return;
- }
-
- int min = Math.min(newItemsSize, oldItemsSize);
- // handle replaced items individually so we don't fire events for unchanged items
- for (int i = 0; i < min; i++) {
- E2 newItem = info.componentLVM.get(i);
- E2 oldItem = info.items.set(i, newItem);
- this.fireItemReplaced(LIST_VALUES, info.begin + i, newItem, oldItem);
- }
-
- int delta = newItemsSize - oldItemsSize;
- if (delta == 0) { // newItemsSize == oldItemsSize
- return;
- }
-
- for (int i = componentLVMIndex + 1; i < this.infoList.size(); i++) {
- this.infoList.get(i).begin += delta;
- }
- this.size += delta;
-
- if (delta < 0) { // newItemsSize < oldItemsSize
- List<E2> subList = info.items.subList(newItemsSize, oldItemsSize);
- ArrayList<E2> removedItems = new ArrayList<E2>(subList); // make a copy
- subList.clear();
- this.fireItemsRemoved(LIST_VALUES, info.begin + newItemsSize, removedItems);
- return;
- }
-
- // newItemsSize > oldItemsSize
- ArrayList<E2> addedItems = new ArrayList<E2>(delta);
- for (int i = oldItemsSize; i < newItemsSize; i++) {
- addedItems.add(info.componentLVM.get(i));
- }
- info.items.addAll(addedItems);
- this.fireItemsAdded(LIST_VALUES, info.begin + oldItemsSize, addedItems);
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E2> getComponentItems(ListAddEvent event) {
- return (Iterable<E2>) event.getItems();
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E2> getComponentItems(ListReplaceEvent event) {
- return (Iterable<E2>) event.getNewItems();
- }
-
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected ListValueModel<E2> getComponentLVM(ListEvent event) {
- return (ListValueModel<E2>) event.getSource();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositePropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositePropertyValueModel.java
deleted file mode 100644
index 5731fab0c3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/CompositePropertyValueModel.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import org.eclipse.jpt.common.utility.internal.IdentityHashBag;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * A <code>CompositePropertyValueModel</code> adapts a
- * {@link CollectionValueModel} holding other {@link PropertyValueModel}s
- * to a single {@link PropertyValueModel}.
- * <p>
- * Subclasses must implement:<ul>
- * <li>{@link #buildValue()}<p>
- * to return the current property value, as derived from the
- * component values
- * </ul>
- * <strong>NB:</strong> The wrapped collection must not contain any duplicates
- * or this class will throw an exception.
- *
- * @param <V> the type of the model's value
- * @param <E> the type of the wrapped collection value model's
- * property value model's values
- */
-public abstract class CompositePropertyValueModel<V, E>
- extends CollectionPropertyValueModelAdapter<V, PropertyValueModel<? extends E>>
-{
- /**
- * Cache the component property value models so we can stop listening to
- * them when they are removed from the collection value model.
- */
- protected final IdentityHashBag<PropertyValueModel<? extends E>> componentPVMs =
- new IdentityHashBag<PropertyValueModel<? extends E>>();
-
- /**
- * Listen to every property value model in the collection value model.
- * If one changes, we need to re-calculate our value.
- */
- protected final PropertyChangeListener componentListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a property value model that is a composite of the specified
- * property value models.
- */
- public CompositePropertyValueModel(PropertyValueModel<? extends E>... collection) {
- this(Arrays.asList(collection));
- }
-
- /**
- * Construct a property value model that is a composite of the specified
- * property value models.
- */
- public <P extends PropertyValueModel<? extends E>> CompositePropertyValueModel(Collection<? extends P> collection) {
- this(new StaticCollectionValueModel<P>(collection));
- }
-
- /**
- * Construct a property value model that is a composite of the specified
- * property value models.
- */
- public <P extends PropertyValueModel<? extends E>> CompositePropertyValueModel(CollectionValueModel<P> collectionModel) {
- super(collectionModel);
- this.componentListener = this.buildComponentListener();
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildComponentListener() {
- return new ComponentListener();
- }
-
- protected class ComponentListener
- extends PropertyChangeAdapter
- {
- @Override
- public void propertyChanged(PropertyChangeEvent event) {
- CompositePropertyValueModel.this.componentChanged(event);
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * Subclasses can override this method if the event can be used to improve
- * the performance of building a new value (e.g. some property changes may
- * not necessitate the re-calculation of the value).
- */
- protected void componentChanged(@SuppressWarnings("unused") PropertyChangeEvent event) {
- this.propertyChanged();
- }
-
-
- // ********** CollectionPropertyValueModelAdapter overrides **********
-
- @Override
- protected void engageModel_() {
- super.engageModel_();
- this.addComponentPVMs(this.collectionModel);
- }
-
- protected <P extends PropertyValueModel<? extends E>> void addComponentPVMs(Iterable<P> pvms) {
- for (P each : pvms) {
- this.componentPVMs.add(each);
- each.addPropertyChangeListener(VALUE, this.componentListener);
- }
- }
-
- @Override
- protected void disengageModel_() {
- this.removeComponentPVMs(this.collectionModel);
- super.disengageModel_();
- }
-
- protected <P extends PropertyValueModel<? extends E>> void removeComponentPVMs(Iterable<P> pvms) {
- for (P each : pvms) {
- each.removePropertyChangeListener(VALUE, this.componentListener);
- this.componentPVMs.remove(each);
- }
- }
-
- @Override
- protected void itemsAdded(CollectionAddEvent event) {
- this.addComponentPVMs(this.getItems(event));
- super.itemsAdded(event);
- }
-
- @Override
- protected void itemsRemoved(CollectionRemoveEvent event) {
- this.removeComponentPVMs(this.getItems(event));
- super.itemsRemoved(event);
- }
-
- @Override
- protected void collectionCleared(CollectionClearEvent event) {
- this.removeAllComponentPVMs();
- super.collectionCleared(event);
- }
-
- protected void removeAllComponentPVMs() {
- // copy the list so we don't eat our own tail
- ArrayList<PropertyValueModel<? extends E>> copy = new ArrayList<PropertyValueModel<? extends E>>(this.componentPVMs);
- this.removeComponentPVMs(copy);
- }
-
- @Override
- protected void collectionChanged(CollectionChangeEvent event) {
- this.removeAllComponentPVMs();
- this.addComponentPVMs(this.collectionModel);
- super.collectionChanged(event);
- }
-
-
- // ********** convenience methods **********
-
- /**
- * Our constructor accepts only a
- * {@link CollectionValueModel}{@code<? extends }{@link PropertyValueModel}{@code<? extends E>>}.
- */
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<? extends PropertyValueModel<? extends E>> getItems(CollectionAddEvent event) {
- return (Iterable<? extends PropertyValueModel<? extends E>>) event.getItems();
- }
-
- /**
- * Our constructor accepts only a
- * {@link CollectionValueModel}{@code<? extends }{@link PropertyValueModel}{@code<? extends E>>}.
- */
- // minimize scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<? extends PropertyValueModel<? extends E>> getItems(CollectionRemoveEvent event) {
- return (Iterable<? extends PropertyValueModel<? extends E>>) event.getItems();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/DoubleModifiablePropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/DoubleModifiablePropertyValueModel.java
deleted file mode 100644
index 9d4e1d7693..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/DoubleModifiablePropertyValueModel.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Add support for changing the double property value model.
- *
- * @param <V> the type of the both the <em>wrapped</em> and <em>wrapper</em>
- * models' values
- */
-public class DoubleModifiablePropertyValueModel<V>
- extends DoublePropertyValueModel<V>
- implements ModifiablePropertyValueModel<V>
-{
- /**
- * Construct a double modifiable property value model for the specified
- * wrapped property value model model.
- */
- public DoubleModifiablePropertyValueModel(PropertyValueModel<? extends ModifiablePropertyValueModel<V>> valueModel) {
- super(valueModel);
- }
-
- public void setValue(V value) {
- ModifiablePropertyValueModel<V> vmv = this.getValueModelValueModel();
- if (vmv == null) {
- this.setValue_(value);
- } else {
- vmv.setValue(value);
- }
- }
-
- @SuppressWarnings("unchecked")
- protected ModifiablePropertyValueModel<V> getValueModelValueModel() {
- return (ModifiablePropertyValueModel<V>) this.valueModelValueModel;
- }
-
- /**
- * The wrapped value model model is missing. Handle the specified new value.
- */
- protected void setValue_(@SuppressWarnings("unused") V value) {
- // do nothing by default
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/DoublePropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/DoublePropertyValueModel.java
deleted file mode 100644
index d8452cb924..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/DoublePropertyValueModel.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This property value model <em>wrapper</em> wraps another property value model
- * and treats the <em>wrapped</em> model's value as the <em>wrapper</em>'s value.
- * Any change events fired by the <em>wrapped</em> model are simply forwarded by
- * the <em>wrapper</em> as its own.
- * Similarly, changing the <em>wrapper</em>'s <em>wrapped</em> model can also
- * trigger a change event
- * (see {@link #wrappedValueChanged(PropertyValueModel, PropertyValueModel)}).
- * That is, the <em>wrapped</em> model is held by yet another property value
- * model!
- * <p>
- * <ul>
- * <li>Double (<em>wrapper</em>) property value model - a client can listen to
- * this model and receive the same change notification whether the
- * <em>wrapped</em> model or the <em>wrapped</em> model's value changes;
- * much like an {@link PropertyAspectAdapter aspect adapter} whose subject
- * model is <em>not</em> another property value model
- * <ul>
- * <li><em>Wrapped</em> property value model - this model is built and
- * maintained by the server that also builds the <em>wrapper</em> model
- * (i.e. the server will monitor some other model that determines when
- * the <em>wrapped</em> model is changed)
- * <ul>
- * <li>Original property value model - this model is the "original"
- * model that contains the value of interest
- * </ul>
- * </ul>
- * </ul>
- * <p>
- * This wrapper is useful when a change in the <em>wrapped</em> model is
- * signaled by a non-value event and a third-party would like to change it.
- *
- * @param <V> the type of the both the <em>wrapped</em> and <em>wrapper</em>
- * models' values
- */
-public class DoublePropertyValueModel<V>
- extends PropertyValueModelWrapper<PropertyValueModel<? extends V>>
- implements PropertyValueModel<V>
-{
- /**
- * The optionally present wrapped value model value; held by
- * {@link #valueModel}. This may be <code>null</code>.
- */
- protected volatile PropertyValueModel<? extends V> valueModelValueModel;
-
- /**
- * A listener that allows us to sync with changes to the wrapped value
- * model model.
- */
- protected final PropertyChangeListener valueModelValueListener;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct a double property value model for the specified
- * wrapped property value model model.
- */
- public DoublePropertyValueModel(PropertyValueModel<? extends PropertyValueModel<? extends V>> valueModel) {
- super(valueModel);
- this.valueModelValueListener = this.buildValueModelValueListener();
- }
-
- protected PropertyChangeListener buildValueModelValueListener() {
- return new ValueModelListener();
- }
-
- /* CU private */ class ValueModelListener
- extends PropertyChangeAdapter
- {
- @Override
- public void propertyChanged(PropertyChangeEvent event) {
- DoublePropertyValueModel.this.wrappedValueModelValueChanged(event);
- }
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- public V getValue() {
- return (this.valueModelValueModel == null) ? null : this.valueModelValueModel.getValue();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getValue());
- }
-
-
- // ********** wrapped value model **********
-
- /**
- * The value model has changed.
- * Move our value model listener and
- * notify listeners that the value has changed.
- */
- @Override
- protected void wrappedValueChanged(PropertyValueModel<? extends V> oldValue, PropertyValueModel<? extends V> newValue) {
- if (this.hasListeners()) {
- V old = this.getValue();
- this.disengageValueModel();
- this.engageValueModel();
- this.firePropertyChanged(VALUE, old, this.getValue());
- }
- }
-
-
- // ********** wrapped value model value **********
-
- /**
- * The value of the wrapped value model's value model has changed.
- * Forward the event as our own.
- */
- protected void wrappedValueModelValueChanged(PropertyChangeEvent event) {
- this.firePropertyChanged(event.clone(this));
- }
-
- /**
- * Begin listening to the value model.
- */
- @Override
- protected void engageModel() {
- super.engageModel();
- this.engageValueModel();
- }
-
- protected void engageValueModel() {
- this.valueModelValueModel = this.valueModel.getValue();
- if (this.valueModelValueModel != null) {
- this.valueModelValueModel.addPropertyChangeListener(VALUE, this.valueModelValueListener);
- }
- }
-
- /**
- * Stop listening to the value model.
- */
- @Override
- protected void disengageModel() {
- this.disengageValueModel();
- super.disengageModel();
- }
-
- protected void disengageValueModel() {
- if (this.valueModelValueModel != null) {
- this.valueModelValueModel.removePropertyChangeListener(VALUE, this.valueModelValueListener);
- }
- this.valueModelValueModel = null;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ElementPropertyValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ElementPropertyValueModelAdapter.java
deleted file mode 100644
index 0f88a5676f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ElementPropertyValueModelAdapter.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-
-/**
- * Adapt an element in a collection value model to a property value model.
- * The property model's value is determined by whether the collection model
- * contains the value: If the collection model contains the value,
- * the property model's value is <em>that</em> element; otherwise, the property
- * model's value is <code>null</code>. A {@link #predicate} is used to determine
- * whether the collection model contains the relevant value.
- * <p>
- * This is useful for a client (e.g. a UI widget) that is longer-living than its
- * underlying model. Obviously, the client must be prepared to handle a value of
- * <code>null</code>.
- *
- * @param <V> the type of the both the model's value and
- * the wrapped collection value model's elements
- */
-public class ElementPropertyValueModelAdapter<V>
- extends CollectionPropertyValueModelAdapter<V, V>
-{
- /**
- * A predicate used to determine whether an element in the wrapped
- * collection model is the model's value.
- */
- protected final Filter<V> predicate;
-
-
- /**
- * Construct a property value model whose value depends on whether the
- * specified collection value model contains the value. The specified
- * filter is used to determine whether an element in the specified
- * collection model is the property value.
- */
- public ElementPropertyValueModelAdapter(CollectionValueModel<? extends V> collectionModel, Filter<V> predicate) {
- super(collectionModel);
- if (predicate == null) {
- throw new NullPointerException();
- }
- this.predicate = predicate;
- }
-
- /**
- * If the collection model contains the property model's {@link #value},
- * return that element; otherwise return <code>null</code>.
- */
- @Override
- protected V buildValue() {
- for (V each : this.collectionModel) {
- if (this.predicate.accept(each)) {
- return each;
- }
- }
- return null;
- }
-
- /**
- * Check whether the wrapped collection model now contains the
- * {@link #value}.
- */
- @Override
- protected void itemsAdded(Iterable<V> items) {
- if (this.value == null) {
- this.itemsAdded_(items);
- }
- }
-
- protected void itemsAdded_(Iterable<V> items) {
- for (V each : items) {
- if (this.predicate.accept(each)) {
- this.firePropertyChanged(VALUE, null, this.value = each);
- return;
- }
- }
- }
-
- /**
- * Check whether the wrapped collection model no longer contains the
- * {@link #value}.
- */
- @Override
- protected void itemsRemoved(Iterable<V> items) {
- if (this.value != null) {
- this.itemsRemoved_(items);
- }
- }
-
- protected void itemsRemoved_(Iterable<V> items) {
- for (V each : items) {
- if (this.valuesAreEqual(each, this.value)) {
- V old = this.value;
- this.firePropertyChanged(VALUE, old, this.value = null);
- return;
- }
- }
- }
-
- /**
- * The {@link #value} must now be <code>null</code>.
- */
- @Override
- protected void collectionCleared(CollectionClearEvent event) {
- if (this.value != null) {
- V old = this.value;
- this.firePropertyChanged(VALUE, old, this.value = null);
- }
- }
-
- /**
- * Re-calculate the {@link #value}.
- */
- @Override
- protected void collectionChanged(CollectionChangeEvent event) {
- V old = this.value;
- this.firePropertyChanged(VALUE, old, this.value = this.buildValue());
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ExtendedListValueModelWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ExtendedListValueModelWrapper.java
deleted file mode 100644
index 6601615cc4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ExtendedListValueModelWrapper.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyCompositeListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * This wrapper extends a {@link ListValueModel} (or {@link CollectionValueModel})
- * with fixed collections of items on either end.
- * <p>
- * <strong>NB:</strong> Be careful using or wrapping this list value model, since the
- * "extended" items may be unexpected by the client code or wrapper.
- */
-public class ExtendedListValueModelWrapper<E>
- extends ListValueModelWrapper<E>
- implements ListValueModel<E>
-{
- /** the items "prepended" to the wrapped list */
- protected List<E> prefix;
-
- /** the items "appended" to the wrapped list */
- protected List<E> suffix;
-
-
- // ********** lots o' constructors **********
-
- /**
- * Extend the specified list with a prefix and suffix.
- */
- public ExtendedListValueModelWrapper(List<? extends E> prefix, ListValueModel<? extends E> listHolder, List<? extends E> suffix) {
- super(listHolder);
- this.prefix = new ArrayList<E>(prefix);
- this.suffix = new ArrayList<E>(suffix);
- }
-
- /**
- * Extend the specified list with a prefix and suffix.
- */
- public ExtendedListValueModelWrapper(E prefix, ListValueModel<? extends E> listHolder, E suffix) {
- super(listHolder);
- this.prefix = Collections.singletonList(prefix);
- this.suffix = Collections.singletonList(suffix);
- }
-
- /**
- * Extend the specified list with a prefix.
- */
- public ExtendedListValueModelWrapper(List<? extends E> prefix, ListValueModel<? extends E> listHolder) {
- super(listHolder);
- this.prefix = new ArrayList<E>(prefix);
- this.suffix = Collections.emptyList();
- }
-
- /**
- * Extend the specified list with a prefix.
- */
- public ExtendedListValueModelWrapper(E prefix, ListValueModel<? extends E> listHolder) {
- super(listHolder);
- this.prefix = Collections.singletonList(prefix);
- this.suffix = Collections.emptyList();
- }
-
- /**
- * Extend the specified list with a suffix.
- */
- public ExtendedListValueModelWrapper(ListValueModel<? extends E> listHolder, List<? extends E> suffix) {
- super(listHolder);
- this.prefix = Collections.emptyList();
- this.suffix = new ArrayList<E>(suffix);
- }
-
- /**
- * Extend the specified list with a suffix.
- */
- public ExtendedListValueModelWrapper(ListValueModel<? extends E> listHolder, E suffix) {
- super(listHolder);
- this.prefix = Collections.emptyList();
- this.suffix = Collections.singletonList(suffix);
- }
-
- /**
- * Extend the specified list with a prefix containing a single null item.
- */
- public ExtendedListValueModelWrapper(ListValueModel<? extends E> listHolder) {
- super(listHolder);
- this.prefix = Collections.singletonList(null);
- this.suffix = Collections.emptyList();
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E> listIterator() {
- return new ReadOnlyListIterator<E>(this.listIterator_());
- }
-
- @SuppressWarnings("unchecked")
- protected ListIterator<E> listIterator_() {
- return new ReadOnlyCompositeListIterator<E>(
- this.prefix.listIterator(),
- this.listHolder.listIterator(),
- this.suffix.listIterator()
- );
- }
-
- public E get(int index) {
- int prefixSize = this.prefix.size();
- if (index < prefixSize) {
- return this.prefix.get(index);
- } else if (index >= prefixSize + this.listHolder.size()) {
- return this.suffix.get(index - (prefixSize + this.listHolder.size()));
- } else {
- return this.listHolder.get(index - prefixSize);
- }
- }
-
- public int size() {
- return this.prefix.size() + this.listHolder.size() + this.suffix.size();
- }
-
- public Object[] toArray() {
- ArrayList<E> list = new ArrayList<E>(this.size());
- list.addAll(this.prefix);
- CollectionTools.addAll(list, this.listHolder.iterator());
- list.addAll(this.suffix);
- return list.toArray();
- }
-
-
- // ********** ListValueModelWrapper implementation/overrides **********
-
- @Override
- protected void itemsAdded(ListAddEvent event) {
- this.fireItemsAdded(event.clone(this, LIST_VALUES, this.prefix.size()));
- }
-
- @Override
- protected void itemsRemoved(ListRemoveEvent event) {
- this.fireItemsRemoved(event.clone(this, LIST_VALUES, this.prefix.size()));
- }
-
- @Override
- protected void itemsReplaced(ListReplaceEvent event) {
- this.fireItemsReplaced(event.clone(this, LIST_VALUES, this.prefix.size()));
- }
-
- @Override
- protected void itemsMoved(ListMoveEvent event) {
- this.fireItemsMoved(event.clone(this, LIST_VALUES, this.prefix.size()));
- }
-
- @Override
- protected void listCleared(ListClearEvent event) {
- this.fireListChanged(LIST_VALUES, this.buildList()); // not "cleared"
- }
-
- @Override
- protected void listChanged(ListChangeEvent event) {
- this.fireListChanged(LIST_VALUES, this.buildList());
- }
-
- @Override
- public void toString(StringBuilder sb) {
- StringTools.append(sb, this);
- }
-
-
- // ********** miscellaneous **********
-
- public void setPrefix(List<E> prefix) {
- this.prefix = prefix;
- this.fireListChanged(LIST_VALUES, this.buildList());
- }
-
- public void setSuffix(List<E> suffix) {
- this.suffix = suffix;
- this.fireListChanged(LIST_VALUES, this.buildList());
- }
-
- private List<E> buildList() {
- return CollectionTools.list(this.listIterator_());
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringCollectionValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringCollectionValueModel.java
deleted file mode 100644
index 0a92b48e96..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringCollectionValueModel.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * A <code>FilteringCollectionValueModel</code> wraps another
- * {@link CollectionValueModel} and uses a {@link Filter}
- * to determine which items in the collection are returned by calls
- * to {@link #iterator()}.
- * <p>
- * The filter can be changed at any time; allowing the same
- * adapter to be used with different filter criteria (e.g. when the user
- * wants to view a list of <code>.java</code> files).
- * <p>
- * <strong>NB:</strong> If the objects in the "filtered" collection can change in such a way
- * that they should be removed from the "filtered" collection, you will
- * need to wrap the original collection in an {@link ItemAspectListValueModelAdapter}.
- * For example, if the filter only "accepts" items whose names begin
- * with "X" and the names of the items can change, you will need to
- * wrap the original list of unfiltered items with an
- * {@link ItemPropertyListValueModelAdapter} that listens for changes to each
- * item's name and fires the appropriate event whenever an item's name
- * changes. The event will cause this wrapper to re-filter the changed
- * item and add or remove it from the "filtered" collection as appropriate.
- */
-public class FilteringCollectionValueModel<E>
- extends CollectionValueModelWrapper<E>
- implements CollectionValueModel<E>
-{
- /** This filters the items in the nested collection. */
- private Filter<E> filter;
-
- /** Cache the items that were accepted by the filter */
- private final ArrayList<E> filteredItems = new ArrayList<E>();
-
-
- // ********** constructors **********
-
- /**
- * Construct a collection value model with the specified wrapped
- * collection value model and a filter that simply accepts every object.
- */
- public FilteringCollectionValueModel(CollectionValueModel<? extends E> collectionModel) {
- this(collectionModel, Filter.Transparent.<E>instance());
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * collection value model and filter.
- */
- public FilteringCollectionValueModel(CollectionValueModel<? extends E> collectionModel, Filter<E> filter) {
- super(collectionModel);
- this.filter = filter;
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * list value model and a filter that simply accepts every object.
- */
- public FilteringCollectionValueModel(ListValueModel<? extends E> listModel) {
- this(new ListCollectionValueModelAdapter<E>(listModel));
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * list value model and filter.
- */
- public FilteringCollectionValueModel(ListValueModel<? extends E> listModel, Filter<E> filter) {
- this(new ListCollectionValueModelAdapter<E>(listModel), filter);
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public Iterator<E> iterator() {
- return new ReadOnlyIterator<E>(this.filteredItems);
- }
-
- public int size() {
- return this.filteredItems.size();
- }
-
-
- // ********** CollectionValueModelWrapper overrides/implementation **********
-
- @Override
- protected void engageModel() {
- super.engageModel();
- // sync our cache *after* we start listening to the nested collection,
- // since its value might change when a listener is added
- CollectionTools.addAll(this.filteredItems, this.filter(this.collectionHolder));
- }
-
- @Override
- protected void disengageModel() {
- super.disengageModel();
- // clear out the cache when we are not listening to the nested collection
- this.filteredItems.clear();
- }
-
- @Override
- protected void itemsAdded(CollectionAddEvent event) {
- // filter the values before propagating the change event
- this.addItemsToCollection(this.filter(this.getItems(event)), this.filteredItems, VALUES);
- }
-
- @Override
- protected void itemsRemoved(CollectionRemoveEvent event) {
- // do *not* filter the values, because they may no longer be
- // "accepted" and that might be why they were removed in the first place;
- // anyway, any extraneous items are harmless
- this.removeItemsFromCollection(event.getItems(), this.filteredItems, VALUES);
- }
-
- @Override
- protected void collectionCleared(CollectionClearEvent event) {
- this.clearCollection(this.filteredItems, VALUES);
- }
-
- @Override
- protected void collectionChanged(CollectionChangeEvent event) {
- this.rebuildFilteredItems();
- }
-
-
- // ********** miscellaneous **********
-
- /**
- * Change the filter and rebuild the collection.
- */
- public void setFilter(Filter<E> filter) {
- this.filter = filter;
- this.rebuildFilteredItems();
- }
-
- /**
- * Return an iterable that filters the specified iterable.
- */
- protected Iterable<E> filter(Iterable<? extends E> items) {
- return new FilteringIterable<E>(items, this.filter);
- }
-
- /**
- * Synchronize our cache with the wrapped collection.
- */
- protected void rebuildFilteredItems() {
- this.filteredItems.clear();
- CollectionTools.addAll(this.filteredItems, this.filter(this.collectionHolder));
- this.fireCollectionChanged(VALUES, this.filteredItems);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.filteredItems);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringPropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringPropertyValueModel.java
deleted file mode 100644
index 5fb549409c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringPropertyValueModel.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * A <code>FilteringPropertyValueModel</code> wraps another
- * {@link PropertyValueModel} and uses a {@link Filter}
- * to determine when the wrapped value is to be returned by calls
- * to {@link #getValue()}.
- * <p>
- * One, possibly undesirable, side-effect of using this value model is that
- * it must return <em>something</em> as the value. The default behavior is
- * to return <code>null</code> whenever the wrapped value is not "accepted",
- * which can be configured and/or overridden ({@link #getDefaultValue()}).
- *
- * @param <V> the type of the model's <em>filtered</em> value
- * @see Filter
- */
-public class FilteringPropertyValueModel<V>
- extends PropertyValueModelWrapper<V>
- implements PropertyValueModel<V>
-{
- /**
- * The model returns any wrapped value accepted by this filter and returns
- * the {@link #defaultValue} in place of any wrapped value rejected by this
- * filter.
- */
- protected final Filter<V> filter;
-
- /**
- * The value returned by the model if the wrapped value is reject by the
- * {@link #filter}.
- */
- protected final V defaultValue;
-
-
- // ********** constructors **********
-
- /**
- * Construct a filtering property value model with the specified nested
- * property value model and filter.
- * The default value will be <code>null</code>.
- */
- public FilteringPropertyValueModel(PropertyValueModel<? extends V> valueModel, Filter<V> filter) {
- this(valueModel, filter, null);
- }
-
- /**
- * Construct a filtering property value model with the specified nested
- * property value model, filter, and default value.
- */
- public FilteringPropertyValueModel(PropertyValueModel<? extends V> valueModel, Filter<V> filter, V defaultValue) {
- super(valueModel);
- if (filter == null) {
- throw new NullPointerException();
- }
- this.filter = filter;
- this.defaultValue = defaultValue;
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- public V getValue() {
- return this.filterValue(this.valueModel.getValue());
- }
-
-
- // ********** PropertyValueModelWrapper implementation **********
-
- @Override
- protected void wrappedValueChanged(V oldValue, V newValue) {
- // filter the values before propagating the change event
- this.firePropertyChanged(VALUE, this.filterValue(oldValue), this.filterValue(newValue));
- }
-
-
- // ********** queries **********
-
- /**
- * If the specified value is "accepted" simply return it,
- * otherwise return the default value.
- */
- protected V filterValue(V value) {
- return this.filter.accept(value) ? value : this.getDefaultValue();
- }
-
- /**
- * Return the object that should be returned if
- * the nested value was rejected by the filter.
- * The default is <code>null</code>.
- */
- protected V getDefaultValue() {
- return this.defaultValue;
- }
-
- /**
- * Print the filtered value.
- */
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getValue());
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringWritablePropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringWritablePropertyValueModel.java
deleted file mode 100644
index 4a3c040eb7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/FilteringWritablePropertyValueModel.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * A <code>FilteringWritablePropertyValueModel</code> wraps another
- * {@link ModifiablePropertyValueModel} and uses a pair of {@link Filter}s
- * to determine when the wrapped value is to be returned by calls
- * to {@link #getValue()} and modified by calls to
- * {@link #setValue(Object) setValue(V)}.
- * <p>
- * One, possibly undesirable, side-effect of using this value model is that
- * it must return <em>something</em> as the value. The default behavior is
- * to return <code>null</code> whenever the wrapped value is not "accepted",
- * which can be configured and/or overridden
- * ({@link FilteringPropertyValueModel#getDefaultValue() getDefaultValue()}).
- * <p>
- * Another, possibly undesirable, side-effect of using this value model is that
- * it will not fire an event if a new value is not "accepted", even if it is
- * different than the current value.
- * <p>
- * Similarly, if an incoming value is not "reverse accepted", <em>nothing</em>
- * will passed through to the wrapped value model, not even <code>null</code>.
- *
- * @param <V> the type of the model's <em>filtered</em> value
- * @see Filter
- */
-public class FilteringWritablePropertyValueModel<V>
- extends FilteringPropertyValueModel<V>
- implements ModifiablePropertyValueModel<V>
-{
- /**
- * The model sets the wrapped value to any value accepted by this filter
- * and does nothing with any value rejected by this filter.
- */
- protected final Filter<V> setFilter;
-
-
- // ********** constructors **********
-
- /**
- * Construct a filtering property value model with the specified nested
- * property value model, <em>get</em> filter, and <em>set</em> filter.
- * The default value will be <code>null</code>.
- */
- public FilteringWritablePropertyValueModel(ModifiablePropertyValueModel<V> valueModel, Filter<V> getFilter, Filter<V> setFilter) {
- this(valueModel, getFilter, setFilter, null);
- }
-
- /**
- * Construct a filtering property value model with the specified nested
- * property value model, <em>get</em> filter, <em>set</em> filter,
- * and default value.
- */
- public FilteringWritablePropertyValueModel(ModifiablePropertyValueModel<V> valueModel, Filter<V> getFilter, Filter<V> setFilter, V defaultValue) {
- super(valueModel, getFilter, defaultValue);
- if (setFilter == null) {
- throw new NullPointerException();
- }
- this.setFilter = setFilter;
- }
-
-
- // ********** WritablePropertyValueModel implementation **********
-
- public void setValue(V value) {
- if (this.setFilter.accept(value)) {
- this.getValueModel().setValue(value);
- }
- }
-
- /**
- * Our constructor accepts only a {@link ModifiablePropertyValueModel}{@code<T>}.
- */
- @SuppressWarnings("unchecked")
- protected ModifiablePropertyValueModel<V> getValueModel() {
- return (ModifiablePropertyValueModel<V>) this.valueModel;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemAspectListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemAspectListValueModelAdapter.java
deleted file mode 100644
index eff8183982..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemAspectListValueModelAdapter.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.EventObject;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.SimpleIntReference;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * Abstract list value model that provides behavior for wrapping a {@link ListValueModel}
- * (or {@link CollectionValueModel}) and listening for changes to aspects of the
- * <em>items</em> held by the list (or collection). Changes to the actual list
- * (or collection) are also monitored.
- *
- * This is useful if you have a collection of items that can be modified by adding
- * or removing items or the items themselves might change in a fashion that
- * might change the list or collection's external appearance.
- *
- * Subclasses need to override two methods:<ul>
- * <li>{@link #engageItem_(Model)}<p>
- * begin listening to the appropriate aspect of the specified item and call
- * {@link #itemAspectChanged(EventObject)} whenever the aspect changes
- * <li>{@link #disengageItem_(Model)}<p>
- * stop listening to the appropriate aspect of the specified item
- * </ul>
- */
-public abstract class ItemAspectListValueModelAdapter<E>
- extends ListValueModelWrapper<E>
- implements ListValueModel<E>
-{
-
- /**
- * Maintain a counter for each of the items in the
- * wrapped list holder we are listening to.
- */
- protected final IdentityHashMap<E, SimpleIntReference> counters;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the list holder is required.
- */
- protected ItemAspectListValueModelAdapter(ListValueModel<? extends E> listHolder) {
- super(listHolder);
- this.counters = new IdentityHashMap<E, SimpleIntReference>();
- }
-
- /**
- * Constructor - the collection holder is required.
- */
- protected ItemAspectListValueModelAdapter(CollectionValueModel<? extends E> collectionHolder) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder));
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E> listIterator() {
- return new ReadOnlyListIterator<E>(this.listHolder.listIterator());
- }
-
- public E get(int index) {
- return this.listHolder.get(index);
- }
-
- public int size() {
- return this.listHolder.size();
- }
-
- public Object[] toArray() {
- return this.listHolder.toArray();
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the list holder and the items in the list.
- */
- @Override
- protected void engageModel() {
- super.engageModel();
- this.engageAllItems();
- }
-
- protected void engageAllItems() {
- this.engageItems(this.listHolder);
- }
-
- protected void engageItems(Iterable<? extends E> items) {
- for (E item : items) {
- this.engageItem(item);
- }
- }
-
- protected void engageItem(E item) {
- // listen to each item only once
- SimpleIntReference counter = this.counters.get(item);
- if (counter == null) {
- counter = new SimpleIntReference();
- this.counters.put(item, counter);
- this.engageItem_((Model) item);
- }
- counter.increment();
- }
-
- /**
- * Start listening to the specified item.
- */
- protected abstract void engageItem_(Model item);
-
- /**
- * Stop listening to the list holder and the items in the list.
- */
- @Override
- protected void disengageModel() {
- this.disengageAllItems();
- super.disengageModel();
- }
-
- protected void disengageAllItems() {
- this.disengageItems(this.listHolder);
- }
-
- protected void disengageItems(Iterable<? extends E> items) {
- for (E item : items) {
- this.disengageItem(item);
- }
- }
-
- protected void disengageItem(E item) {
- // stop listening to each item only once
- SimpleIntReference counter = this.counters.get(item);
- if (counter == null) {
- // something is wrong if this happens... ~bjv
- throw new IllegalStateException("missing counter: " + item); //$NON-NLS-1$
- }
- if (counter.decrement() == 0) {
- this.counters.remove(item);
- this.disengageItem_((Model) item);
- }
- }
-
- /**
- * Stop listening to the specified item.
- */
- protected abstract void disengageItem_(Model item);
-
- @Override
- public void toString(StringBuilder sb) {
- StringTools.append(sb, this);
- }
-
-
- // ********** list change support **********
-
- /**
- * Items were added to the wrapped list holder.
- * Forward the event and begin listening to the added items.
- */
- @Override
- protected void itemsAdded(ListAddEvent event) {
- // re-fire event with the wrapper as the source
- this.fireItemsAdded(event.clone(this, LIST_VALUES));
- this.engageItems(this.getItems(event));
- }
-
- /**
- * Items were removed from the wrapped list holder.
- * Stop listening to the removed items and forward the event.
- */
- @Override
- protected void itemsRemoved(ListRemoveEvent event) {
- this.disengageItems(this.getItems(event));
- // re-fire event with the wrapper as the source
- this.fireItemsRemoved(event.clone(this, LIST_VALUES));
- }
-
- /**
- * Items were replaced in the wrapped list holder.
- * Stop listening to the removed items, forward the event,
- * and begin listening to the added items.
- */
- @Override
- protected void itemsReplaced(ListReplaceEvent event) {
- this.disengageItems(this.getOldItems(event));
- // re-fire event with the wrapper as the source
- this.fireItemsReplaced(event.clone(this, LIST_VALUES));
- this.engageItems(this.getNewItems(event));
- }
-
- /**
- * Items were moved in the wrapped list holder.
- * No need to change any listeners; just forward the event.
- */
- @Override
- protected void itemsMoved(ListMoveEvent event) {
- // re-fire event with the wrapper as the source
- this.fireItemsMoved(event.clone(this, LIST_VALUES));
- }
-
- /**
- * The wrapped list holder was cleared.
- * Stop listening to the removed items and forward the event.
- */
- @Override
- protected void listCleared(ListClearEvent event) {
- // we should only need to disengage each item once...
- // make a copy to prevent a ConcurrentModificationException
- Collection<E> keys = new ArrayList<E>(this.counters.keySet());
- this.disengageItems(keys);
- this.counters.clear();
- // re-fire event with the wrapper as the source
- this.fireListCleared(LIST_VALUES);
- }
-
- /**
- * The wrapped list holder has changed in some dramatic fashion.
- * Reconfigure our listeners and forward the event.
- */
- @Override
- protected void listChanged(ListChangeEvent event) {
- // we should only need to disengage each item once...
- // make a copy to prevent a ConcurrentModificationException
- Collection<E> keys = new ArrayList<E>(this.counters.keySet());
- this.disengageItems(keys);
- this.counters.clear();
- // re-fire event with the wrapper as the source
- this.fireListChanged(event.clone(this));
- this.engageAllItems();
- }
-
-
- // ********** item change support **********
-
- /**
- * The specified item has a bound property that has changed.
- * Notify listeners of the change. The listeners will have to determine
- * whether the item aspect change is significant.
- */
- protected void itemAspectChanged(@SuppressWarnings("unused") EventObject event) {
- this.fireListChanged(LIST_VALUES, CollectionTools.list(this.listHolder, this.listHolder.size()));
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemChangeListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemChangeListValueModelAdapter.java
deleted file mode 100644
index fd54e605fd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemChangeListValueModelAdapter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.AbstractChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * Extend {@link ItemAspectListValueModelAdapter} to listen to all of the changes
- * of each item in the wrapped list model.
- */
-public class ItemChangeListValueModelAdapter<E>
- extends ItemAspectListValueModelAdapter<E>
-{
- /** Listener that listens to all the items in the list. */
- protected final ChangeListener itemChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified items.
- */
- public ItemChangeListValueModelAdapter(ListValueModel<E> listHolder) {
- super(listHolder);
- this.itemChangeListener = this.buildItemChangeListener();
- }
-
-
- // ********** initialization **********
-
- protected ChangeListener buildItemChangeListener() {
- return new ItemChangeListener();
- }
-
- protected class ItemChangeListener
- extends AbstractChangeListener
- {
- @Override
- protected void modelChanged(ChangeEvent event) {
- ItemChangeListValueModelAdapter.this.itemAspectChanged(event);
- }
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void engageItem_(Model item) {
- item.addChangeListener(this.itemChangeListener);
- }
-
- @Override
- protected void disengageItem_(Model item) {
- item.removeChangeListener(this.itemChangeListener);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemCollectionListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemCollectionListValueModelAdapter.java
deleted file mode 100644
index 8079739d76..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemCollectionListValueModelAdapter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * Extend {@link ItemAspectListValueModelAdapter} to listen to one or more collection
- * aspects of each item in the wrapped list model.
- */
-public class ItemCollectionListValueModelAdapter<E>
- extends ItemAspectListValueModelAdapter<E>
-{
-
- /** The names of the items' collections that we listen to. */
- protected final String[] collectionNames;
-
- /** Listener that listens to all the items in the list. */
- protected final CollectionChangeListener itemCollectionListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified item Collections.
- */
- public ItemCollectionListValueModelAdapter(ListValueModel<E> listHolder, String... collectionNames) {
- super(listHolder);
- this.collectionNames = collectionNames;
- this.itemCollectionListener = this.buildItemCollectionListener();
- }
-
- /**
- * Construct an adapter for the specified item Collections.
- */
- public ItemCollectionListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... collectionNames) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder), collectionNames);
- }
-
-
- // ********** initialization **********
-
- /**
- * All we really care about is the fact that a Collection aspect has
- * changed. Do the same thing no matter which event occurs.
- */
- protected CollectionChangeListener buildItemCollectionListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent event) {
- ItemCollectionListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void itemsRemoved(CollectionRemoveEvent event) {
- ItemCollectionListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void collectionCleared(CollectionClearEvent event) {
- ItemCollectionListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- ItemCollectionListValueModelAdapter.this.itemAspectChanged(event);
- }
- @Override
- public String toString() {
- return "item collection listener: " + Arrays.asList(ItemCollectionListValueModelAdapter.this.collectionNames); //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void engageItem_(Model item) {
- for (String collectionName : this.collectionNames) {
- item.addCollectionChangeListener(collectionName, this.itemCollectionListener);
- }
- }
-
- @Override
- protected void disengageItem_(Model item) {
- for (String collectionName : this.collectionNames) {
- item.removeCollectionChangeListener(collectionName, this.itemCollectionListener);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemListListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemListListValueModelAdapter.java
deleted file mode 100644
index 79cac2cdcc..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemListListValueModelAdapter.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * Extend {@link ItemAspectListValueModelAdapter} to listen to one or more list
- * aspects of each item in the wrapped list model.
- */
-public class ItemListListValueModelAdapter<E>
- extends ItemAspectListValueModelAdapter<E>
-{
-
- /** The names of the subject's lists that we listen to. */
- protected final String[] listNames;
-
- /** Listener that listens to all the items in the list. */
- protected final ListChangeListener itemListListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified item List aspects.
- */
- public ItemListListValueModelAdapter(ListValueModel<E> listHolder, String... listNames) {
- super(listHolder);
- this.listNames = listNames;
- this.itemListListener = this.buildItemListListener();
- }
-
- /**
- * Construct an adapter for the specified item List aspects.
- */
- public ItemListListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... listNames) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder), listNames);
- }
-
-
- // ********** initialization **********
-
- /**
- * All we really care about is the fact that the List aspect has
- * changed. Do the same thing no matter which event occurs.
- */
- protected ListChangeListener buildItemListListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void itemsRemoved(ListRemoveEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void itemsReplaced(ListReplaceEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void itemsMoved(ListMoveEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void listCleared(ListClearEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void listChanged(ListChangeEvent event) {
- ItemListListValueModelAdapter.this.itemAspectChanged(event);
- }
- @Override
- public String toString() {
- return "item list listener: " + Arrays.asList(ItemListListValueModelAdapter.this.listNames); //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void engageItem_(Model item) {
- for (String listName : this.listNames) {
- item.addListChangeListener(listName, this.itemListListener);
- }
- }
-
- @Override
- protected void disengageItem_(Model item) {
- for (String listName : this.listNames) {
- item.removeListChangeListener(listName, this.itemListListener);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemPropertyListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemPropertyListValueModelAdapter.java
deleted file mode 100644
index 1c2808c34d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemPropertyListValueModelAdapter.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Arrays;
-import java.util.EventListener;
-import java.util.EventObject;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * Extend {@link ItemAspectListValueModelAdapter} to listen to one or more
- * properties of each item in the wrapped list model.
- */
-public class ItemPropertyListValueModelAdapter<E>
- extends ItemAspectListValueModelAdapter<E>
-{
-
- /** The names of the items' properties that we listen to. */
- protected final String[] propertyNames;
-
- /** Listener that listens to all the items in the list. */
- protected final PropertyChangeListener itemPropertyListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified item properties.
- */
- public ItemPropertyListValueModelAdapter(ListValueModel<E> listHolder, String... propertyNames) {
- super(listHolder);
- this.propertyNames = propertyNames;
- this.itemPropertyListener = this.buildItemPropertyListener();
- }
-
- /**
- * Construct an adapter for the specified item properties.
- */
- public ItemPropertyListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... propertyNames) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder), propertyNames);
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildItemPropertyListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- ItemPropertyListValueModelAdapter.this.itemAspectChanged(event);
- }
- @Override
- public String toString() {
- return "item property listener: " + Arrays.asList(ItemPropertyListValueModelAdapter.this.propertyNames); //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void engageItem_(Model item) {
- for (String propertyName : this.propertyNames) {
- item.addPropertyChangeListener(propertyName, this.itemPropertyListener);
- }
- }
-
- @Override
- protected void disengageItem_(Model item) {
- for (String propertyName : this.propertyNames) {
- item.removePropertyChangeListener(propertyName, this.itemPropertyListener);
- }
- }
-
- /**
- * bug 342171
- * Override to just fire an itemReplaced event instead of a listChanged event.
- * An aspect of the item has changed, so no reason to say that the entire list has changed.
- * Added a LocalChangeSupport so that I can fire a ListReplacedEvent for an old list
- * and new list containing the same item.
- */
- @Override
- protected void itemAspectChanged(EventObject event) {
- Object item = event.getSource();
- this.getChangeSupport().fireItemsReplaced(
- new ListReplaceEvent(this, LIST_VALUES, CollectionTools.indexOf(this.listHolder, item), item, item));
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new LocalChangeSupport(this, ListChangeListener.class, ListValueModel.LIST_VALUES);
- }
-
- private class LocalChangeSupport extends SingleAspectChangeSupport {
- public LocalChangeSupport(Model source, Class<? extends EventListener> validListenerClass, String validAspectName) {
- super(source, validListenerClass, validAspectName);
- }
- @Override
- public boolean fireItemsReplaced(ListReplaceEvent event) {
- this.check(LIST_CHANGE_LISTENER_CLASS, event.getListName());
- if (event.getItemsSize() != 0) {
- this.fireItemsReplaced_(event);
- return true;
- }
- return false;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemStateListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemStateListValueModelAdapter.java
deleted file mode 100644
index b4dc5ee61d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemStateListValueModelAdapter.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * Extend {@link ItemAspectListValueModelAdapter} to listen to the
- * "state" of each item in the wrapped list model.
- */
-public class ItemStateListValueModelAdapter<E>
- extends ItemAspectListValueModelAdapter<E>
-{
- /** Listener that listens to all the items in the list. */
- protected final StateChangeListener itemStateListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the item state.
- */
- public ItemStateListValueModelAdapter(ListValueModel<E> listHolder) {
- super(listHolder);
- this.itemStateListener = this.buildItemStateListener();
- }
-
- /**
- * Construct an adapter for the item state.
- */
- public ItemStateListValueModelAdapter(CollectionValueModel<E> collectionHolder) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder));
- }
-
-
- // ********** initialization **********
-
- protected StateChangeListener buildItemStateListener() {
- return new StateChangeListener() {
- public void stateChanged(StateChangeEvent event) {
- ItemStateListValueModelAdapter.this.itemAspectChanged(event);
- }
- @Override
- public String toString() {
- return "item state listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void engageItem_(Model item) {
- item.addStateChangeListener(this.itemStateListener);
- }
-
- @Override
- protected void disengageItem_(Model item) {
- item.removeStateChangeListener(this.itemStateListener);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemTreeListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemTreeListValueModelAdapter.java
deleted file mode 100644
index 5ae5a968bd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ItemTreeListValueModelAdapter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.TreeChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * Extend {@link ItemAspectListValueModelAdapter} to listen to one or more tree
- * aspects of each item in the wrapped list model.
- */
-public class ItemTreeListValueModelAdapter<E>
- extends ItemAspectListValueModelAdapter<E>
-{
-
- /** The names of the items' tree that we listen to. */
- protected final String[] treeNames;
-
- /** Listener that listens to all the items in the list. */
- protected final TreeChangeListener itemTreeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified item trees.
- */
- public ItemTreeListValueModelAdapter(ListValueModel<E> listHolder, String... treeNames) {
- super(listHolder);
- this.treeNames = treeNames;
- this.itemTreeListener = this.buildItemTreeListener();
- }
-
- /**
- * Construct an adapter for the specified item trees.
- */
- public ItemTreeListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... treeNames) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder), treeNames);
- }
-
-
- // ********** initialization **********
-
- /**
- * All we really care about is the fact that a tree aspect has
- * changed. Do the same thing no matter which event occurs.
- */
- protected TreeChangeListener buildItemTreeListener() {
- return new TreeChangeListener() {
- public void nodeAdded(TreeAddEvent event) {
- ItemTreeListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void nodeRemoved(TreeRemoveEvent event) {
- ItemTreeListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void treeCleared(TreeClearEvent event) {
- ItemTreeListValueModelAdapter.this.itemAspectChanged(event);
- }
- public void treeChanged(TreeChangeEvent event) {
- ItemTreeListValueModelAdapter.this.itemAspectChanged(event);
- }
- @Override
- public String toString() {
- return "item tree listener: " + Arrays.asList(ItemTreeListValueModelAdapter.this.treeNames); //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void engageItem_(Model item) {
- for (String treeName : this.treeNames) {
- item.addTreeChangeListener(treeName, this.itemTreeListener);
- }
- }
-
- @Override
- protected void disengageItem_(Model item) {
- for (String treeName : this.treeNames) {
- item.removeTreeChangeListener(treeName, this.itemTreeListener);
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListAspectAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListAspectAdapter.java
deleted file mode 100644
index 495e940419..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListAspectAdapter.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Collection;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This extension of {@link AspectListValueModelAdapter} provides
- * basic list change support.
- * This converts a set of one or more lists into
- * a single {@link #LIST_VALUES} list.
- * <p>
- * The typical subclass will override the following methods (see the descriptions
- * in {@link AspectListValueModelAdapter}):<ul>
- * <li>{@link #listIterator_()}
- * <li>{@link #get(int)}
- * <li>{@link #size_()}
- * <li>{@link #toArray_()}
- * <li>{@link #listIterator()}
- * <li>{@link #size()}
- * <li>{@link #toArray()}
- * </ul>
- *
- * @param <S> the type of the adapter's subject
- * @param <E> the type of the adapter's list's elements
- */
-public abstract class ListAspectAdapter<S extends Model, E>
- extends AspectListValueModelAdapter<S, E>
-{
- /**
- * The name of the subject's lists that we use for the value.
- */
- protected final String[] aspectNames;
- protected static final String[] EMPTY_ASPECT_NAMES = new String[0];
-
- /** A listener that listens to the subject's list aspects. */
- protected final ListChangeListener aspectChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a list aspect adapter for the specified subject
- * and list aspect.
- */
- protected ListAspectAdapter(String aspectName, S subject) {
- this(new String[] {aspectName}, subject);
- }
-
- /**
- * Construct a list aspect adapter for the specified subject
- * and list aspects.
- */
- protected ListAspectAdapter(String[] aspectNames, S subject) {
- this(new StaticPropertyValueModel<S>(subject), aspectNames);
- }
-
- /**
- * Construct a list aspect adapter for the specified subject holder
- * and lists.
- */
- protected ListAspectAdapter(PropertyValueModel<? extends S> subjectModel, String... aspectNames) {
- super(subjectModel);
- this.aspectNames = aspectNames;
- this.aspectChangeListener = this.buildAspectChangeListener();
- }
-
- /**
- * Construct a list aspect adapter for the specified subject holder
- * and lists.
- */
- protected ListAspectAdapter(PropertyValueModel<? extends S> subjectModel, Collection<String> aspectNames) {
- this(subjectModel, aspectNames.toArray(new String[aspectNames.size()]));
- }
-
- /**
- * Construct a list aspect adapter for an "unchanging" list in
- * the specified subject. This is useful for a list aspect that does not
- * change for a particular subject; but the subject will change, resulting in
- * a new list.
- */
- protected ListAspectAdapter(PropertyValueModel<? extends S> subjectModel) {
- this(subjectModel, EMPTY_ASPECT_NAMES);
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildAspectChangeListener() {
- return new AspectChangeListener();
- }
-
- /**
- * Transform the subject's list change events into {@link #LIST_VALUES}
- * list change events
- */
- protected class AspectChangeListener
- extends ListChangeAdapter
- {
- @Override
- public void itemsAdded(ListAddEvent event) {
- ListAspectAdapter.this.aspectItemsAdded(event);
- }
- @Override
- public void itemsRemoved(ListRemoveEvent event) {
- ListAspectAdapter.this.aspectItemsRemoved(event);
- }
- @Override
- public void itemsReplaced(ListReplaceEvent event) {
- ListAspectAdapter.this.aspectItemsReplaced(event);
- }
- @Override
- public void itemsMoved(ListMoveEvent event) {
- ListAspectAdapter.this.aspectItemsMoved(event);
- }
- @Override
- public void listCleared(ListClearEvent event) {
- ListAspectAdapter.this.aspectListCleared(event);
- }
- @Override
- public void listChanged(ListChangeEvent event) {
- ListAspectAdapter.this.aspectListChanged(event);
- }
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected void engageSubject_() {
- for (String listName : this.aspectNames) {
- this.subject.addListChangeListener(listName, this.aspectChangeListener);
- }
- }
-
- @Override
- protected void disengageSubject_() {
- for (String listName : this.aspectNames) {
- this.subject.removeListChangeListener(listName, this.aspectChangeListener);
- }
- }
-
-
- // ********** behavior **********
-
- protected void aspectItemsAdded(ListAddEvent event) {
- this.fireItemsAdded(event.clone(this, LIST_VALUES));
- }
-
- protected void aspectItemsRemoved(ListRemoveEvent event) {
- this.fireItemsRemoved(event.clone(this, LIST_VALUES));
- }
-
- protected void aspectItemsReplaced(ListReplaceEvent event) {
- this.fireItemsReplaced(event.clone(this, LIST_VALUES));
- }
-
- protected void aspectItemsMoved(ListMoveEvent event) {
- this.fireItemsMoved(event.clone(this, LIST_VALUES));
- }
-
- protected void aspectListCleared(ListClearEvent event) {
- this.fireListCleared(event.clone(this, LIST_VALUES));
- }
-
- protected void aspectListChanged(ListChangeEvent event) {
- this.fireListChanged(event.clone(this, LIST_VALUES));
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListCollectionValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListCollectionValueModelAdapter.java
deleted file mode 100644
index a99ecf83c1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListCollectionValueModelAdapter.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * An adapter that allows us to make a {@link ListValueModel} behave like
- * a read-only {@link CollectionValueModel}, sorta.
- * <p>
- * We keep an internal collection somewhat in sync with the wrapped list.
- * <p>
- * <strong>NB:</strong> Since we only listen to the wrapped list when we have
- * listeners ourselves and we can only stay in sync with the wrapped
- * list while we are listening to it, results to various methods
- * (e.g. {@link #size()}, {@link #iterator()}) will be unpredictable whenever
- * we do not have any listeners. This should not be too painful since,
- * most likely, client objects will also be listeners.
- */
-public class ListCollectionValueModelAdapter<E>
- extends AbstractCollectionValueModel
- implements CollectionValueModel<E>
-{
- /** The wrapped list value model. */
- protected final ListValueModel<? extends E> listHolder;
-
- /** A listener that forwards any events fired by the list holder. */
- protected final ListChangeListener listChangeListener;
-
- /**
- * Our internal collection, which holds the same elements as
- * the wrapped list.
- */
- // we declare this an ArrayList so we can use #clone() and #ensureCapacity(int)
- protected final ArrayList<E> collection;
-
-
- // ********** constructors **********
-
- /**
- * Wrap the specified list value model.
- */
- public ListCollectionValueModelAdapter(ListValueModel<? extends E> listHolder) {
- super();
- if (listHolder == null) {
- throw new NullPointerException();
- }
- this.listHolder = listHolder;
- this.listChangeListener = this.buildListChangeListener();
- this.collection = new ArrayList<E>();
- // postpone building the collection and listening to the underlying list
- // until we have listeners ourselves...
- }
-
-
- // ********** initialization **********
-
- /**
- * The wrapped list has changed, forward an equivalent
- * collection change event to our listeners.
- */
- protected ListChangeListener buildListChangeListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent event) {
- ListCollectionValueModelAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(ListRemoveEvent event) {
- ListCollectionValueModelAdapter.this.itemsRemoved(event);
- }
- public void itemsReplaced(ListReplaceEvent event) {
- ListCollectionValueModelAdapter.this.itemsReplaced(event);
- }
- public void itemsMoved(ListMoveEvent event) {
- ListCollectionValueModelAdapter.this.itemsMoved(event);
- }
- public void listCleared(ListClearEvent event) {
- ListCollectionValueModelAdapter.this.listCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- ListCollectionValueModelAdapter.this.listChanged(event);
- }
- @Override
- public String toString() {
- return "list change listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public Iterator<E> iterator() {
- // try to prevent backdoor modification of the list
- return new ReadOnlyIterator<E>(this.collection);
- }
-
- public int size() {
- return this.collection.size();
- }
-
-
- // ********** AbstractCollectionValueModel implementation **********
-
- @Override
- protected void engageModel() {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- // sync our collection *after* we start listening to the list model,
- // since its value might change when a listener is added
- this.buildCollection();
- }
-
- @Override
- protected void disengageModel() {
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- // clear out the collection when we are not listening to the list holder
- this.collection.clear();
- }
-
-
- // ********** behavior **********
-
- protected void itemsAdded(ListAddEvent event) {
- this.addItemsToCollection(this.getItems(event), this.collection, VALUES);
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(ListAddEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- protected void itemsRemoved(ListRemoveEvent event) {
- this.removeItemsFromCollection(this.getItems(event), this.collection, VALUES);
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(ListRemoveEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- protected void itemsReplaced(ListReplaceEvent event) {
- this.removeItemsFromCollection(this.getOldItems(event), this.collection, VALUES);
- this.addItemsToCollection(this.getNewItems(event), this.collection, VALUES);
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getOldItems(ListReplaceEvent event) {
- return (Iterable<E>) event.getOldItems();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getNewItems(ListReplaceEvent event) {
- return (Iterable<E>) event.getNewItems();
- }
-
- protected void itemsMoved(@SuppressWarnings("unused") ListMoveEvent event) {
- // do nothing? moving items in a list has no net effect on a collection...
- }
-
- protected void listCleared(@SuppressWarnings("unused") ListClearEvent event) {
- // put in empty check so we don't fire events unnecessarily
- if ( ! this.collection.isEmpty()) {
- this.collection.clear();
- this.fireCollectionCleared(VALUES);
- }
- }
-
- /**
- * synchronize our internal collection with the wrapped list
- * and fire the appropriate events
- */
- protected void listChanged(@SuppressWarnings("unused") ListChangeEvent event) {
- if (this.listHolder.size() == 0) {
- if (this.collection.isEmpty()) {
- // no change
- } else {
- this.clearCollection(this.collection, VALUES);
- }
- } else {
- if (this.collection.isEmpty()) {
- this.buildCollection();
- this.fireItemsAdded(VALUES, this.collection);
- } else {
- this.collection.clear();
- this.buildCollection();
- this.fireCollectionChanged(VALUES, this.collection);
- }
- }
- }
-
- protected void buildCollection() {
- // if the new list is empty, do nothing
- int size = this.listHolder.size();
- if (size != 0) {
- this.buildCollection(size);
- }
- }
-
- protected void buildCollection(int size) {
- this.collection.ensureCapacity(size);
- for (E each : this.listHolder) {
- this.collection.add(each);
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.collection);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListCurator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListCurator.java
deleted file mode 100644
index 60cf3e2184..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListCurator.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.EventListener;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This extension of {@link AspectAdapter} provides list change support
- * by adapting a subject's state change events to a minimum set
- * of list change events.
- *
- * @param <S> the type of the adapter's subject
- * @param <E> the type of the adapter's list's elements
- */
-public abstract class ListCurator<S extends Model, E>
- extends AspectAdapter<S, List<E>>
- implements ListValueModel<E>
-{
- /** How the list looked before the last state change */
- private final ArrayList<E> record;
-
- /** A listener that listens for the subject's state to change */
- private final StateChangeListener stateChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a curator for the specified subject.
- */
- protected ListCurator(S subject) {
- this(new StaticPropertyValueModel<S>(subject));
- }
-
- /**
- * Construct a curator for the specified subject model.
- * The subject model cannot be <code>null</code>.
- */
- protected ListCurator(PropertyValueModel<? extends S> subjectModel) {
- super(subjectModel);
- this.record = new ArrayList<E>();
- this.stateChangeListener = this.buildStateChangeListener();
- }
-
-
- // ********** initialization **********
-
- /**
- * The subject's state has changed, do inventory and report to listeners.
- */
- protected StateChangeListener buildStateChangeListener() {
- return new SubjectStateChangeListener();
- }
-
- protected class SubjectStateChangeListener
- extends StateChangeAdapter
- {
- @Override
- public void stateChanged(StateChangeEvent event) {
- ListCurator.this.submitInventoryReport();
- }
- }
-
-
- // ********** ListValueModel implementation **********
-
- public ListIterator<E> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E> listIterator() {
- return new ReadOnlyListIterator<E>(this.record);
- }
-
- /**
- * Return the item at the specified index of the subject's list aspect.
- */
- public E get(int index) {
- return this.record.get(index);
- }
-
- /**
- * Return the size of the subject's list aspect.
- */
- public int size() {
- return this.record.size();
- }
-
- /**
- * Return an array manifestation of the subject's list aspect.
- */
- public Object[] toArray() {
- return this.record.toArray();
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected List<E> getAspectValue() {
- return this.record;
- }
-
- @Override
- protected Class<? extends EventListener> getListenerClass() {
- return ListChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return LIST_VALUES;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyListChangeListeners(LIST_VALUES);
- }
-
- /**
- * The aspect has changed, notify listeners appropriately.
- */
- @Override
- protected void fireAspectChanged(List<E> oldValue, List<E> newValue) {
- this.fireListChanged(LIST_VALUES, this.record);
- }
-
- /**
- * The subject is not null - add our listener.
- */
- @Override
- protected void engageSubject_() {
- ((Model) this.subject).addStateChangeListener(this.stateChangeListener);
- // sync our list *after* we start listening to the subject,
- // since its value might change when a listener is added
- CollectionTools.addAll(this.record, this.iteratorForRecord());
- }
-
- /**
- * The subject is not null - remove our listener.
- */
- @Override
- protected void disengageSubject_() {
- ((Model) this.subject).removeStateChangeListener(this.stateChangeListener);
- // clear out the list when we are not listening to the subject
- this.record.clear();
- }
-
-
- // ********** ListCurator protocol **********
-
- /**
- * This is intended to be different from {@link ListValueModel#iterator()}.
- * It is intended to be used only when the subject changes or the
- * subject's "state" changes (as signified by a state change event).
- */
- protected abstract Iterator<E> iteratorForRecord();
-
-
- // ********** behavior **********
-
- void submitInventoryReport() {
- List<E> newRecord = CollectionTools.list(this.iteratorForRecord());
- int recordIndex = 0;
-
- // add items from the new record
- for (E newItem : newRecord) {
- this.inventoryNewItem(recordIndex, newItem);
- recordIndex++;
- }
-
- // clean out items that are no longer in the new record
- for (recordIndex = 0; recordIndex < this.record.size(); ) {
- E item = this.record.get(recordIndex);
-
- if (newRecord.contains(item)) {
- recordIndex++;
- } else {
- this.removeItemFromInventory(recordIndex, item);
- }
- }
- }
-
- private void inventoryNewItem(int recordIndex, E newItem) {
- List<E> rec = new ArrayList<E>(this.record);
-
- if ((recordIndex < rec.size()) && rec.get(recordIndex).equals(newItem)) {
- return;
- }
- if (rec.contains(newItem)) {
- this.removeItemFromInventory(recordIndex, rec.get(recordIndex));
- this.inventoryNewItem(recordIndex, newItem);
- } else {
- this.addItemToInventory(recordIndex, newItem);
- }
- }
-
- private void addItemToInventory(int index, E item) {
- this.addItemToList(index, item, this.record, LIST_VALUES);
- }
-
- private void removeItemFromInventory(int index, @SuppressWarnings("unused") E item) {
- this.removeItemFromList(index, this.record, LIST_VALUES);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.record);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListPropertyValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListPropertyValueModelAdapter.java
deleted file mode 100644
index de238160c9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListPropertyValueModelAdapter.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * a list value model, "lazily" listen to it, and convert
- * its change notifications into property value model change
- * notifications.
- * <p>
- * Subclasses must override:<ul>
- * <li>{@link #buildValue()}<p>
- * to return the current property value, as derived from the
- * current list value
- * </ul>
- * Subclasses might want to override the following methods
- * to improve performance (by not recalculating the value, if possible):<ul>
- * <li>{@link #itemsAdded(ListAddEvent event)}
- * <li>{@link #itemsRemoved(ListRemoveEvent event)}
- * <li>{@link #itemsReplaced(ListReplaceEvent event)}
- * <li>{@link #itemsMoved(ListMoveEvent event)}
- * <li>{@link #listCleared(ListClearEvent event)}
- * <li>{@link #listChanged(ListChangeEvent event)}
- * </ul>
- */
-public abstract class ListPropertyValueModelAdapter<T>
- extends AbstractPropertyValueModelAdapter<T>
-{
- /** The wrapped list value model. */
- protected final ListValueModel<?> listModel;
-
- /** A listener that allows us to sync with changes to the wrapped list model. */
- protected final ListChangeListener listListener;
-
-
- // ********** constructor/initialization **********
-
- /**
- * Construct a property value model with the specified wrapped
- * list value model.
- */
- protected ListPropertyValueModelAdapter(ListValueModel<?> listModel) {
- super();
- if (listModel == null) {
- throw new NullPointerException();
- }
- this.listModel = listModel;
- this.listListener = this.buildListListener();
- }
-
- protected ListChangeListener buildListListener() {
- return new ListListener();
- }
-
- protected class ListListener
- extends ListChangeAdapter
- {
- @Override
- public void itemsAdded(ListAddEvent event) {
- ListPropertyValueModelAdapter.this.itemsAdded(event);
- }
- @Override
- public void itemsRemoved(ListRemoveEvent event) {
- ListPropertyValueModelAdapter.this.itemsRemoved(event);
- }
- @Override
- public void itemsReplaced(ListReplaceEvent event) {
- ListPropertyValueModelAdapter.this.itemsReplaced(event);
- }
- @Override
- public void itemsMoved(ListMoveEvent event) {
- ListPropertyValueModelAdapter.this.itemsMoved(event);
- }
- @Override
- public void listCleared(ListClearEvent event) {
- ListPropertyValueModelAdapter.this.listCleared(event);
- }
- @Override
- public void listChanged(ListChangeEvent event) {
- ListPropertyValueModelAdapter.this.listChanged(event);
- }
- }
-
-
- // ********** listener **********
-
- /**
- * Start listening to the list holder.
- */
- @Override
- protected void engageModel_() {
- this.listModel.addListChangeListener(ListValueModel.LIST_VALUES, this.listListener);
- }
-
- /**
- * Stop listening to the list holder.
- */
- @Override
- protected void disengageModel_() {
- this.listModel.removeListChangeListener(ListValueModel.LIST_VALUES, this.listListener);
- }
-
-
- // ********** list change support **********
-
- /**
- * Items were added to the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected void itemsAdded(@SuppressWarnings("unused") ListAddEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * Items were removed from the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected void itemsRemoved(@SuppressWarnings("unused") ListRemoveEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * Items were replaced in the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected void itemsReplaced(@SuppressWarnings("unused") ListReplaceEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * Items were moved in the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected void itemsMoved(@SuppressWarnings("unused") ListMoveEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * The wrapped list holder was cleared;
- * propagate the change notification appropriately.
- */
- protected void listCleared(@SuppressWarnings("unused") ListClearEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-
- /**
- * The value of the wrapped list holder has changed;
- * propagate the change notification appropriately.
- */
- protected void listChanged(@SuppressWarnings("unused") ListChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListValueModelWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListValueModelWrapper.java
deleted file mode 100644
index 1e5ef8807a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ListValueModelWrapper.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * another list value model, "lazily" listen to it, and propagate
- * its change notifications. Subclasses must implement the appropriate
- * {@link ListValueModel}.
- */
-public abstract class ListValueModelWrapper<E>
- extends AbstractListValueModel
-{
- /** The wrapped list value model. */
- protected final ListValueModel<? extends E> listHolder;
-
- /** A listener that allows us to sync with changes to the wrapped list model. */
- protected final ListChangeListener listChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a list value model with the specified wrapped
- * list value model.
- */
- protected ListValueModelWrapper(ListValueModel<? extends E> listHolder) {
- super();
- if (listHolder == null) {
- throw new NullPointerException();
- }
- this.listHolder = listHolder;
- this.listChangeListener = this.buildListChangeListener();
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildListChangeListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent event) {
- ListValueModelWrapper.this.itemsAdded(event);
- }
- public void itemsRemoved(ListRemoveEvent event) {
- ListValueModelWrapper.this.itemsRemoved(event);
- }
- public void itemsReplaced(ListReplaceEvent event) {
- ListValueModelWrapper.this.itemsReplaced(event);
- }
- public void itemsMoved(ListMoveEvent event) {
- ListValueModelWrapper.this.itemsMoved(event);
- }
- public void listCleared(ListClearEvent event) {
- ListValueModelWrapper.this.listCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- ListValueModelWrapper.this.listChanged(event);
- }
- @Override
- public String toString() {
- return "list change listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the list holder.
- */
- @Override
- protected void engageModel() {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
- /**
- * Stop listening to the list holder.
- */
- @Override
- protected void disengageModel() {
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(ListAddEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getItems(ListRemoveEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getNewItems(ListReplaceEvent event) {
- return (Iterable<E>) event.getNewItems();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<E> getOldItems(ListReplaceEvent event) {
- return (Iterable<E>) event.getOldItems();
- }
-
-
- // ********** list change support **********
-
- /**
- * Items were added to the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsAdded(ListAddEvent event);
-
- /**
- * Items were removed from the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsRemoved(ListRemoveEvent event);
-
- /**
- * Items were replaced in the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsReplaced(ListReplaceEvent event);
-
- /**
- * Items were moved in the wrapped list holder;
- * propagate the change notification appropriately.
- */
- protected abstract void itemsMoved(ListMoveEvent event);
-
- /**
- * The wrapped list holder was cleared;
- * propagate the change notification appropriately.
- */
- protected abstract void listCleared(ListClearEvent event);
-
- /**
- * The value of the wrapped list holder has changed;
- * propagate the change notification appropriately.
- */
- protected abstract void listChanged(ListChangeEvent event);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyCollectionValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyCollectionValueModelAdapter.java
deleted file mode 100644
index 694a681933..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyCollectionValueModelAdapter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * An adapter that allows us to make a {@link ModifiablePropertyValueModel} behave like
- * a single-element {@link ModifiableCollectionValueModel}, sorta.
- * <p>
- * If the property's value is <code>null</code>, an empty iterator is returned
- * (i.e. you can't have a collection with a <code>null</code> element).
- * Also, only a single-element collection can be written to the adapter.
- */
-public class ModifiablePropertyCollectionValueModelAdapter<E>
- extends PropertyCollectionValueModelAdapter<E>
- implements ModifiableCollectionValueModel<E>
-{
- // ********** constructor **********
-
- /**
- * Convert the specified writable property value model to a writable
- * collection value model.
- */
- public ModifiablePropertyCollectionValueModelAdapter(ModifiablePropertyValueModel<E> valueHolder) {
- super(valueHolder);
- }
-
-
- // ********** WritableCollectionValueModel implementation **********
-
- public void setValues(Iterable<E> values) {
- Iterator<E> stream = values.iterator();
- if (stream.hasNext()) {
- E newValue = stream.next();
- if (stream.hasNext()) {
- throw new IllegalArgumentException("non-singleton collection: " + values); //$NON-NLS-1$
- }
- this.getValueHolder().setValue(newValue);
- } else {
- this.getValueHolder().setValue(null);
- }
- }
-
- // our constructor takes only writable property value models
- @SuppressWarnings("unchecked")
- protected ModifiablePropertyValueModel<E> getValueHolder() {
- return (ModifiablePropertyValueModel<E>) this.valueHolder;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyListValueModelAdapter.java
deleted file mode 100644
index 96902062fe..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ModifiablePropertyListValueModelAdapter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.model.value.ModifiableListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * An adapter that allows us to make a {@link ModifiablePropertyValueModel} behave like
- * a single-element {@link ModifiableListValueModel}, sorta.
- * <p>
- * If the property's value is <code>null</code>, an empty iterator is returned
- * (i.e. you can't have a list with a <code>null</code> element).
- * Also, only a single-element list can be written to the adapter.
- */
-public class ModifiablePropertyListValueModelAdapter<E>
- extends PropertyListValueModelAdapter<E>
- implements ModifiableListValueModel<E>
-{
- // ********** constructor **********
-
- /**
- * Convert the specified writable property value model to a writable
- * collection value model.
- */
- public ModifiablePropertyListValueModelAdapter(ModifiablePropertyValueModel<E> valueHolder) {
- super(valueHolder);
- }
-
-
- // ********** WritableListValueModel implementation **********
-
- public void setListValues(Iterable<E> listValues) {
- Iterator<E> stream = listValues.iterator();
- if (stream.hasNext()) {
- E newValue = stream.next();
- if (stream.hasNext()) {
- throw new IllegalArgumentException("non-singleton list: " + listValues); //$NON-NLS-1$
- }
- this.getValueHolder().setValue(newValue);
- } else {
- this.getValueHolder().setValue(null);
- }
- }
-
- // our constructor takes only writable property value models
- @SuppressWarnings("unchecked")
- protected ModifiablePropertyValueModel<E> getValueHolder() {
- return (ModifiablePropertyValueModel<E>) this.valueHolder;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullCollectionValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullCollectionValueModel.java
deleted file mode 100644
index ba1061b96c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullCollectionValueModel.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-
-/**
- * A read-only collection value model for when you
- * don't need to support a collection. In particular, this
- * is useful for the leaf nodes of a tree that never have
- * children.
- * <p>
- * We don't use a singleton because we hold on to listeners.
- */
-public final class NullCollectionValueModel<E>
- extends AbstractModel
- implements CollectionValueModel<E>
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * Default constructor.
- */
- public NullCollectionValueModel() {
- super();
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public int size() {
- return 0;
- }
-
- public Iterator<E> iterator() {
- return EmptyIterator.instance();
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullListValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullListValueModel.java
deleted file mode 100644
index 78801cce30..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullListValueModel.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * An empty list value model for when you don't
- * need to support a list.
- * <p>
- * We don't use a singleton because we hold on to listeners.
- */
-public final class NullListValueModel<E>
- extends AbstractModel
- implements ListValueModel<E>
-{
- private static final Object[] EMPTY_ARRAY = new Object[0];
- private static final long serialVersionUID = 1L;
-
- /**
- * Default constructor.
- */
- public NullListValueModel() {
- super();
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return EmptyIterator.instance();
- }
-
- public ListIterator<E> listIterator() {
- return EmptyListIterator.instance();
- }
-
- public int size() {
- return 0;
- }
-
- public E get(int index) {
- throw new IndexOutOfBoundsException("Index: " + index + ", Size: 0"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public Object[] toArray() {
- return EMPTY_ARRAY;
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullPropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullPropertyValueModel.java
deleted file mode 100644
index 1183325ea9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullPropertyValueModel.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * A property value model for when you
- * don't need to support a value.
- * <p>
- * We don't use a singleton because we hold on to listeners.
- */
-public final class NullPropertyValueModel<T>
- extends AbstractModel
- implements PropertyValueModel<T>, Serializable
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * Default constructor.
- */
- public NullPropertyValueModel() {
- super();
- }
-
- public T getValue() {
- return null;
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullTreeValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullTreeValueModel.java
deleted file mode 100644
index ad4b960b6e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/NullTreeValueModel.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.value.TreeValueModel;
-
-/**
- * A tree value model for when you
- * don't need to support any nodes.
- * <p>
- * We don't use a singleton because we hold on to listeners.
- */
-public final class NullTreeValueModel<E>
- extends AbstractModel
- implements TreeValueModel<E>
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * Default constructor.
- */
- public NullTreeValueModel() {
- super();
- }
-
-
- // ********** TreeValueModel implementation **********
-
- public Iterator<E> nodes() {
- return EmptyIterator.instance();
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyAspectAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyAspectAdapter.java
deleted file mode 100644
index f5969076a8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyAspectAdapter.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Collection;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This {@link AspectPropertyValueModelAdapter} provides basic property change support.
- * This converts a set of one or more standard properties into
- * a single {@link #VALUE} property.
- * <p>
- * The typical subclass will override the following methods (see the descriptions
- * in {@link AspectPropertyValueModelAdapter}):<ul>
- * <li>{@link #buildValue_()}
- * <li>{@link #setValue_(Object)}
- * <li>{@link #buildValue()}
- * <li>{@link #setValue(Object)}
- * </ul>
- *
- * @param <S> the type of the model's subject
- * @param <V> the type of the subject's property aspect
- */
-public abstract class PropertyAspectAdapter<S extends Model, V>
- extends AspectPropertyValueModelAdapter<S, V>
-{
- /** The name of the subject's properties that we use for the value. */
- protected final String[] aspectNames;
- protected static final String[] EMPTY_ASPECT_NAMES = new String[0];
-
- /** A listener that listens to the appropriate properties of the subject. */
- protected final PropertyChangeListener aspectChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a property aspect adapter for the specified subject
- * and property aspect.
- */
- protected PropertyAspectAdapter(String aspectName, S subject) {
- this(new String[] {aspectName}, subject);
- }
-
- /**
- * Construct a property aspect adapter for the specified subject
- * and property aspects.
- */
- protected PropertyAspectAdapter(String[] aspectNames, S subject) {
- this(new StaticPropertyValueModel<S>(subject), aspectNames);
- }
-
- /**
- * Construct a property aspect adapter for the specified subject model
- * and property aspects.
- */
- protected PropertyAspectAdapter(PropertyValueModel<? extends S> subjectModel, String... aspectNames) {
- super(subjectModel);
- this.aspectNames = aspectNames;
- this.aspectChangeListener = this.buildAspectChangeListener();
- }
-
- /**
- * Construct a property aspect adapter for the specified subject model
- * and property aspects.
- */
- protected PropertyAspectAdapter(PropertyValueModel<? extends S> subjectModel, Collection<String> aspectNames) {
- this(subjectModel, aspectNames.toArray(new String[aspectNames.size()]));
- }
-
- /**
- * Construct a property aspect adapter for an "unchanging" property aspect in
- * the specified subject. This is useful for a property aspect that does not
- * change for a particular subject; but the subject will change, resulting in
- * a new property. (A {@link TransformationPropertyValueModel} could also be
- * used in this situation.)
- */
- protected PropertyAspectAdapter(PropertyValueModel<? extends S> subjectModel) {
- this(subjectModel, EMPTY_ASPECT_NAMES);
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildAspectChangeListener() {
- return new AspectChangeListener();
- }
-
- /**
- * Transform the subject's property change events into
- * {@link #VALUE} property change events.
- */
- protected class AspectChangeListener
- extends PropertyChangeAdapter
- {
- @Override
- public void propertyChanged(PropertyChangeEvent event) {
- PropertyAspectAdapter.this.aspectChanged(event);
- }
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected void engageSubject_() {
- for (String propertyName : this.aspectNames) {
- this.subject.addPropertyChangeListener(propertyName, this.aspectChangeListener);
- }
- }
-
- @Override
- protected void disengageSubject_() {
- for (String propertyName : this.aspectNames) {
- this.subject.removePropertyChangeListener(propertyName, this.aspectChangeListener);
- }
- }
-
- protected void aspectChanged(@SuppressWarnings("unused") PropertyChangeEvent event) {
- this.aspectChanged();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyCollectionValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyCollectionValueModelAdapter.java
deleted file mode 100644
index 24af307f1c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyCollectionValueModelAdapter.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Collections;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * An adapter that allows us to make a {@link PropertyValueModel} behave like
- * a read-only, single-element {@link CollectionValueModel}, sorta.
- * <p>
- * If the property's value is null, an empty iterator is returned
- * (i.e. you can't have a collection with a <code>null</code> element).
- */
-public class PropertyCollectionValueModelAdapter<E>
- extends AbstractCollectionValueModel
- implements CollectionValueModel<E>
-{
- /** The wrapped property value model. */
- protected final PropertyValueModel<? extends E> valueHolder;
-
- /** A listener that forwards any events fired by the value holder. */
- protected final PropertyChangeListener propertyChangeListener;
-
- /** Cache the value. */
- protected E value;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Convert the specified property value model to a collection
- * value model.
- */
- public PropertyCollectionValueModelAdapter(PropertyValueModel<? extends E> valueHolder) {
- super();
- if (valueHolder == null) {
- throw new NullPointerException();
- }
- this.valueHolder = valueHolder;
- this.propertyChangeListener = this.buildPropertyChangeListener();
- this.value = null;
- // postpone building the value and listening to the underlying value
- // until we have listeners ourselves...
- }
-
- /**
- * The wrapped value has changed, forward an equivalent
- * collection change event to our listeners.
- */
- protected PropertyChangeListener buildPropertyChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- @SuppressWarnings("unchecked")
- E eventNewValue = (E) event.getNewValue();
- PropertyCollectionValueModelAdapter.this.valueChanged(eventNewValue);
- }
- @Override
- public String toString() {
- return "property change listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public Iterator<E> iterator() {
- return (this.value == null) ? EmptyIterator.<E>instance() : this.iterator_();
- }
-
- protected Iterator<E> iterator_() {
- return new SingleElementIterator<E>(this.value);
- }
-
- public int size() {
- return (this.value == null) ? 0 : 1;
- }
-
-
- // ********** AbstractCollectionValueModel implementation **********
-
- @Override
- protected void engageModel() {
- this.valueHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.propertyChangeListener);
- // sync our value *after* we start listening to the value model,
- // since its value might change when a listener is added
- this.value = this.valueHolder.getValue();
- }
-
- @Override
- protected void disengageModel() {
- this.valueHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.propertyChangeListener);
- // clear out the value when we are not listening to the value holder
- this.value = null;
- }
-
-
- // ********** behavior **********
-
- /**
- * synchronize our internal value with the wrapped value
- * and fire the appropriate events
- */
- protected void valueChanged(E newValue) {
- E oldValue = this.value;
- this.value = newValue;
- if (oldValue == null) {
- // we wouldn't get the event if the new value were null too
- this.fireItemAdded(VALUES, newValue);
- } else {
- if (newValue == null) {
- this.fireItemRemoved(VALUES, oldValue);
- } else {
- // we wouldn't get the event if the new value was the same as the old
- this.fireCollectionChanged(VALUES, Collections.singleton(newValue));
- }
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- StringTools.append(sb, this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyListValueModelAdapter.java
deleted file mode 100644
index c845d4fa5e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyListValueModelAdapter.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementListIterator;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * An adapter that allows us to make a {@link PropertyValueModel} behave like
- * a read-only, single-element {@link ListValueModel}, sorta.
- * <p>
- * If the property's value is null, an empty iterator is returned
- * (i.e. you can't have a collection with a <code>null</code> element).
- */
-public class PropertyListValueModelAdapter<E>
- extends AbstractListValueModel
- implements ListValueModel<E>
-{
- /** The wrapped property value model. */
- protected final PropertyValueModel<? extends E> valueHolder;
-
- /** A listener that forwards any events fired by the value holder. */
- protected final PropertyChangeListener propertyChangeListener;
-
- /** Cache the value. */
- protected E value;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Convert the specified property value model to a list
- * value model.
- */
- public PropertyListValueModelAdapter(PropertyValueModel<? extends E> valueHolder) {
- super();
- if (valueHolder == null) {
- throw new NullPointerException();
- }
- this.valueHolder = valueHolder;
- this.propertyChangeListener = this.buildPropertyChangeListener();
- // postpone building the value and listening to the underlying value
- // until we have listeners ourselves...
- }
-
- /**
- * The wrapped value has changed, forward an equivalent
- * list change event to our listeners.
- */
- protected PropertyChangeListener buildPropertyChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- @SuppressWarnings("unchecked")
- E eventNewValue = (E) event.getNewValue();
- PropertyListValueModelAdapter.this.valueChanged(eventNewValue);
- }
- @Override
- public String toString() {
- return "property change listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E> listIterator() {
- return (this.value == null) ?
- EmptyListIterator.<E>instance()
- :
- new SingleElementListIterator<E>(this.value);
- }
-
- public int size() {
- return (this.value == null) ? 0 : 1;
- }
-
- public E get(int index) {
- if (this.value == null) {
- throw this.buildIOOBE(index, 0);
- }
- if (index > 0) {
- throw this.buildIOOBE(index, 1);
- }
- return this.value;
- }
-
- protected static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
- public Object[] toArray() {
- return (this.value == null) ? EMPTY_OBJECT_ARRAY : new Object[] {this.value};
- }
-
-
- // ********** behavior **********
-
- protected IndexOutOfBoundsException buildIOOBE(int index, int size) {
- return new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Override
- protected void engageModel() {
- this.valueHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.propertyChangeListener);
- // sync our value *after* we start listening to the value model,
- // since its value might change when a listener is added
- this.value = this.valueHolder.getValue();
- }
-
- @Override
- protected void disengageModel() {
- this.valueHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.propertyChangeListener);
- // clear out the value when we are not listening to the value holder
- this.value = null;
- }
-
- /**
- * synchronize our internal value with the wrapped value
- * and fire the appropriate events
- */
- protected void valueChanged(E newValue) {
- E oldValue = this.value;
- this.value = newValue;
- if (oldValue == null) {
- this.fireItemAdded(LIST_VALUES, 0, newValue);
- } else {
- if (newValue == null) {
- this.fireItemRemoved(LIST_VALUES, 0, oldValue);
- } else {
- this.fireItemReplaced(LIST_VALUES, 0, newValue, oldValue);
- }
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- StringTools.append(sb, this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelWrapper.java
deleted file mode 100644
index eebc569e89..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/PropertyValueModelWrapper.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * another property value model, "lazily" listen to it, and propagate
- * its change notifications. Subclasses must implement the appropriate
- * {@link PropertyValueModel}.
- * <p>
- * Subclasses must implement one of the following methods:<ul>
- * <li>{@link #wrappedValueChanged(PropertyChangeEvent)}<p>
- * implement this method to propagate the appropriate change notification
- * <li>{@link #wrappedValueChanged(Object, Object) valueChanged(V, V)}<p>
- * implement this method to propagate the appropriate change notification
- * </ul>
- *
- * @param <V> the type of the <em>wrapped</em> model's value
- */
-public abstract class PropertyValueModelWrapper<V>
- extends AbstractPropertyValueModel
-{
- /** The wrapped property value model. Never <code>null</code>. */
- protected final PropertyValueModel<? extends V> valueModel;
-
- /** A listener that allows us to sync with changes to the wrapped value model. */
- protected final PropertyChangeListener valueListener;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct a property value model with the specified wrapped
- * property value model.
- */
- protected PropertyValueModelWrapper(PropertyValueModel<? extends V> valueModel) {
- super();
- if (valueModel == null) {
- throw new NullPointerException();
- }
- this.valueModel = valueModel;
- this.valueListener = this.buildValueListener();
- }
-
- protected PropertyChangeListener buildValueListener() {
- return new ValueListener();
- }
-
- /* CU private */ class ValueListener
- extends PropertyChangeAdapter
- {
- @Override
- public void propertyChanged(PropertyChangeEvent event) {
- PropertyValueModelWrapper.this.wrappedValueChanged(event);
- }
- }
-
-
- // ********** listen to wrapped value model **********
-
- /**
- * Begin listening to the value holder.
- */
- @Override
- protected void engageModel() {
- this.valueModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.valueListener);
- }
-
- /**
- * Stop listening to the value holder.
- */
- @Override
- protected void disengageModel() {
- this.valueModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.valueListener);
- }
-
-
- // ********** property change support **********
-
- /**
- * The value of the wrapped value model has changed;
- * propagate the change notification appropriately.
- * @see #wrappedValueChanged(Object, Object)
- */
- @SuppressWarnings("unchecked")
- protected void wrappedValueChanged(PropertyChangeEvent event) {
- this.wrappedValueChanged((V) event.getOldValue(), (V) event.getNewValue());
- }
-
- /**
- * The value of the wrapped value model has changed;
- * propagate the change notification appropriately.
- * @see #wrappedValueChanged(PropertyChangeEvent)
- */
- protected void wrappedValueChanged(@SuppressWarnings("unused") V oldValue, @SuppressWarnings("unused") V newValue) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ReadOnlyWritablePropertyValueModelWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ReadOnlyWritablePropertyValueModelWrapper.java
deleted file mode 100644
index 9c7fbc7a18..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ReadOnlyWritablePropertyValueModelWrapper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * A simple implementation of {@link ModifiablePropertyValueModel} that actually
- * ... <em>isn't</em> ... writable. It can however be used in places that require a
- * {@link ModifiablePropertyValueModel} and where the developer is sure that no
- * attempt will be made to write to it.
- */
-public class ReadOnlyWritablePropertyValueModelWrapper<T>
- extends PropertyValueModelWrapper<T>
- implements ModifiablePropertyValueModel<T>
-{
- public ReadOnlyWritablePropertyValueModelWrapper(PropertyValueModel<? extends T> valueModel) {
- super(valueModel);
- }
-
-
- public T getValue() {
- return this.valueModel.getValue();
- }
-
- public void setValue(T value) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void wrappedValueChanged(PropertyChangeEvent event) {
- this.firePropertyChanged(event.clone(this));
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getValue());
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SetCollectionValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SetCollectionValueModel.java
deleted file mode 100644
index 8fac2c1442..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SetCollectionValueModel.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * A <code>SetCollectionValueModel</code> wraps another
- * {@link CollectionValueModel} and returns the items in the collection
- * only once.
- */
-public class SetCollectionValueModel<E>
- extends CollectionValueModelWrapper<E>
- implements CollectionValueModel<E>
-{
- private final HashBag<E> bag = new HashBag<E>();
-
-
- // ********** constructors **********
-
- /**
- * Construct a collection value model with the specified wrapped
- * collection value model and a filter that simply accepts every object.
- */
- public SetCollectionValueModel(CollectionValueModel<? extends E> collectionHolder) {
- super(collectionHolder);
- }
-
- /**
- * Construct a collection value model with the specified wrapped
- * list value model and a filter that simply accepts every object.
- */
- public SetCollectionValueModel(ListValueModel<E> listHolder) {
- this(new ListCollectionValueModelAdapter<E>(listHolder));
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public Iterator<E> iterator() {
- return new ReadOnlyIterator<E>(this.bag.uniqueIterator());
- }
-
- public int size() {
- return this.bag.uniqueCount();
- }
-
-
- // ********** CollectionValueModelWrapper overrides/implementation **********
-
- @Override
- protected void engageModel() {
- super.engageModel();
- // sync our cache *after* we start listening to the nested collection,
- // since its value might change when a listener is added
- CollectionTools.addAll(this.bag, this.collectionHolder);
- }
-
- @Override
- protected void disengageModel() {
- super.disengageModel();
- // clear out the cache when we are not listening to the nested collection
- this.bag.clear();
- }
-
- @Override
- protected void itemsAdded(CollectionAddEvent event) {
- ArrayList<E> addedItems = new ArrayList<E>(event.getItemsSize());
- int uniqueCount = this.bag.uniqueCount();
- for (E item : this.getItems(event)) {
- this.bag.add(item);
- if (this.bag.uniqueCount() > uniqueCount) {
- uniqueCount = this.bag.uniqueCount();
- addedItems.add(item);
- }
- }
- this.fireItemsAdded(VALUES, addedItems);
- }
-
- @Override
- protected void itemsRemoved(CollectionRemoveEvent event) {
- ArrayList<E> removedItems = new ArrayList<E>(event.getItemsSize());
- int uniqueCount = this.bag.uniqueCount();
- for (E item : this.getItems(event)) {
- if (this.bag.remove(item)) {
- if (this.bag.uniqueCount() < uniqueCount) {
- uniqueCount = this.bag.uniqueCount();
- removedItems.add(item);
- }
- } else {
- throw new IllegalStateException("missing item: " + item); //$NON-NLS-1$
- }
- }
- this.fireItemsRemoved(VALUES, removedItems);
- }
-
- @Override
- protected void collectionCleared(CollectionClearEvent event) {
- this.clearCollection(this.bag, VALUES);
- }
-
- @Override
- protected void collectionChanged(CollectionChangeEvent event) {
- this.bag.clear();
- CollectionTools.addAll(this.bag, this.collectionHolder);
- this.fireCollectionChanged(VALUES, new HashSet<E>(this.bag));
- }
-
- @Override
- public void toString(StringBuilder sb) {
- StringTools.append(sb, this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimpleCollectionValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimpleCollectionValueModel.java
deleted file mode 100644
index b54e02d92b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimpleCollectionValueModel.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Collection;
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
-
-/**
- * Implementation of {@link ModifiableCollectionValueModel} and {@link Collection}
- * that simply holds a collection and notifies listeners of any changes.
- */
-public class SimpleCollectionValueModel<E>
- extends AbstractModel
- implements ModifiableCollectionValueModel<E>, Collection<E>
-{
- /** The collection. */
- protected final Collection<E> collection;
-
-
- // ********** constructors **********
-
- /**
- * Construct a collection value model for the specified collection.
- */
- public SimpleCollectionValueModel(Collection<E> collection) {
- super();
- if (collection == null) {
- throw new NullPointerException();
- }
- this.collection = collection;
- }
-
- /**
- * Construct a collection value model with an empty initial collection.
- */
- public SimpleCollectionValueModel() {
- this(new HashBag<E>());
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, CollectionChangeListener.class, VALUES);
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public Iterator<E> iterator() {
- return new LocalIterator<E>(this.collection.iterator());
- }
-
- public int size() {
- return this.collection.size();
- }
-
-
- // ********** WritableCollectionValueModel implementation **********
-
- /**
- * Allow the collection's elements to be replaced.
- */
- public void setValues(Iterable<E> values) {
- if (values == null) {
- throw new NullPointerException();
- }
- this.collection.clear();
- CollectionTools.addAll(this.collection, values);
- this.fireCollectionChanged(VALUES, this.collection);
- }
-
-
- // ********** Collection implementation **********
-
- public boolean isEmpty() {
- return this.collection.isEmpty();
- }
-
- public boolean contains(Object o) {
- return this.collection.contains(o);
- }
-
- public Object[] toArray() {
- return this.collection.toArray();
- }
-
- public <T extends Object> T[] toArray(T[] a) {
- return this.collection.toArray(a);
- }
-
- public boolean add(E o) {
- return this.addItemToCollection(o, this.collection, VALUES);
- }
-
- public boolean remove(Object o) {
- return this.removeItemFromCollection(o, this.collection, VALUES);
- }
-
- public boolean containsAll(Collection<?> c) {
- return this.collection.containsAll(c);
- }
-
- public boolean addAll(Collection<? extends E> c) {
- return this.addItemsToCollection(c, this.collection, VALUES);
- }
-
- public boolean removeAll(Collection<?> c) {
- return this.removeItemsFromCollection(c, this.collection, VALUES);
- }
-
- public boolean retainAll(Collection<?> c) {
- return this.retainItemsInCollection(c, this.collection, VALUES);
- }
-
- public void clear() {
- this.clearCollection(this.collection, VALUES);
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if ((o instanceof Collection<?>) && (o instanceof CollectionValueModel<?>)) {
- Collection<E> c1 = CollectionTools.collection(this.collection);
- @SuppressWarnings("unchecked")
- Collection<E> c2 = CollectionTools.collection(((Collection<E>) o).iterator());
- return c1.equals(c2);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return CollectionTools.collection(this.collection).hashCode();
- }
-
-
- // ********** miscellaneous **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.collection);
- }
-
-
- // ********** iterator **********
-
- private class LocalIterator<T> implements Iterator<T> {
- private final Iterator<T> iterator;
- private T next;
-
- LocalIterator(Iterator<T> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasNext() {
- return this.iterator.hasNext();
- }
-
- public T next() {
- return this.next = this.iterator.next();
- }
-
- @SuppressWarnings("synthetic-access")
- public void remove() {
- this.iterator.remove();
- SimpleCollectionValueModel.this.fireItemRemoved(VALUES, this.next);
- }
-
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimpleListValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimpleListValueModel.java
deleted file mode 100644
index d160c25350..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimpleListValueModel.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiableListValueModel;
-
-/**
- * Implementation of {@link ListValueModel} and {@link List} that simply holds a
- * list and notifies listeners of any changes.
- */
-public class SimpleListValueModel<E>
- extends AbstractModel
- implements ModifiableListValueModel<E>, List<E>
-{
- /** The list. */
- protected List<E> list;
-
-
- // ********** constructors **********
-
- /**
- * Construct a list value model for the specified list.
- */
- public SimpleListValueModel(List<E> list) {
- super();
- if (list == null) {
- throw new NullPointerException();
- }
- this.list = list;
- }
-
- /**
- * Construct a list value model with an empty initial list.
- */
- public SimpleListValueModel() {
- this(new ArrayList<E>());
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, ListChangeListener.class, LIST_VALUES);
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return new LocalIterator<E>(this.list.iterator());
- }
-
- public ListIterator<E> listIterator() {
- return new LocalListIterator<E>(this.list.listIterator());
- }
-
- public int size() {
- return this.list.size();
- }
-
- public E get(int index) {
- return this.list.get(index);
- }
-
-
- // ********** WritableListValueModel implementation **********
-
- /**
- * Allow the list's elements to be replaced.
- */
- public void setListValues(Iterable<E> list) {
- if (list == null) {
- throw new NullPointerException();
- }
- this.list.clear();
- CollectionTools.addAll(this.list, list);
- this.fireListChanged(LIST_VALUES, this.list);
- }
-
-
- // ********** List implementation **********
-
- public boolean isEmpty() {
- return this.list.isEmpty();
- }
-
- public boolean contains(Object o) {
- return this.list.contains(o);
- }
-
- public Object[] toArray() {
- return this.list.toArray();
- }
-
- public <T extends Object> T[] toArray(T[] a) {
- return this.list.toArray(a);
- }
-
- public boolean add(E o) {
- return this.addItemToList(o, this.list, LIST_VALUES);
- }
-
- public boolean remove(Object o) {
- return this.removeItemFromList(o, this.list, LIST_VALUES);
- }
-
- public boolean containsAll(Collection<?> c) {
- return this.list.containsAll(c);
- }
-
- public boolean addAll(Collection<? extends E> c) {
- return this.addItemsToList(c, this.list, LIST_VALUES);
- }
-
- public boolean addAll(int index, Collection<? extends E> c) {
- return this.addItemsToList(index, c, this.list, LIST_VALUES);
- }
-
- public boolean removeAll(Collection<?> c) {
- return this.removeItemsFromList(c, this.list, LIST_VALUES);
- }
-
- public boolean retainAll(Collection<?> c) {
- return this.retainItemsInList(c, this.list, LIST_VALUES);
- }
-
- public void clear() {
- this.clearList(this.list, LIST_VALUES);
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) {
- return true;
- }
- if ((o instanceof List<?>) && (o instanceof ListValueModel<?>)) {
- List<E> l1 = CollectionTools.list(this.list);
- @SuppressWarnings("unchecked")
- List<E> l2 = CollectionTools.list(((List<E>) o).iterator());
- return l1.equals(l2);
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return this.list.hashCode();
- }
-
- public E set(int index, E element) {
- return this.setItemInList(index, element, this.list, LIST_VALUES);
- }
-
- public void add(int index, E element) {
- this.addItemToList(index, element, this.list, LIST_VALUES);
- }
-
- public E remove(int index) {
- return this.removeItemFromList(index, this.list, LIST_VALUES);
- }
-
- public int indexOf(Object o) {
- return this.list.indexOf(o);
- }
-
- public int lastIndexOf(Object o) {
- return this.list.lastIndexOf(o);
- }
-
- public ListIterator<E> listIterator(int index) {
- return new LocalListIterator<E>(this.list.listIterator(index));
- }
-
- public List<E> subList(int fromIndex, int toIndex) {
- // TODO hmmm ~bjv
- throw new UnsupportedOperationException();
- }
-
-
- // ********** additional behavior **********
-
- /**
- * Move a single element.
- */
- public void move(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.list, LIST_VALUES);
- }
-
- /**
- * Move a sub-list of elements.
- */
- public void move(int targetIndex, int sourceIndex, int length) {
- this.moveItemsInList(targetIndex, sourceIndex, length, this.list, LIST_VALUES);
- }
-
- /**
- * Remove a range of elements.
- */
- public void remove(int index, int length) {
- this.removeItemsFromList(index, length, this.list, LIST_VALUES);
- }
-
- /**
- * Set a range of elements.
- */
- public void set(int index, List<E> elements) {
- this.setItemsInList(index, elements, this.list, LIST_VALUES);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.list);
- }
-
-
- // ********** iterators **********
-
- private class LocalIterator<T> implements Iterator<T> {
- private final Iterator<T> iterator;
- private int index = -1;
- private T next;
-
- LocalIterator(Iterator<T> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasNext() {
- return this.iterator.hasNext();
- }
-
- public T next() {
- this.next = this.iterator.next();
- this.index++;
- return this.next;
- }
-
- @SuppressWarnings("synthetic-access")
- public void remove() {
- this.iterator.remove();
- SimpleListValueModel.this.fireItemRemoved(LIST_VALUES, this.index, this.next);
- }
-
- }
-
- private class LocalListIterator<T> implements ListIterator<T> {
- private final ListIterator<T> iterator;
- private int last = -1;
- private int next = 0;
- private T current;
-
- LocalListIterator(ListIterator<T> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public boolean hasNext() {
- return this.iterator.hasNext();
- }
-
- public T next() {
- this.current = this.iterator.next();
- this.last = this.next++;
- return this.current;
- }
-
- public int nextIndex() {
- return this.iterator.nextIndex();
- }
-
- public boolean hasPrevious() {
- return this.iterator.hasPrevious();
- }
-
- public T previous() {
- this.current = this.iterator.previous();
- this.last = --this.next;
- return this.current;
- }
-
- public int previousIndex() {
- return this.iterator.previousIndex();
- }
-
- @SuppressWarnings("synthetic-access")
- public void set(T o) {
- this.iterator.set(o);
- SimpleListValueModel.this.fireItemReplaced(LIST_VALUES, this.last, o, this.current);
- }
-
- @SuppressWarnings("synthetic-access")
- public void add(T o) {
- this.iterator.add(o);
- SimpleListValueModel.this.fireItemAdded(LIST_VALUES, this.next, o);
- }
-
- @SuppressWarnings("synthetic-access")
- public void remove() {
- this.iterator.remove();
- SimpleListValueModel.this.fireItemRemoved(LIST_VALUES, this.last, this.current);
- }
-
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimplePropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimplePropertyValueModel.java
deleted file mode 100644
index 845898c381..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SimplePropertyValueModel.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Implementation of {@link ModifiablePropertyValueModel} that simply holds on to
- * an object, uses it as the value, and fires the appropriate event when the
- * value changes.
- *
- * @param <V> the type of the model's value
- */
-public class SimplePropertyValueModel<V>
- extends AbstractModel
- implements ModifiablePropertyValueModel<V>
-{
- /** The value. */
- protected V value;
-
-
- /**
- * Construct a property value model for the specified value.
- */
- public SimplePropertyValueModel(V value) {
- super();
- this.value = value;
- }
-
- /**
- * Construct a property value model with a value of <code>null</code>.
- */
- public SimplePropertyValueModel() {
- this(null);
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, PropertyChangeListener.class, VALUE);
- }
-
-
- public V getValue() {
- return this.value;
- }
-
- public void setValue(V value) {
- V old = this.value;
- this.value = value;
- this.firePropertyChanged(VALUE, old, value);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.value);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SortedListValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SortedListValueModelAdapter.java
deleted file mode 100644
index 3cf9d24d80..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SortedListValueModelAdapter.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.Range;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-
-/**
- * An adapter that allows us to make a {@link CollectionValueModel}
- * (or {@link org.eclipse.jpt.common.utility.model.value.ListValueModel ListValueModel})
- * behave like a {@link org.eclipse.jpt.common.utility.model.value.ListValueModel ListValueModel}
- * that keeps its contents sorted and notifies listeners appropriately.
- * <p>
- * The {@link Comparator} can be changed at any time; allowing the same
- * adapter to be used with different sort criteria (e.g. when the user
- * wants to sort a list of files first by name, then by date, then by size).
- * <p>
- * <strong>NB:</strong> Since we only listen to the wrapped collection when we have
- * listeners ourselves and we can only stay in sync with the wrapped
- * collection while we are listening to it, results to various methods
- * (e.g. {@link #size()}, {@link #get(int)}) will be
- * unpredictable whenever
- * we do not have any listeners. This should not be too painful since,
- * most likely, client objects will also be listeners.
- *
- * @see SortedListValueModelWrapper
- */
-public class SortedListValueModelAdapter<E>
- extends CollectionListValueModelAdapter<E>
-{
- /**
- * A comparator used for sorting the elements;
- * if it is null, we use "natural ordering".
- */
- protected Comparator<E> comparator;
-
-
- // ********** constructors **********
-
- /**
- * Wrap the specified collection value model and sort its contents
- * using the specified comparator.
- */
- public SortedListValueModelAdapter(CollectionValueModel<? extends E> collectionHolder, Comparator<E> comparator) {
- super(collectionHolder);
- this.comparator = comparator;
- }
-
- /**
- * Wrap the specified collection value model and sort its contents
- * based on the elements' "natural ordering".
- */
- public SortedListValueModelAdapter(CollectionValueModel<? extends E> collectionHolder) {
- this(collectionHolder, null);
- }
-
-
- // ********** accessors **********
-
- public void setComparator(Comparator<E> comparator) {
- this.comparator = comparator;
- this.sortList();
- }
-
-
- // ********** behavior **********
-
- /**
- * Sort the internal list before the superclass
- * sends out change notification.
- */
- @Override
- protected void buildList(int size) {
- super.buildList(size);
- Collections.sort(this.list, this.comparator);
- }
-
- /**
- * Sort the list after adding the items.
- */
- @Override
- protected void itemsAdded(CollectionAddEvent event) {
- @SuppressWarnings("unchecked")
- ArrayList<E> newList = (ArrayList<E>) this.list.clone();
- newList.ensureCapacity(newList.size() + event.getItemsSize());
- CollectionTools.addAll(newList, this.getItems(event));
- Collections.sort(newList, this.comparator);
- this.synchronizeList(newList, this.list, LIST_VALUES);
- }
-
- @Override
- protected Iterable<? extends E> buildSyncList() {
- return CollectionTools.sortedSet(this.collectionHolder, this.comparator, this.collectionHolder.size());
- }
-
- /**
- * sort the list and notify our listeners, if necessary;
- */
- protected void sortList() {
- // save the unsorted state of the sorted list so we can minimize the number of "replaced" items
- @SuppressWarnings("unchecked")
- ArrayList<E> unsortedList = (ArrayList<E>) this.list.clone();
- Collections.sort(this.list, this.comparator);
- Range diffRange = CollectionTools.identityDiffRange(unsortedList, this.list);
- if (diffRange.size > 0) {
- List<E> unsortedItems = unsortedList.subList(diffRange.start, diffRange.end + 1);
- List<E> sortedItems = this.list.subList(diffRange.start, diffRange.end + 1);
- this.fireItemsReplaced(LIST_VALUES, diffRange.start, sortedItems, unsortedItems);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SortedListValueModelWrapper.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SortedListValueModelWrapper.java
deleted file mode 100644
index 0195f52616..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/SortedListValueModelWrapper.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.Range;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * A wrapper that keeps the contents of a {@link ListValueModel} sorted
- * and notifies listeners appropriately.
- * <p>
- * The {@link Comparator} can be changed at any time; allowing the same
- * adapter to be used with different sort criteria (e.g. when the user
- * wants to sort a list of files first by name, then by date, then by size).
- * <p>
- * <strong>NB:</strong> Since we only listen to the wrapped collection when we have
- * listeners ourselves and we can only stay in sync with the wrapped
- * collection while we are listening to it, results to various methods
- * (e.g. {@link #size()}, {@link #get(int)}) will be unpredictable whenever
- * we do not have any listeners. This should not be too painful since,
- * most likely, client objects will also be listeners.
- *
- * @see SortedListValueModelAdapter
- */
-public class SortedListValueModelWrapper<E>
- extends ListValueModelWrapper<E>
- implements ListValueModel<E>
-{
- /**
- * A comparator used for sorting the elements;
- * if it is null, we use "natural ordering".
- */
- protected Comparator<E> comparator;
-
- /**
- * Our internal list, which holds the same elements as
- * the wrapped list, but keeps them sorted.
- */
- // we declare this an ArrayList so we can use #clone() and #ensureCapacity(int)
- protected final ArrayList<E> sortedList;
-
-
- // ********** constructors **********
-
- /**
- * Wrap the specified list value model and sort its contents
- * using the specified comparator.
- */
- public SortedListValueModelWrapper(ListValueModel<? extends E> listHolder, Comparator<E> comparator) {
- super(listHolder);
- this.comparator = comparator;
- this.sortedList = new ArrayList<E>(listHolder.size());
- // postpone building the sorted list and listening to the wrapped list
- // until we have listeners ourselves...
- }
-
- /**
- * Wrap the specified list value model and sort its contents
- * based on the elements' "natural ordering".
- */
- public SortedListValueModelWrapper(ListValueModel<? extends E> listHolder) {
- this(listHolder, null);
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E> listIterator() {
- return new ReadOnlyListIterator<E>(this.sortedList);
- }
-
- public E get(int index) {
- return this.sortedList.get(index);
- }
-
- public int size() {
- return this.sortedList.size();
- }
-
- public Object[] toArray() {
- return this.sortedList.toArray();
- }
-
-
- // ********** accessors **********
-
- public void setComparator(Comparator<E> comparator) {
- this.comparator = comparator;
- this.sortList();
- }
-
-
- // ********** behavior **********
-
- @Override
- protected void engageModel() {
- super.engageModel();
- // sync the sorted list *after* we start listening to the wrapped list model,
- // since its value might change when a listener is added
- this.buildSortedList();
- }
-
- @Override
- protected void disengageModel() {
- super.disengageModel();
- // clear out the sorted list when we are not listening to the wrapped list holder
- this.sortedList.clear();
- }
-
- protected void buildSortedList() {
- // if the new list is empty, do nothing
- int size = this.listHolder.size();
- if (size != 0) {
- this.buildSortedList(size);
- }
- }
-
- protected void buildSortedList(int size) {
- this.sortedList.ensureCapacity(size);
- for (E each : this.listHolder) {
- this.sortedList.add(each);
- }
- Collections.sort(this.sortedList, this.comparator);
- }
-
-
- // ********** list change support **********
-
- /**
- * Items were added to the wrapped list.
- */
- @Override
- protected void itemsAdded(ListAddEvent event) {
- // first add the items and notify our listeners...
- this.addItemsToList(this.getItems(event), this.sortedList, LIST_VALUES);
- // ...then sort the list and notify our listeners
- this.sortList();
- }
-
- /**
- * Items were removed from the wrapped list.
- */
- @Override
- protected void itemsRemoved(ListRemoveEvent event) {
- this.removeItemsFromList(this.getItems(event), this.sortedList, LIST_VALUES);
- // no sorting needed
- }
-
- /**
- * Items were replaced in the wrapped list.
- */
- @Override
- protected void itemsReplaced(ListReplaceEvent event) {
- // first remove the old items and notify our listeners...
- this.removeItemsFromList(this.getOldItems(event), this.sortedList, LIST_VALUES);
- // then add the new items and notify our listeners...
- this.addItemsToList(this.getNewItems(event), this.sortedList, LIST_VALUES);
- // ...then sort the list and notify our listeners
- this.sortList();
- }
-
- /**
- * Items were moved in the wrapped list.
- */
- @Override
- protected void itemsMoved(ListMoveEvent event) {
- // do nothing - sort order should remain unchanged
- }
-
- /**
- * The wrapped list was cleared.
- */
- @Override
- protected void listCleared(ListClearEvent event) {
- this.clearList(this.sortedList, LIST_VALUES);
- }
-
- /**
- * The wrapped list has changed in some dramatic fashion.
- * Rebuild our sorted list and notify our listeners.
- */
- @Override
- protected void listChanged(ListChangeEvent event) {
- int size = this.listHolder.size();
- if (size == 0) {
- if (this.sortedList.isEmpty()) {
- // no change
- } else {
- this.clearList(this.sortedList, LIST_VALUES);
- }
- } else {
- if (this.sortedList.isEmpty()) {
- this.buildSortedList(size);
- this.fireItemsAdded(LIST_VALUES, 0, this.sortedList);
- } else {
- this.sortedList.clear();
- this.buildSortedList(size);
- this.fireListChanged(LIST_VALUES, this.sortedList);
- }
- }
- }
-
- /**
- * sort the sorted list and notify our listeners, if necessary;
- */
- protected void sortList() {
- // save the unsorted state of the sorted list so we can minimize the number of "replaced" items
- @SuppressWarnings("unchecked")
- ArrayList<E> unsortedList = (ArrayList<E>) this.sortedList.clone();
- Collections.sort(this.sortedList, this.comparator);
- Range diffRange = CollectionTools.identityDiffRange(unsortedList, this.sortedList);
- if (diffRange.size > 0) {
- List<E> unsortedItems = unsortedList.subList(diffRange.start, diffRange.end + 1);
- List<E> sortedItems = this.sortedList.subList(diffRange.start, diffRange.end + 1);
- this.fireItemsReplaced(LIST_VALUES, diffRange.start, sortedItems, unsortedItems);
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.sortedList);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StatePropertyValueModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StatePropertyValueModelAdapter.java
deleted file mode 100644
index 011195c562..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StatePropertyValueModelAdapter.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-
-/**
- * This abstract class provides the infrastructure needed to wrap
- * a model, "lazily" listen to it, and convert
- * its state change notifications into property value model change
- * notifications.
- * <p>
- * Subclasses must implement:<ul>
- * <li>{@link #buildValue()}<p>
- * to return the current property value, as derived from the
- * current model
- * </ul>
- * Subclasses might want to override the following methods
- * to improve performance (by not recalculating the value, if possible):<ul>
- * <li>{@link #stateChanged(StateChangeEvent event)}
- * </ul>
- */
-public abstract class StatePropertyValueModelAdapter<T>
- extends AbstractPropertyValueModelAdapter<T>
-{
- /** The wrapped model. */
- protected final Model model;
-
- /** A listener that allows us to sync with changes to the wrapped model. */
- protected final StateChangeListener stateListener;
-
-
- // ********** constructor/initialization **********
-
- /**
- * Construct a property value model with the specified wrapped model.
- */
- protected StatePropertyValueModelAdapter(Model model) {
- super();
- if (model == null) {
- throw new NullPointerException();
- }
- this.model = model;
- this.stateListener = this.buildStateListener();
- }
-
- protected StateChangeListener buildStateListener() {
- return new StateListener();
- }
-
- protected class StateListener
- extends StateChangeAdapter
- {
- @Override
- public void stateChanged(StateChangeEvent event) {
- StatePropertyValueModelAdapter.this.stateChanged(event);
- }
- }
-
-
- // ********** listener **********
-
- /**
- * Start listening to the model.
- */
- @Override
- protected void engageModel_() {
- this.model.addStateChangeListener(this.stateListener);
- }
-
- /**
- * Stop listening to the model.
- */
- @Override
- protected void disengageModel_() {
- this.model.removeStateChangeListener(this.stateListener);
- }
-
-
- // ********** state change support **********
-
- /**
- * The model's state changed;
- * propagate the change notification appropriately.
- */
- protected void stateChanged(@SuppressWarnings("unused") StateChangeEvent event) {
- // by default, simply recalculate the value and fire an event
- this.propertyChanged();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticCollectionValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticCollectionValueModel.java
deleted file mode 100644
index 854528690a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticCollectionValueModel.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Arrays;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-
-/**
- * Implementation of {@link CollectionValueModel} that can be used for
- * returning an iterator on a static collection, but still allows listeners to be added.
- * Listeners will <em>never</em> be notified of any changes, because there should be none.
- */
-public class StaticCollectionValueModel<E>
- extends AbstractModel
- implements CollectionValueModel<E>
-{
- /** The elements. */
- protected final Object[] elements;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a static collection value model for the specified array.
- */
- public StaticCollectionValueModel(E... elements) {
- super();
- this.elements = elements.clone();
- }
-
- /**
- * Construct a static collection value model for the specified elements.
- */
- public StaticCollectionValueModel(Iterable<? extends E> elements) {
- super();
- this.elements = ArrayTools.array(elements);
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- public int size() {
- return this.elements.length;
- }
-
- @SuppressWarnings("unchecked")
- public Iterator<E> iterator() {
- // we can cast here since our constructors require the elements to be
- // of type E and ArrayIterator is read-only
- return (Iterator<E>) new ArrayIterator<Object>(this.elements);
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(Arrays.toString(this.elements));
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticListValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticListValueModel.java
deleted file mode 100644
index c08b6f42e8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticListValueModel.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayListIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * Implementation of {@link ListValueModel} that can be used for
- * returning a list iterator on a static list, but still allows listeners to be added.
- * Listeners will <em>never</em> be notified of any changes, because there should be none.
- */
-public class StaticListValueModel<E>
- extends AbstractModel
- implements ListValueModel<E>
-{
- /** The elements. */
- protected final Object[] elements;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a static list value model for the specified elements.
- */
- public StaticListValueModel(E... elements) {
- super();
- this.elements = elements.clone();
- }
-
- /**
- * Construct a static list value model for the specified elements.
- */
- public StaticListValueModel(Iterable<? extends E> elements) {
- super();
- this.elements = ArrayTools.array(elements);
- }
-
-
- // ********** ListValueModel implementation **********
-
- @SuppressWarnings("unchecked")
- public Iterator<E> iterator() {
- // we can cast here since our constructors require the elements to be
- // of type E and ArrayIterator is read-only
- return (Iterator<E>) new ArrayIterator<Object>(this.elements);
- }
-
- @SuppressWarnings("unchecked")
- public ListIterator<E> listIterator() {
- // we can cast here since our constructors require the elements to be
- // of type E and ArrayListIterator is read-only
- return (ListIterator<E>) new ArrayListIterator<Object>(this.elements);
- }
-
- public int size() {
- return this.elements.length;
- }
-
- @SuppressWarnings("unchecked")
- public E get(int index) {
- // we can cast here since our constructors require the elements to be
- // of type E
- return (E) this.elements[index];
- }
-
- public Object[] toArray() {
- return this.elements.clone();
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(Arrays.toString(this.elements));
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticPropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticPropertyValueModel.java
deleted file mode 100644
index 678f5aaefd..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticPropertyValueModel.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * Implementation of {@link PropertyValueModel} that can be used for
- * returning a static value, but still allows listeners to be added.
- * Listeners will <em>never</em> be notified of any changes, because there should be none.
- */
-public class StaticPropertyValueModel<T>
- extends AbstractModel
- implements PropertyValueModel<T>
-{
- /** The value. */
- protected final T value;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a static property value model for the specified value.
- */
- public StaticPropertyValueModel(T value) {
- super();
- this.value = value;
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- public T getValue() {
- return this.value;
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.value);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticTreeValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticTreeValueModel.java
deleted file mode 100644
index 576e608985..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/StaticTreeValueModel.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.value.TreeValueModel;
-
-/**
- * Implementation of {@link TreeValueModel} that can be used for
- * returning an iterator on a static tree, but still allows listeners to be added.
- * Listeners will <em>never</em> be notified of any changes, because there should be none.
- */
-public class StaticTreeValueModel<E>
- extends AbstractModel
- implements TreeValueModel<E>
-{
- /** The tree's nodes. */
- protected final Iterable<? extends E> nodes;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a read-only tree value model for the specified nodes.
- */
- public StaticTreeValueModel(Iterable<? extends E> nodes) {
- super();
- if (nodes == null) {
- throw new NullPointerException();
- }
- this.nodes = nodes;
- }
-
- // ********** TreeValueModel implementation **********
-
- public Iterator<E> nodes() {
- return new ReadOnlyIterator<E>(this.nodes.iterator());
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.nodes);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationListValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationListValueModel.java
deleted file mode 100644
index af9d0bbace..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationListValueModel.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * An adapter that allows us to transform a {@link ListValueModel}
- * (or adapted {@link CollectionValueModel}) into a read-only {@link ListValueModel}
- * whose items are tranformations of the items in the wrapped
- * {@link ListValueModel}. It will keep its contents in sync with
- * the contents of the wrapped {@link ListValueModel} and notifies its
- * listeners of any changes.
- * <p>
- * The {@link Transformer} can be changed at any time; allowing the same
- * adapter to be used with different transformations.
- * <p>
- * As an alternative to building a {@link Transformer},
- * a subclass of <code>TransformationListValueModelAdapter</code> can
- * either override {@link #transformItem_(Object)} or,
- * if something other than <code>null</code> should be returned when the
- * wrapped item is <code>null</code>, override {@link #transformItem(Object)}.
- * <p>
- * <strong>NB:</strong> Since we only listen to the wrapped list when we have
- * listeners ourselves and we can only stay in sync with the wrapped
- * list while we are listening to it, results to various methods
- * (e.g. {@link #size()}, {@link #get(int)}) will be unpredictable whenever
- * we do not have any listeners. This should not be too painful since,
- * most likely, clients will also be listeners.
- *
- * @see Transformer
- */
-public class TransformationListValueModel<E1, E2>
- extends ListValueModelWrapper<E1>
- implements ListValueModel<E2>
-{
-
- /** This transforms the items, unless the subclass overrides {@link #transformItem(Object)}). */
- protected Transformer<E1, E2> transformer;
-
- /** The list of transformed items. */
- protected final List<E2> transformedList;
-
-
- // ********** constructors **********
-
- /**
- * Construct a list value model with the specified nested
- * list value model and transformer.
- */
- public TransformationListValueModel(ListValueModel<? extends E1> listHolder, Transformer<E1, E2> transformer) {
- super(listHolder);
- this.transformer = transformer;
- this.transformedList = new ArrayList<E2>();
- }
-
- /**
- * Construct a list value model with the specified nested
- * list value model and the default transformer.
- * Use this constructor if you want to override
- * {@link #transformItem_(Object)} or {@link #transformItem(Object)}
- * method instead of building a {@link Transformer}.
- */
- public TransformationListValueModel(ListValueModel<? extends E1> listHolder) {
- super(listHolder);
- this.transformer = this.buildTransformer();
- this.transformedList = new ArrayList<E2>();
- }
-
- /**
- * Construct a list value model with the specified nested
- * collection value model and transformer.
- */
- public TransformationListValueModel(CollectionValueModel<? extends E1> collectionHolder, Transformer<E1, E2> transformer) {
- this(new CollectionListValueModelAdapter<E1>(collectionHolder), transformer);
- }
-
- /**
- * Construct a list value model with the specified nested
- * collection value model and the default transformer.
- * Use this constructor if you want to override
- * {@link #transformItem_(Object)} or {@link #transformItem(Object)}
- * method instead of building a {@link Transformer}.
- */
- public TransformationListValueModel(CollectionValueModel<? extends E1> collectionHolder) {
- this(new CollectionListValueModelAdapter<E1>(collectionHolder));
- }
-
- protected Transformer<E1, E2> buildTransformer() {
- return new DefaultTransformer();
- }
-
-
- // ********** ListValueModel implementation **********
-
- public Iterator<E2> iterator() {
- return this.listIterator();
- }
-
- public ListIterator<E2> listIterator() {
- return new ReadOnlyListIterator<E2>(this.transformedList);
- }
-
- public E2 get(int index) {
- return this.transformedList.get(index);
- }
-
- public int size() {
- return this.transformedList.size();
- }
-
- public Object[] toArray() {
- return this.transformedList.toArray();
- }
-
- // ********** behavior **********
-
- @Override
- protected void engageModel() {
- super.engageModel();
- // sync the transformed list *after* we start listening to the list model,
- // since its value might change when a listener is added
- this.transformedList.addAll(this.transformItems(this.listHolder));
- }
-
- @Override
- protected void disengageModel() {
- super.disengageModel();
- // clear out the list when we are not listening to the collection holder
- this.transformedList.clear();
- }
-
- /**
- * Transform the items in the specified list value model.
- */
- protected List<E2> transformItems(ListValueModel<? extends E1> lvm) {
- return this.transformItems(lvm, lvm.size());
- }
-
- /**
- * Transform the items associated with the specified event.
- */
- protected List<E2> transformItems(ListAddEvent event) {
- return this.transformItems(this.getItems(event), event.getItemsSize());
- }
-
- /**
- * Transform the items associated with the specified event.
- */
- protected List<E2> transformItems(ListRemoveEvent event) {
- return this.transformItems(this.getItems(event), event.getItemsSize());
- }
-
- /**
- * Transform the new items associated with the specified event.
- */
- protected List<E2> transformNewItems(ListReplaceEvent event) {
- return this.transformItems(this.getNewItems(event), event.getItemsSize());
- }
-
- /**
- * Transform the old items associated with the specified event.
- */
- protected List<E2> transformOldItems(ListReplaceEvent event) {
- return this.transformItems(this.getOldItems(event), event.getItemsSize());
- }
-
- /**
- * Transform the specified items.
- */
- protected List<E2> transformItems(Iterable<? extends E1> items, int size) {
- List<E2> result = new ArrayList<E2>(size);
- for (E1 item : items) {
- result.add(this.transformItem(item));
- }
- return result;
- }
-
- /**
- * Transform the specified item.
- */
- protected E2 transformItem(E1 item) {
- return this.transformer.transform(item);
- }
-
- /**
- * Transform the specified, non-null, item and return the result.
- */
- protected E2 transformItem_(@SuppressWarnings("unused") E1 item) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- /**
- * Change the transformer and rebuild the collection.
- */
- public void setTransformer(Transformer<E1, E2> transformer) {
- this.transformer = transformer;
- this.rebuildTransformedList();
- }
-
- /**
- * Synchronize our cache with the wrapped collection.
- */
- protected void rebuildTransformedList() {
- this.synchronizeList(this.transformItems(this.listHolder), this.transformedList, LIST_VALUES);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.transformedList);
- }
-
-
- // ********** list change support **********
-
- /**
- * Items were added to the wrapped list holder.
- * Transform them, add them to our transformation list,
- * and notify our listeners.
- */
- @Override
- protected void itemsAdded(ListAddEvent event) {
- this.addItemsToList(event.getIndex(), this.transformItems(event), this.transformedList, LIST_VALUES);
- }
-
- /**
- * Items were removed from the wrapped list holder.
- * Remove the corresponding items from our transformation list
- * and notify our listeners.
- */
- @Override
- protected void itemsRemoved(ListRemoveEvent event) {
- this.removeItemsFromList(event.getIndex(), event.getItemsSize(), this.transformedList, LIST_VALUES);
- }
-
- /**
- * Items were replaced in the wrapped list holder.
- * Replace the corresponding items in our transformation list
- * and notify our listeners.
- */
- @Override
- protected void itemsReplaced(ListReplaceEvent event) {
- this.setItemsInList(event.getIndex(), this.transformNewItems(event), this.transformedList, LIST_VALUES);
- }
-
- /**
- * Items were moved in the wrapped list holder.
- * Move the corresponding items in our transformation list
- * and notify our listeners.
- */
- @Override
- protected void itemsMoved(ListMoveEvent event) {
- this.moveItemsInList(event.getTargetIndex(), event.getSourceIndex(), event.getLength(), this.transformedList, LIST_VALUES);
- }
-
- /**
- * The wrapped list holder was cleared.
- * Clear our transformation list and notify our listeners.
- */
- @Override
- protected void listCleared(ListClearEvent event) {
- this.clearList(this.transformedList, LIST_VALUES);
- }
-
- /**
- * The wrapped list holder has changed in some dramatic fashion.
- * Rebuild our transformation list and notify our listeners.
- */
- @Override
- protected void listChanged(ListChangeEvent event) {
- this.rebuildTransformedList();
- }
-
-
- // ********** default transformer **********
-
- /**
- * The default transformer will return null if the wrapped item is null.
- * If the wrapped item is not null, it is transformed by a subclass
- * implementation of {@link TransformationListValueModel#transformItem_(Object)}.
- */
- protected class DefaultTransformer implements Transformer<E1, E2> {
- public E2 transform(E1 item) {
- return (item == null) ? null : TransformationListValueModel.this.transformItem_(item);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationPropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationPropertyValueModel.java
deleted file mode 100644
index 8798ec7c8c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationPropertyValueModel.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * A <code>TransformationPropertyValueModel</code> wraps another
- * {@link PropertyValueModel} and uses a {@link Transformer}
- * to transform the wrapped value before it is returned by {@link #getValue()}.
- * <p>
- * The transformed value is calculated and cached during initialization and every
- * time the wrapped value changes. This can be useful when the old value
- * passed in to {@link #wrappedValueChanged(org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent)}
- * can no longer be "transformed" because its state is no longer valid.
- * This caching can also improve time performance in some situations.
- * <p>
- * As an alternative to building a {@link Transformer},
- * a subclass of <code>TransformationPropertyValueModel</code> can
- * either override {@link #transform_(Object)} or,
- * if something other than <code>null</code> should be returned when the
- * wrapped value is <code>null</code>, override {@link #transform(Object)}.
- *
- * @param <V1> the type of the <em>wrapped</em> model's value
- * @param <V2> the type of the model's <em>transformed</em> value
- * @see Transformer
- */
-public class TransformationPropertyValueModel<V1, V2>
- extends PropertyValueModelWrapper<V1>
- implements PropertyValueModel<V2>
-{
- /**
- * Cache the transformed value so that during property change event
- * notification we do not have to transform the old value. It is possible
- * the old value is no longer be valid in the model; as a result,
- * transforming it would not be valid.
- */
- protected volatile V2 value;
-
- protected final Transformer<V1, V2> transformer;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct a property value model with the specified nested
- * property value model and the default transformer.
- * Use this constructor if you want to override
- * {@link #transform_(Object)} or {@link #transform(Object)}
- * method instead of building a {@link Transformer}.
- */
- public TransformationPropertyValueModel(PropertyValueModel<? extends V1> valueModel) {
- super(valueModel);
- this.transformer = this.buildTransformer();
- }
-
- /**
- * Construct a property value model with the specified nested
- * property value model and transformer. Depending on the nested model,
- * the transformer may be required to handle a <code>null</code> value.
- */
- public TransformationPropertyValueModel(PropertyValueModel<? extends V1> valueModel, Transformer<V1, V2> transformer) {
- super(valueModel);
- if (transformer == null) {
- throw new NullPointerException();
- }
- this.transformer = transformer;
- }
-
- protected Transformer<V1, V2> buildTransformer() {
- return new DefaultTransformer();
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- /**
- * No need to transform the nested value, simply return the cached value,
- * which is already transformed.
- */
- public V2 getValue() {
- return this.value;
- }
-
-
- // ********** PropertyValueModelWrapper implementation **********
-
- /**
- * Propagate the event with transformed values.
- */
- @Override
- protected void wrappedValueChanged(V1 oldValue, V1 newValue) {
- V2 old = this.value;
- this.firePropertyChanged(VALUE, old, this.value = this.transform(newValue));
- }
-
-
- // ********** transformation **********
-
- /**
- * Transform the specified value and return the result.
- */
- protected V2 transform(V1 v) {
- return this.transformer.transform(v);
- }
-
- /**
- * Transform the specified, non-<code>null</code>, value and return the result.
- */
- protected V2 transform_(@SuppressWarnings("unused") V1 v) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.value);
- }
-
-
- // ********** listeners **********
-
- /**
- * We have listeners, transform the nested value and cache the result.
- */
- @Override
- protected void engageModel() {
- super.engageModel();
- this.value = this.transform(this.valueModel.getValue());
- }
-
- /**
- * We have no more listeners, clear the cached value.
- */
- @Override
- protected void disengageModel() {
- this.value = null;
- super.disengageModel();
- }
-
-
- // ********** default transformer **********
-
- /**
- * The default transformer will return <code>null</code> if the wrapped
- * value is <code>null</code>. If the wrapped value is not
- * <code>null</code>, it is transformed by a subclass
- * implementation of {@link TransformationPropertyValueModel#transform_(Object)}.
- */
- protected class DefaultTransformer
- implements Transformer<V1, V2>
- {
- public V2 transform(V1 v) {
- return (v == null) ? null : TransformationPropertyValueModel.this.transform_(v);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationWritablePropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationWritablePropertyValueModel.java
deleted file mode 100644
index 01213ae8c2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/TransformationWritablePropertyValueModel.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * A <code>TransformationWritablePropertyValueModel</code> wraps another
- * {@link ModifiablePropertyValueModel} and uses two {@link Transformer}s
- * to:<ul>
- * <li>transform the wrapped value before it is returned by {@link #getValue()}
- * <li>"reverse-transform" the new value that comes in via
- * {@link #setValue(Object)}
- * </ul>
- * <strong>NB:</strong> If the mapping between the wrapped values and the
- * transformed values is not strictly one-to-one, the behavior of the
- * transformation model may seem unpredictable; since the wrapped model's
- * change events can cause the transformation model's value to change.
- * For example: If the value is a string to be <em>transformed</em> to uppercase
- * and <em>reverse-transformed</em> to lowercase; then mixed case values passed to
- * the transformation model will be<ul>
- * <li>unchanged if the transformation model has <em>no</em> listeners
- * <li>changed to uppercase if the transformation model has any listeners
- * ({@link #wrappedValueChanged(org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent)})
- * </ul>
- * As an alternative to building two {@link Transformer}s,
- * a subclass of <code>TransformationWritablePropertyValueModel</code> can
- * override {@link #transform_(Object)} and {@link #reverseTransform_(Object)};
- * or, if something other than <code>null</code> should be returned when the
- * wrapped value is <code>null</code> or the new value is <code>null</code>,
- * override {@link #transform(Object)} and {@link #reverseTransform(Object)}.
- *
- * @param <V1> the type of the <em>wrapped</em> model's value
- * @param <V2> the type of the model's <em>transformed</em> value
- * @see Transformer
- */
-public class TransformationWritablePropertyValueModel<V1, V2>
- extends TransformationPropertyValueModel<V1, V2>
- implements ModifiablePropertyValueModel<V2>
-{
- protected final Transformer<V2, V1> reverseTransformer;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct a writable property value model with the specified nested
- * writable property value model and the default transformers.
- * Use this constructor if you want to override the
- * {@link #transform_(Object)} and {@link #reverseTransform_(Object)}
- * (or {@link #transform(Object)} and {@link #reverseTransform(Object)})
- * methods instead of building {@link Transformer}s.
- */
- public TransformationWritablePropertyValueModel(ModifiablePropertyValueModel<V1> valueModel) {
- super(valueModel);
- this.reverseTransformer = this.buildReverseTransformer();
- }
-
- /**
- * Construct a writable property value model with the specified nested
- * writable property value model and transformers.
- */
- public TransformationWritablePropertyValueModel(ModifiablePropertyValueModel<V1> valueModel, Transformer<V1, V2> transformer, Transformer<V2, V1> reverseTransformer) {
- super(valueModel, transformer);
- if (reverseTransformer == null) {
- throw new NullPointerException();
- }
- this.reverseTransformer = reverseTransformer;
- }
-
- protected Transformer<V2, V1> buildReverseTransformer() {
- return new DefaultReverseTransformer();
- }
-
-
- // ********** WritablePropertyValueModel implementation **********
-
- /**
- * Cache and "reverse-transform" the new value before passing it to the the
- * nested value model.
- * A side-effect of caching the new value is that the wrapper will
- * <em>not</em> fire an event when the wrapped model fires an event when
- * called from here.
- * @see #wrappedValueChanged(org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent)
- */
- public void setValue(V2 value) {
- this.value = value;
- this.getValueModel().setValue(this.reverseTransform(value));
- }
-
-
- // ********** transformation **********
-
- /**
- * "Reverse-transform" the specified value and return the result.
- * This is called by {@link #setValue(Object)}.
- */
- protected V1 reverseTransform(V2 v) {
- return this.reverseTransformer.transform(v);
- }
-
- /**
- * "Reverse-transform" the specified, non-<code>null</code>,
- * value and return the result.
- */
- protected V1 reverseTransform_(@SuppressWarnings("unused") V2 v) {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
-
- // ********** queries **********
-
- /**
- * Our constructors accept only a {@link ModifiablePropertyValueModel}{@code<V>},
- * so this cast should be safe.
- */
- @SuppressWarnings("unchecked")
- protected ModifiablePropertyValueModel<V1> getValueModel() {
- return (ModifiablePropertyValueModel<V1>) this.valueModel;
- }
-
-
- // ********** default reverse transformer **********
-
- /**
- * The default reverse transformer will return <code>null</code>
- * if the new value is <code>null</code>.
- * If the new value is not <code>null</code>, it is reverse-transformed
- * by a subclass implementation of {@link #reverseTransform_(Object)}.
- */
- protected class DefaultReverseTransformer
- implements Transformer<V2, V1>
- {
- public V1 transform(V2 v) {
- return (v == null) ? null : TransformationWritablePropertyValueModel.this.reverseTransform_(v);
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueAspectAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueAspectAdapter.java
deleted file mode 100644
index f71e12d2f7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueAspectAdapter.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Abstract class that provides support for wrapping a {@link ModifiablePropertyValueModel}
- * and listening for changes to <em>aspects</em> of the <em>value</em> held
- * by the {@link ModifiablePropertyValueModel}. Changes to the
- * {@link ModifiablePropertyValueModel}'s value are also monitored.
- * <p>
- * This is useful if you have a value that may change, but whose aspects can also
- * change in a fashion that might be of interest to the client.
- * <p>
- * <strong>NB:</strong> Clients will need to listen for two different change
- * notifications:<ul>
- * <li>a property change event will be be fired when the <em>value</em> changes;
- * <li>a state change event will be fired when an <em>aspect</em> of the value changes.
- * </ul>
- * Subclasses need to override two methods:<ul>
- * <li>{@link #engageValue_()}<p>
- * begin listening to the appropriate aspect of the value and call
- * {@link #valueAspectChanged()} whenever the aspect changes
- * (this will fire a state change event)
- * <li>{@link #disengageValue_()}<p>
- * stop listening to the appropriate aspect of the value
- * </ul>
- */
-public abstract class ValueAspectAdapter<V>
- extends PropertyValueModelWrapper<V>
- implements ModifiablePropertyValueModel<V>
-{
- /** Cache the value so we can disengage. */
- protected volatile V value;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Constructor - the value model is required.
- */
- protected ValueAspectAdapter(ModifiablePropertyValueModel<V> valueModel) {
- super(valueModel);
- this.value = null;
- }
-
- /**
- * Override to allow both property and state change listeners.
- */
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new ChangeSupport(this);
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- public V getValue() {
- return this.value;
- }
-
-
- // ********** WritablePropertyValueModel implementation **********
-
- public void setValue(V value) {
- this.getValueModel().setValue(value);
- }
-
-
- // ********** PropertyValueModelWrapper implementation **********
-
- @Override
- protected void wrappedValueChanged(PropertyChangeEvent event) {
- this.disengageValue();
- this.engageValue();
- this.firePropertyChanged(event.clone(this));
- }
-
-
- // ********** listeners **********
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public synchronized void addStateChangeListener(StateChangeListener listener) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addStateChangeListener(listener);
- }
-
- /**
- * Extend to stop listening to the underlying model if necessary.
- */
- @Override
- public synchronized void removeStateChangeListener(StateChangeListener listener) {
- super.removeStateChangeListener(listener);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Extend to check for state change listeners.
- */
- @Override
- protected boolean hasListeners() {
- return this.hasAnyStateChangeListeners() || super.hasListeners();
- }
-
- /**
- * Extend to engage an aspect of the value model's value.
- */
- @Override
- protected void engageModel() {
- super.engageModel();
- this.engageValue();
- }
-
- /**
- * Extend to disengage an aspect of the value model's value.
- */
- @Override
- protected void disengageModel() {
- this.disengageValue();
- super.disengageModel();
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to an aspect of the current value.
- */
- protected void engageValue() {
- this.value = this.valueModel.getValue();
- if (this.value != null) {
- this.engageValue_();
- }
- }
-
- /**
- * Start listening to some aspect of the current value.
- * At this point we can be sure the value is not <code>null</code>.
- */
- protected abstract void engageValue_();
-
- /**
- * Stop listening to an aspect of the current value.
- */
- protected void disengageValue() {
- if (this.value != null) {
- this.disengageValue_();
- this.value = null;
- }
- }
-
- /**
- * Stop listening to an aspect of the current value.
- * At this point we can be sure the value is not <code>null</code>.
- */
- protected abstract void disengageValue_();
-
- /**
- * Subclasses should call this method whenever the value's aspect changes.
- */
- protected void valueAspectChanged() {
- this.fireStateChanged();
- }
-
- /**
- * Our constructor accepts only a {@link ModifiablePropertyValueModel}{@code<V>}.
- */
- @SuppressWarnings("unchecked")
- protected ModifiablePropertyValueModel<V> getValueModel() {
- return (ModifiablePropertyValueModel<V>) this.valueModel;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getValue());
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueChangeAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueChangeAdapter.java
deleted file mode 100644
index 7e477a778f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueChangeAdapter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.AbstractChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Extend {@link ValueAspectAdapter} to listen to all the aspects
- * of the value in the wrapped value model.
- */
-public class ValueChangeAdapter<V extends Model>
- extends ValueAspectAdapter<V>
-{
- /** Listener that listens to the value. */
- protected final ChangeListener valueAspectListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a change adapter for the specified value.
- */
- public ValueChangeAdapter(ModifiablePropertyValueModel<V> valueHolder) {
- super(valueHolder);
- this.valueAspectListener = this.buildValueAspectListener();
- }
-
-
- // ********** initialization **********
-
- protected ChangeListener buildValueAspectListener() {
- return new ValueAspectListener();
- }
-
- protected class ValueAspectListener
- extends AbstractChangeListener
- {
- @Override
- protected void modelChanged(ChangeEvent event) {
- ValueChangeAdapter.this.valueAspectChanged(event);
- }
- }
-
-
- // ********** ValueAspectAdapter implementation **********
-
- @Override
- protected void engageValue_() {
- this.value.addChangeListener(this.valueAspectListener);
- }
-
- @Override
- protected void disengageValue_() {
- this.value.removeChangeListener(this.valueAspectListener);
- }
-
-
- // ********** change events **********
-
- protected void valueAspectChanged(@SuppressWarnings("unused") ChangeEvent event) {
- this.valueAspectChanged();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueCollectionAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueCollectionAdapter.java
deleted file mode 100644
index ff661ee1b8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueCollectionAdapter.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Extend {@link ValueAspectAdapter} to listen to one or more collection
- * aspects of the value in the wrapped value model.
- */
-public class ValueCollectionAdapter<V extends Model>
- extends ValueAspectAdapter<V>
-{
- /** The names of the value's collections that we listen to. */
- protected final String[] collectionNames;
-
- /** Listener that listens to the value. */
- protected final CollectionChangeListener valueCollectionListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified value collections.
- */
- public ValueCollectionAdapter(ModifiablePropertyValueModel<V> valueHolder, String... collectionNames) {
- super(valueHolder);
- this.collectionNames = collectionNames;
- this.valueCollectionListener = this.buildValueCollectionListener();
- }
-
-
- // ********** initialization **********
-
- protected CollectionChangeListener buildValueCollectionListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent event) {
- ValueCollectionAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(CollectionRemoveEvent event) {
- ValueCollectionAdapter.this.itemsRemoved(event);
- }
- public void collectionCleared(CollectionClearEvent event) {
- ValueCollectionAdapter.this.collectionCleared(event);
- }
- public void collectionChanged(CollectionChangeEvent event) {
- ValueCollectionAdapter.this.collectionChanged(event);
- }
- @Override
- public String toString() {
- return "value collection listener: " + Arrays.asList(ValueCollectionAdapter.this.collectionNames); //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ValueAspectAdapter implementation **********
-
- @Override
- protected void engageValue_() {
- for (String collectionName : this.collectionNames) {
- this.value.addCollectionChangeListener(collectionName, this.valueCollectionListener);
- }
- }
-
- @Override
- protected void disengageValue_() {
- for (String collectionName : this.collectionNames) {
- this.value.removeCollectionChangeListener(collectionName, this.valueCollectionListener);
- }
- }
-
-
- // ********** change events **********
-
- protected void itemsAdded(@SuppressWarnings("unused") CollectionAddEvent event) {
- this.valueAspectChanged();
- }
-
- protected void itemsRemoved(@SuppressWarnings("unused") CollectionRemoveEvent event) {
- this.valueAspectChanged();
- }
-
- protected void collectionCleared(@SuppressWarnings("unused") CollectionClearEvent event) {
- this.valueAspectChanged();
- }
-
- protected void collectionChanged(@SuppressWarnings("unused") CollectionChangeEvent event) {
- this.valueAspectChanged();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueListAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueListAdapter.java
deleted file mode 100644
index 0c0978c49c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueListAdapter.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Extend {@link ValueAspectAdapter} to listen to one or more list
- * aspects of the value in the wrapped value model.
- */
-public class ValueListAdapter<V extends Model>
- extends ValueAspectAdapter<V>
-{
- /** The names of the value's lists that we listen to. */
- protected final String[] listNames;
-
- /** Listener that listens to the value. */
- protected final ListChangeListener valueListListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified value lists.
- */
- public ValueListAdapter(ModifiablePropertyValueModel<V> valueHolder, String... listNames) {
- super(valueHolder);
- this.listNames = listNames;
- this.valueListListener = this.buildValueListListener();
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildValueListListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent event) {
- ValueListAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(ListRemoveEvent event) {
- ValueListAdapter.this.itemsRemoved(event);
- }
- public void itemsReplaced(ListReplaceEvent event) {
- ValueListAdapter.this.itemsReplaced(event);
- }
- public void itemsMoved(ListMoveEvent event) {
- ValueListAdapter.this.itemsMoved(event);
- }
- public void listCleared(ListClearEvent event) {
- ValueListAdapter.this.listCleared(event);
- }
- public void listChanged(ListChangeEvent event) {
- ValueListAdapter.this.listChanged(event);
- }
- @Override
- public String toString() {
- return "value list listener: " + Arrays.asList(ValueListAdapter.this.listNames); //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ValueAspectAdapter implementation **********
-
- @Override
- protected void engageValue_() {
- for (String listName : this.listNames) {
- this.value.addListChangeListener(listName, this.valueListListener);
- }
- }
-
- @Override
- protected void disengageValue_() {
- for (String listName : this.listNames) {
- this.value.removeListChangeListener(listName, this.valueListListener);
- }
- }
-
-
- // ********** change events **********
-
- protected void itemsAdded(@SuppressWarnings("unused") ListAddEvent event) {
- this.valueAspectChanged();
- }
-
- protected void itemsRemoved(@SuppressWarnings("unused") ListRemoveEvent event) {
- this.valueAspectChanged();
- }
-
- protected void itemsReplaced(@SuppressWarnings("unused") ListReplaceEvent event) {
- this.valueAspectChanged();
- }
-
- protected void itemsMoved(@SuppressWarnings("unused") ListMoveEvent event) {
- this.valueAspectChanged();
- }
-
- protected void listCleared(@SuppressWarnings("unused") ListClearEvent event) {
- this.valueAspectChanged();
- }
-
- protected void listChanged(@SuppressWarnings("unused") ListChangeEvent event) {
- this.valueAspectChanged();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValuePropertyAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValuePropertyAdapter.java
deleted file mode 100644
index 596e509661..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValuePropertyAdapter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Arrays;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Extend {@link ValueAspectAdapter} to listen to one or more
- * properties of the value in the wrapped value model.
- */
-public class ValuePropertyAdapter<V extends Model>
- extends ValueAspectAdapter<V>
-{
- /** The names of the value's properties we listen to. */
- protected final String[] propertyNames;
-
- /** Listener that listens to the value. */
- protected final PropertyChangeListener valuePropertyListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified value properties.
- */
- public ValuePropertyAdapter(ModifiablePropertyValueModel<V> valueHolder, String... propertyNames) {
- super(valueHolder);
- this.propertyNames = propertyNames;
- this.valuePropertyListener = this.buildValuePropertyListener();
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildValuePropertyListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- ValuePropertyAdapter.this.propertyChanged(event);
- }
- @Override
- public String toString() {
- return "value property listener: " + Arrays.asList(ValuePropertyAdapter.this.propertyNames); //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ValueAspectAdapter implementation **********
-
- @Override
- protected void engageValue_() {
- for (String propertyName : this.propertyNames) {
- this.value.addPropertyChangeListener(propertyName, this.valuePropertyListener);
- }
- }
-
- @Override
- protected void disengageValue_() {
- for (String propertyName : this.propertyNames) {
- this.value.removePropertyChangeListener(propertyName, this.valuePropertyListener);
- }
- }
-
-
- // ********** change events **********
-
- protected void propertyChanged(@SuppressWarnings("unused") PropertyChangeEvent event) {
- this.valueAspectChanged();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueStateAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueStateAdapter.java
deleted file mode 100644
index 14a9639d06..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueStateAdapter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Extend {@link ValueAspectAdapter} to listen to the
- * "state" of the value in the wrapped value model.
- */
-public class ValueStateAdapter<V extends Model>
- extends ValueAspectAdapter<V>
-{
- /** Listener that listens to value. */
- protected final StateChangeListener valueStateListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the value state.
- */
- public ValueStateAdapter(ModifiablePropertyValueModel<V> valueHolder) {
- super(valueHolder);
- this.valueStateListener = this.buildValueStateListener();
- }
-
-
- // ********** initialization **********
-
- protected StateChangeListener buildValueStateListener() {
- return new StateChangeListener() {
- public void stateChanged(StateChangeEvent event) {
- ValueStateAdapter.this.stateChanged(event);
- }
- @Override
- public String toString() {
- return "value state listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ValueAspectAdapter implementation **********
-
- @Override
- protected void engageValue_() {
- this.value.addStateChangeListener(this.valueStateListener);
- }
-
- @Override
- protected void disengageValue_() {
- this.value.removeStateChangeListener(this.valueStateListener);
- }
-
-
- // ********** change events **********
-
- protected void stateChanged(@SuppressWarnings("unused") StateChangeEvent event) {
- this.valueAspectChanged();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueTreeAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueTreeAdapter.java
deleted file mode 100644
index db7e6683df..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/ValueTreeAdapter.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value;
-
-import java.util.Arrays;
-
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.TreeChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Extend {@link ValueAspectAdapter} to listen to one or more
- * tree aspects of the value in the wrapped value model.
- */
-public class ValueTreeAdapter<V extends Model>
- extends ValueAspectAdapter<V>
-{
- /** The names of the value's trees that we listen to. */
- protected final String[] treeNames;
-
- /** Listener that listens to the value. */
- protected final TreeChangeListener valueTreeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified value trees.
- */
- public ValueTreeAdapter(ModifiablePropertyValueModel<V> valueHolder, String... treeNames) {
- super(valueHolder);
- this.treeNames = treeNames;
- this.valueTreeListener = this.buildValueTreeListener();
- }
-
-
- // ********** initialization **********
-
- protected TreeChangeListener buildValueTreeListener() {
- return new TreeChangeListener() {
- public void nodeAdded(TreeAddEvent event) {
- ValueTreeAdapter.this.nodeAdded(event);
- }
- public void nodeRemoved(TreeRemoveEvent event) {
- ValueTreeAdapter.this.nodeRemoved(event);
- }
- public void treeCleared(TreeClearEvent event) {
- ValueTreeAdapter.this.treeCleared(event);
- }
- public void treeChanged(TreeChangeEvent event) {
- ValueTreeAdapter.this.treeChanged(event);
- }
- @Override
- public String toString() {
- return "value tree listener: " + Arrays.asList(ValueTreeAdapter.this.treeNames); //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ValueAspectAdapter implementation **********
-
- @Override
- protected void engageValue_() {
- for (String treeName : this.treeNames) {
- this.value.addTreeChangeListener(treeName, this.valueTreeListener);
- }
- }
-
- @Override
- protected void disengageValue_() {
- for (String treeName : this.treeNames) {
- this.value.removeTreeChangeListener(treeName, this.valueTreeListener);
- }
- }
-
-
- // ********** change events **********
-
- protected void nodeAdded(@SuppressWarnings("unused") TreeAddEvent event) {
- this.valueAspectChanged();
- }
-
- protected void nodeRemoved(@SuppressWarnings("unused") TreeRemoveEvent event) {
- this.valueAspectChanged();
- }
-
- protected void treeCleared(@SuppressWarnings("unused") TreeClearEvent event) {
- this.valueAspectChanged();
- }
-
- protected void treeChanged(@SuppressWarnings("unused") TreeChangeEvent event) {
- this.valueAspectChanged();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/prefs/PreferencePropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/prefs/PreferencePropertyValueModel.java
deleted file mode 100644
index 0f63a9fa51..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/prefs/PreferencePropertyValueModel.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.prefs;
-
-import java.util.EventListener;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.Preferences;
-
-import org.eclipse.jpt.common.utility.internal.BidiStringConverter;
-import org.eclipse.jpt.common.utility.internal.model.value.AspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This adapter wraps a Preference and converts it into a PropertyValueModel.
- * It listens for the appropriate "preference" changes and converts them into
- * VALUE property changes. It also allows the specification of a default value
- * for the Preference, which, by default, is null (and is probably *not* a very
- * good default).
- *
- * You can configure whether the preference's value is returned,
- * unchanged, as a string or as some other object (e.g. an Integer) by
- * setting the adapter's converter. Internally, the preference's value
- * is stored as the converted object; and the conversions take place
- * when reading or writing from the preferences node or retrieving the
- * value from an event fired by the preferences node.
- *
- * This adapter is a bit different from most other adapters because the
- * change events fired off by a Preferences node are asynchronous from
- * the change itself. (AbstractPreferences uses an event dispatch daemon.)
- * As a result, a client can set our value with #setValue(Object) and we
- * will return from that method before we ever receive notification from
- * the Preferences node that *it* has changed. This means we cannot
- * rely on that event to keep our internally cached value in synch.
- */
-public class PreferencePropertyValueModel<P>
- extends AspectAdapter<Preferences, P>
- implements ModifiablePropertyValueModel<P>
-{
- /** The key to the preference we use for the value. */
- protected final String key;
-
- /**
- * Cache the current (object) value of the preference so we
- * can pass an "old value" when we fire a property change event.
- */
- protected P value;
-
- /**
- * The default (object) value returned if there is no value
- * associated with the preference.
- */
- protected final P defaultValue;
-
- /**
- * This converter is used to convert the preference's
- * string value to and from an object.
- */
- protected final BidiStringConverter<P> converter;
-
- /** A listener that listens to the appropriate preference. */
- protected final PreferenceChangeListener preferenceChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified preference.
- * The default value of the preference will be null.
- */
- public PreferencePropertyValueModel(Preferences preferences, String key) {
- this(preferences, key, null);
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public PreferencePropertyValueModel(Preferences preferences, String key, P defaultValue) {
- this(preferences, key, defaultValue, BidiStringConverter.Default.<P>instance());
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public PreferencePropertyValueModel(Preferences preferences, String key, P defaultValue, BidiStringConverter<P> converter) {
- this(new StaticPropertyValueModel<Preferences>(preferences), key, defaultValue, converter);
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public static PreferencePropertyValueModel<Boolean> forBoolean(Preferences preferences, String key, boolean defaultValue) {
- return new PreferencePropertyValueModel<Boolean>(
- preferences,
- key,
- defaultValue ? Boolean.TRUE : Boolean.FALSE,
- BidiStringConverter.BooleanConverter.instance()
- );
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public static PreferencePropertyValueModel<Integer> forInteger(Preferences preferences, String key, int defaultValue) {
- return new PreferencePropertyValueModel<Integer>(
- preferences,
- key,
- Integer.valueOf(defaultValue),
- BidiStringConverter.IntegerConverter.instance()
- );
- }
-
- /**
- * Construct an adapter for the specified preference.
- * The default value of the preference will be null.
- */
- public PreferencePropertyValueModel(PropertyValueModel<? extends Preferences> preferencesHolder, String key) {
- this(preferencesHolder, key, null);
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public PreferencePropertyValueModel(PropertyValueModel<? extends Preferences> preferencesHolder, String key, P defaultValue) {
- this(preferencesHolder, key, defaultValue, BidiStringConverter.Default.<P>instance());
- }
-
- /**
- * Construct an adapter for the specified preference with
- * the specified default value for the preference.
- */
- public PreferencePropertyValueModel(PropertyValueModel<? extends Preferences> preferencesHolder, String key, P defaultValue, BidiStringConverter<P> converter) {
- super(preferencesHolder);
- this.key = key;
- this.defaultValue = defaultValue;
- this.converter = converter;
- this.preferenceChangeListener = this.buildPreferenceChangeListener();
- // our value is null when we are not listening to the preference
- this.value = null;
- }
-
-
- // ********** initialization **********
-
- /**
- * A preference has changed, notify the listeners if necessary.
- */
- protected PreferenceChangeListener buildPreferenceChangeListener() {
- // transform the preference change events into VALUE property change events
- return new PreferenceChangeListener() {
- public void preferenceChange(PreferenceChangeEvent event) {
- PreferencePropertyValueModel.this.preferenceChanged(event.getKey(), event.getNewValue());
- }
- @Override
- public String toString() {
- return "preference change listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ValueModel implementation **********
-
- /**
- * Return the cached (converted) value.
- */
- public synchronized P getValue() {
- return this.value;
- }
-
-
- // ********** PropertyValueModel implementation **********
-
- /**
- * Set the cached value, then set the appropriate preference value.
- */
- public synchronized void setValue(P value) {
- if (this.hasNoListeners()) {
- return; // no changes allowed when we have no listeners
- }
-
- Object old = this.value;
- this.value = value;
- this.fireAspectChanged(old, value);
-
- if ((this.subject != null) && this.preferenceIsToBeSet(old, value)) {
- this.setValue_(value);
- }
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected synchronized P getAspectValue() {
- return this.value;
- }
-
- @Override
- protected Class<? extends EventListener> getListenerClass() {
- return PropertyChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return VALUE;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyPropertyChangeListeners(VALUE);
- }
-
- @Override
- protected void fireAspectChanged(Object oldValue, Object newValue) {
- this.firePropertyChanged(VALUE, oldValue, newValue);
- }
-
- @Override
- protected synchronized void engageSubject_() {
- this.subject.addPreferenceChangeListener(this.preferenceChangeListener);
- this.value = this.buildValue();
- }
-
- @Override
- protected synchronized void disengageSubject_() {
- try {
- this.subject.removePreferenceChangeListener(this.preferenceChangeListener);
- } catch (IllegalStateException ex) {
- // for some odd reason, we are not allowed to remove a listener from a "dead"
- // preferences node; so handle the exception that gets thrown here
- if ( ! ex.getMessage().equals("Node has been removed.")) { //$NON-NLS-1$
- // if it is not the expected exception, re-throw it
- throw ex;
- }
- }
- this.value = null;
- }
-
-
- // ********** AbstractModel implementation **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.key);
- sb.append(" => "); //$NON-NLS-1$
- sb.append(this.value);
- }
-
-
- // ********** public API **********
-
- /**
- * Return the preference's key.
- */
- public String getKey() {
- return this.key;
- }
-
-
- // ********** internal methods **********
-
- /**
- * Return the preference's value.
- * At this point the subject may be null.
- */
- protected P buildValue() {
- return (this.subject == null) ? null : this.buildValue_();
- }
-
- /**
- * Return the appropriate preference, converted to the appropriate object.
- * At this point we can be sure that the subject is not null.
- */
- protected P buildValue_() {
- return this.convertToObject(this.subject.get(this.key, this.convertToString(this.defaultValue)));
- }
-
- /**
- * Set the appropriate preference after converting the value to a string.
- * At this point we can be sure that the subject is not null.
- */
- protected void setValue_(P value) {
- this.subject.put(this.key, this.convertToString(value));
- }
-
- /**
- * Return whether the specified new value should be passed
- * through to the preference. By default, only if the value has changed,
- * will it be passed through to the preference. This also has the
- * effect of not creating new preferences in the "backing store"
- * if the new value is the same as the default value.
- *
- * Subclasses can override this method to return true if they
- * would like to ALWAYS pass through the new value to the preference.
- */
- protected boolean preferenceIsToBeSet(Object oldValue, Object newValue) {
- return this.attributeValueHasChanged(oldValue, newValue);
- }
-
- /**
- * Convert the specified object to a string that can be stored as
- * the value of the preference.
- */
- protected String convertToString(P o) {
- return this.converter.convertToString(o);
- }
-
- /**
- * Convert the specified preference value string to an
- * appropriately-typed object to be returned to the client.
- */
- protected P convertToObject(String s) {
- return this.converter.convertToObject(s);
- }
-
- protected void preferenceChanged(String prefKey, @SuppressWarnings("unused") String newValue) {
- if (prefKey.equals(this.key)) {
- this.preferenceChanged();
- }
- }
-
- /**
- * The underlying preference changed; either because we changed it
- * in #setValue_(Object) or a third-party changed it.
- * If this is called because of our own change, the event will be
- * swallowed because the old and new values are the same.
- */
- protected synchronized void preferenceChanged() {
- Object old = this.value;
- this.value = this.buildValue();
- this.fireAspectChanged(old, this.value);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java
deleted file mode 100644
index e37b2666ca..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.prefs;
-
-import java.util.EventListener;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.prefs.BackingStoreException;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.Preferences;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.common.utility.internal.model.value.AspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-
-/**
- * This adapter wraps a Preferences node and converts its preferences into a
- * CollectionValueModel of PreferencePropertyValueModels. It listens for
- * "preference" changes and converts them into VALUE collection changes.
- */
-public class PreferencesCollectionValueModel<P>
- extends AspectAdapter<Preferences, Object>
- implements CollectionValueModel<PreferencePropertyValueModel<P>>
-{
-
- /** Cache the current preferences, stored in models and keyed by name. */
- protected final HashMap<String, PreferencePropertyValueModel<P>> preferences;
-
- /** A listener that listens to the preferences node for added or removed preferences. */
- protected final PreferenceChangeListener preferenceChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct an adapter for the specified preferences node.
- */
- public PreferencesCollectionValueModel(Preferences preferences) {
- this(new StaticPropertyValueModel<Preferences>(preferences));
- }
-
- /**
- * Construct an adapter for the specified preferences node.
- */
- public PreferencesCollectionValueModel(PropertyValueModel<? extends Preferences> preferencesHolder) {
- super(preferencesHolder);
- this.preferences = new HashMap<String, PreferencePropertyValueModel<P>>();
- this.preferenceChangeListener = this.buildPreferenceChangeListener();
- }
-
-
- // ********** initialization **********
-
- /**
- * A preferences have changed, notify the listeners.
- */
- protected PreferenceChangeListener buildPreferenceChangeListener() {
- // transform the preference change events into VALUE collection change events
- return new PreferenceChangeListener() {
- public void preferenceChange(PreferenceChangeEvent event) {
- PreferencesCollectionValueModel.this.preferenceChanged(event.getKey(), event.getNewValue());
- }
- @Override
- public String toString() {
- return "preference change listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** CollectionValueModel implementation **********
-
- /**
- * Return an iterator on the preference models.
- */
- public synchronized Iterator<PreferencePropertyValueModel<P>> iterator() {
- return this.preferences.values().iterator();
- }
-
- public synchronized int size() {
- return this.preferences.size();
- }
-
-
- // ********** AspectAdapter implementation **********
-
- @Override
- protected Object getAspectValue() {
- return this.iterator();
- }
-
- @Override
- protected Class<? extends EventListener> getListenerClass() {
- return CollectionChangeListener.class;
- }
-
- @Override
- protected String getListenerAspectName() {
- return VALUES;
- }
-
- @Override
- protected boolean hasListeners() {
- return this.hasAnyCollectionChangeListeners(VALUES);
- }
-
- @Override
- protected void fireAspectChanged(Object oldValue, Object newValue) {
- @SuppressWarnings("unchecked") Iterator<PreferencePropertyValueModel<P>> iterator = (Iterator<PreferencePropertyValueModel<P>>) newValue;
- this.fireCollectionChanged(VALUES, CollectionTools.collection(iterator));
- }
-
- @Override
- protected void engageSubject_() {
- this.subject.addPreferenceChangeListener(this.preferenceChangeListener);
- for (Iterator<PreferencePropertyValueModel<P>> stream = this.preferenceModels(); stream.hasNext(); ) {
- PreferencePropertyValueModel<P> preferenceModel = stream.next();
- this.preferences.put(preferenceModel.getKey(), preferenceModel);
- }
- }
-
- @Override
- protected void disengageSubject_() {
- try {
- this.subject.removePreferenceChangeListener(this.preferenceChangeListener);
- } catch (IllegalStateException ex) {
- // for some odd reason, we are not allowed to remove a listener from a "dead"
- // preferences node; so handle the exception that gets thrown here
- if ( ! ex.getMessage().equals("Node has been removed.")) { //$NON-NLS-1$
- // if it is not the expected exception, re-throw it
- throw ex;
- }
- }
- this.preferences.clear();
- }
-
-
- // ********** AbstractModel implementation **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.subject);
- }
-
-
- // ********** internal methods **********
-
- /**
- * Return an iterator on the preference models.
- * At this point we can be sure that the subject is not null.
- */
- protected Iterator<PreferencePropertyValueModel<P>> preferenceModels() {
- String[] keys;
- try {
- keys = this.subject.keys();
- } catch (BackingStoreException ex) {
- throw new RuntimeException(ex);
- }
- return new TransformationIterator<String, PreferencePropertyValueModel<P>>(new ArrayIterator<String>(keys)) {
- @Override
- protected PreferencePropertyValueModel<P> transform(String key) {
- return PreferencesCollectionValueModel.this.buildPreferenceModel(key);
- }
- };
- }
-
- /**
- * Override this method to tweak the model used to wrap the
- * specified preference (e.g. to customize the model's converter).
- */
- protected PreferencePropertyValueModel<P> buildPreferenceModel(String key) {
- return new PreferencePropertyValueModel<P>(this.subjectHolder, key);
- }
-
- protected synchronized void preferenceChanged(String key, String newValue) {
- if (newValue == null) {
- // a preference was removed
- PreferencePropertyValueModel<P> preferenceModel = this.preferences.remove(key);
- this.fireItemRemoved(VALUES, preferenceModel);
- } else if ( ! this.preferences.containsKey(key)) {
- // a preference was added
- PreferencePropertyValueModel<P> preferenceModel = this.buildPreferenceModel(key);
- this.preferences.put(key, preferenceModel);
- this.fireItemAdded(VALUES, preferenceModel);
- } else {
- // a preference's value changed - do nothing
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/AbstractTreeModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/AbstractTreeModel.java
deleted file mode 100644
index 0a3ab42d06..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/AbstractTreeModel.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import java.io.Serializable;
-import javax.swing.event.EventListenerList;
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.TreeModel;
-
-/**
- * Abstract class that should have been provided by the JDK
- * (à la javax.swing.AbstractListModel). This class provides:
- * - support for a collection of listeners
- * - a number of convenience methods for firing events for those listeners
- */
-public abstract class AbstractTreeModel
- implements TreeModel, Serializable
-{
- /** Our listeners. */
- protected final EventListenerList listenerList;
-
-
- // ********** constructors/initialization **********
-
- protected AbstractTreeModel() {
- super();
- this.listenerList = new EventListenerList();
- }
-
-
- // ********** partial TreeModel implementation **********
-
- public void addTreeModelListener(TreeModelListener l) {
- this.listenerList.add(TreeModelListener.class, l);
- }
-
- public void removeTreeModelListener(TreeModelListener l) {
- this.listenerList.remove(TreeModelListener.class, l);
- }
-
-
- // ********** queries **********
-
- /**
- * Return the model's current collection of listeners.
- * (There seems to be a pattern of making this type of method public;
- * although it should probably be protected....)
- */
- public TreeModelListener[] treeModelListeners() {
- return this.listenerList.getListeners(TreeModelListener.class);
- }
-
- /**
- * Return whether this model has no listeners.
- */
- protected boolean hasNoTreeModelListeners() {
- return this.listenerList.getListenerCount(TreeModelListener.class) == 0;
- }
-
- /**
- * Return whether this model has any listeners.
- */
- protected boolean hasTreeModelListeners() {
- return ! this.hasNoTreeModelListeners();
- }
-
-
- // ********** behavior **********
-
- /**
- * Notify listeners of a model change.
- * A significant property of the nodes changed, but the nodes themselves
- * are still the same objects.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodesChanged(Object[] path, int[] childIndices, Object[] children) {
- // guaranteed to return a non-null array
- Object[] listeners = this.listenerList.getListenerList();
- TreeModelEvent event = null;
- // process the listeners last to first, notifying
- // those that are interested in this event
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==TreeModelListener.class) {
- // lazily create the event
- if (event == null) {
- event = new TreeModelEvent(this, path, childIndices, children);
- }
- ((TreeModelListener) listeners[i+1]).treeNodesChanged(event);
- }
- }
- }
-
-
- /**
- * Notify listeners of a model change.
- * A significant property of the node changed, but the node itself is the same object.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodeChanged(Object[] path, int childIndex, Object child) {
- this.fireTreeNodesChanged(path, new int[] {childIndex}, new Object[] {child});
- }
-
- /**
- * Notify listeners of a model change.
- * A significant property of the root changed, but the root itself is the same object.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeRootChanged(Object root) {
- this.fireTreeNodesChanged(new Object[] {root}, null, null);
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodesInserted(Object[] path, int[] childIndices, Object[] children) {
- // guaranteed to return a non-null array
- Object[] listeners = this.listenerList.getListenerList();
- TreeModelEvent event = null;
- // process the listeners last to first, notifying
- // those that are interested in this event
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==TreeModelListener.class) {
- // lazily create the event
- if (event == null) {
- event = new TreeModelEvent(this, path, childIndices, children);
- }
- ((TreeModelListener) listeners[i+1]).treeNodesInserted(event);
- }
- }
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodeInserted(Object[] path, int childIndex, Object child) {
- this.fireTreeNodesInserted(path, new int[] {childIndex}, new Object[] {child});
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodesRemoved(Object[] path, int[] childIndices, Object[] children) {
- // guaranteed to return a non-null array
- Object[] listeners = this.listenerList.getListenerList();
- TreeModelEvent event = null;
- // process the listeners last to first, notifying
- // those that are interested in this event
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==TreeModelListener.class) {
- // lazily create the event
- if (event == null) {
- event = new TreeModelEvent(this, path, childIndices, children);
- }
- ((TreeModelListener) listeners[i+1]).treeNodesRemoved(event);
- }
- }
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeNodeRemoved(Object[] path, int childIndex, Object child) {
- this.fireTreeNodesRemoved(path, new int[] {childIndex}, new Object[] {child});
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeStructureChanged(Object[] path) {
- // guaranteed to return a non-null array
- Object[] listeners = this.listenerList.getListenerList();
- TreeModelEvent event = null;
- // process the listeners last to first, notifying
- // those that are interested in this event
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==TreeModelListener.class) {
- // lazily create the event
- if (event == null) {
- event = new TreeModelEvent(this, path);
- }
- ((TreeModelListener) listeners[i+1]).treeStructureChanged(event);
- }
- }
- }
-
- /**
- * Notify listeners of a model change.
- * @see javax.swing.event.TreeModelEvent
- * @see javax.swing.event.TreeModelListener
- */
- protected void fireTreeRootReplaced(Object newRoot) {
- this.fireTreeStructureChanged(new Object[] {newRoot});
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/CheckBoxModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/CheckBoxModelAdapter.java
deleted file mode 100644
index df70901b28..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/CheckBoxModelAdapter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This javax.swing.ButtonModel can be used to keep a listener
- * (e.g. a JCheckBox) in synch with a PropertyValueModel that
- * holds a boolean.
- *
- * Maybe not the richest class in our toolbox, but it was the
- * victim of refactoring.... ~bjv
- */
-public class CheckBoxModelAdapter
- extends ToggleButtonModelAdapter
-{
-
- // ********** constructors **********
-
- /**
- * Constructor - the boolean holder is required.
- */
- public CheckBoxModelAdapter(ModifiablePropertyValueModel<Boolean> booleanHolder, boolean defaultValue) {
- super(booleanHolder, defaultValue);
- }
-
- /**
- * Constructor - the boolean holder is required.
- * The default value will be false.
- */
- public CheckBoxModelAdapter(ModifiablePropertyValueModel<Boolean> booleanHolder) {
- super(booleanHolder);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ColumnAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ColumnAdapter.java
deleted file mode 100644
index b88e44d6b9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ColumnAdapter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-
-/**
- * This adapter is used by the table model adapter to
- * convert a model object into the models used for each of
- * the cells for the object's corresponding row in the table.
- */
-public interface ColumnAdapter {
- /**
- * Return the number of columns in the table.
- * Typically this is static.
- */
- int columnCount();
-
- /**
- * Return the name of the specified column.
- */
- String columnName(int index);
-
- /**
- * Return the class of the specified column.
- */
- Class<?> columnClass(int index);
-
- /**
- * Return whether the specified column is editable.
- * Typically this is the same for every row.
- */
- boolean columnIsEditable(int index);
-
- /**
- * Return the cell models for the specified subject
- * that corresponds to a single row in the table.
- */
- ModifiablePropertyValueModel<Object>[] cellModels(Object subject);
-
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ComboBoxModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ComboBoxModelAdapter.java
deleted file mode 100644
index 9db0d020a5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ComboBoxModelAdapter.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import javax.swing.ComboBoxModel;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This javax.swing.ComboBoxModel can be used to keep a ListDataListener
- * (e.g. a JComboBox) in synch with a ListValueModel (or a CollectionValueModel).
- * For combo boxes, the model object that holds the current selection is
- * typically a different model object than the one that holds the collection
- * of choices.
- *
- * For example, a MWReference (the selectionOwner) has an attribute
- * "sourceTable" (the collectionOwner)
- * which holds on to a collection of MWDatabaseFields. When the selection
- * is changed this model will keep the listeners aware of the changes.
- * The inherited list model will keep its listeners aware of changes to the
- * collection model
- *
- * In addition to the collection holder required by the superclass,
- * an instance of this ComboBoxModel must be supplied with a
- * selection holder, which is a PropertyValueModel that provides access
- * to the selection (typically a PropertyAspectAdapter).
- */
-public class ComboBoxModelAdapter
- extends ListModelAdapter
- implements ComboBoxModel
-{
- protected final ModifiablePropertyValueModel<Object> selectionHolder;
- protected final PropertyChangeListener selectionListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the list holder and selection holder are required;
- */
- public ComboBoxModelAdapter(ListValueModel<?> listHolder, ModifiablePropertyValueModel<Object> selectionHolder) {
- super(listHolder);
- if (selectionHolder == null) {
- throw new NullPointerException();
- }
- this.selectionHolder = selectionHolder;
- this.selectionListener = this.buildSelectionListener();
- }
-
- /**
- * Constructor - the collection holder and selection holder are required;
- */
- public ComboBoxModelAdapter(CollectionValueModel<?> collectionHolder, ModifiablePropertyValueModel<Object> selectionHolder) {
- super(collectionHolder);
- if (selectionHolder == null) {
- throw new NullPointerException();
- }
- this.selectionHolder = selectionHolder;
- this.selectionListener = this.buildSelectionListener();
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildSelectionListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildSelectionListener_());
- }
-
- protected PropertyChangeListener buildSelectionListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- // notify listeners that the selection has changed
- ComboBoxModelAdapter.this.fireSelectionChanged();
- }
- @Override
- public String toString() {
- return "selection listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ComboBoxModel implementation **********
-
- public Object getSelectedItem() {
- return this.selectionHolder.getValue();
- }
-
- public void setSelectedItem(Object selectedItem) {
- this.selectionHolder.setValue(selectedItem);
- }
-
-
- // ********** behavior **********
-
- /**
- * Extend to engage the selection holder.
- */
- @Override
- protected void engageModel() {
- super.engageModel();
- this.selectionHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.selectionListener);
- }
-
- /**
- * Extend to disengage the selection holder.
- */
- @Override
- protected void disengageModel() {
- this.selectionHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.selectionListener);
- super.disengageModel();
- }
-
- /**
- * Notify the listeners that the selection has changed.
- */
- protected void fireSelectionChanged() {
- // I guess this will work...
- this.fireContentsChanged(this, -1, -1);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.selectionHolder + ":" + this.listHolder); //$NON-NLS-1$
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/DateSpinnerModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/DateSpinnerModelAdapter.java
deleted file mode 100644
index 1676162257..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/DateSpinnerModelAdapter.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import java.util.Calendar;
-import java.util.Date;
-import javax.swing.SpinnerDateModel;
-import javax.swing.event.ChangeListener;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This javax.swing.SpinnerDateModel can be used to keep a ChangeListener
- * (e.g. a JSpinner) in synch with a PropertyValueModel that holds a date.
- *
- * This class must be a sub-class of SpinnerDateModel because of some
- * crappy jdk code.... ~bjv
- * @see javax.swing.JSpinner#createEditor(javax.swing.SpinnerModel)
- *
- * If this class needs to be modified, it would behoove us to review the
- * other, similar classes:
- * @see ListSpinnerModelAdapter
- * @see NumberSpinnerModelAdapter
- */
-public class DateSpinnerModelAdapter
- extends SpinnerDateModel
-{
-
- /**
- * The default spinner value; used when the underlying model date value is null.
- * The default is the current date.
- */
- private final Date defaultValue;
-
- /** A value model on the underlying date. */
- private final ModifiablePropertyValueModel<Object> dateHolder;
-
- /** A listener that allows us to synchronize with changes made to the underlying date. */
- private final PropertyChangeListener dateChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the date holder is required.
- * The default spinner value is the current date.
- */
- public DateSpinnerModelAdapter(ModifiablePropertyValueModel<Object> dateHolder) {
- this(dateHolder, new Date());
- }
-
- /**
- * Constructor - the date holder and default value are required.
- */
- public DateSpinnerModelAdapter(ModifiablePropertyValueModel<Object> dateHolder, Date defaultValue) {
- this(dateHolder, null, null, Calendar.DAY_OF_MONTH, defaultValue);
- }
-
- /**
- * Constructor - the date holder is required.
- * The default spinner value is the current date.
- */
- public DateSpinnerModelAdapter(ModifiablePropertyValueModel<Object> dateHolder, Comparable<?> start, Comparable<?> end, int calendarField) {
- this(dateHolder, start, end, calendarField, new Date());
- }
-
- /**
- * Constructor - the date holder is required.
- */
- public DateSpinnerModelAdapter(ModifiablePropertyValueModel<Object> dateHolder, Comparable<?> start, Comparable<?> end, int calendarField, Date defaultValue) {
- super(dateHolder.getValue() == null ? defaultValue : (Date) dateHolder.getValue(), start, end, calendarField);
- this.dateHolder = dateHolder;
- this.dateChangeListener = this.buildDateChangeListener();
- // postpone listening to the underlying date
- // until we have listeners ourselves...
- this.defaultValue = defaultValue;
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildDateChangeListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildDateChangeListener_());
- }
-
- protected PropertyChangeListener buildDateChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- DateSpinnerModelAdapter.this.synchronize(event.getNewValue());
- }
- @Override
- public String toString() {
- return "date listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** SpinnerModel implementation **********
-
- /**
- * Extend to check whether this method is being called before we
- * have any listeners.
- * This is necessary because some crappy jdk code gets the value
- * from the model *before* listening to the model. ~bjv
- * @see javax.swing.JSpinner.DefaultEditor(javax.swing.JSpinner)
- */
- @Override
- public Object getValue() {
- if (this.getChangeListeners().length == 0) {
- // sorry about this "lateral" call to super ~bjv
- super.setValue(this.spinnerValueOf(this.dateHolder.getValue()));
- }
- return super.getValue();
- }
-
- /**
- * Extend to update the underlying date directly.
- * The resulting event will be ignored: @see #synchronize(Object).
- */
- @Override
- public void setValue(Object value) {
- super.setValue(value);
- this.dateHolder.setValue(value);
- }
-
- /**
- * Extend to start listening to the underlying date if necessary.
- */
- @Override
- public void addChangeListener(ChangeListener listener) {
- if (this.getChangeListeners().length == 0) {
- this.dateHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.dateChangeListener);
- this.synchronize(this.dateHolder.getValue());
- }
- super.addChangeListener(listener);
- }
-
- /**
- * Extend to stop listening to the underlying date if appropriate.
- */
- @Override
- public void removeChangeListener(ChangeListener listener) {
- super.removeChangeListener(listener);
- if (this.getChangeListeners().length == 0) {
- this.dateHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.dateChangeListener);
- }
- }
-
-
- // ********** queries **********
-
- protected Date getDefaultValue() {
- return this.defaultValue;
- }
-
- /**
- * Convert to a non-null value.
- */
- protected Object spinnerValueOf(Object value) {
- return (value == null) ? this.getDefaultValue() : value;
- }
-
-
- // ********** behavior **********
-
- /**
- * Set the spinner value if it has changed.
- */
- void synchronize(Object value) {
- Object newValue = this.spinnerValueOf(value);
- // check to see whether the spinner date has already been synchronized
- // (via #setValue())
- if ( ! this.getValue().equals(newValue)) {
- this.setValue(newValue);
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.dateHolder);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/DocumentAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/DocumentAdapter.java
deleted file mode 100644
index 173017361b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/DocumentAdapter.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.util.EventObject;
-
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.event.EventListenerList;
-import javax.swing.event.UndoableEditEvent;
-import javax.swing.event.UndoableEditListener;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.Document;
-import javax.swing.text.Element;
-import javax.swing.text.PlainDocument;
-import javax.swing.text.Position;
-import javax.swing.text.Segment;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This javax.swing.text.Document can be used to keep a DocumentListener
- * (e.g. a JTextField) in synch with a PropertyValueModel that holds a string.
- *
- * NB: This model should only be used for "small" documents;
- * i.e. documents used by text fields, not text panes.
- * @see #synchronizeDelegate(String)
- */
-public class DocumentAdapter
- implements Document, Serializable
-{
-
- /** The delegate document whose behavior we "enhance". */
- protected final Document delegate;
-
- /** A listener that allows us to forward any changes made to the delegate document. */
- protected final CombinedListener delegateListener;
-
- /** A value model on the underlying model string. */
- protected final ModifiablePropertyValueModel<String> stringHolder;
-
- /** A listener that allows us to synchronize with changes made to the underlying model string. */
- protected transient PropertyChangeListener stringListener;
-
- /** The event listener list for the document. */
- protected final EventListenerList listenerList = new EventListenerList();
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the string holder is required.
- * Wrap the specified document.
- */
- public DocumentAdapter(ModifiablePropertyValueModel<String> stringHolder, Document delegate) {
- super();
- if (stringHolder == null || delegate == null) {
- throw new NullPointerException();
- }
- this.stringHolder = stringHolder;
- // postpone listening to the underlying model string
- // until we have listeners ourselves...
- this.delegate = delegate;
- this.stringListener = this.buildStringListener();
- this.delegateListener = this.buildDelegateListener();
- }
-
- /**
- * Constructor - the string holder is required.
- * Wrap a plain document.
- */
- public DocumentAdapter(ModifiablePropertyValueModel<String> stringHolder) {
- this(stringHolder, new PlainDocument());
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildStringListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildStringListener_());
- }
-
- protected PropertyChangeListener buildStringListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- DocumentAdapter.this.stringChanged(event);
- }
- @Override
- public String toString() {
- return "string listener"; //$NON-NLS-1$
- }
- };
- }
-
- protected CombinedListener buildDelegateListener() {
- return new InternalListener();
- }
-
-
- // ********** Document implementation **********
-
- public int getLength() {
- return this.delegate.getLength();
- }
-
- /**
- * Extend to start listening to the underlying models if necessary.
- */
- public void addDocumentListener(DocumentListener listener) {
- if (this.listenerList.getListenerCount(DocumentListener.class) == 0) {
- this.delegate.addDocumentListener(this.delegateListener);
- this.engageStringHolder();
- }
- this.listenerList.add(DocumentListener.class, listener);
- }
-
- /**
- * Extend to stop listening to the underlying models if appropriate.
- */
- public void removeDocumentListener(DocumentListener listener) {
- this.listenerList.remove(DocumentListener.class, listener);
- if (this.listenerList.getListenerCount(DocumentListener.class) == 0) {
- this.disengageStringHolder();
- this.delegate.removeDocumentListener(this.delegateListener);
- }
- }
-
- /**
- * Extend to start listening to the delegate document if necessary.
- */
- public void addUndoableEditListener(UndoableEditListener listener) {
- if (this.listenerList.getListenerCount(UndoableEditListener.class) == 0) {
- this.delegate.addUndoableEditListener(this.delegateListener);
- }
- this.listenerList.add(UndoableEditListener.class, listener);
- }
-
- /**
- * Extend to stop listening to the delegate document if appropriate.
- */
- public void removeUndoableEditListener(UndoableEditListener listener) {
- this.listenerList.remove(UndoableEditListener.class, listener);
- if (this.listenerList.getListenerCount(UndoableEditListener.class) == 0) {
- this.delegate.removeUndoableEditListener(this.delegateListener);
- }
- }
-
- public Object getProperty(Object key) {
- return this.delegate.getProperty(key);
- }
-
- public void putProperty(Object key, Object value) {
- this.delegate.putProperty(key, value);
- }
-
- /**
- * Extend to update the underlying model string directly.
- * The resulting event will be ignored: @see #synchronizeDelegate(String).
- */
- public void remove(int offset, int len) throws BadLocationException {
- this.delegate.remove(offset, len);
- this.stringHolder.setValue(this.delegate.getText(0, this.delegate.getLength()));
- }
-
- /**
- * Extend to update the underlying model string directly.
- * The resulting event will be ignored: @see #synchronizeDelegate(String).
- */
- public void insertString(int offset, String insertedString, AttributeSet a) throws BadLocationException {
- this.delegate.insertString(offset, insertedString, a);
- this.stringHolder.setValue(this.delegate.getText(0, this.delegate.getLength()));
- }
-
- public String getText(int offset, int length) throws BadLocationException {
- return this.delegate.getText(offset, length);
- }
-
- public void getText(int offset, int length, Segment txt) throws BadLocationException {
- this.delegate.getText(offset, length, txt);
- }
-
- public Position getStartPosition() {
- return this.delegate.getStartPosition();
- }
-
- public Position getEndPosition() {
- return this.delegate.getEndPosition();
- }
-
- public Position createPosition(int offs) throws BadLocationException {
- return this.delegate.createPosition(offs);
- }
-
- public Element[] getRootElements() {
- return this.delegate.getRootElements();
- }
-
- public Element getDefaultRootElement() {
- return this.delegate.getDefaultRootElement();
- }
-
- public void render(Runnable r) {
- this.delegate.render(r);
- }
-
-
- // ********** queries **********
-
- public DocumentListener[] documentListeners() {
- return this.listenerList.getListeners(DocumentListener.class);
- }
-
- public UndoableEditListener[] undoableEditListeners() {
- return this.listenerList.getListeners(UndoableEditListener.class);
- }
-
-
- // ********** behavior **********
-
- /**
- * A third party has modified the underlying model string.
- * Synchronize the delegate document accordingly.
- */
- protected void stringChanged(PropertyChangeEvent event) {
- this.synchronizeDelegate((String) event.getNewValue());
- }
-
- /**
- * Replace the document's entire text string with the new string.
- */
- protected void synchronizeDelegate(String s) {
- try {
- int len = this.delegate.getLength();
- // check to see whether the delegate has already been synchronized
- // (via #insertString() or #remove())
- if ( ! this.delegate.getText(0, len).equals(s)) {
- this.delegate.remove(0, len);
- this.delegate.insertString(0, s, null);
- }
- } catch (BadLocationException ex) {
- throw new IllegalStateException(ex.getMessage()); // this should not happen...
- }
- }
-
- protected void engageStringHolder() {
- this.stringHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.stringListener);
- this.synchronizeDelegate(this.stringHolder.getValue());
- }
-
- protected void disengageStringHolder() {
- this.stringHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.stringListener);
- }
-
- protected void delegateChangedUpdate(DocumentEvent event) {
- // no need to lazy-initialize the event;
- // we wouldn't get here if we did not have listeners...
- DocumentEvent ee = new InternalDocumentEvent(this, event);
- DocumentListener[] listeners = this.documentListeners();
- for (int i = listeners.length; i-- > 0; ) {
- listeners[i].changedUpdate(ee);
- }
- }
-
- protected void delegateInsertUpdate(DocumentEvent event) {
- // no need to lazy-initialize the event;
- // we wouldn't get here if we did not have listeners...
- DocumentEvent ee = new InternalDocumentEvent(this, event);
- DocumentListener[] listeners = this.documentListeners();
- for (int i = listeners.length; i-- > 0; ) {
- listeners[i].insertUpdate(ee);
- }
- }
-
- protected void delegateRemoveUpdate(DocumentEvent event) {
- // no need to lazy-initialize the event;
- // we wouldn't get here if we did not have listeners...
- DocumentEvent ee = new InternalDocumentEvent(this, event);
- DocumentListener[] listeners = this.documentListeners();
- for (int i = listeners.length; i-- > 0; ) {
- listeners[i].removeUpdate(ee);
- }
- }
-
- protected void delegateUndoableEditHappened(UndoableEditEvent event) {
- // no need to lazy-initialize the event;
- // we wouldn't get here if we did not have listeners...
- UndoableEditEvent ee = new UndoableEditEvent(this, event.getEdit());
- UndoableEditListener[] listeners = this.undoableEditListeners();
- for (int i = listeners.length; i-- > 0; ) {
- listeners[i].undoableEditHappened(ee);
- }
- }
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.stringHolder);
- }
-
- private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
- // read in any hidden stuff
- s.defaultReadObject();
- this.stringListener = this.buildStringListener();
- }
-
-
-// ********** inner class **********
-
- protected interface CombinedListener extends DocumentListener, UndoableEditListener, Serializable {
- // just consolidate the two interfaces
- }
-
- protected class InternalListener implements CombinedListener {
- private static final long serialVersionUID = 1L;
- public void changedUpdate(DocumentEvent event) {
- DocumentAdapter.this.delegateChangedUpdate(event);
- }
- public void insertUpdate(DocumentEvent event) {
- DocumentAdapter.this.delegateInsertUpdate(event);
- }
- public void removeUpdate(DocumentEvent event) {
- DocumentAdapter.this.delegateRemoveUpdate(event);
- }
- public void undoableEditHappened(UndoableEditEvent event) {
- DocumentAdapter.this.delegateUndoableEditHappened(event);
- }
- }
-
- protected static class InternalDocumentEvent
- extends EventObject
- implements DocumentEvent
- {
- protected DocumentEvent delegate;
-
- protected InternalDocumentEvent(Document document, DocumentEvent delegate) {
- super(document);
- this.delegate = delegate;
- }
- public ElementChange getChange(Element elem) {
- return this.delegate.getChange(elem);
- }
- public Document getDocument() {
- return (Document) this.source;
- }
- public int getLength() {
- return this.delegate.getLength();
- }
- public int getOffset() {
- return this.delegate.getOffset();
- }
- public EventType getType() {
- return this.delegate.getType();
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ListModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ListModelAdapter.java
deleted file mode 100644
index 2d1c1e4b5d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ListModelAdapter.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import javax.swing.AbstractListModel;
-import javax.swing.event.ListDataListener;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTListChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionListValueModelAdapter;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * This javax.swing.ListModel can be used to keep a ListDataListener
- * (e.g. a JList) in synch with a ListValueModel (or a CollectionValueModel).
- *
- * An instance of this ListModel *must* be supplied with a value model,
- * which is a ListValueModel on the bound list or a CollectionValueModel
- * on the bound collection. This is required - the list (or collection)
- * itself can be null, but the value model that holds it cannot.
- */
-public class ListModelAdapter
- extends AbstractListModel
-{
- /** A value model on the underlying model list. */
- protected ListValueModel<?> listHolder;
-
- /**
- * Cache the size of the list for "dramatic" changes.
- * @see #listChanged(ListChangeEvent)
- */
- protected int listSize;
-
- /** A listener that allows us to forward changes made to the underlying model list. */
- protected final ListChangeListener listChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Default constructor - initialize stuff.
- */
- private ListModelAdapter() {
- super();
- this.listSize = 0;
- this.listChangeListener = this.buildListChangeListener();
- }
-
- /**
- * Constructor - the list holder is required.
- */
- public ListModelAdapter(ListValueModel<?> listHolder) {
- this();
- this.setModel(listHolder);
- }
-
- /**
- * Constructor - the collection holder is required.
- */
- public ListModelAdapter(CollectionValueModel<?> collectionHolder) {
- this();
- this.setModel(collectionHolder);
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildListChangeListener() {
- return new AWTListChangeListenerWrapper(this.buildListChangeListener_());
- }
-
- protected ListChangeListener buildListChangeListener_() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent event) {
- ListModelAdapter.this.itemsAdded(event);
- }
- public void itemsRemoved(ListRemoveEvent event) {
- ListModelAdapter.this.itemsRemoved(event);
- }
- public void itemsReplaced(ListReplaceEvent event) {
- ListModelAdapter.this.itemsReplaced(event);
- }
- public void itemsMoved(ListMoveEvent event) {
- ListModelAdapter.this.itemsMoved(event);
- }
- public void listCleared(ListClearEvent event) {
- ListModelAdapter.this.listCleared();
- }
- public void listChanged(ListChangeEvent event) {
- ListModelAdapter.this.listChanged();
- }
- @Override
- public String toString() {
- return "list listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ListModel implementation **********
-
- public int getSize() {
- return this.listHolder.size();
- }
-
- public Object getElementAt(int index) {
- return this.listHolder.get(index);
- }
-
- /**
- * Extend to start listening to the underlying model list if necessary.
- */
- @Override
- public void addListDataListener(ListDataListener l) {
- if (this.hasNoListDataListeners()) {
- this.engageModel();
- this.listSize = this.listHolder.size();
- }
- super.addListDataListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model list if appropriate.
- */
- @Override
- public void removeListDataListener(ListDataListener l) {
- super.removeListDataListener(l);
- if (this.hasNoListDataListeners()) {
- this.disengageModel();
- this.listSize = 0;
- }
- }
-
-
- // ********** public API **********
-
- /**
- * Return the underlying list model.
- */
- public ListValueModel<?> model() {
- return this.listHolder;
- }
-
- /**
- * Set the underlying list model.
- */
- public void setModel(ListValueModel<?> listHolder) {
- if (listHolder == null) {
- throw new NullPointerException();
- }
- boolean hasListeners = this.hasListDataListeners();
- if (hasListeners) {
- this.disengageModel();
- }
- this.listHolder = listHolder;
- if (hasListeners) {
- this.engageModel();
- this.listChanged();
- }
- }
-
- /**
- * Set the underlying collection model.
- */
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void setModel(CollectionValueModel<?> collectionHolder) {
- this.setModel(new CollectionListValueModelAdapter(collectionHolder));
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether this model has no listeners.
- */
- protected boolean hasNoListDataListeners() {
- return this.getListDataListeners().length == 0;
- }
-
- /**
- * Return whether this model has any listeners.
- */
- protected boolean hasListDataListeners() {
- return ! this.hasNoListDataListeners();
- }
-
-
- // ********** behavior **********
-
- protected void engageModel() {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
- protected void disengageModel() {
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
-
-
- // ********** list change support **********
-
- /**
- * Items were added to the underlying model list.
- * Notify listeners of the changes.
- */
- protected void itemsAdded(ListAddEvent event) {
- int start = event.getIndex();
- int end = start + event.getItemsSize() - 1;
- this.fireIntervalAdded(this, start, end);
- this.listSize += event.getItemsSize();
- }
-
- /**
- * Items were removed from the underlying model list.
- * Notify listeners of the changes.
- */
- protected void itemsRemoved(ListRemoveEvent event) {
- int start = event.getIndex();
- int end = start + event.getItemsSize() - 1;
- this.fireIntervalRemoved(this, start, end);
- this.listSize -= event.getItemsSize();
- }
-
- /**
- * Items were replaced in the underlying model list.
- * Notify listeners of the changes.
- */
- protected void itemsReplaced(ListReplaceEvent event) {
- int start = event.getIndex();
- int end = start + event.getItemsSize() - 1;
- this.fireContentsChanged(this, start, end);
- }
-
- /**
- * Items were moved in the underlying model list.
- * Notify listeners of the changes.
- */
- protected void itemsMoved(ListMoveEvent event) {
- int start = Math.min(event.getSourceIndex(), event.getTargetIndex());
- int end = Math.max(event.getSourceIndex(), event.getTargetIndex()) + event.getLength() - 1;
- this.fireContentsChanged(this, start, end);
- }
-
- /**
- * The underlying model list was cleared.
- * Notify listeners of the changes.
- */
- protected void listCleared() {
- if (this.listSize != 0) {
- this.fireIntervalRemoved(this, 0, this.listSize - 1);
- this.listSize = 0;
- }
- }
-
- /**
- * The underlying model list has changed "dramatically".
- * Notify listeners of the changes.
- */
- protected void listChanged() {
- if (this.listSize != 0) {
- this.fireIntervalRemoved(this, 0, this.listSize - 1);
- }
- this.listSize = this.listHolder.size();
- if (this.listSize != 0) {
- this.fireIntervalAdded(this, 0, this.listSize - 1);
- }
- }
-
-
- // ********** Object overrides **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.listHolder);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ListSpinnerModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ListSpinnerModelAdapter.java
deleted file mode 100644
index 02430c396f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ListSpinnerModelAdapter.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import java.util.Arrays;
-import java.util.List;
-import javax.swing.SpinnerListModel;
-import javax.swing.event.ChangeListener;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This javax.swing.SpinnerListModel can be used to keep a ChangeListener
- * (e.g. a JSpinner) in synch with a PropertyValueModel that holds a value
- * in the list.
- *
- * This class must be a sub-class of SpinnerListModel because of some
- * crappy jdk code.... ~bjv
- * @see javax.swing.JSpinner#createEditor(javax.swing.SpinnerModel)
- *
- * NB: This model should only be used for values that have a reasonably
- * inexpensive #equals() implementation.
- * @see #synchronize(Object)
- *
- * If this class needs to be modified, it would behoove us to review the
- * other, similar classes:
- * @see DateSpinnerModelAdapter
- * @see NumberSpinnerModelAdapter
- */
-public class ListSpinnerModelAdapter
- extends SpinnerListModel
-{
-
- /**
- * The default spinner value; used when the underlying model value is null.
- * The default is the first item on the list.
- */
- private final Object defaultValue;
-
- /** A value model on the underlying value. */
- private final ModifiablePropertyValueModel<Object> valueHolder;
-
- /** A listener that allows us to synchronize with changes made to the underlying value. */
- private final PropertyChangeListener valueChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the value holder is required.
- * Use the model value itself as the default spinner value.
- */
- public ListSpinnerModelAdapter(ModifiablePropertyValueModel<Object> valueHolder) {
- this(valueHolder, valueHolder.getValue());
- }
-
- /**
- * Constructor - the value holder is required.
- */
- public ListSpinnerModelAdapter(ModifiablePropertyValueModel<Object> valueHolder, Object defaultValue) {
- this(valueHolder, new Object[] {defaultValue}, defaultValue);
- }
-
- /**
- * Constructor - the value holder is required.
- * Use the first item in the list of values as the default spinner value.
- */
- public ListSpinnerModelAdapter(ModifiablePropertyValueModel<Object> valueHolder, Object[] values) {
- this(valueHolder, values, values[0]);
- }
-
- /**
- * Constructor - the value holder is required.
- */
- public ListSpinnerModelAdapter(ModifiablePropertyValueModel<Object> valueHolder, Object[] values, Object defaultValue) {
- this(valueHolder, Arrays.asList(values), defaultValue);
- }
-
- /**
- * Constructor - the value holder is required.
- * Use the first item in the list of values as the default spinner value.
- */
- public ListSpinnerModelAdapter(ModifiablePropertyValueModel<Object> valueHolder, List<Object> values) {
- this(valueHolder, values, values.get(0));
- }
-
- /**
- * Constructor - the value holder is required.
- */
- public ListSpinnerModelAdapter(ModifiablePropertyValueModel<Object> valueHolder, List<Object> values, Object defaultValue) {
- super(values);
- this.valueHolder = valueHolder;
- this.valueChangeListener = this.buildValueChangeListener();
- // postpone listening to the underlying value
- // until we have listeners ourselves...
- this.defaultValue = defaultValue;
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildValueChangeListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildValueChangeListener_());
- }
-
- protected PropertyChangeListener buildValueChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- ListSpinnerModelAdapter.this.synchronize(event.getNewValue());
- }
- @Override
- public String toString() {
- return "value listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** SpinnerModel implementation **********
-
- /**
- * Extend to check whether this method is being called before we
- * have any listeners.
- * This is necessary because some crappy jdk code gets the value
- * from the model *before* listening to the model. ~bjv
- * @see javax.swing.JSpinner.DefaultEditor(javax.swing.JSpinner)
- */
- @Override
- public Object getValue() {
- if (this.getChangeListeners().length == 0) {
- // sorry about this "lateral" call to super ~bjv
- super.setValue(this.spinnerValueOf(this.valueHolder.getValue()));
- }
- return super.getValue();
- }
-
- /**
- * Extend to update the underlying value directly.
- * The resulting event will be ignored: @see #synchronize(Object).
- */
- @Override
- public void setValue(Object value) {
- super.setValue(value);
- this.valueHolder.setValue(value);
- }
-
- /**
- * Extend to start listening to the underlying value if necessary.
- */
- @Override
- public void addChangeListener(ChangeListener listener) {
- if (this.getChangeListeners().length == 0) {
- this.valueHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.valueChangeListener);
- this.synchronize(this.valueHolder.getValue());
- }
- super.addChangeListener(listener);
- }
-
- /**
- * Extend to stop listening to the underlying value if appropriate.
- */
- @Override
- public void removeChangeListener(ChangeListener listener) {
- super.removeChangeListener(listener);
- if (this.getChangeListeners().length == 0) {
- this.valueHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.valueChangeListener);
- }
- }
-
-
- // ********** queries **********
-
- protected Object getDefaultValue() {
- return this.defaultValue;
- }
-
- /**
- * Convert to a non-null value.
- */
- protected Object spinnerValueOf(Object value) {
- return (value == null) ? this.getDefaultValue() : value;
- }
-
-
- // ********** behavior **********
-
- /**
- * Set the spinner value if it has changed.
- */
- void synchronize(Object value) {
- Object newValue = this.spinnerValueOf(value);
- // check to see whether the spinner value has already been synchronized
- // (via #setValue())
- if ( ! this.getValue().equals(newValue)) {
- this.setValue(newValue);
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.valueHolder);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java
deleted file mode 100644
index c61a899f1a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import javax.swing.SpinnerNumberModel;
-import javax.swing.event.ChangeListener;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This javax.swing.SpinnerNumberModel can be used to keep a ChangeListener
- * (e.g. a JSpinner) in synch with a PropertyValueModel that holds a number.
- *
- * This class must be a sub-class of SpinnerNumberModel because of some
- * crappy jdk code.... ~bjv
- * @see javax.swing.JSpinner#createEditor(javax.swing.SpinnerModel)
- *
- * If this class needs to be modified, it would behoove us to review the
- * other, similar classes:
- * @see DateSpinnerModelAdapter
- * @see ListSpinnerModelAdapter
- */
-public class NumberSpinnerModelAdapter
- extends SpinnerNumberModel
-{
-
- /**
- * The default spinner value; used when the
- * underlying model number value is null.
- */
- private final Number defaultValue;
-
- /** A value model on the underlying number. */
- private final ModifiablePropertyValueModel<Number> numberHolder;
-
- /**
- * A listener that allows us to synchronize with
- * changes made to the underlying number.
- */
- private final PropertyChangeListener numberChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the number holder is required.
- * The default spinner value is zero.
- * The step size is one.
- */
- public NumberSpinnerModelAdapter(ModifiablePropertyValueModel<Number> numberHolder) {
- this(numberHolder, 0);
- }
-
- /**
- * Constructor - the number holder is required.
- * The step size is one.
- */
- public NumberSpinnerModelAdapter(ModifiablePropertyValueModel<Number> numberHolder, int defaultValue) {
- this(numberHolder, null, null, Integer.valueOf(1), Integer.valueOf(defaultValue));
- }
-
- /**
- * Constructor - the number holder is required.
- * Use the minimum value as the default spinner value.
- */
- public NumberSpinnerModelAdapter(ModifiablePropertyValueModel<Number> numberHolder, int minimum, int maximum, int stepSize) {
- this(numberHolder, minimum, maximum, stepSize, minimum);
- }
-
- /**
- * Constructor - the number holder is required.
- */
- public NumberSpinnerModelAdapter(ModifiablePropertyValueModel<Number> numberHolder, int minimum, int maximum, int stepSize, int defaultValue) {
- this(numberHolder, Integer.valueOf(minimum), Integer.valueOf(maximum), Integer.valueOf(stepSize), Integer.valueOf(defaultValue));
- }
-
- /**
- * Constructor - the number holder is required.
- * Use the minimum value as the default spinner value.
- */
- public NumberSpinnerModelAdapter(ModifiablePropertyValueModel<Number> numberHolder, double minimum, double maximum, double stepSize) {
- this(numberHolder, minimum, maximum, stepSize, minimum);
- }
-
- /**
- * Constructor - the number holder is required.
- */
- public NumberSpinnerModelAdapter(ModifiablePropertyValueModel<Number> numberHolder, double minimum, double maximum, double stepSize, double defaultValue) {
- this(numberHolder, Double.valueOf(minimum), Double.valueOf(maximum), Double.valueOf(stepSize), Double.valueOf(defaultValue));
- }
-
- /**
- * Constructor - the number holder is required.
- */
- public NumberSpinnerModelAdapter(ModifiablePropertyValueModel<Number> numberHolder, Comparable<?> minimum, Comparable<?> maximum, Number stepSize, Number defaultValue) {
- super(numberHolder.getValue() == null ? defaultValue : (Number) numberHolder.getValue(), minimum, maximum, stepSize);
- this.numberHolder = numberHolder;
- this.numberChangeListener = this.buildNumberChangeListener();
- // postpone listening to the underlying number
- // until we have listeners ourselves...
- this.defaultValue = defaultValue;
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildNumberChangeListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildNumberChangeListener_());
- }
-
- protected PropertyChangeListener buildNumberChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- NumberSpinnerModelAdapter.this.synchronize(event.getNewValue());
- }
- @Override
- public String toString() {
- return "number listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** SpinnerModel implementation **********
-
- /**
- * Extend to check whether this method is being called before we
- * have any listeners.
- * This is necessary because some crappy jdk code gets the value
- * from the model *before* listening to the model. ~bjv
- * @see javax.swing.JSpinner.DefaultEditor(javax.swing.JSpinner)
- */
- @Override
- public Object getValue() {
- if (this.getChangeListeners().length == 0) {
- // sorry about this "lateral" call to super ~bjv
- super.setValue(this.spinnerValueOf(this.numberHolder.getValue()));
- }
- return super.getValue();
- }
-
- /**
- * Extend to update the underlying number directly.
- * The resulting event will be ignored: @see #synchronizeDelegate(Object).
- */
- @Override
- public void setValue(Object value) {
- super.setValue(value);
- this.numberHolder.setValue((Number) value);
- }
-
- /**
- * Extend to start listening to the underlying number if necessary.
- */
- @Override
- public void addChangeListener(ChangeListener listener) {
- if (this.getChangeListeners().length == 0) {
- this.numberHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.numberChangeListener);
- this.synchronize(this.numberHolder.getValue());
- }
- super.addChangeListener(listener);
- }
-
- /**
- * Extend to stop listening to the underlying number if appropriate.
- */
- @Override
- public void removeChangeListener(ChangeListener listener) {
- super.removeChangeListener(listener);
- if (this.getChangeListeners().length == 0) {
- this.numberHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.numberChangeListener);
- }
- }
-
-
- // ********** queries **********
-
- protected Number getDefaultValue() {
- return this.defaultValue;
- }
-
- /**
- * Convert to a non-null value.
- */
- protected Object spinnerValueOf(Object value) {
- return (value == null) ? this.getDefaultValue() : value;
- }
-
-
- // ********** behavior **********
-
- /**
- * Set the spinner value if it has changed.
- */
- void synchronize(Object value) {
- Object newValue = this.spinnerValueOf(value);
- // check to see whether the date has already been synchronized
- // (via #setValue())
- if ( ! this.getValue().equals(newValue)) {
- this.setValue(newValue);
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.numberHolder);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ObjectListSelectionModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ObjectListSelectionModel.java
deleted file mode 100644
index 98538e7061..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ObjectListSelectionModel.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import javax.swing.DefaultListSelectionModel;
-import javax.swing.ListModel;
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-import javax.swing.event.ListSelectionListener;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-
-/**
- * This ListSelectionModel is aware of the ListModel and
- * provides convenience methods to access and set the
- * selected *objects*, as opposed to the selected *indexes*.
- */
-public class ObjectListSelectionModel
- extends DefaultListSelectionModel
-{
- /** The list model referenced by the list selection model. */
- private final ListModel listModel;
-
- /** A listener that allows us to clear the selection when the list model has changed. */
- private final ListDataListener listDataListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a list selection model for the specified list model.
- */
- public ObjectListSelectionModel(ListModel listModel) {
- super();
- this.listModel = listModel;
- this.listDataListener = this.buildListDataListener();
- }
-
-
- // ********** initialization **********
-
- private ListDataListener buildListDataListener() {
- return new ListDataListener() {
- public void intervalAdded(ListDataEvent event) {
- // this does not affect the selection
- }
- public void intervalRemoved(ListDataEvent event) {
- // this does not affect the selection
- }
- public void contentsChanged(ListDataEvent event) {
- ObjectListSelectionModel.this.listModelContentsChanged(event);
- }
- @Override
- public String toString() {
- return "list data listener"; //$NON-NLS-1$
- }
- };
- }
-
- /**
- * Typically, the selection does not need to be cleared when the
- * contents of the list have changed. Most of the time this just
- * means an item has changed in a way that affects its display string
- * or icon. We typically only use the class for edits involving
- * single selection.
- * A subclass can override this method if the selection
- * should be cleared because a change could mean the selection is invalid.
- */
- protected void listModelContentsChanged(@SuppressWarnings("unused") ListDataEvent event) {
- /**this.clearSelection();*/
- }
-
-
- // ********** ListSelectionModel implementation **********
-
- @Override
- public void addListSelectionListener(ListSelectionListener l) {
- if (this.hasNoListSelectionListeners()) {
- this.listModel.addListDataListener(this.listDataListener);
- }
- super.addListSelectionListener(l);
- }
-
- @Override
- public void removeListSelectionListener(ListSelectionListener l) {
- super.removeListSelectionListener(l);
- if (this.hasNoListSelectionListeners()) {
- this.listModel.removeListDataListener(this.listDataListener);
- }
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether this model has no listeners.
- */
- protected boolean hasNoListSelectionListeners() { // private-protected
- return this.getListSelectionListeners().length == 0;
- }
-
- /**
- * Return the list model referenced by the list selection model.
- */
- public ListModel getListModel() {
- return this.listModel;
- }
-
- public int selectedValuesSize() {
- int min = this.getMinSelectionIndex();
- int max = this.getMaxSelectionIndex();
-
- if ((min < 0) || (max < 0)) {
- return 0;
- }
-
- int n = 0;
- int count = this.getListModel().getSize();
- for (int i = min; i <= max; i++) {
- if (this.isSelectedIndex(i) && (i < count)) {
- n++;
- }
- }
- return n;
- }
-
- /**
- * Return the first selected value.
- * Return null if the selection is empty.
- */
- public Object selectedValue() {
- int index = this.getMinSelectionIndex();
- if (index == -1) {
- return null;
- }
- if (this.getListModel().getSize() <= index) {
- return null;
- }
- return this.getListModel().getElementAt(index);
- }
-
- /**
- * Return an array of the selected values.
- */
- public Object[] selectedValues() {
- int min = this.getMinSelectionIndex();
- int max = this.getMaxSelectionIndex();
-
- if ((min < 0) || (max < 0)) {
- return new Object[0];
- }
-
- int maxSize = (max - min) + 1;
- Object[] temp = new Object[maxSize];
- int n = 0;
- int count = this.getListModel().getSize();
- for (int i = min; i <= max; i++) {
- if (this.isSelectedIndex(i) && (i < count)) {
- temp[n++] = this.getListModel().getElementAt(i);
- }
- }
- if (n == maxSize) {
- // all the elements in the range were selected
- return temp;
- }
- // only some of the elements in the range were selected
- Object[] result = new Object[n];
- System.arraycopy(temp, 0, result, 0, n);
- return result;
- }
-
- /**
- * Return an array of the selected indices in order.
- */
- public int[] selectedIndices() {
- int min = this.getMinSelectionIndex();
- int max = this.getMaxSelectionIndex();
-
- if ((min < 0) || (max < 0)) {
- return new int[0];
- }
-
- int maxSize = (max - min) + 1;
- int[] temp = new int[maxSize];
- int n = 0;
- int count = this.getListModel().getSize();
- for (int i = min; i <= max; i++) {
- if (this.isSelectedIndex(i) && (i < count)) {
- temp[n++] = i;
- }
- }
- if (n == maxSize) {
- // all the elements in the range were selected
- Arrays.sort(temp);
- return temp;
- }
- // only some of the elements in the range were selected
- int[] result = new int[n];
- System.arraycopy(temp, 0, result, 0, n);
- Arrays.sort(result);
- return result;
- }
-
- /**
- * Set the selected value.
- */
- public void setSelectedValue(Object object) {
- this.setSelectedValues(CollectionTools.singletonIterator(object));
- }
-
- /**
- * Set the current set of selected objects to the specified objects.
- * @see javax.swing.ListSelectionModel#setSelectionInterval(int, int)
- */
- public void setSelectedValues(Iterator<?> objects) {
- this.setValueIsAdjusting(true);
- this.clearSelection();
- this.addSelectedValuesInternal(objects);
- this.setValueIsAdjusting(false);
- }
-
- /**
- * Set the current set of selected objects to the specified objects.
- * @see javax.swing.ListSelectionModel#setSelectionInterval(int, int)
- */
- public void setSelectedValues(Collection<?> objects) {
- this.setSelectedValues(objects.iterator());
- }
-
- /**
- * Set the current set of selected objects to the specified objects.
- * @see javax.swing.ListSelectionModel#setSelectionInterval(int, int)
- */
- public void setSelectedValues(Object[] objects) {
- this.setSelectedValues(CollectionTools.iterator(objects));
- }
-
- /**
- * Add the specified object to the current set of selected objects.
- * @see javax.swing.ListSelectionModel#addSelectionInterval(int, int)
- */
- public void addSelectedValue(Object object) {
- this.addSelectedValues(CollectionTools.singletonIterator(object));
- }
-
- /**
- * Add the specified objects to the current set of selected objects.
- * @see javax.swing.ListSelectionModel#addSelectionInterval(int, int)
- */
- public void addSelectedValues(Iterator<?> objects) {
- this.setValueIsAdjusting(true);
- this.addSelectedValuesInternal(objects);
- this.setValueIsAdjusting(false);
- }
-
- /**
- * Add the specified objects to the current set of selected objects.
- * @see javax.swing.ListSelectionModel#addSelectionInterval(int, int)
- */
- public void addSelectedValues(Collection<?> objects) {
- this.addSelectedValues(objects.iterator());
- }
-
- /**
- * Add the specified objects to the current set of selected objects.
- * @see javax.swing.ListSelectionModel#addSelectionInterval(int, int)
- */
- public void addSelectedValues(Object[] objects) {
- this.addSelectedValues(CollectionTools.iterator(objects));
- }
-
- /**
- * Remove the specified object from the current set of selected objects.
- * @see javax.swing.ListSelectionModel#removeSelectionInterval(int, int)
- */
- public void removeSelectedValue(Object object) {
- this.removeSelectedValues(CollectionTools.singletonIterator(object));
- }
-
- /**
- * Remove the specified objects from the current set of selected objects.
- * @see javax.swing.ListSelectionModel#removeSelectionInterval(int, int)
- */
- public void removeSelectedValues(Iterator<?> objects) {
- this.setValueIsAdjusting(true);
- ListModel lm = this.getListModel();
- int lmSize = lm.getSize();
- while (objects.hasNext()) {
- int index = this.indexOf(objects.next(), lm, lmSize);
- this.removeSelectionInterval(index, index);
- }
- this.setValueIsAdjusting(false);
- }
-
- /**
- * Remove the specified objects from the current set of selected objects.
- * @see javax.swing.ListSelectionModel#removeSelectionInterval(int, int)
- */
- public void removeSelectedValues(Collection<?> objects) {
- this.removeSelectedValues(objects.iterator());
- }
-
- /**
- * Remove the specified objects from the current set of selected objects.
- * @see javax.swing.ListSelectionModel#removeSelectionInterval(int, int)
- */
- public void removeSelectedValues(Object[] objects) {
- this.removeSelectedValues(CollectionTools.iterator(objects));
- }
-
- /**
- * @see javax.swing.ListSelectionModel#getAnchorSelectionIndex()
- * Return null if the anchor selection is empty.
- */
- public Object getAnchorSelectedValue() {
- int index = this.getAnchorSelectionIndex();
- if (index == -1) {
- return null;
- }
- return this.getListModel().getElementAt(index);
- }
-
- /**
- * @see javax.swing.ListSelectionModel#setAnchorSelectionIndex(int)
- */
- public void setAnchorSelectedValue(Object object) {
- this.setAnchorSelectionIndex(this.indexOf(object));
- }
-
- /**
- * @see javax.swing.ListSelectionModel#getLeadSelectionIndex()
- * Return null if the lead selection is empty.
- */
- public Object getLeadSelectedValue() {
- int index = this.getLeadSelectionIndex();
- if (index == -1) {
- return null;
- }
- return this.getListModel().getElementAt(index);
- }
-
- /**
- * @see javax.swing.ListSelectionModel#setLeadSelectionIndex(int)
- */
- public void setLeadSelectedValue(Object object) {
- this.setLeadSelectionIndex(this.indexOf(object));
- }
-
- /**
- * @see javax.swing.ListSelectionModel#getMaxSelectionIndex()
- * Return null if the max selection is empty.
- */
- public Object getMaxSelectedValue() {
- int index = this.getMaxSelectionIndex();
- if (index == -1) {
- return null;
- }
- return this.getListModel().getElementAt(index);
- }
-
- /**
- * @see javax.swing.ListSelectionModel#getMinSelectionIndex()
- * Return null if the min selection is empty.
- */
- public Object getMinSelectedValue() {
- int index = this.getMinSelectionIndex();
- if (index == -1) {
- return null;
- }
- return this.getListModel().getElementAt(index);
- }
-
- /**
- * @see javax.swing.ListSelectionModel#isSelectedIndex(int)
- */
- public boolean valueIsSelected(Object object) {
- return this.isSelectedIndex(this.indexOf(object));
- }
-
- /**
- * Add the specified objects to the current set of selected objects,
- * without wrapping the actions in "adjusting" events.
- */
- private void addSelectedValuesInternal(Iterator<?> objects) {
- ListModel lm = this.getListModel();
- int listModelSize = lm.getSize();
- while (objects.hasNext()) {
- int index = this.indexOf(objects.next(), lm, listModelSize);
- this.addSelectionInterval(index, index);
- }
- }
-
- /**
- * Return the index in the list model of the specified object.
- * Return -1 if the object is not in the list model.
- */
- private int indexOf(Object object) {
- ListModel lm = this.getListModel();
- return this.indexOf(object, lm, lm.getSize());
- }
-
- /**
- * Return the index in the list model of the specified object.
- * Return -1 if the object is not in the list model.
- */
- // we're just jerking around with performance optimizations here
- // (in memory of Phil...);
- // call this method inside loops that do not modify the listModel
- private int indexOf(Object object, ListModel lm, int listModelSize) {
- for (int i = listModelSize; i-- > 0; ) {
- if (lm.getElementAt(i).equals(object)) {
- return i;
- }
- }
- return -1;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/PrimitiveListTreeModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/PrimitiveListTreeModel.java
deleted file mode 100644
index 9fe9fca0e8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/PrimitiveListTreeModel.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.MutableTreeNode;
-import javax.swing.tree.TreeNode;
-import javax.swing.tree.TreePath;
-
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTListChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * This TreeModel implementation provides a tree with a "null" root that
- * has a set of "primitive" children. These "primitive" children do not have
- * children themselves, making the tree a maximum of 2 levels deep.
- * This model automatically synchronizes the root's children with a
- * ListValueModel that holds a collection of primitive (non-model) objects
- * (e.g. Strings).
- *
- * This is useful for providing an "editable" list of primitives. Since the JDK
- * does not provide us with an editable listbox, we must use an editable tree.
- * We wrap everything in DefaultMutableTreeNodes.
- *
- * Subclasses must implement #primitiveChanged(int, Object) and update
- * the model appropriately. This method is called when the user edits the
- * list directly and presses <Enter>.
- *
- * The JTree using this model must be configured as "editable":
- * tree.setEditable(true);
- */
-// TODO convert to use an adapter instead of requiring subclass
-public abstract class PrimitiveListTreeModel
- extends DefaultTreeModel
-{
- /** a model on the list of primitives */
- private final ListValueModel<?> listHolder;
-
- /** a listener that handles the adding, removing, and replacing of the primitives */
- private final ListChangeListener listChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Public constructor - the list holder is required
- */
- public PrimitiveListTreeModel(ListValueModel<?> listHolder) {
- super(new DefaultMutableTreeNode(null, true)); // true = the root can have children
- if (listHolder == null) {
- throw new NullPointerException();
- }
- this.listHolder = listHolder;
- this.listChangeListener = this.buildListChangeListener();
- // postpone listening to the model until we have listeners ourselves
- }
-
- protected ListChangeListener buildListChangeListener() {
- return new AWTListChangeListenerWrapper(this.buildListChangeListener_());
- }
-
- protected ListChangeListener buildListChangeListener_() {
- return new PrimitiveListChangeListener();
- }
-
-
- // ********** behavior **********
-
- /**
- * Subclasses should override this method to update the
- * model appropriately. The primitive at the specified index was
- * edited directly by the user and the new value is as specified.
- * Convert the value appropriately and place it in the model.
- */
- protected abstract void primitiveChanged(int index, Object newValue);
-
-
- // ********** TreeModel implementation **********
-
- /**
- * Override to change the underlying model instead of changing the node directly.
- */
- @Override
- public void valueForPathChanged(TreePath path, Object newValue) {
- TreeNode node = (TreeNode) path.getLastPathComponent();
- int index = ((TreeNode) this.getRoot()).getIndex(node);
- this.primitiveChanged(index, newValue);
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addTreeModelListener(TreeModelListener l) {
- if (this.getTreeModelListeners().length == 0) {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- this.synchronizeList();
- }
- super.addTreeModelListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if appropriate.
- */
- @Override
- public void removeTreeModelListener(TreeModelListener l) {
- super.removeTreeModelListener(l);
- if (this.getTreeModelListeners().length == 0) {
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * Synchronize our list of nodes with the list of primitives
- */
- void synchronizeList() {
- this.clearList();
- this.buildList();
- }
-
- void clearList() {
- int childcount = this.root.getChildCount();
- for (int i = childcount - 1; i >= 0; i--) {
- this.removeNodeFromParent((MutableTreeNode)this.root.getChildAt(i));
- }
- }
-
- private void buildList() {
- for (Iterator<?> stream = this.listHolder.iterator(); stream.hasNext(); ) {
- this.addPrimitive(stream.next());
- }
- }
-
- /**
- * Add the specified primitive to the end of the list.
- */
- private void addPrimitive(Object primitive) {
- this.insertPrimitive(this.root.getChildCount(), primitive);
- }
-
- /**
- * Create a node for the specified primitive
- * and insert it as a child of the root.
- */
- void insertPrimitive(int index, Object primitive) {
- DefaultMutableTreeNode node = new DefaultMutableTreeNode(primitive, false); // don't allow children on the child node
- this.insertNodeInto(node, (MutableTreeNode) this.root, index);
- }
-
- /**
- * Remove node at the specified index.
- */
- MutableTreeNode removeNode(int index) {
- MutableTreeNode node = (MutableTreeNode) this.root.getChildAt(index);
- this.removeNodeFromParent(node);
- return node;
- }
-
- /**
- * Replace the user object of the node at childIndex.
- */
- void replacePrimitive(int index, Object primitive) {
- MutableTreeNode node = (MutableTreeNode) this.root.getChildAt(index);
- node.setUserObject(primitive);
- this.nodeChanged(node);
- }
-
-
- // ********** inner class **********
-
- private class PrimitiveListChangeListener implements ListChangeListener {
- PrimitiveListChangeListener() {
- super();
- }
-
- public void itemsAdded(ListAddEvent event) {
- int i = event.getIndex();
- for (Object item : event.getItems()) {
- PrimitiveListTreeModel.this.insertPrimitive(i++, item);
- }
- }
-
- public void itemsRemoved(ListRemoveEvent event) {
- for (int i = 0; i < event.getItemsSize(); i++) {
- PrimitiveListTreeModel.this.removeNode(event.getIndex());
- }
- }
-
- public void itemsReplaced(ListReplaceEvent event) {
- int i = event.getIndex();
- for (Object item : event.getNewItems()) {
- PrimitiveListTreeModel.this.replacePrimitive(i++, item);
- }
- }
-
- public void itemsMoved(ListMoveEvent event) {
- ArrayList<MutableTreeNode> temp = new ArrayList<MutableTreeNode>(event.getLength());
- for (int i = 0; i < event.getLength(); i++) {
- temp.add(PrimitiveListTreeModel.this.removeNode(event.getSourceIndex()));
- }
- int i = event.getTargetIndex();
- for (MutableTreeNode node : temp) {
- PrimitiveListTreeModel.this.insertPrimitive(i++, node);
- }
- }
-
- public void listCleared(ListClearEvent event) {
- PrimitiveListTreeModel.this.clearList();
- }
-
- public void listChanged(ListChangeEvent event) {
- PrimitiveListTreeModel.this.synchronizeList();
- }
-
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/RadioButtonModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/RadioButtonModelAdapter.java
deleted file mode 100644
index f37251c757..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/RadioButtonModelAdapter.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.model.value.FilteringWritablePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationWritablePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This {@link javax.swing.ButtonModel} can be used to keep a listener
- * (e.g. a {@link javax.swing.JRadioButton}) in synch with a (typically shared)
- * {@link org.eclipse.jpt.common.utility.model.value.PropertyValueModel}
- * that holds one value out of a set of values.
- * <p>
- * <strong>NB:</strong> Do <em>not</em> use this model with a
- * {@link javax.swing.ButtonGroup}, since the
- * shared value holder and the wrappers built by this adapter will
- * keep the appropriate radio button checked. Also, this allows
- * us to uncheck all the radio buttons in a group when the shared
- * value is <code>null</code>.
- */
-public class RadioButtonModelAdapter
- extends ToggleButtonModelAdapter
-{
- // ********** constructors **********
-
- /**
- * Constructor - the value holder is required.
- */
- public RadioButtonModelAdapter(ModifiablePropertyValueModel<Object> valueHolder, Object buttonValue, boolean defaultValue) {
- super(buildBooleanHolder(valueHolder, buttonValue), defaultValue);
- }
-
- /**
- * Constructor - the value holder is required.
- * The default value will be false.
- */
- public RadioButtonModelAdapter(ModifiablePropertyValueModel<Object> valueHolder, Object buttonValue) {
- super(buildBooleanHolder(valueHolder, buttonValue));
- }
-
-
- // ********** static methods **********
-
- /**
- * Build up a set of wrappers that will convert the
- * specified value holder and button value to/from a boolean.
- *
- * If the value holder's value matches the button value,
- * the wrapper will return true. Likewise, if the value holder's
- * value is set to true, the wrapper will set the value holder's
- * value to the button value.
- */
- public static ModifiablePropertyValueModel<Boolean> buildBooleanHolder(ModifiablePropertyValueModel<Object> valueHolder, Object buttonValue) {
- ModifiablePropertyValueModel<Object> filteringPVM = new FilteringWritablePropertyValueModel<Object>(valueHolder, Filter.Transparent.instance(), new SetRadioButtonFilter(buttonValue));
- return new TransformationWritablePropertyValueModel<Object, Boolean>(filteringPVM, new RadioButtonTransformer(buttonValue), new ReverseRadioButtonTransformer(buttonValue));
- }
-
-
- // ********** overrides **********
-
- /**
- * The user cannot de-select a radio button - the user
- * can only *select* a radio button. Only the model can
- * cause a radio button to be de-selected. We use the
- * ARMED flag to indicate whether we are being de-selected
- * by the user.
- */
- @Override
- public void setSelected(boolean b) {
- // do not allow the user to de-select a radio button
- // radio buttons can
- if ((b == false) && this.isArmed()) {
- return;
- }
- super.setSelected(b);
- }
-
-
- // ********** filters **********
-
- /**
- * This filter will only pass through a new value to the wrapped
- * value model when it matches the configured button value.
- */
- public static class SetRadioButtonFilter
- implements Filter<Object>
- {
- private Object buttonValue;
-
- public SetRadioButtonFilter(Object buttonValue) {
- super();
- this.buttonValue = buttonValue;
- }
-
- /**
- * pass through the value to the wrapped property value model
- * *only* when it matches our button value
- */
- public boolean accept(Object value) {
- return (value != null) && value.equals(this.buttonValue);
- }
- }
-
-
- // ********** transformers **********
-
- /**
- * This transformer will convert a value to {@link Boolean#TRUE}
- * when it matches the configured button value.
- */
- public static class RadioButtonTransformer
- implements Transformer<Object, Boolean>
- {
- private Object buttonValue;
-
- public RadioButtonTransformer(Object buttonValue) {
- super();
- this.buttonValue = buttonValue;
- }
-
- /**
- * If the specified value matches the button value return {@link Boolean#TRUE},
- * if it is some other value return {@link Boolean#FALSE};
- * but if it is <code>null</code> simply pass it through because it will
- * cause the button model's default value to be used
- */
- public Boolean transform(Object value) {
- return (value == null) ? null : Boolean.valueOf(value.equals(this.buttonValue));
- }
- }
-
- /**
- * This transformer will convert {@link Boolean#TRUE} to the configured
- * button value and {@link Boolean#FALSE} to <code>null</code>.
- */
- public static class ReverseRadioButtonTransformer
- implements Transformer<Boolean, Object>
- {
- private Object buttonValue;
-
- public ReverseRadioButtonTransformer(Object buttonValue) {
- super();
- this.buttonValue = buttonValue;
- }
-
- /**
- * If the specified value is {@link Boolean#TRUE},
- * pass through the our button value;
- * otherwise pass through <code>null</code>.
- */
- public Object transform (Boolean value) {
- return (value.booleanValue()) ? this.buttonValue : null;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/SpinnerModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/SpinnerModelAdapter.java
deleted file mode 100644
index 2e37b72718..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/SpinnerModelAdapter.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import javax.swing.AbstractSpinnerModel;
-import javax.swing.SpinnerModel;
-import javax.swing.SpinnerNumberModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This javax.swing.SpinnerModel can be used to keep a ChangeListener
- * (e.g. a JSpinner) in synch with a PropertyValueModel that holds a value.
- *
- * Note: it is likely you want to use one of the following classes instead of
- * this one:
- * DateSpinnerModelAdapter
- * NumberSpinnerModelAdapter
- * ListSpinnerModelAdapter
- *
- * NB: This model should only be used for values that have a fairly
- * inexpensive #equals() implementation.
- * @see #synchronizeDelegate(Object)
- */
-public class SpinnerModelAdapter
- extends AbstractSpinnerModel
-{
- /** The delegate spinner model whose behavior we "enhance". */
- protected final SpinnerModel delegate;
-
- /** A listener that allows us to forward any changes made to the delegate spinner model. */
- protected final ChangeListener delegateListener;
-
- /** A value model on the underlying value. */
- protected final ModifiablePropertyValueModel<Object> valueHolder;
-
- /** A listener that allows us to synchronize with changes made to the underlying value. */
- protected final PropertyChangeListener valueListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the value holder and delegate are required.
- */
- public SpinnerModelAdapter(ModifiablePropertyValueModel<Object> valueHolder, SpinnerModel delegate) {
- super();
- if (valueHolder == null || delegate == null) {
- throw new NullPointerException();
- }
- this.valueHolder = valueHolder;
- this.delegate = delegate;
- // postpone listening to the underlying value
- // until we have listeners ourselves...
- this.valueListener = this.buildValueListener();
- this.delegateListener = this.buildDelegateListener();
- }
-
- /**
- * Constructor - the value holder is required.
- * This will wrap a simple number spinner model.
- */
- public SpinnerModelAdapter(ModifiablePropertyValueModel<Object> valueHolder) {
- this(valueHolder, new SpinnerNumberModel());
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildValueListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildValueListener_());
- }
-
- protected PropertyChangeListener buildValueListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- SpinnerModelAdapter.this.valueChanged(event);
- }
- @Override
- public String toString() {
- return "value listener"; //$NON-NLS-1$
- }
- };
- }
-
- /**
- * expand access a bit for inner class
- */
- @Override
- protected void fireStateChanged() {
- super.fireStateChanged();
- }
-
- protected ChangeListener buildDelegateListener() {
- return new ChangeListener() {
- public void stateChanged(ChangeEvent event) {
- // forward the event, with this as the source
- SpinnerModelAdapter.this.fireStateChanged();
- }
- @Override
- public String toString() {
- return "delegate listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** SpinnerModel implementation **********
-
- public Object getValue() {
- return this.delegate.getValue();
- }
-
- /**
- * Extend to update the underlying value directly.
- * The resulting event will be ignored: @see #synchronizeDelegate(Object).
- */
- public void setValue(Object value) {
- this.delegate.setValue(value);
- this.valueHolder.setValue(value);
- }
-
- public Object getNextValue() {
- return this.delegate.getNextValue();
- }
-
- public Object getPreviousValue() {
- return this.delegate.getPreviousValue();
- }
-
- /**
- * Extend to start listening to the underlying value if necessary.
- */
- @Override
- public void addChangeListener(ChangeListener listener) {
- if (this.listenerList.getListenerCount(ChangeListener.class) == 0) {
- this.delegate.addChangeListener(this.delegateListener);
- this.engageValueHolder();
- }
- super.addChangeListener(listener);
- }
-
- /**
- * Extend to stop listening to the underlying value if appropriate.
- */
- @Override
- public void removeChangeListener(ChangeListener listener) {
- super.removeChangeListener(listener);
- if (this.listenerList.getListenerCount(ChangeListener.class) == 0) {
- this.disengageValueHolder();
- this.delegate.removeChangeListener(this.delegateListener);
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * A third party has modified the underlying value.
- * Synchronize the delegate model accordingly.
- */
- protected void valueChanged(PropertyChangeEvent event) {
- this.synchronizeDelegate(event.getNewValue());
- }
-
- /**
- * Set the delegate's value if it has changed.
- */
- protected void synchronizeDelegate(Object value) {
- // check to see whether the delegate has already been synchronized
- // (via #setValue())
- if ( ! this.delegate.getValue().equals(value)) {
- this.delegate.setValue(value);
- }
- }
-
- protected void engageValueHolder() {
- this.valueHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.valueListener);
- this.synchronizeDelegate(this.valueHolder.getValue());
- }
-
- protected void disengageValueHolder() {
- this.valueHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.valueListener);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.valueHolder);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/TableModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/TableModelAdapter.java
deleted file mode 100644
index d9f1348da2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/TableModelAdapter.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.swing.event.TableModelListener;
-import javax.swing.table.AbstractTableModel;
-
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTListChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionListValueModelAdapter;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This TableModel can be used to keep a TableModelListener (e.g. a JTable)
- * in synch with a ListValueModel that holds a collection of model objects,
- * each of which corresponds to a row in the table.
- * Typically, each column of the table will be bound to a different aspect
- * of the contained model objects.
- *
- * For example, a MWTable has an attribute 'databaseFields' that holds
- * a collection of MWDatabaseFields that would correspond to the rows of
- * a JTable; and each MWDatabaseField has a number
- * of attributes (e.g. name, type, size) that can be bound to the columns of
- * a row in the JTable. As these database fields are added, removed, and
- * changed, this model will keep the listeners aware of the changes.
- *
- * An instance of this TableModel must be supplied with a
- * list holder (e.g. the 'databaseFields'), which is a value
- * model on the bound collection This is required - the
- * collection itself can be null, but the list value model that
- * holds it is required. Typically this list will be sorted (@see
- * SortedListValueModelAdapter).
- *
- * This TableModel must also be supplied with a ColumnAdapter that
- * will be used to configure the headers, renderers, editors, and contents
- * of the various columns.
- *
- * Design decision:
- * Cell listener options (from low space/high time to high space/low time):
- * - 1 cell listener listening to every cell (this is the current implementation)
- * - 1 cell listener per row
- * - 1 cell listener per cell
- */
-public class TableModelAdapter<E>
- extends AbstractTableModel
-{
- /**
- * a list of user objects that are converted to
- * rows via the column adapter
- */
- private ListValueModel<? extends E> listHolder;
- private final ListChangeListener listChangeListener;
-
- /**
- * each row is an array of cell models
- */
- // declare as ArrayList so we can use #ensureCapacity(int)
- private final ArrayList<ModifiablePropertyValueModel<Object>[]> rows;
-
- /**
- * client-supplied adapter that provides with the various column
- * settings and converts the objects in the LVM
- * into an array of cell models
- */
- private final ColumnAdapter columnAdapter;
-
- /**
- * the single listener that listens to every cell's model
- */
- private final PropertyChangeListener cellListener;
-
-
- // ********** constructors **********
-
- /**
- * Construct a table model adapter for the specified objects
- * and adapter.
- */
- public TableModelAdapter(ListValueModel<? extends E> listHolder, ColumnAdapter columnAdapter) {
- super();
- if (listHolder == null) {
- throw new NullPointerException();
- }
- this.listHolder = listHolder;
- this.columnAdapter = columnAdapter;
- this.listChangeListener = this.buildListChangeListener();
- this.rows = new ArrayList<ModifiablePropertyValueModel<Object>[]>();
- this.cellListener = this.buildCellListener();
- }
-
- /**
- * Construct a table model adapter for the specified objects
- * and adapter.
- */
- public TableModelAdapter(CollectionValueModel<? extends E> collectionHolder, ColumnAdapter columnAdapter) {
- this(new CollectionListValueModelAdapter<E>(collectionHolder), columnAdapter);
- }
-
-
- // ********** initialization **********
-
- protected ListChangeListener buildListChangeListener() {
- return new AWTListChangeListenerWrapper(this.buildListChangeListener_());
- }
-
- protected ListChangeListener buildListChangeListener_() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent event) {
- TableModelAdapter.this.addRows(event.getIndex(), event.getItemsSize(), this.getItems(event));
- }
- public void itemsRemoved(ListRemoveEvent event) {
- TableModelAdapter.this.removeRows(event.getIndex(), event.getItemsSize());
- }
- public void itemsReplaced(ListReplaceEvent event) {
- TableModelAdapter.this.replaceRows(event.getIndex(), this.getNewItems(event));
- }
- public void itemsMoved(ListMoveEvent event) {
- TableModelAdapter.this.moveRows(event.getTargetIndex(), event.getSourceIndex(), event.getLength());
- }
- public void listCleared(ListClearEvent event) {
- TableModelAdapter.this.clearTable();
- }
- public void listChanged(ListChangeEvent event) {
- TableModelAdapter.this.rebuildTable();
- }
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<Object> getItems(ListAddEvent event) {
- return (Iterable<Object>) event.getItems();
- }
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<Object> getNewItems(ListReplaceEvent event) {
- return (Iterable<Object>) event.getNewItems();
- }
- @Override
- public String toString() {
- return "list listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- protected PropertyChangeListener buildCellListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildCellListener_());
- }
-
- protected PropertyChangeListener buildCellListener_() {
- return new PropertyChangeListener() {
- @SuppressWarnings("unchecked")
- public void propertyChanged(PropertyChangeEvent event) {
- TableModelAdapter.this.cellChanged((ModifiablePropertyValueModel<Object>) event.getSource());
- }
- @Override
- public String toString() {
- return "cell listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** TableModel implementation **********
-
- public int getColumnCount() {
- return this.columnAdapter.columnCount();
- }
-
- public int getRowCount() {
- return this.rows.size();
- }
-
- @Override
- public String getColumnName(int column) {
- return this.columnAdapter.columnName(column);
- }
-
- @Override
- public Class<?> getColumnClass(int columnIndex) {
- return this.columnAdapter.columnClass(columnIndex);
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return this.columnAdapter.columnIsEditable(columnIndex);
- }
-
- public Object getValueAt(int rowIndex, int columnIndex) {
- ModifiablePropertyValueModel<Object>[] row = this.rows.get(rowIndex);
- return row[columnIndex].getValue();
- }
-
- @Override
- public void setValueAt(Object value, int rowIndex, int columnIndex) {
- ModifiablePropertyValueModel<Object>[] row = this.rows.get(rowIndex);
- row[columnIndex].setValue(value);
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addTableModelListener(TableModelListener l) {
- if (this.hasNoTableModelListeners()) {
- this.engageModel();
- }
- super.addTableModelListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if necessary.
- */
- @Override
- public void removeTableModelListener(TableModelListener l) {
- super.removeTableModelListener(l);
- if (this.hasNoTableModelListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** public API **********
-
- /**
- * Return the underlying list model.
- */
- public ListValueModel<? extends E> getModel() {
- return this.listHolder;
- }
-
- /**
- * Set the underlying list model.
- */
- public void setModel(ListValueModel<E> listHolder) {
- if (listHolder == null) {
- throw new NullPointerException();
- }
- boolean hasListeners = this.hasTableModelListeners();
- if (hasListeners) {
- this.disengageModel();
- }
- this.listHolder = listHolder;
- if (hasListeners) {
- this.engageModel();
- this.fireTableDataChanged();
- }
- }
-
- /**
- * Set the underlying collection model.
- */
- public void setModel(CollectionValueModel<E> collectionHolder) {
- this.setModel(new CollectionListValueModelAdapter<E>(collectionHolder));
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether this model has no listeners.
- */
- protected boolean hasNoTableModelListeners() {
- return this.listenerList.getListenerCount(TableModelListener.class) == 0;
- }
-
- /**
- * Return whether this model has any listeners.
- */
- protected boolean hasTableModelListeners() {
- return ! this.hasNoTableModelListeners();
- }
-
-
- // ********** behavior **********
-
- /**
- * Start listening to the list of objects and the various aspects
- * of the objects that make up the rows.
- */
- private void engageModel() {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- this.engageAllCells();
- }
-
- /**
- * Convert the objects into rows and listen to the cells.
- */
- private void engageAllCells() {
- this.rows.ensureCapacity(this.listHolder.size());
- for (Iterator<? extends E> stream = this.listHolder.iterator(); stream.hasNext(); ) {
- ModifiablePropertyValueModel<Object>[] row = this.columnAdapter.cellModels(stream.next());
- this.engageRow(row);
- this.rows.add(row);
- }
- }
-
- /**
- * Listen to the cells in the specified row.
- */
- private void engageRow(ModifiablePropertyValueModel<Object>[] row) {
- for (int i = row.length; i-- > 0; ) {
- row[i].addPropertyChangeListener(PropertyValueModel.VALUE, this.cellListener);
- }
- }
-
- /**
- * Stop listening.
- */
- private void disengageModel() {
- this.disengageAllCells();
- this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
- }
-
- private void disengageAllCells() {
- for (ModifiablePropertyValueModel<Object>[] row : this.rows) {
- this.disengageRow(row);
- }
- this.rows.clear();
- }
-
- private void disengageRow(ModifiablePropertyValueModel<Object>[] row) {
- for (int i = row.length; i-- > 0; ) {
- row[i].removePropertyChangeListener(PropertyValueModel.VALUE, this.cellListener);
- }
- }
-
- /**
- * brute-force search for the cell(s) that changed...
- */
- void cellChanged(ModifiablePropertyValueModel<Object> cellHolder) {
- for (int i = this.rows.size(); i-- > 0; ) {
- ModifiablePropertyValueModel<Object>[] row = this.rows.get(i);
- for (int j = row.length; j-- > 0; ) {
- if (row[j] == cellHolder) {
- this.fireTableCellUpdated(i, j);
- }
- }
- }
- }
-
- /**
- * convert the items to rows
- */
- void addRows(int index, int size, Iterable<Object> items) {
- List<ModifiablePropertyValueModel<Object>[]> newRows = new ArrayList<ModifiablePropertyValueModel<Object>[]>(size);
- for (Object item : items) {
- ModifiablePropertyValueModel<Object>[] row = this.columnAdapter.cellModels(item);
- this.engageRow(row);
- newRows.add(row);
- }
- this.rows.addAll(index, newRows);
- this.fireTableRowsInserted(index, index + size - 1);
- }
-
- void removeRows(int index, int size) {
- for (int i = 0; i < size; i++) {
- this.disengageRow(this.rows.remove(index));
- }
- this.fireTableRowsDeleted(index, index + size - 1);
- }
-
- void replaceRows(int index, Iterable<Object> items) {
- int i = index;
- for (Object item : items) {
- ModifiablePropertyValueModel<Object>[] row = this.rows.get(i);
- this.disengageRow(row);
- row = this.columnAdapter.cellModels(item);
- this.engageRow(row);
- this.rows.set(i, row);
- i++;
- }
- this.fireTableRowsUpdated(index, i - 1);
- }
-
- void moveRows(int targetIndex, int sourceIndex, int length) {
- ArrayList<ModifiablePropertyValueModel<Object>[]> temp = new ArrayList<ModifiablePropertyValueModel<Object>[]>(length);
- for (int i = 0; i < length; i++) {
- temp.add(this.rows.remove(sourceIndex));
- }
- this.rows.addAll(targetIndex, temp);
-
- int start = Math.min(targetIndex, sourceIndex);
- int end = Math.max(targetIndex, sourceIndex) + length - 1;
- this.fireTableRowsUpdated(start, end);
- }
-
- void clearTable() {
- this.disengageAllCells();
- this.fireTableDataChanged();
- }
-
- void rebuildTable() {
- this.disengageAllCells();
- this.engageAllCells();
- this.fireTableDataChanged();
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ToggleButtonModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ToggleButtonModelAdapter.java
deleted file mode 100644
index a51dad0dea..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/ToggleButtonModelAdapter.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import java.awt.event.ActionListener;
-import java.awt.event.ItemListener;
-import javax.swing.JToggleButton.ToggleButtonModel;
-import javax.swing.event.ChangeListener;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * This javax.swing.ButtonModel can be used to keep a listener
- * (e.g. a JCheckBox or a JRadioButton) in synch with a PropertyValueModel
- * on a boolean.
- */
-public class ToggleButtonModelAdapter
- extends ToggleButtonModel
-{
- /**
- * The default setting for the toggle button; for when the underlying model is null.
- * The default [default value] is false (i.e. the toggle button is unchecked/empty).
- */
- protected final boolean defaultValue;
-
- /** A value model on the underlying model boolean. */
- protected final ModifiablePropertyValueModel<Boolean> booleanHolder;
-
- /**
- * A listener that allows us to synchronize with
- * changes made to the underlying model boolean.
- */
- protected final PropertyChangeListener booleanChangeListener;
-
-
- // ********** constructors **********
-
- /**
- * Constructor - the boolean holder is required.
- */
- public ToggleButtonModelAdapter(ModifiablePropertyValueModel<Boolean> booleanHolder, boolean defaultValue) {
- super();
- if (booleanHolder == null) {
- throw new NullPointerException();
- }
- this.booleanHolder = booleanHolder;
- this.booleanChangeListener = this.buildBooleanChangeListener();
- // postpone listening to the underlying model
- // until we have listeners ourselves...
- this.defaultValue = defaultValue;
- }
-
- /**
- * Constructor - the boolean holder is required.
- * The default value will be false.
- */
- public ToggleButtonModelAdapter(ModifiablePropertyValueModel<Boolean> booleanHolder) {
- this(booleanHolder, false);
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildBooleanChangeListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildBooleanChangeListener_());
- }
-
- protected PropertyChangeListener buildBooleanChangeListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- ToggleButtonModelAdapter.this.booleanChanged(event);
- }
- @Override
- public String toString() {
- return "boolean listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** ButtonModel implementation **********
-
- /**
- * Extend to update the underlying model if necessary.
- */
- @Override
- public void setSelected(boolean b) {
- if (this.isSelected() != b) { // stop the recursion!
- super.setSelected(b);//put the super call first, otherwise the following gets called twice
- this.booleanHolder.setValue(Boolean.valueOf(b));
- }
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addActionListener(ActionListener l) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addActionListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if appropriate.
- */
- @Override
- public void removeActionListener(ActionListener l) {
- super.removeActionListener(l);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addItemListener(ItemListener l) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addItemListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if appropriate.
- */
- @Override
- public void removeItemListener(ItemListener l) {
- super.removeItemListener(l);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addChangeListener(ChangeListener l) {
- if (this.hasNoListeners()) {
- this.engageModel();
- }
- super.addChangeListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if appropriate.
- */
- @Override
- public void removeChangeListener(ChangeListener l) {
- super.removeChangeListener(l);
- if (this.hasNoListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** queries **********
-
- /**
- * Return whether we have no listeners at all.
- */
- protected boolean hasNoListeners() {
- return this.listenerList.getListenerCount() == 0;
- }
-
- protected boolean getDefaultValue() {
- return this.defaultValue;
- }
-
-
- // ********** behavior **********
-
- /**
- * Synchronize with the specified value.
- * If it is null, use the default value (which is typically false).
- */
- protected void setSelected(Boolean value) {
- if (value == null) {
- this.setSelected(this.getDefaultValue());
- } else {
- this.setSelected(value.booleanValue());
- }
- }
-
- /**
- * The underlying model has changed - synchronize accordingly.
- */
- protected void booleanChanged(PropertyChangeEvent event) {
- this.setSelected((Boolean) event.getNewValue());
- }
-
- protected void engageModel() {
- this.booleanHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.booleanChangeListener);
- this.setSelected(this.booleanHolder.getValue());
- }
-
- protected void disengageModel() {
- this.booleanHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.booleanChangeListener);
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.booleanHolder);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/TreeModelAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/TreeModelAdapter.java
deleted file mode 100644
index 12f0faf3a7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/model/value/swing/TreeModelAdapter.java
+++ /dev/null
@@ -1,914 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.IdentityHashMap;
-import java.util.List;
-
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.TreePath;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTListChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTPropertyChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.model.listener.awt.AWTStateChangeListenerWrapper;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.TreeNodeValueModel;
-
-/**
- * This javax.swing.tree.TreeModel can be used to keep a TreeModelListener
- * (e.g. a JTree) in synch with a tree of TreeNodeValueModel objects. Unlike
- * javax.swing.tree.DefaultTreeModel, you do not add and remove nodes with
- * methods implemented here. You can add and remove nodes by adding and
- * removing them directly to/from the nodes (or, more typically, the domain
- * objects the nodes are wrapping and listening to).
- *
- * Due to limitations in JTree, the root of the tree can never be null,
- * which, typically, should not be a problem. (If you want to display an empty
- * tree you can set the JTree's treeModel to null.)
- */
-public class TreeModelAdapter<T>
- extends AbstractTreeModel
-{
- /**
- * A value model on the underlying tree's root node and its
- * corresponding listener. This allows clients to swap out
- * the entire tree. Due to limitations in JTree, the root should
- * never be set to null while we have listeners.
- */
- private final PropertyValueModel<TreeNodeValueModel<T>> rootHolder;
- private final PropertyChangeListener rootListener;
-
- /**
- * A listener that notifies us when a node's internal
- * "state" changes (as opposed to the node's value or list of
- * children), allowing us to forward notification to our listeners.
- */
- private final StateChangeListener nodeStateListener;
-
- /**
- * A listener that notifies us when a node's "value"
- * changes (as opposed to the node's state or list of
- * children), allowing us to forward notification to our listeners.
- * Typically, this will only happen with nodes that hold
- * primitive data.
- */
- private final PropertyChangeListener nodeValueListener;
-
- /**
- * A listener that notifies us when an underlying node's
- * "list" of children changes, allowing us to keep our
- * internal tree in synch with the underlying tree model.
- */
- private final ListChangeListener childrenListener;
-
- /* these attributes make up our internal tree */
- /**
- * The root cannot be null while we have listeners, which is
- * most of the time. The root is cached so we can disengage
- * from it when it has been swapped out.
- */
- private TreeNodeValueModel<T> root;
-
- /**
- * Map the nodes to their lists of children.
- * We cache these so we can swap out the entire list of children
- * when we receive a #listChanged() event (which does not include
- * the items that were affected).
- * @see EventChangePolicy#rebuildChildren()
- */
- final IdentityHashMap<TreeNodeValueModel<T>, List<TreeNodeValueModel<T>>> childrenLists;
-
- /**
- * Map the children models to their parents.
- * We cache these so we can figure out the "real" source of the
- * list change events (the parent).
- * @see EventChangePolicy#parent()
- */
- final IdentityHashMap<ListValueModel<TreeNodeValueModel<T>>, TreeNodeValueModel<T>> parents;
-
-
- // ********** constructors **********
-
- /**
- * Construct a tree model for the specified root.
- */
- public TreeModelAdapter(PropertyValueModel<TreeNodeValueModel<T>> rootHolder) {
- super();
- if (rootHolder == null) {
- throw new NullPointerException();
- }
- this.rootHolder = rootHolder;
- this.rootListener = this.buildRootListener();
- this.nodeStateListener = this.buildNodeStateListener();
- this.nodeValueListener = this.buildNodeValueListener();
- this.childrenListener = this.buildChildrenListener();
- this.childrenLists = new IdentityHashMap<TreeNodeValueModel<T>, List<TreeNodeValueModel<T>>>();
- this.parents = new IdentityHashMap<ListValueModel<TreeNodeValueModel<T>>, TreeNodeValueModel<T>>();
- }
-
- /**
- * Construct a tree model for the specified root.
- */
- public TreeModelAdapter(TreeNodeValueModel<T> root) {
- this(new StaticPropertyValueModel<TreeNodeValueModel<T>>(root));
- }
-
-
- // ********** initialization **********
-
- protected PropertyChangeListener buildRootListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildRootListener_());
- }
-
- protected PropertyChangeListener buildRootListener_() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- TreeModelAdapter.this.rootChanged();
- }
- @Override
- public String toString() {
- return "root listener"; //$NON-NLS-1$
- }
- };
- }
-
- protected PropertyChangeListener buildNodeValueListener() {
- return new AWTPropertyChangeListenerWrapper(this.buildNodeValueListener_());
- }
-
- protected PropertyChangeListener buildNodeValueListener_() {
- return new PropertyChangeListener() {
- @SuppressWarnings("unchecked")
- public void propertyChanged(PropertyChangeEvent event) {
- TreeModelAdapter.this.nodeChanged((TreeNodeValueModel<T>) event.getSource());
- }
- @Override
- public String toString() {
- return "node value listener"; //$NON-NLS-1$
- }
- };
- }
-
- protected StateChangeListener buildNodeStateListener() {
- return new AWTStateChangeListenerWrapper(this.buildNodeStateListener_());
- }
-
- protected StateChangeListener buildNodeStateListener_() {
- return new StateChangeListener() {
- @SuppressWarnings("unchecked")
- public void stateChanged(StateChangeEvent event) {
- TreeModelAdapter.this.nodeChanged((TreeNodeValueModel<T>) event.getSource());
- }
- @Override
- public String toString() {
- return "node state listener"; //$NON-NLS-1$
- }
- };
- }
-
- protected ListChangeListener buildChildrenListener() {
- return new AWTListChangeListenerWrapper(this.buildChildrenListener_());
- }
-
- protected ListChangeListener buildChildrenListener_() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent event) {
- new AddEventChangePolicy(event).addChildren();
- }
- public void itemsRemoved(ListRemoveEvent event) {
- new RemoveEventChangePolicy(event).removeChildren();
- }
- public void itemsReplaced(ListReplaceEvent event) {
- new ReplaceEventChangePolicy(event).replaceChildren();
- }
- public void itemsMoved(ListMoveEvent event) {
- new MoveEventChangePolicy(event).moveChildren();
- }
- public void listCleared(ListClearEvent event) {
- new ClearEventChangePolicy(event).clearChildren();
- }
- public void listChanged(ListChangeEvent event) {
- new ChangeEventChangePolicy(event).rebuildChildren();
- }
- @Override
- public String toString() {
- return "children listener"; //$NON-NLS-1$
- }
- };
- }
-
-
- // ********** TreeModel implementation **********
-
- public Object getRoot() {
- return this.root;
- }
-
- @SuppressWarnings("unchecked")
- public Object getChild(Object parent, int index) {
- return ((TreeNodeValueModel<T>) parent).child(index);
- }
-
- @SuppressWarnings("unchecked")
- public int getChildCount(Object parent) {
- return ((TreeNodeValueModel<T>) parent).childrenSize();
- }
-
- @SuppressWarnings("unchecked")
- public boolean isLeaf(Object node) {
- return ((TreeNodeValueModel<T>) node).isLeaf();
- }
-
- @SuppressWarnings("unchecked")
- public void valueForPathChanged(TreePath path, Object newValue) {
- ((TreeNodeValueModel<T>) path.getLastPathComponent()).setValue((T) newValue);
- }
-
- @SuppressWarnings("unchecked")
- public int getIndexOfChild(Object parent, Object child) {
- return ((TreeNodeValueModel<T>) parent).indexOfChild((TreeNodeValueModel<T>) child);
- }
-
- /**
- * Extend to start listening to the underlying model if necessary.
- */
- @Override
- public void addTreeModelListener(TreeModelListener l) {
- if (this.hasNoTreeModelListeners()) {
- this.engageModel();
- }
- super.addTreeModelListener(l);
- }
-
- /**
- * Extend to stop listening to the underlying model if appropriate.
- */
- @Override
- public void removeTreeModelListener(TreeModelListener l) {
- super.removeTreeModelListener(l);
- if (this.hasNoTreeModelListeners()) {
- this.disengageModel();
- }
- }
-
-
- // ********** behavior **********
-
- /**
- * Listen to the root and all the other nodes
- * in the underlying tree model.
- */
- private void engageModel() {
- this.rootHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.rootListener);
- this.root = this.rootHolder.getValue();
- if (this.root == null) {
- throw new NullPointerException(); // the root cannot be null while we have listeners
- }
- this.engageNode(this.root);
- this.addRoot();
- }
-
- /**
- * Add the root and all of the nodes to the underlying tree.
- */
- private void addRoot() {
- this.addNode(0, this.root);
- }
-
- /**
- * Stop listening to the root and all the other
- * nodes in the underlying tree model.
- */
- private void disengageModel() {
- this.removeRoot();
- this.disengageNode(this.root);
- this.root = null;
- this.rootHolder.removePropertyChangeListener(PropertyValueModel.VALUE, this.rootListener);
- }
-
- /**
- * Remove the root and all of the nodes from the underlying tree.
- */
- private void removeRoot() {
- this.removeNode(0, this.root);
- }
-
- /**
- * The root has been swapped.
- * This method is a bit gnarly because the API for notifying listeners
- * that the root has changed is a bit inconsistent with that used for
- * non-root nodes.
- */
- void rootChanged() {
- TreeNodeValueModel<T> newRoot = this.rootHolder.getValue();
- if (newRoot == null) {
- throw new NullPointerException(); // the root cannot be null while we have listeners
- }
- // remove all the current root's children from the tree
- // and remove the it from the internal tree
- this.removeRoot();
-
- // save the old root and swap in the new root
- TreeNodeValueModel<T> oldRoot = this.root;
- this.root = newRoot;
-
- // we must be listening to both the old and new roots when we fire the event
- // because their values can be affected by whether they have listeners
- this.engageNode(this.root);
- this.fireTreeRootReplaced(this.root);
- // now we can stop listening to the old root
- this.disengageNode(oldRoot);
-
- // add the new root to the internal tree and
- // add all its children to the tree also
- this.addRoot();
- }
-
- /**
- * Either the "value" or the "state" of the specified node has changed,
- * forward notification to our listeners.
- */
- void nodeChanged(TreeNodeValueModel<T> node) {
- TreeNodeValueModel<T> parent = node.parent();
- if (parent == null) {
- this.fireTreeRootChanged(node);
- } else {
- this.fireTreeNodeChanged(parent.path(), parent.indexOfChild(node), node);
- }
- }
-
- /**
- * Listen to the nodes, notify our listeners that the nodes were added,
- * and then add the nodes to our internal tree.
- * We must listen to the nodes before notifying anybody, because
- * adding a listener can change the value of a node.
- */
- void addChildren(TreeNodeValueModel<T>[] path, int[] childIndices, TreeNodeValueModel<T>[] children) {
- int len = childIndices.length;
- for (int i = 0; i < len; i++) {
- this.engageNode(children[i]);
- }
- this.fireTreeNodesInserted(path, childIndices, children);
- for (int i = 0; i < len; i++) {
- this.addNode(childIndices[i], children[i]);
- }
- }
-
- /**
- * Listen to the node and its children model.
- */
- private void engageNode(TreeNodeValueModel<T> node) {
- node.addStateChangeListener(this.nodeStateListener);
- node.addPropertyChangeListener(PropertyValueModel.VALUE, this.nodeValueListener);
- node.childrenModel().addListChangeListener(ListValueModel.LIST_VALUES, this.childrenListener);
- }
-
- /**
- * Add the node to our internal tree;
- * then recurse down through the node's children,
- * adding them to the internal tree also.
- */
- private void addNode(int index, TreeNodeValueModel<T> node) {
- this.addNodeToInternalTree(node.parent(), index, node, node.childrenModel());
- new NodeChangePolicy(node).addChildren();
- }
-
- /**
- * Add the specified node to our internal tree.
- */
- private void addNodeToInternalTree(TreeNodeValueModel<T> parent, int index, TreeNodeValueModel<T> node, ListValueModel<TreeNodeValueModel<T>> childrenModel) {
- List<TreeNodeValueModel<T>> siblings = this.childrenLists.get(parent);
- if (siblings == null) {
- siblings = new ArrayList<TreeNodeValueModel<T>>();
- this.childrenLists.put(parent, siblings);
- }
- siblings.add(index, node);
-
- this.parents.put(childrenModel, node);
- }
-
- /**
- * Remove nodes from our internal tree, notify our listeners that the
- * nodes were removed, then stop listening to the nodes.
- * We must listen to the nodes until after notifying anybody, because
- * removing a listener can change the value of a node.
- */
- void removeChildren(TreeNodeValueModel<T>[] path, int[] childIndices, TreeNodeValueModel<T>[] children) {
- int len = childIndices.length;
- for (int i = 0; i < len; i++) {
- // the indices slide down a notch each time we remove a child
- this.removeNode(childIndices[i] - i, children[i]);
- }
- this.fireTreeNodesRemoved(path, childIndices, children);
- for (int i = 0; i < len; i++) {
- this.disengageNode(children[i]);
- }
- }
-
- /**
- * First, recurse down through the node's children,
- * removing them from our internal tree;
- * then remove the node itself from our internal tree.
- */
- private void removeNode(int index, TreeNodeValueModel<T> node) {
- new NodeChangePolicy(node).removeChildren();
- this.removeNodeFromInternalTree(node.parent(), index, node.childrenModel());
- }
-
- /**
- * Remove the specified node from our internal tree.
- */
- private void removeNodeFromInternalTree(TreeNodeValueModel<T> parent, int index, ListValueModel<TreeNodeValueModel<T>> childrenModel) {
- this.parents.remove(childrenModel);
-
- List<TreeNodeValueModel<T>> siblings = this.childrenLists.get(parent);
- siblings.remove(index);
- if (siblings.isEmpty()) {
- this.childrenLists.remove(parent);
- }
- }
-
- /**
- * Stop listening to the node and its children model.
- */
- private void disengageNode(TreeNodeValueModel<T> node) {
- node.childrenModel().removeListChangeListener(ListValueModel.LIST_VALUES, this.childrenListener);
- node.removePropertyChangeListener(PropertyValueModel.VALUE, this.nodeValueListener);
- node.removeStateChangeListener(this.nodeStateListener);
- }
-
- void moveChildren(TreeNodeValueModel<T> parent, int targetIndex, int sourceIndex, int length) {
- List<TreeNodeValueModel<T>> childrenList = this.childrenLists.get(parent);
- ArrayList<TreeNodeValueModel<T>> temp = new ArrayList<TreeNodeValueModel<T>>(length);
- for (int i = 0; i < length; i++) {
- temp.add(childrenList.remove(sourceIndex));
- }
- childrenList.addAll(targetIndex, temp);
-
- this.fireTreeStructureChanged(parent.path());
- }
-
-
- // ********** standard methods **********
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.root);
- }
-
-
- // ********** inner classes **********
-
- /**
- * Coalesce some of the common change policy behavior.
- */
- abstract class ChangePolicy {
-
- ChangePolicy() {
- super();
- }
-
- /**
- * Add the current set of children.
- */
- void addChildren() {
- TreeModelAdapter.this.addChildren(this.parent().path(), this.childIndices(), this.childArray());
- }
-
- /**
- * Remove the current set of children.
- */
- void removeChildren() {
- TreeModelAdapter.this.removeChildren(this.parent().path(), this.childIndices(), this.childArray());
- }
-
- /**
- * Return an array of the indices of the current set of children,
- * which should be contiguous.
- */
- int[] childIndices() {
- return this.buildIndices(this.childrenStartIndex(), this.childrenSize());
- }
-
- /**
- * Return an array of the current set of children.
- */
- TreeNodeValueModel<T>[] childArray() {
- return this.buildArray(this.getChildren(), this.childrenSize());
- }
-
- /**
- * Build an array to hold the elements in the specified iterator.
- * If they are different sizes, something is screwed up...
- */
- TreeNodeValueModel<T>[] buildArray(Iterable<TreeNodeValueModel<T>> elements, int size) {
- @SuppressWarnings("unchecked")
- TreeNodeValueModel<T>[] array = new TreeNodeValueModel[size];
- int i = 0;
- for (TreeNodeValueModel<T> element : elements) {
- array[i++] = element;
- }
- return array;
- }
-
- /**
- * Return a set of indices, starting at zero and
- * continuing for the specified size.
- */
- int[] buildIndices(int size) {
- return buildIndices(0, size);
- }
-
- /**
- * Return a set of indices, starting at the specified index and
- * continuing for the specified size.
- */
- int[] buildIndices(int start, int size) {
- int[] indices = new int[size];
- int index = start;
- for (int i = 0; i < size; i++) {
- indices[i] = index++;
- }
- return indices;
- }
-
- /**
- * Return the parent of the current set of children.
- */
- abstract TreeNodeValueModel<T> parent();
-
- /**
- * Return the starting index for the current set of children.
- */
- abstract int childrenStartIndex();
-
- /**
- * Return the size of the current set of children.
- */
- abstract int childrenSize();
-
- /**
- * Return the current set of children.
- */
- abstract Iterable<TreeNodeValueModel<T>> getChildren();
-
- }
-
-
- /**
- * Wraps a ListEvent for adding, removing, replacing,
- * and changing children.
- */
- abstract class EventChangePolicy extends ChangePolicy {
- final ListEvent event;
-
- EventChangePolicy(ListEvent event) {
- super();
- this.event = event;
- }
-
- /**
- * Map the ListChangeEvent's source to the corresponding parent.
- */
- @Override
- TreeNodeValueModel<T> parent() {
- return TreeModelAdapter.this.parents.get(this.event.getSource());
- }
-
- }
-
-
- /**
- * Wraps a ListAddEvent for adding children.
- */
- class AddEventChangePolicy extends EventChangePolicy {
-
- AddEventChangePolicy(ListAddEvent event) {
- super(event);
- }
-
- private ListAddEvent getEvent() {
- return (ListAddEvent) this.event;
- }
-
- /**
- * The ListAddEvent's item index is the children start index.
- */
- @Override
- int childrenStartIndex() {
- return this.getEvent().getIndex();
- }
-
- /**
- * The ListAddEvent's size is the children size.
- */
- @Override
- int childrenSize() {
- return this.getEvent().getItemsSize();
- }
-
- /**
- * The ListAddEvent's items are the children.
- */
- @Override
- @SuppressWarnings("unchecked")
- Iterable<TreeNodeValueModel<T>> getChildren() {
- return (Iterable<TreeNodeValueModel<T>>) this.getEvent().getItems();
- }
-
- }
-
-
- /**
- * Wraps a ListRemoveEvent for adding children.
- */
- class RemoveEventChangePolicy extends EventChangePolicy {
-
- RemoveEventChangePolicy(ListRemoveEvent event) {
- super(event);
- }
-
- private ListRemoveEvent getEvent() {
- return (ListRemoveEvent) this.event;
- }
-
- /**
- * The ListRemoveEvent's item index is the children start index.
- */
- @Override
- int childrenStartIndex() {
- return this.getEvent().getIndex();
- }
-
- /**
- * The ListRemoveEvent's size is the children size.
- */
- @Override
- int childrenSize() {
- return this.getEvent().getItemsSize();
- }
-
- /**
- * The ListRemoveEvent's items are the children.
- */
- @Override
- @SuppressWarnings("unchecked")
- Iterable<TreeNodeValueModel<T>> getChildren() {
- return (Iterable<TreeNodeValueModel<T>>) this.getEvent().getItems();
- }
-
- }
-
-
- /**
- * Wraps a ListReplaceEvent for replacing children.
- */
- class ReplaceEventChangePolicy extends EventChangePolicy {
-
- ReplaceEventChangePolicy(ListReplaceEvent event) {
- super(event);
- }
-
- private ListReplaceEvent getEvent() {
- return (ListReplaceEvent) this.event;
- }
-
- /**
- * The ListReplaceEvent's item index is the children start index.
- */
- @Override
- int childrenStartIndex() {
- return this.getEvent().getIndex();
- }
-
- /**
- * The ListReplaceEvent's size is the children size.
- */
- @Override
- int childrenSize() {
- return this.getEvent().getItemsSize();
- }
-
- /**
- * The ListReplaceEvent's items are the children.
- */
- @Override
- @SuppressWarnings("unchecked")
- Iterable<TreeNodeValueModel<T>> getChildren() {
- return (Iterable<TreeNodeValueModel<T>>) this.getEvent().getNewItems();
- }
-
- /**
- * Remove the old nodes and add the new ones.
- */
- void replaceChildren() {
- TreeNodeValueModel<T>[] parentPath = this.parent().path();
- int[] childIndices = this.childIndices();
- TreeModelAdapter.this.removeChildren(parentPath, childIndices, this.getOldChildren());
- TreeModelAdapter.this.addChildren(parentPath, childIndices, this.childArray());
- }
-
- TreeNodeValueModel<T>[] getOldChildren() {
- return this.buildArray(this.getOldItems(), this.getEvent().getItemsSize());
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- protected Iterable<TreeNodeValueModel<T>> getOldItems() {
- return (Iterable<TreeNodeValueModel<T>>) this.getEvent().getOldItems();
- }
-
- }
-
-
- /**
- * Wraps a ListMoveEvent for moving children.
- */
- class MoveEventChangePolicy extends EventChangePolicy {
-
- MoveEventChangePolicy(ListMoveEvent event) {
- super(event);
- }
-
- private ListMoveEvent getEvent() {
- return (ListMoveEvent) this.event;
- }
-
- void moveChildren() {
- TreeModelAdapter.this.moveChildren(this.parent(), this.getEvent().getTargetIndex(), this.getEvent().getSourceIndex(), this.getEvent().getLength());
- }
-
- @Override
- int childrenStartIndex() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- int childrenSize() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- Iterable<TreeNodeValueModel<T>> getChildren() {
- throw new UnsupportedOperationException();
- }
-
- }
-
-
- /**
- * Wraps a ListClearEvent for clearing children.
- */
- class ClearEventChangePolicy extends EventChangePolicy {
-
- ClearEventChangePolicy(ListClearEvent event) {
- super(event);
- }
-
- /**
- * Clear all the nodes.
- */
- void clearChildren() {
- TreeNodeValueModel<T> parent = this.parent();
- TreeNodeValueModel<T>[] parentPath = parent.path();
- List<TreeNodeValueModel<T>> childrenList = TreeModelAdapter.this.childrenLists.get(parent);
- int[] childIndices = this.buildIndices(childrenList.size());
- TreeNodeValueModel<T>[] childArray = this.buildArray(childrenList, childrenList.size());
- TreeModelAdapter.this.removeChildren(parentPath, childIndices, childArray);
- }
-
- @Override
- int childrenStartIndex() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- int childrenSize() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- Iterable<TreeNodeValueModel<T>> getChildren() {
- throw new UnsupportedOperationException();
- }
-
- }
-
-
- /**
- * Wraps a ListChangeEvent for clearing children.
- */
- class ChangeEventChangePolicy extends EventChangePolicy {
-
- ChangeEventChangePolicy(ListChangeEvent event) {
- super(event);
- }
-
- /**
- * Remove all the old nodes and add all the new nodes.
- */
- void rebuildChildren() {
- TreeNodeValueModel<T> parent = this.parent();
- TreeNodeValueModel<T>[] parentPath = parent.path();
- List<TreeNodeValueModel<T>> childrenList = TreeModelAdapter.this.childrenLists.get(parent);
- int[] childIndices = this.buildIndices(childrenList.size());
- TreeNodeValueModel<T>[] childArray = this.buildArray(childrenList, childrenList.size());
- TreeModelAdapter.this.removeChildren(parentPath, childIndices, childArray);
-
- childIndices = this.buildIndices(parent.childrenModel().size());
- childArray = this.buildArray(parent.childrenModel(), parent.childrenSize());
- TreeModelAdapter.this.addChildren(parentPath, childIndices, childArray);
- }
-
- @Override
- int childrenStartIndex() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- int childrenSize() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- Iterable<TreeNodeValueModel<T>> getChildren() {
- throw new UnsupportedOperationException();
- }
-
- }
-
-
- /**
- * Wraps a TreeNodeValueModel for adding and removing its children.
- */
- class NodeChangePolicy extends ChangePolicy {
- private final TreeNodeValueModel<T> node;
-
- NodeChangePolicy(TreeNodeValueModel<T> node) {
- super();
- this.node = node;
- }
-
- /**
- * The node itself is the parent.
- */
- @Override
- TreeNodeValueModel<T> parent() {
- return this.node;
- }
-
- /**
- * Since we will always be dealing with all of the node's
- * children, the children start index is always zero.
- */
- @Override
- int childrenStartIndex() {
- return 0;
- }
-
- /**
- * Since we will always be dealing with all of the node's
- * children, the children size is always equal to the size
- * of the children model.
- */
- @Override
- int childrenSize() {
- return this.node.childrenModel().size();
- }
-
- /**
- * Since we will always be dealing with all of the node's
- * children, the children are all the objects held by
- * the children model.
- */
- @Override
- Iterable<TreeNodeValueModel<T>> getChildren() {
- return this.node.childrenModel();
- }
-
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/AbstractNode.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/AbstractNode.java
deleted file mode 100644
index 449642da78..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/AbstractNode.java
+++ /dev/null
@@ -1,940 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.node;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Set;
-import java.util.Vector;
-
-import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.AspectChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-
-/**
- * Base class for Node classes.
- * Provides support for the following:
- * initialization
- * enforced object identity wrt #equals()/#hashCode()
- * containment hierarchy (parent/child)
- * user comment
- * dirty flag
- * problems
- * sorting
- *
- * Typically, subclasses should consider implementing the following methods:
- * the appropriate constructors
- * (with the appropriately-restrictive type declaration for parent)
- * #initialize()
- * #initialize(Node parentNode)
- * #checkParent(Node parentNode)
- * #addChildrenTo(List list)
- * #nodeRemoved(Node)
- * #validator()
- * #transientAspectNames() or
- * #addTransientAspectNamesTo(Set transientAspectNames)
- * #addProblemsTo(List currentProblems)
- * #nonValidatedAspectNames()
- * #addNonValidatedAspectNamesTo(Set nonValidatedAspectNames)
- * #displayString()
- * #toString(StringBuilder sb)
- */
-public abstract class AbstractNode
- extends AbstractModel
- implements Node
-{
-
- /** Containment hierarchy. */
- private Node parent; // pseudo-final
-
- /** Track whether the node has changed. */
- private volatile boolean dirty;
- private volatile boolean dirtyBranch;
-
- /**
- * The node's problems, as calculated during validation.
- * This list should only be modified via a ProblemSynchronizer,
- * allowing for asynchronous modification from another thread.
- */
- private Vector<Problem> problems; // pseudo-final
- private static final Object[] EMPTY_PROBLEM_MESSAGE_ARGUMENTS = new Object[0];
-
- /**
- * Cache the node's "branch" problems, as calculated during validation.
- * This list should only be modified via a ProblemSynchronizer,
- * allowing for asynchronous modification from another thread.
- * This must be recalculated every time this node or one of its
- * descendants changes it problems.
- */
- private Vector<Problem> branchProblems; // pseudo-final
-
- /** User comment. */
- private volatile String comment;
-
-
- // ********** static fields **********
-
- /**
- * Sets of transient aspect names, keyed by class.
- * This is built up lazily, as the objects are modified.
- */
- private static final HashMap<Class<? extends AbstractNode>, HashSet<String>> transientAspectNameSets = new HashMap<Class<? extends AbstractNode>, HashSet<String>>();
-
- /**
- * Sets of non-validated aspect names, keyed by class.
- * This is built up lazily, as the objects are modified.
- */
- private static final HashMap<Class<? extends AbstractNode>, HashSet<String>> nonValidatedAspectNameSets = new HashMap<Class<? extends AbstractNode>, HashSet<String>>();
-
-
- // ********** constructors **********
-
- /**
- * Most objects must have a parent.
- * Use this constructor to create a new node.
- * @see #initialize(Node)
- */
- protected AbstractNode(Node parent) {
- super();
- this.initialize();
- this.initialize(parent);
- }
-
-
- // ********** initialization **********
-
- /**
- * Initialize a newly-created instance.
- * @see #initialize(Node)
- */
- protected void initialize() {
- this.comment = ""; //$NON-NLS-1$
-
- // a new object is dirty, by definition
- this.dirty = true;
- this.dirtyBranch = true;
-
- this.problems = new Vector<Problem>();
- this.branchProblems = new Vector<Problem>();
-
- // when you override this method, don't forget to include:
- // super.initialize();
- }
-
- /**
- * Initialize a newly-created instance.
- * @see #initialize()
- */
- protected void initialize(Node parentNode) {
- this.checkParent(parentNode);
- this.parent = parentNode;
- // when you override this method, don't forget to include:
- // super.initialize(parentNode);
- }
-
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new AspectChangeSupport(this, this.buildChangeSupportListener());
- }
-
- protected AspectChangeSupport.Listener buildChangeSupportListener() {
- return new AspectChangeSupport.Listener() {
- public void aspectChanged(String aspectName) {
- AbstractNode.this.aspectChanged(aspectName);
- }
- };
- }
-
-
- // ********** equality **********
-
- /**
- * Enforce object identity - do not allow objects to be equal unless
- * they are the same object.
- * Do NOT override this method - we rely on object identity extensively.
- */
- @Override
- public final boolean equals(Object o) {
- return this == o;
- }
-
- /**
- * Enforce object identity - do not allow objects to be equal unless
- * they are the same object.
- * Do NOT override this method - we rely on object identity extensively.
- */
- @Override
- public final int hashCode() {
- return super.hashCode();
- }
-
-
- // ********** containment hierarchy (parent/children) **********
-
- /**
- * INTRA-TREE API?
- * Return the node's parent in the containment hierarchy.
- * Most nodes must have a parent.
- * @see #children()
- */
- public Node getParent() {
- return this.parent;
- }
-
- /**
- * Throw an IllegalArgumentException if the parent is not valid
- * for the node.
- * By default require a non-null parent. Override if other restrictions exist
- * or the parent should be null.
- * NB: Root node model implementations will need to override this method.
- */
- protected void checkParent(Node parentNode) {
- if (parentNode == null) {
- throw new IllegalArgumentException("The parent node cannot be null"); //$NON-NLS-1$
- }
- }
-
- /**
- * INTRA-TREE API?
- * Return the node's children, which are also nodes.
- * Do NOT override this method.
- * Override #addChildrenTo(List).
- * @see #getParent()
- * @see #addChildrenTo(java.util.List)
- */
- public final Iterator<Node> children() {
- List<Node> children = new ArrayList<Node>();
- this.addChildrenTo(children);
- return children.iterator();
- }
-
- /**
- * Subclasses should override this method to add their children
- * to the specified list.
- * @see #children()
- */
- protected void addChildrenTo(@SuppressWarnings("unused") List<Node> list) {
- // this class has no children, subclasses will...
- // when you override this method, don't forget to include:
- // super.addChildrenTo(list);
- }
-
- /**
- * INTRA-TREE API?
- * Return the containment hierarchy's root node.
- * Most nodes must have a root.
- * @see #getParent()
- * NB: Assume the root has no parent.
- */
- public Node root() {
- Node p = this.parent;
- return (p == null) ? this : p.root();
- }
-
- /**
- * Return whether the node is a descendant of the specified node.
- * By definition, a node is a descendant of itself.
- */
- public boolean isDescendantOf(Node node) {
- return (this == node) || this.parentIsDescendantOf(node);
- }
-
- protected boolean parentIsDescendantOf(Node node) {
- return (this.parent != null) && this.parent.isDescendantOf(node);
- }
-
- /**
- * Return a collection holding all the node's "references", and all
- * the node's descendants' "references". "References" are
- * objects that are "referenced" by another object, as opposed
- * to "owned" by another object.
- */
- public Iterator<Node.Reference> branchReferences() {
- Collection<Node.Reference> branchReferences = new ArrayList<Node.Reference>(1000); // start big
- this.addBranchReferencesTo(branchReferences);
- return branchReferences.iterator();
- }
-
- /**
- * INTRA-TREE API
- * Add the node's "references", and all the node's descendants'
- * "references", to the specified collection. "References" are
- * objects that are "referenced" by another object, as opposed
- * to "owned" by another object.
- * This method is of particular concern to Handles, since most
- * (hopefully all) "references" are held by Handles.
- * @see Reference
- * @see #children()
- */
- public void addBranchReferencesTo(Collection<Node.Reference> branchReferences) {
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.addBranchReferencesTo(branchReferences);
- }
- }
-
- /**
- * Return all the nodes in the object's branch of the tree,
- * including the node itself. The nodes will probably returned
- * in "depth-first" order.
- * Only really used for testing and debugging.
- */
- public Iterator<Node> allNodes() {
- Collection<Node> nodes = new ArrayList<Node>(1000); // start big
- this.addAllNodesTo(nodes);
- return nodes.iterator();
- }
-
- /**
- * INTRA-TREE API?
- * Add all the nodes in the object's branch of the tree,
- * including the node itself, to the specified collection.
- * Only really used for testing and debugging.
- */
- public void addAllNodesTo(Collection<Node> nodes) {
- nodes.add(this);
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.addAllNodesTo(nodes);
- }
- }
-
-
- // ********** model synchronization support **********
-
- /**
- * INTRA-TREE API
- * This is a general notification that the specified node has been
- * removed from the tree. The node receiving this notification
- * should perform any necessary updates to remain in synch
- * with the tree (e.g. clearing out or replacing any references
- * to the removed node or any of the removed node's descendants).
- * @see #isDescendantOf(Node)
- */
- public void nodeRemoved(Node node) {
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.nodeRemoved(node);
- }
- // when you override this method, don't forget to include:
- // super.nodeRemoved(node);
- }
-
- /**
- * convenience method
- * return whether node1 is a descendant of node2;
- * node1 can be null
- */
- protected boolean nodeIsDescendantOf(Node node1, Node node2) {
- return (node1 != null) && node1.isDescendantOf(node2);
- }
-
- /**
- * INTRA-TREE API
- * This is a general notification that the specified node has been
- * renamed. The node receiving this notification should mark its
- * branch dirty if necessary (i.e. it references the renamed node
- * or one of its descendants). This method is of particular concern
- * to Handles.
- * @see #isDescendantOf(Node)
- */
- public void nodeRenamed(Node node) {
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.nodeRenamed(node);
- }
- // when you override this method, don't forget to include:
- // super.nodeRenamed(node);
- }
-
-
- // ********** user comment **********
-
- /**
- * Return the object's user comment.
- */
- public final String comment() {
- return this.comment;
- }
-
- /**
- * Set the object's user comment.
- */
- public final void setComment(String comment) {
- Object old = this.comment;
- this.comment = comment;
- this.firePropertyChanged(COMMENT_PROPERTY, old, comment);
- }
-
-
- // ********** change support **********
-
- /**
- * An aspect of the node has changed:
- * - if it is a persistent aspect, mark the object dirty
- * - if it is a significant aspect, validate the object
- */
- protected void aspectChanged(String aspectName) {
- if (this.aspectIsPersistent(aspectName)) {
- // System.out.println(Thread.currentThread() + " dirty change: " + this + ": " + aspectName);
- this.markDirty();
- }
- if (this.aspectChangeRequiresValidation(aspectName)) {
- // System.out.println(Thread.currentThread() + " validation change: " + this + ": " + aspectName);
- this.validate();
- }
- }
-
- protected void validate() {
- this.getValidator().validate();
- }
-
- /**
- * INTRA-TREE API
- * Return a validator that will be invoked whenever a
- * "validated" aspect of the node tree changes.
- * Typically only the root node directly holds a validator.
- * NB: Root node model implementations will need to override this method.
- */
- public Node.Validator getValidator() {
- if (this.parent == null) {
- throw new IllegalStateException("This node should not be firing change events during its construction."); //$NON-NLS-1$
- }
- return this.parent.getValidator();
- }
-
- /**
- * Set a validator that will be invoked whenever a
- * "validated" aspect of the node tree changes.
- * Typically only the root node directly holds a validator.
- * NB: Root node model implementations will need to override this method.
- */
- public void setValidator(Node.Validator validator) {
- if (this.parent == null) {
- throw new IllegalStateException("This root node should implement #setValidator(Node.Validator)."); //$NON-NLS-1$
- }
- throw new UnsupportedOperationException("Only root nodes implement #setValidator(Node.Validator)."); //$NON-NLS-1$
- }
-
-
- // ********** dirty flag support **********
-
- /**
- * Return whether any persistent aspects of the object
- * have changed since the object was last read or saved.
- * This does NOT include changes to the object's descendants.
- */
- public final boolean isDirty() {
- return this.dirty;
- }
-
- /**
- * Return whether any persistent aspects of the object,
- * or any of its descendants, have changed since the object and
- * its descendants were last read or saved.
- */
- public final boolean isDirtyBranch() {
- return this.dirtyBranch;
- }
-
- /**
- * Return whether the object is unmodified
- * since it was last read or saved.
- * This does NOT include changes to the object's descendants.
- */
- public final boolean isClean() {
- return ! this.dirty;
- }
-
- /**
- * Return whether the object and all of its descendants
- * are unmodified since the object and
- * its descendants were last read or saved.
- */
- public final boolean isCleanBranch() {
- return ! this.dirtyBranch;
- }
-
- /**
- * Set the dirty branch flag setting. This is set to true
- * when either the object or one of its descendants becomes dirty.
- */
- private void setIsDirtyBranch(boolean dirtyBranch) {
- boolean old = this.dirtyBranch;
- this.dirtyBranch = dirtyBranch;
- this.firePropertyChanged(DIRTY_BRANCH_PROPERTY, old, dirtyBranch);
- }
-
- /**
- * Mark the object as dirty and as a dirty branch.
- * An object is marked dirty when either a "persistent" attribute
- * has changed or its save location has changed.
- */
- private void markDirty() {
- this.dirty = true;
- this.markBranchDirty();
- }
-
- /**
- * INTRA-TREE API
- * Mark the node and its parent as dirty branches.
- * This message is propagated up the containment
- * tree when a particular node becomes dirty.
- */
- public void markBranchDirty() {
- // short-circuit any unnecessary propagation
- if (this.dirtyBranch) {
- // if this is already a dirty branch, the parent must be also
- return;
- }
-
- this.setIsDirtyBranch(true);
- this.markParentBranchDirty();
- }
-
- protected void markParentBranchDirty() {
- if (this.parent != null) {
- this.parent.markBranchDirty();
- }
- }
-
- /**
- * Mark the object and all its descendants as dirty.
- * This is used when the save location of some
- * top-level object is changed and the entire
- * containment tree must be marked dirty so it
- * will be written out.
- */
- public final void markEntireBranchDirty() {
- this.markDirty();
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.markEntireBranchDirty();
- }
- }
-
- /**
- * Mark the object and all its descendants as clean.
- * Then notify the object's parent that it (the parent)
- * might now be a clean branch also.
- * Typically used when the object has just been
- * read in or written out.
- */
- public final void markEntireBranchClean() {
- this.cascadeMarkEntireBranchClean();
- this.markParentBranchCleanIfPossible();
- }
-
- protected void markParentBranchCleanIfPossible() {
- if (this.parent != null) {
- this.parent.markBranchCleanIfPossible();
- }
- }
-
- /**
- * INTRA-TREE API
- * Mark the node and all its descendants as clean.
- * Typically used when the node has just been
- * read in or written out.
- * This method is for internal use only; it is not for
- * client use.
- * Not the best of method names.... :-(
- */
- public final void cascadeMarkEntireBranchClean() {
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.cascadeMarkEntireBranchClean();
- }
- this.dirty = false;
- this.setIsDirtyBranch(false);
- }
-
- /**
- * INTRA-TREE API
- * A child node's branch has been marked clean. If the node
- * itself is clean and if all of its children are also clean, the
- * node's branch can be marked clean. Then, if the node's
- * branch is clean, the node will notify its parent that it might
- * be clean also. This message is propagated up the containment
- * tree when a particular node becomes clean.
- */
- public final void markBranchCleanIfPossible() {
- // short-circuit any unnecessary propagation
- if (this.dirty) {
- // if the object is "locally" dirty, it is still a dirty branch
- return;
- }
-
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- if (child.isDirtyBranch()) {
- return;
- }
- }
-
- this.setIsDirtyBranch(false);
- this.markParentBranchCleanIfPossible();
- }
-
- private boolean aspectIsPersistent(String aspectName) {
- return ! this.aspectIsTransient(aspectName);
- }
-
- private boolean aspectIsTransient(String aspectName) {
- return this.transientAspectNames().contains(aspectName);
- }
-
- /**
- * Return a set of the object's transient aspect names.
- * These are the aspects that, when they change, will NOT cause the
- * object to be marked dirty.
- * If you need instance-based calculation of your transient aspects,
- * override this method. If class-based calculation is sufficient,
- * override #addTransientAspectNamesTo(Set).
- */
- protected final Set<String> transientAspectNames() {
- synchronized (transientAspectNameSets) {
- HashSet<String> transientAspectNames = transientAspectNameSets.get(this.getClass());
- if (transientAspectNames == null) {
- transientAspectNames = new HashSet<String>();
- this.addTransientAspectNamesTo(transientAspectNames);
- transientAspectNameSets.put(this.getClass(), transientAspectNames);
- }
- return transientAspectNames;
- }
- }
-
- /**
- * Add the object's transient aspect names to the specified set.
- * These are the aspects that, when they change, will NOT cause the
- * object to be marked dirty.
- * If class-based calculation of your transient aspects is sufficient,
- * override this method. If you need instance-based calculation,
- * override #transientAspectNames().
- */
- protected void addTransientAspectNamesTo(Set<String> transientAspectNames) {
- transientAspectNames.add(DIRTY_BRANCH_PROPERTY);
- transientAspectNames.add(BRANCH_PROBLEMS_LIST);
- transientAspectNames.add(HAS_BRANCH_PROBLEMS_PROPERTY);
- // when you override this method, don't forget to include:
- // super.addTransientAspectNamesTo(transientAspectNames);
- }
-
- /**
- * Return the dirty nodes in the object's branch of the tree,
- * including the node itself (if appropriate).
- * Only really used for testing and debugging.
- */
- public final Iterator<Node> allDirtyNodes() {
- return new FilteringIterator<Node>(this.allNodes()) {
- @Override
- protected boolean accept(Node node) {
- return (node instanceof AbstractNode) && ((AbstractNode) node).isDirty();
- }
- };
- }
-
-
- // ********** problems **********
-
- /**
- * Return the node's problems.
- * This does NOT include the problems of the node's descendants.
- * @see #branchProblems()
- */
- public final Iterator<Problem> problems() {
- return new CloneIterator<Problem>(this.problems); // removes are not allowed
- }
-
- /**
- * Return the size of the node's problems.
- * This does NOT include the problems of the node's descendants.
- * @see #branchProblemsSize()
- */
- public final int problemsSize() {
- return this.problems.size();
- }
-
- /**
- * Return whether the node has problems
- * This does NOT include the problems of the node's descendants.
- * @see #hasBranchProblems()
- */
- public final boolean hasProblems() {
- return ! this.problems.isEmpty();
- }
-
- /**
- * Return all the node's problems along with all the
- * node's descendants' problems.
- */
- public final ListIterator<Problem> branchProblems() {
- return new CloneListIterator<Problem>(this.branchProblems); // removes are not allowed
- }
-
- /**
- * Return the size of all the node's problems along with all the
- * node's descendants' problems.
- */
- public final int branchProblemsSize() {
- return this.branchProblems.size();
- }
-
- /**
- * Return whether the node or any of its descendants have problems.
- */
- public final boolean hasBranchProblems() {
- return ! this.branchProblems.isEmpty();
- }
-
- public final boolean containsBranchProblem(Problem problem) {
- return this.branchProblems.contains(problem);
- }
-
- protected final Problem buildProblem(String messageKey, int messageType, Object... messageArguments) {
- return new DefaultProblem(this, messageKey, messageType, messageArguments);
- }
-
- protected final Problem buildProblem(String messageKey, int messageType) {
- return this.buildProblem(messageKey, messageType, EMPTY_PROBLEM_MESSAGE_ARGUMENTS);
- }
-
- /**
- * Validate the node and all of its descendants,
- * and update their sets of "branch" problems.
- * If the node's "branch" problems have changed,
- * notify the node's parent.
- */
- public void validateBranch() {
- if (this.validateBranchInternal()) {
- // if our "branch" problems have changed, then
- // our parent must rebuild its "branch" problems also
- this.rebuildParentBranchProblems();
- }
- }
-
- protected void rebuildParentBranchProblems() {
- if (this.parent != null) {
- this.parent.rebuildBranchProblems();
- }
- }
-
- /**
- * INTRA-TREE API
- * Validate the node and all of its descendants,
- * and update their sets of "branch" problems.
- * Return true if the collection of "branch" problems has changed.
- * This method is for internal use only; it is not for
- * client use.
- */
- public boolean validateBranchInternal() {
- // rebuild "branch" problems in children first
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- // ignore the return value because we are going to rebuild our "branch"
- // problems no matter what, to see if they have changed
- child.validateBranchInternal();
- }
-
- this.problems.clear();
- this.addProblemsTo(this.problems);
-
- return this.checkBranchProblems();
- }
-
- /**
- * Check for any problems and add them to the specified list.
- * This method should ONLY add problems for this particular node;
- * it should NOT add problems for any of this node's descendants
- * or ancestors. (Although there will be times when it is debatable
- * as to which node a problem "belongs" to....)
- *
- * NB: This method should NOT modify ANY part of the node's state!
- * It is a READ-ONLY behavior. ONLY the list of current problems
- * passed in to the method should be modified.
- */
- protected void addProblemsTo(@SuppressWarnings("unused") List<Problem> currentProblems) {
- // The default is to do nothing.
- // When you override this method, don't forget to include:
- // super.addProblemsTo(currentProblems);
- }
-
- /**
- * Rebuild the "branch" problems and return whether they have
- * changed.
- * NB: The entire collection of "branch" problems must be re-calculated
- * with EVERY "significant" change - we cannot keep it in sync via
- * change notifications because if a descendant with problems is
- * removed or replaced we will not receive notification that its
- * problems were removed from our "branch" problems.
- */
- private boolean checkBranchProblems() {
- Vector<Problem> oldBranchProblems = new Vector<Problem>(this.branchProblems);
- int oldSize = this.branchProblems.size();
-
- this.branchProblems.clear();
- this.branchProblems.addAll(this.problems);
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- child.addBranchProblemsTo(this.branchProblems);
- }
-
- // if the size has changed to or from zero, our virtual flag has changed
- int newSize = this.branchProblems.size();
- if ((oldSize == 0) && (newSize != 0)) {
- this.firePropertyChanged(HAS_BRANCH_PROBLEMS_PROPERTY, false, true);
- } else if ((oldSize != 0) && (newSize == 0)) {
- this.firePropertyChanged(HAS_BRANCH_PROBLEMS_PROPERTY, true, false);
- }
-
- if (oldBranchProblems.equals(this.branchProblems)) {
- return false; // our "branch" problems did not change
- }
- // our "branch" problems changed
- this.fireListChanged(BRANCH_PROBLEMS_LIST, this.branchProblems);
- return true;
- }
-
- /**
- * INTRA-TREE API
- * Add all the problems of the node and all
- * the problems of its descendants to the
- * specified collection.
- */
- public final void addBranchProblemsTo(List<Problem> list) {
- list.addAll(this.branchProblems);
- }
-
- /**
- * INTRA-TREE API
- * A child node's "branch" problems changed;
- * therefore the node's "branch" problems have changed also and
- * must be rebuilt.
- */
- public final void rebuildBranchProblems() {
- if ( ! this.checkBranchProblems()) {
- throw new IllegalStateException("we should not get here unless our \"branch\" problems have changed"); //$NON-NLS-1$
- }
- this.rebuildParentBranchProblems();
- }
-
- /**
- * Clear the node's "branch" problems and the "branch"
- * problems of all of its descendants.
- * If the node's "branch" problems have changed,
- * notify the node's parent.
- */
- public final void clearAllBranchProblems() {
- if (this.clearAllBranchProblemsInternal()) {
- // if our "branch" problems have changed, then
- // our parent must rebuild its "branch" problems also
- this.rebuildParentBranchProblems();
- }
- }
-
- /**
- * INTRA-TREE API
- * Clear the node's "branch" problems and the "branch"
- * problems of all of its descendants.
- * Return true if the collection of "branch" problems has changed.
- * This method is for internal use only; it is not for
- * client use.
- */
- public final boolean clearAllBranchProblemsInternal() {
- if (this.branchProblems.isEmpty()) {
- return false;
- }
- for (Iterator<Node> stream = this.children(); stream.hasNext(); ) {
- Node child = stream.next(); // pull out the child to ease debugging
- // ignore the return value because we are going to clear our "branch"
- // problems no matter what
- child.clearAllBranchProblemsInternal();
- }
- this.problems.clear();
- this.branchProblems.clear();
- this.firePropertyChanged(HAS_BRANCH_PROBLEMS_PROPERTY, true, false);
- this.fireListChanged(BRANCH_PROBLEMS_LIST, this.branchProblems);
- return true;
- }
-
- /**
- * Return whether a change to specified aspect requires a re-validation
- * of the node's tree.
- */
- private boolean aspectChangeRequiresValidation(String aspectName) {
- return ! this.aspectChangeDoesNotRequireValidation(aspectName);
- }
-
- private boolean aspectChangeDoesNotRequireValidation(String aspectName) {
- return this.nonValidatedAspectNames().contains(aspectName);
- }
-
- /**
- * Return a set of the object's "non-validated" aspect names.
- * These are the aspects that, when they change, will NOT cause the
- * object (or its containing tree) to be validated, i.e. checked for problems.
- * If you need instance-based calculation of your "non-validated" aspects,
- * override this method. If class-based calculation is sufficient,
- * override #addNonValidatedAspectNamesTo(Set).
- */
- protected final Set<String> nonValidatedAspectNames() {
- synchronized (nonValidatedAspectNameSets) {
- HashSet<String> nonValidatedAspectNames = nonValidatedAspectNameSets.get(this.getClass());
- if (nonValidatedAspectNames == null) {
- nonValidatedAspectNames = new HashSet<String>();
- this.addNonValidatedAspectNamesTo(nonValidatedAspectNames);
- nonValidatedAspectNameSets.put(this.getClass(), nonValidatedAspectNames);
- }
- return nonValidatedAspectNames;
- }
- }
-
- /**
- * Add the object's "non-validated" aspect names to the specified set.
- * These are the aspects that, when they change, will NOT cause the
- * object (or its containing tree) to be validated, i.e. checked for problems.
- * If class-based calculation of your "non-validated" aspects is sufficient,
- * override this method. If you need instance-based calculation,
- * override #nonValidatedAspectNames().
- */
- protected void addNonValidatedAspectNamesTo(Set<String> nonValidatedAspectNames) {
- nonValidatedAspectNames.add(COMMENT_PROPERTY);
- nonValidatedAspectNames.add(DIRTY_BRANCH_PROPERTY);
- nonValidatedAspectNames.add(BRANCH_PROBLEMS_LIST);
- nonValidatedAspectNames.add(HAS_BRANCH_PROBLEMS_PROPERTY);
- // when you override this method, don't forget to include:
- // super.addNonValidatedAspectNamesTo(nonValidatedAspectNames);
- }
-
-
- // ********** display methods **********
-
- /**
- * Return a developer-friendly String. If you want something useful for
- * displaying in a user interface, use #displayString().
- * If you want to give more information in your #toString(),
- * override #toString(StringBuilder sb).
- * Whatever you add to that string buffer will show up between the parentheses.
- * @see AbstractModel#toString(StringBuilder sb)
- * @see #displayString()
- */
- @Override
- public final String toString() {
- return super.toString();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/AsynchronousValidator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/AsynchronousValidator.java
deleted file mode 100644
index 88a06f1b08..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/AsynchronousValidator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.node;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean;
-
-/**
- * This implementation of the PluggableValidator.Delegate interface
- * simply sets a shared "validate" flag to true. This should trigger a
- * separate "validation" thread to begin validating the appropriate
- * branch of nodes.
- */
-public class AsynchronousValidator
- implements PluggableValidator.Delegate
-{
- private SynchronizedBoolean validateFlag;
-
- /**
- * Construct a validator delegate with the specified shared
- * "validate" flag. This flag should be shared with
- * another thread that will perform the actual validation.
- */
- public AsynchronousValidator(SynchronizedBoolean validateFlag) {
- super();
- this.validateFlag = validateFlag;
- }
-
- /**
- * Set the shared "validate" flag to true, triggering
- * an asynchronous validation of the appropriate
- * branch of nodes.
- */
- public void validate() {
- this.validateFlag.setTrue();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.validateFlag);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/DefaultProblem.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/DefaultProblem.java
deleted file mode 100644
index 6ba2f3a7ad..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/DefaultProblem.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.node;
-
-import java.util.Arrays;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This class is a straightforward implementation of the Problem interface.
- */
-public class DefaultProblem
- implements Problem
-{
- private final Node source;
- private final String messageKey;
- private final int messageType;
- private final Object[] messageArguments;
-
-
- DefaultProblem(Node source, String messageKey, int messageType, Object[] messageArguments) {
- super();
- this.source = source;
- this.messageKey = messageKey;
- this.messageType = messageType;
- this.messageArguments = messageArguments;
- }
-
-
- // ********** Problem implementation **********
-
- public Node source() {
- return this.source;
- }
-
- public String messageKey() {
- return this.messageKey;
- }
-
- public int messageType() {
- return this.messageType;
- }
-
- public Object[] messageArguments() {
- return this.messageArguments;
- }
-
-
- // ********** Object overrides **********
-
- /**
- * We implement #equals(Object) because problems are repeatedly
- * re-calculated and the resulting problems merged with the existing
- * set of problems; and we want to keep the original problems and
- * ignore any freshly-generated duplicates.
- * Also, problems are not saved to disk....
- */
- @Override
- public boolean equals(Object o) {
- if ( ! (o instanceof Problem)) {
- return false;
- }
- Problem other = (Problem) o;
- return this.source == other.source()
- && this.messageKey.equals(other.messageKey())
- && Arrays.equals(this.messageArguments, other.messageArguments());
- }
-
- @Override
- public int hashCode() {
- return this.source.hashCode() ^ this.messageKey.hashCode();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.messageKey);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/Node.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/Node.java
deleted file mode 100644
index 2eab200247..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/Node.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.node;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * This interface defines the methods that must be implemented
- * by any class whose instances are to be part of a containment hierarchy
- * that supports a "dirty" state and validation "problems".
- *
- * Note: Methods marked "INTRA-TREE API" are typically only used by
- * the nodes themselves, as opposed to clients of the nodes. These
- * methods are called by a node on either its parent or its children.
- */
-public interface Node extends Model {
-
-
- // ********** containment hierarchy (parent/children) **********
-
- /**
- * INTRA-TREE API?
- * Return the node's parent in the containment hierarchy.
- * Most nodes must have a parent. The parent is immutable.
- * @see #children()
- */
- Node getParent();
-
- /**
- * INTRA-TREE API?
- * Return the node's children, which are also nodes.
- * @see #getParent()
- */
- Iterator<Node> children();
-
- /**
- * INTRA-TREE API?
- * Return the containment hierarchy's root node.
- * Most nodes must have a root.
- * @see #getParent()
- */
- Node root();
-
- /**
- * Return whether the node is a descendant of the specified node.
- * By definition, a node is a descendant of itself.
- */
- boolean isDescendantOf(Node node);
-
- /**
- * INTRA-TREE API
- * Add the node's "references", and all the node's descendants'
- * "references", to the specified collection. "References" are
- * objects that are "referenced" by another object, as opposed
- * to "owned" by another object.
- * This method is of particular concern to Handles, since most
- * (hopefully all) "references" are held by Handles.
- * @see Reference
- * @see #children()
- */
- void addBranchReferencesTo(Collection<Node.Reference> branchReferences);
-
- /**
- * INTRA-TREE API?
- * Add all the nodes in the object's branch of the tree,
- * including the node itself, to the specified collection.
- * Only really used for testing and debugging.
- */
- void addAllNodesTo(Collection<Node> nodes);
-
-
- // ********** model synchronization support **********
-
- /**
- * INTRA-TREE API
- * This is a general notification that the specified node has been
- * removed from the tree. The node receiving this notification
- * should perform any necessary updates to remain in synch
- * with the tree (e.g. clearing out or replacing any references
- * to the removed node or any of the removed node's descendants).
- * @see #isDescendantOf(Node)
- */
- void nodeRemoved(Node node);
-
- /**
- * INTRA-TREE API
- * This is a general notification that the specified node has been
- * renamed. The node receiving this notification should mark its
- * branch dirty if necessary (i.e. it references the renamed node
- * or one of its descendants). This method is of particular concern
- * to Handles.
- * @see #isDescendantOf(Node)
- */
- void nodeRenamed(Node node);
-
-
- // ********** dirty flag support **********
-
- /**
- * Return whether any persistent aspects of the node,
- * or any of its descendants, have changed since the node and
- * its descendants were last read or saved.
- */
- boolean isDirtyBranch();
- String DIRTY_BRANCH_PROPERTY = "dirtyBranch"; //$NON-NLS-1$
-
- /**
- * INTRA-TREE API
- * Mark the node and its parent as dirty branches.
- * This message is propagated up the containment
- * tree when a particular node becomes dirty.
- */
- void markBranchDirty();
-
- /**
- * Mark the node and all its descendants as dirty.
- * This is used when the save location of some
- * top-level node is changed and the entire
- * containment tree must be marked dirty so it
- * will be written out.
- */
- void markEntireBranchDirty();
-
- /**
- * INTRA-TREE API
- * A child node's branch has been marked clean. If the node
- * itself is clean and if all of its children are also clean, the
- * node's branch can be marked clean. Then, if the node's
- * branch is clean, the node will notify its parent that it might
- * be clean also. This message is propagated up the containment
- * tree when a particular node becomes clean.
- */
- void markBranchCleanIfPossible();
-
- /**
- * INTRA-TREE API
- * Mark the node and all its descendants as clean.
- * Typically used when the node has just been
- * read in or written out.
- * This method is for internal use only; it is not for
- * client use.
- * Not the best of method names.... :-(
- */
- void cascadeMarkEntireBranchClean();
-
-
- // ********** problems **********
-
- /**
- * INTRA-TREE API
- * Return a validator that will be invoked whenever a
- * "validated" aspect of the node tree changes.
- * Typically only the root node directly holds a validator.
- */
- Validator getValidator();
-
- /**
- * Set a validator that will be invoked whenever a
- * "validated" aspect of the node tree changes.
- * Typically only the root node directly holds a validator.
- */
- void setValidator(Validator validator);
-
- /**
- * Validate the node and its descendants.
- * This is an explicit request invoked by a client; and it will
- * typically be followed by a call to one of the following methods:
- * #branchProblems()
- * #hasBranchProblems()
- * Whether the node maintains its problems on the fly
- * or waits until this method is called is determined by the
- * implementation.
- * @see Problem
- */
- void validateBranch();
-
- /**
- * INTRA-TREE API
- * Validate the node and all of its descendants,
- * and update their sets of "branch" problems.
- * Return true if the collection of "branch" problems has changed.
- * This method is for internal use only; it is not for
- * client use.
- */
- boolean validateBranchInternal();
-
- /**
- * Return all the node's problems along with all the
- * node's descendants' problems.
- */
- ListIterator<Problem> branchProblems();
- String BRANCH_PROBLEMS_LIST = "branchProblems"; //$NON-NLS-1$
-
- /**
- * Return the size of all the node's problems along with all the
- * node's descendants' problems.
- */
- int branchProblemsSize();
-
- /**
- * Return whether the node or any of its descendants have problems.
- */
- boolean hasBranchProblems();
- String HAS_BRANCH_PROBLEMS_PROPERTY = "hasBranchProblems"; //$NON-NLS-1$
-
- /**
- * Return whether the node contains the specified branch problem.
- */
- boolean containsBranchProblem(Problem problem);
-
- /**
- * INTRA-TREE API
- * Something changed, rebuild the node's collection of branch problems.
- */
- void rebuildBranchProblems();
-
- /**
- * INTRA-TREE API
- * Add the node's problems, and all the node's descendants'
- * problems, to the specified list.
- * A call to this method should be immediately preceded by a call to
- * #validateBranch() or all of the problems might not be
- * added to the list.
- * @see Problem
- */
- void addBranchProblemsTo(List<Problem> branchProblems);
-
- /**
- * Clear the node's "branch" problems and the "branch"
- * problems of all of its descendants.
- */
- void clearAllBranchProblems();
-
- /**
- * INTRA-TREE API
- * Clear the node's "branch" problems and the "branch"
- * problems of all of its descendants.
- * Return true if the collection of "branch" problems has changed.
- * This method is for internal use only; it is not for
- * client use.
- */
- boolean clearAllBranchProblemsInternal();
-
-
- // ********** comment **********
-
- /**
- * Return the user comment concerning the node.
- */
- String comment();
- String COMMENT_PROPERTY = "comment"; //$NON-NLS-1$
-
- /**
- * Set the user comment concerning the node.
- */
- void setComment(String comment);
-
-
- // ********** displaying/sorting **********
-
- /**
- * Return a string representation of the model, suitable for sorting.
- */
- String displayString();
-
-
- // ********** sub-interfaces **********
-
- /**
- * Simple interface defining a "reference" between two nodes.
- * @see Node#addBranchReferencesTo(java.util.Collection)
- */
- interface Reference {
-
- /**
- * Return the "source" node of the reference, i.e. the node that
- * references the "target" node.
- */
- Node source();
-
- /**
- * Return the "target" node of the reference, i.e. the node that
- * is referenced by the "source" node.
- */
- Node target();
-
- }
-
-
- /**
- * A validator will validate a node as appropriate.
- * Typically the validation will
- * - occur whenever a node has changed
- * - encompass the entire tree containing the node
- * - execute asynchronously
- */
- interface Validator {
-
- /**
- * A "significant" aspect has changed;
- * validate the node as appropriate
- */
- void validate();
-
- /**
- * Stop all validation of the node until #resume() is called.
- * This can be used to improve the performance of any long-running
- * action that triggers numerous changes to the node. Be sure to
- * match a call to this method with a corresponding call to
- * #resume().
- */
- void pause();
-
- /**
- * Resume validation of the node. This method can only be
- * called after a matching call to #pause().
- */
- void resume();
-
- }
-
-
- // ********** helper implementations **********
-
- /**
- * Straightforward implementation of the Reference interface
- * defined above.
- */
- public class SimpleReference implements Reference {
- private Node source;
- private Node target;
- public SimpleReference(Node source, Node target) {
- super();
- if (source == null || target == null) {
- throw new NullPointerException();
- }
- this.source = source;
- this.target = target;
- }
- public Node source() {
- return this.source;
- }
- public Node target() {
- return this.target;
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.source + " => " + this.target); //$NON-NLS-1$
- }
- }
-
-
- /**
- * This validator does nothing to validate the node.
- */
- Validator NULL_VALIDATOR =
- new PluggableValidator(PluggableValidator.Delegate.Null.instance()) {
- @Override
- public String toString() {
- return "Node.NULL_VALIDATOR"; //$NON-NLS-1$
- }
- };
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/PluggableValidator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/PluggableValidator.java
deleted file mode 100644
index fdf27d26eb..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/PluggableValidator.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.node;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean;
-
-/**
- * This implementation of the Validator interface implements the
- * pause/resume portion of the protocol, but delegates the actual
- * validation to a "pluggable" delegate.
- */
-public class PluggableValidator
- implements Node.Validator
-{
- private boolean pause;
- private boolean validateOnResume;
- private final Delegate delegate;
-
-
- /**
- * Convenience factory method.
- */
- public static Node.Validator buildAsynchronousValidator(SynchronizedBoolean validateFlag) {
- return new PluggableValidator(new AsynchronousValidator(validateFlag));
- }
-
- /**
- * Convenience factory method.
- */
- public static Node.Validator buildSynchronousValidator(Node node) {
- return new PluggableValidator(new SynchronousValidator(node));
- }
-
- /**
- * Construct a validator with the specified delegate.
- */
- public PluggableValidator(Delegate delegate) {
- super();
- this.pause = false;
- this.validateOnResume = false;
- this.delegate = delegate;
- }
-
- public synchronized void validate() {
- if (this.pause) {
- this.validateOnResume = true;
- } else {
- this.delegate.validate();
- }
- }
-
- public synchronized void pause() {
- if (this.pause) {
- throw new IllegalStateException("already paused"); //$NON-NLS-1$
- }
- this.pause = true;
- }
-
- public synchronized void resume() {
- if ( ! this.pause) {
- throw new IllegalStateException("not paused"); //$NON-NLS-1$
- }
- this.pause = false;
- // validate any changes that occurred while the validation was paused
- if (this.validateOnResume) {
- this.validateOnResume = false;
- this.delegate.validate();
- }
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.delegate);
- }
-
-
- // ********** member interface **********
-
- /**
- * Interface implemented by any delegates of a pluggable validator.
- */
- public interface Delegate {
-
- /**
- * The validator is not "paused" - perform the appropriate validation.
- */
- void validate();
-
-
- /**
- * This delegate does nothing.
- */
- final class Null
- implements Delegate, Serializable
- {
- public static final Delegate INSTANCE = new Null();
- public static Delegate instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void validate() {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/Problem.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/Problem.java
deleted file mode 100644
index 13b4778a71..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/Problem.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.node;
-
-/**
- * Define an interface describing the problems associated with a node.
- */
-public interface Problem {
-
- /**
- * Return the node most closely associated with the problem.
- */
- Node source();
-
- /**
- * Return a key that can be used to uniquely identify the problem's message.
- */
- String messageKey();
-
- /**
- * Return the arguments associate with the problem's message.
- */
- Object[] messageArguments();
-
- /**
- * Return the type of the identified problem's message
- */
- int messageType();
-
- /**
- * Return whether the problem is equal to the specified object.
- * It is equal if the specified object is a implementation of the
- * Problem interface and its source, message key, and message
- * arguments are all equal to this problem's.
- */
- boolean equals(Object o);
-
- /**
- * Return the problem's hash code, which should calculated as an
- * XOR of the source's hash code and the message key's hash code.
- */
- int hashCode();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/SynchronousValidator.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/SynchronousValidator.java
deleted file mode 100644
index b176685613..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/node/SynchronousValidator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.node;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This implementation of the PluggableValidator.Delegate interface
- * will validate the node immediately.
- *
- * This is useful for debugging in a single thread or generating
- * problem reports.
- */
-public class SynchronousValidator
- implements PluggableValidator.Delegate
-{
- private final Node node;
-
- /**
- * Construct a validator that will immediately validate the
- * specified node.
- */
- public SynchronousValidator(Node node) {
- super();
- this.node = node;
- }
-
- public void validate() {
- this.node.validateBranch();
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.node);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/CachingComboBoxModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/CachingComboBoxModel.java
deleted file mode 100644
index cd6412e91e..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/CachingComboBoxModel.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import javax.swing.ComboBoxModel;
-
-/**
- * This interface allows a client to better control the performance of
- * a combo box model by allowing the client to specify when it is
- * acceptable for the model to "cache" and "uncache" its list of elements.
- * The model may ignore these hints if appropriate.
- */
-public interface CachingComboBoxModel extends ComboBoxModel {
-
- /**
- * Cache the comboBoxModel List. If you call this, you
- * must make sure to call uncacheList() as well. Otherwise
- * stale data will be in the ComboBox until cacheList() is
- * called again or uncacheList() is called.
- */
- void cacheList();
-
- /**
- * Clear the cached list. Next time the list is needed it will
- * be built when it is not cached.
- */
- void uncacheList();
-
- /**
- * Check to see if the list is already cached. This can be used for
- * MouseEvents, since they are not terribly predictable.
- */
- boolean isCached();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/CheckBoxTableCellRenderer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/CheckBoxTableCellRenderer.java
deleted file mode 100644
index 87a2b2e5ef..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/CheckBoxTableCellRenderer.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import javax.swing.BorderFactory;
-import javax.swing.Icon;
-import javax.swing.JCheckBox;
-import javax.swing.JTable;
-import javax.swing.SwingConstants;
-import javax.swing.UIManager;
-import javax.swing.border.Border;
-import org.eclipse.jpt.common.utility.internal.swing.TableCellEditorAdapter.ImmediateEditListener;
-
-/**
- * Make the cell look like a check box.
- */
-public class CheckBoxTableCellRenderer implements TableCellEditorAdapter.Renderer {
-
- /** the component used to paint the cell */
- private final JCheckBox checkBox;
-
- /** the listener to be notified on an immediate edit */
- protected TableCellEditorAdapter.ImmediateEditListener immediateEditListener;
-
- /** "normal" border - assume the default table "focus" border is 1 pixel thick */
- private static final Border NO_FOCUS_BORDER = BorderFactory.createEmptyBorder(1, 1, 1, 1);
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct a cell renderer with no label or icon.
- */
- public CheckBoxTableCellRenderer() {
- super();
- this.checkBox = this.buildCheckBox();
- // by default, check boxes do not paint their borders
- this.checkBox.setBorderPainted(true);
- // this setting is recommended for check boxes inside of trees and tables
- this.checkBox.setBorderPaintedFlat(true);
- }
-
- /**
- * Construct a cell renderer with the specified text and icon,
- * either of which may be null.
- */
- public CheckBoxTableCellRenderer(String text, Icon icon) {
- this();
- this.setText(text);
- this.setIcon(icon);
- }
-
- /**
- * Construct a cell renderer with the specified text.
- */
- public CheckBoxTableCellRenderer(String text) {
- this(text, null);
- }
-
- /**
- * Construct a cell renderer with the specified icon.
- */
- public CheckBoxTableCellRenderer(Icon icon) {
- this(null, icon);
- }
-
- protected JCheckBox buildCheckBox() {
- JCheckBox cb = new JCheckBox();
- cb.addActionListener(this.buildActionListener());
- return cb;
- }
-
- private ActionListener buildActionListener() {
- return new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- if (CheckBoxTableCellRenderer.this.immediateEditListener != null) {
- CheckBoxTableCellRenderer.this.immediateEditListener.immediateEdit();
- }
- }
- };
- }
-
-
- // ********** TableCellRenderer implementation **********
-
- public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
- this.checkBox.setHorizontalAlignment(SwingConstants.CENTER);
- this.checkBox.setComponentOrientation(table.getComponentOrientation());
- this.checkBox.setFont(table.getFont());
- this.checkBox.setEnabled(table.isEnabled());
-
- this.checkBox.setForeground(this.foregroundColor(table, value, selected, hasFocus, row, column));
- this.checkBox.setBackground(this.backgroundColor(table, value, selected, hasFocus, row, column));
- // once the colors are set, calculate opaque setting
- this.checkBox.setOpaque(this.cellIsOpaqueIn(table, value, selected, hasFocus, row, column));
- this.checkBox.setBorder(this.border(table, value, selected, hasFocus, row, column));
-
- this.setValue(value);
- return this.checkBox;
- }
-
- /**
- * Return the cell's foreground color.
- */
- protected Color foregroundColor(JTable table, @SuppressWarnings("unused") Object value, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return UIManager.getColor("Table.focusCellForeground"); //$NON-NLS-1$
- }
- return table.getSelectionForeground();
- }
- return table.getForeground();
- }
-
- /**
- * Return the cell's background color.
- */
- protected Color backgroundColor(JTable table, @SuppressWarnings("unused") Object value, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return UIManager.getColor("Table.focusCellBackground"); //$NON-NLS-1$
- }
- return table.getSelectionBackground();
- }
- return table.getBackground();
- }
-
- /**
- * Return the cell's border.
- */
- protected Border border(@SuppressWarnings("unused") JTable table, @SuppressWarnings("unused") Object value, @SuppressWarnings("unused") boolean selected, boolean hasFocus, @SuppressWarnings("unused") int row, @SuppressWarnings("unused") int column) {
- return hasFocus ? UIManager.getBorder("Table.focusCellHighlightBorder") : NO_FOCUS_BORDER; //$NON-NLS-1$
- }
-
- /**
- * Return whether the cell should be opaque in the table.
- * If the cell's background is the same as the table's background
- * and table is opaque, we don't need to paint the background -
- * the table will do it.
- */
- protected boolean cellIsOpaqueIn(JTable table, @SuppressWarnings("unused") Object value, @SuppressWarnings("unused") boolean selected, @SuppressWarnings("unused") boolean hasFocus, @SuppressWarnings("unused") int row, @SuppressWarnings("unused") int column) {
- Color cellBackground = this.checkBox.getBackground();
- Color tableBackground = table.getBackground();
- return ! (table.isOpaque() && cellBackground.equals(tableBackground));
- }
-
- /**
- * Set the check box's value.
- */
- protected void setValue(Object value) {
- // CR#3999318 - This null check needs to be removed once JDK bug is fixed
- if (value == null) {
- value = Boolean.FALSE;
- }
- this.checkBox.setSelected(((Boolean) value).booleanValue());
- }
-
-
- // ********** TableCellEditorAdapter.Renderer implementation **********
-
- public Object getValue() {
- return Boolean.valueOf(this.checkBox.isSelected());
- }
-
- public void setImmediateEditListener(ImmediateEditListener listener) {
- this.immediateEditListener = listener;
- }
-
- // ********** public API **********
-
- /**
- * Set the check box's text; which by default is blank.
- */
- public void setText(String text) {
- this.checkBox.setText(text);
- }
-
- /**
- * Set the check box's icon; which by default is not present.
- */
- public void setIcon(Icon icon) {
- this.checkBox.setIcon(icon);
- }
-
- /**
- * Return the renderer's preferred height. This allows you
- * to set the table's row height to something the check box
- * will look good in....
- */
- public int preferredHeight() {
- // add in space for the border top and bottom
- return (int) this.checkBox.getPreferredSize().getHeight() + 2;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/ComboBoxTableCellRenderer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/ComboBoxTableCellRenderer.java
deleted file mode 100644
index 055a43b09b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/ComboBoxTableCellRenderer.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Graphics;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import javax.swing.BorderFactory;
-import javax.swing.ComboBoxModel;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JTable;
-import javax.swing.ListCellRenderer;
-import javax.swing.SwingConstants;
-import javax.swing.UIManager;
-import javax.swing.border.Border;
-import javax.swing.event.PopupMenuEvent;
-import javax.swing.event.PopupMenuListener;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-
-/**
- * Make the cell look like a combo-box.
- */
-public class ComboBoxTableCellRenderer implements TableCellEditorAdapter.Renderer {
-
- /* caching the combo box because we are caching the comboBoxModel.
- * Everytime we rebuilt the comboBox we would set the model on it and not
- * remove the model from the old combo box. This meant that new listeners
- * kept being added to the comboBoxModel for every comboBox build.
- * Not sure if there is a way to clear out the old combo box, or why
- * we were buildig a new combo box every time so I went with caching it.
- */
- private JComboBox comboBox;
-
- /** the items used to populate the combo box */
- private CachingComboBoxModel model;
- private ListCellRenderer renderer;
- Object value;
- private static int height = -1;
- boolean fakeFocusFlag;
-
- /** the listener to be notified on an immediate edit */
- protected TableCellEditorAdapter.ImmediateEditListener immediateEditListener;
-
- /** hold the original colors of the combo-box */
- private static Color defaultForeground;
- private static Color defaultBackground;
-
- /** "normal" border - assume the default table "focus" border is 1 pixel thick */
- private static final Border NO_FOCUS_BORDER = BorderFactory.createEmptyBorder(1, 1, 1, 1);
-
-
- // ********** constructors/initialization **********
-
- /**
- * Default constructor.
- */
- private ComboBoxTableCellRenderer() {
- super();
- initialize();
- }
-
- /**
- * Construct a cell renderer that uses the specified combo-box model.
- */
- public ComboBoxTableCellRenderer(ComboBoxModel model) {
- this(new NonCachingComboBoxModel(model));
- }
-
- /**
- * Construct a cell renderer that uses the specified caching combo-box model.
- */
- public ComboBoxTableCellRenderer(CachingComboBoxModel model) {
- this();
- this.model = model;
- }
-
- /**
- * Construct a cell renderer that uses the specified
- * combo-box model and renderer.
- */
- public ComboBoxTableCellRenderer(ComboBoxModel model, ListCellRenderer renderer) {
- this(new NonCachingComboBoxModel(model), renderer);
- }
-
- /**
- * Construct a cell renderer that uses the specified
- * caching combo-box model and renderer.
- */
- public ComboBoxTableCellRenderer(CachingComboBoxModel model, ListCellRenderer renderer) {
- this(model);
- this.renderer = renderer;
- }
-
- protected void initialize() {
- // save the original colors of the combo-box, so we
- // can use them to paint non-selected cells
- if (height == -1) {
- JComboBox cb = new JComboBox();
- cb.addItem("m"); //$NON-NLS-1$
-
- // add in space for the border top and bottom
- height = cb.getPreferredSize().height + 2;
-
- defaultForeground = cb.getForeground();
- defaultBackground = cb.getBackground();
- }
- }
-
- static JLabel prototypeLabel = new JLabel("Prototype", new EmptyIcon(16), SwingConstants.LEADING); //$NON-NLS-1$
-
- protected JComboBox buildComboBox() {
-
- final JComboBox result = new JComboBox() {
- private boolean fakeFocus;
- @Override
- public boolean hasFocus() {
- return fakeFocus || super.hasFocus();
- }
- @Override
- public void paint(Graphics g) {
- fakeFocus = ComboBoxTableCellRenderer.this.fakeFocusFlag;
- super.paint(g);
- fakeFocus = false;
- }
- //wrap the renderer to deal with the prototypeDisplayValue
- @Override
- public void setRenderer(final ListCellRenderer aRenderer) {
- super.setRenderer(new ListCellRenderer(){
- public Component getListCellRendererComponent(JList list, Object v, int index, boolean isSelected, boolean cellHasFocus) {
- if (v == prototypeLabel) {
- return prototypeLabel;
- }
- return aRenderer.getListCellRendererComponent(list, v, index, isSelected, cellHasFocus);
- }
- });
- }
- @Override
- public int getSelectedIndex() {
- boolean listNotCached = !listIsCached();
- if (listNotCached) {
- cacheList();
- }
-
- int index = super.getSelectedIndex();
-
- if (listNotCached) {
- uncacheList();
- }
- return index;
- }
-
- };
- // stole this code from javax.swing.DefaultCellEditor
- result.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE); //$NON-NLS-1$
- result.addActionListener(this.buildActionListener());
- result.addPopupMenuListener(this.buildPopupMenuListener());
-
- //These are used to workaround problems with Swing trying to
- //determine the size of a comboBox with a large model
- result.setPrototypeDisplayValue(prototypeLabel);
- getListBox(result).setPrototypeCellValue(prototypeLabel);
-
- return result;
- }
-
-
- private JList getListBox(JComboBox result) {
- return (JList) ReflectionTools.getFieldValue(result.getUI(), "listBox"); //$NON-NLS-1$
- }
-
-
- private ActionListener buildActionListener() {
- return new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- JComboBox cb = (JComboBox) e.getSource();
- Object selectedItem = cb.getSelectedItem();
-
- // Only update the selected item and invoke immediateEdit() if the
- // selected item actually changed, during the initialization of the
- // editing, the model changes and causes this method to be invoked,
- // it causes CR#3963675 to occur because immediateEdit() stop the
- // editing, which is done at the wrong time
- if (ComboBoxTableCellRenderer.this.value != selectedItem) {
- ComboBoxTableCellRenderer.this.value = cb.getSelectedItem();
- ComboBoxTableCellRenderer.this.immediateEdit();
- }
- }
- };
- }
-
- void immediateEdit() {
- if (this.immediateEditListener != null) {
- this.immediateEditListener.immediateEdit();
- }
- }
-
- private PopupMenuListener buildPopupMenuListener() {
- return new PopupMenuListener() {
-
- public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
- if (listIsCached()) {
- uncacheList();
- }
- cacheList();
- }
-
- public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
- if (listIsCached()) {
- uncacheList();
- }
-
- }
-
- public void popupMenuCanceled(PopupMenuEvent e) {
- if (listIsCached()) {
- uncacheList();
- }
- }
- };
- }
-
-
- void cacheList() {
- this.model.cacheList();
- }
-
- void uncacheList() {
- this.model.uncacheList();
- }
-
- boolean listIsCached() {
- return this.model.isCached();
- }
- // ********** TableCellRenderer implementation **********
-
- public Component getTableCellRendererComponent(JTable table, Object val, boolean selected, boolean hasFocus, int row, int column) {
- this.fakeFocusFlag = selected || hasFocus;
- if (this.comboBox == null) {
- this.comboBox = this.buildComboBox();
-
- this.comboBox.setComponentOrientation(table.getComponentOrientation());
- this.comboBox.setModel(this.model);
- if (this.renderer != null) {
- this.comboBox.setRenderer(this.renderer);
- }
- this.comboBox.setFont(table.getFont());
- this.comboBox.setEnabled(table.isEnabled());
- this.comboBox.setBorder(this.border(table, val, selected, hasFocus, row, column));
- }
-
- // We need to go through the model since JComboBox might prevent us from
- // selecting the value. This can happen when the value is not contained
- // in the model, see CR#3950044 for an example
- this.model.setSelectedItem(val);
-
- return this.comboBox;
- }
-
- /**
- * Return the cell's foreground color.
- */
- protected Color foregroundColor(JTable table, @SuppressWarnings("unused") Object val, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return defaultForeground;
- }
- return table.getSelectionForeground();
- }
- return defaultForeground;
- }
-
- /**
- * Return the cell's background color.
- */
- protected Color backgroundColor(JTable table, @SuppressWarnings("unused") Object val, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return defaultBackground;
- }
- return table.getSelectionBackground();
- }
- return defaultBackground;
- }
-
- /**
- * Return the cell's border.
- */
- protected Border border(@SuppressWarnings("unused") JTable table, @SuppressWarnings("unused") Object val, @SuppressWarnings("unused") boolean selected, boolean hasFocus, @SuppressWarnings("unused") int row, @SuppressWarnings("unused") int column) {
- return hasFocus ?
- UIManager.getBorder("Table.focusCellHighlightBorder") //$NON-NLS-1$
- :
- NO_FOCUS_BORDER;
- }
-
-
- // ********** TableCellEditorAdapter.Renderer implementation **********
-
- public Object getValue() {
- return this.value;
- }
-
- public void setImmediateEditListener(TableCellEditorAdapter.ImmediateEditListener listener) {
- this.immediateEditListener = listener;
- }
-
-
- // ********** public API **********
-
- /**
- * Return the renderer's preferred height. This allows you
- * to set the row height to something the combo-box will look good in....
- */
- public int preferredHeight() {
- return height;
- }
-
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/Displayable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/Displayable.java
deleted file mode 100644
index 5a3adb7cc4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/Displayable.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import javax.swing.Icon;
-
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * Used by general-purpose UI models and renderers to cast
- * application model objects to something displayable.
- */
-public interface Displayable
- extends Model
-{
-
- /**
- * Return a string that can be used to identify the model
- * in a textual UI setting (typically the object's name).
- * When the display string changes, the model should fire
- * the appropriate change notification:
- * this.firePropertyChanged(DISPLAY_STRING_PROPERTY, oldDisplayString, this.displayString());
- */
- String displayString();
- String DISPLAY_STRING_PROPERTY = "displayString"; //$NON-NLS-1$
-
- /**
- * Return an icon that can be used to identify the model
- * in a UI component that supports icons (the icon can be null).
- * When the icon changes, the model should fire
- * the appropriate change notification:
- * this.firePropertyChanged(ICON_PROPERTY, oldIcon, this.icon());
- */
- Icon icon();
- String ICON_PROPERTY = "icon"; //$NON-NLS-1$
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/EmptyIcon.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/EmptyIcon.java
deleted file mode 100644
index b04fbcf4b0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/EmptyIcon.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import java.awt.Component;
-import java.awt.Graphics;
-import javax.swing.Icon;
-
-/**
- * Implement the Icon interface with an icon that has a size but
- * does not paint anything on the graphics context.
- */
-public class EmptyIcon
- implements Icon
-{
- private final int width;
- private final int height;
-
- public static final EmptyIcon NULL_INSTANCE = new EmptyIcon(0);
-
-
- public EmptyIcon(int width, int height) {
- super();
- this.width = width;
- this.height = height;
- }
-
- public EmptyIcon(int size) {
- this(size, size);
- }
-
-
- // ********** Icon implementation **********
-
- public void paintIcon(Component c, Graphics g, int x, int y) {
- // don't paint anything for an empty icon
- }
-
- public int getIconWidth() {
- return this.width;
- }
-
- public int getIconHeight() {
- return this.height;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/FilteringListBrowser.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/FilteringListBrowser.java
deleted file mode 100644
index 68ee9aa0ec..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/FilteringListBrowser.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import javax.swing.Icon;
-import javax.swing.JComboBox;
-import javax.swing.JOptionPane;
-import javax.swing.ListModel;
-
-/**
- * This implementation of LongListComponent.Browser uses a
- * JOptionPane to prompt the user for the selection. The JOPtionPane
- * is passed a FilteringListPanel to assist the user in making
- * a selection.
- */
-public class FilteringListBrowser<T>
- implements ListChooser.ListBrowser
-{
- private FilteringListPanel<T> panel;
-
- /**
- * Default constructor.
- */
- public FilteringListBrowser() {
- super();
- this.panel = this.buildPanel();
- }
-
- protected FilteringListPanel<T> buildPanel() {
- return new LocalFilteringListPanel<T>();
- }
-
- /**
- * Prompt the user using a JOptionPane with a filtering
- * list panel.
- */
- public void browse(ListChooser chooser) {
- this.initializeCellRenderer(chooser);
-
- int option =
- JOptionPane.showOptionDialog(
- chooser,
- this.message(chooser),
- this.title(chooser),
- this.optionType(chooser),
- this.messageType(chooser),
- this.icon(chooser),
- this.selectionValues(chooser),
- this.initialSelectionValue(chooser)
- );
-
- if (option == JOptionPane.OK_OPTION) {
- chooser.getModel().setSelectedItem(this.panel.selection());
- }
-
- // clear the text field so the list box is re-filtered
- this.panel.textField().setText(""); //$NON-NLS-1$
- }
-
- protected void initializeCellRenderer(JComboBox comboBox) {
- // default behavior should be to use the cell renderer from the combobox.
- this.panel.listBox().setCellRenderer(comboBox.getRenderer());
- }
-
- /**
- * the message can be anything - here we build a component
- */
- protected Object message(JComboBox comboBox) {
- this.panel.setCompleteList(this.convertToArray(comboBox.getModel()));
- this.panel.setSelection(comboBox.getModel().getSelectedItem());
- return this.panel;
- }
-
- protected String title(@SuppressWarnings("unused") JComboBox comboBox) {
- return null;
- }
-
- protected int optionType(@SuppressWarnings("unused") JComboBox comboBox) {
- return JOptionPane.OK_CANCEL_OPTION;
- }
-
- protected int messageType(@SuppressWarnings("unused") JComboBox comboBox) {
- return JOptionPane.QUESTION_MESSAGE;
- }
-
- protected Icon icon(@SuppressWarnings("unused") JComboBox comboBox) {
- return null;
- }
-
- protected Object[] selectionValues(@SuppressWarnings("unused") JComboBox comboBox) {
- return null;
- }
-
- protected Object initialSelectionValue(@SuppressWarnings("unused") JComboBox comboBox) {
- return null;
- }
-
- /**
- * Convert the list of objects in the specified list model
- * into an array.
- */
- protected Object[] convertToArray(ListModel model) {
- int size = model.getSize();
- Object[] result = new Object[size];
- for (int i = 0; i < size; i++) {
- result[i] = model.getElementAt(i);
- }
- return result;
- }
-
-
- // ********** custom panel **********
-
- protected static class LocalFilteringListPanel<S> extends FilteringListPanel<S> {
- protected static final Object[] EMPTY_ARRAY = new Object[0];
-
- protected LocalFilteringListPanel() {
- super(EMPTY_ARRAY, null);
- }
-
- /**
- * Disable the performance tweak because JOptionPane
- * will try open wide enough to disable the horizontal scroll bar;
- * and it looks a bit clumsy.
- */
- @Override
- protected String prototypeCellValue() {
- return null;
- }
-
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/FilteringListPanel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/FilteringListPanel.java
deleted file mode 100644
index e58608c9e4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/FilteringListPanel.java
+++ /dev/null
@@ -1,455 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Font;
-import javax.swing.AbstractListModel;
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-import javax.swing.ListCellRenderer;
-import javax.swing.ListModel;
-import javax.swing.ListSelectionModel;
-import javax.swing.border.Border;
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import org.eclipse.jpt.common.utility.internal.SimpleStringMatcher;
-import org.eclipse.jpt.common.utility.internal.StringConverter;
-import org.eclipse.jpt.common.utility.internal.StringMatcher;
-
-/**
- * This panel presents an entry field and a list box of choices that
- * allows the user to filter the entries in the list box by entering
- * a pattern in the entry field.
- *
- * By default, two wildcards are allowed in the pattern:
- * '*' will match any set of zero or more characters
- * '?' will match any single character
- *
- * The panel consists of 4 components that can be customized:
- * - 1 text field
- * - 1 list box
- * - 2 labels, one for each of the above
- *
- * Other aspects of the panel's behavior can be changed:
- * - the string converter determines how the objects in the
- * list are converted to strings and compared to the pattern
- * entered in the text field; by default the converter simply
- * uses the result of the object's #toString() method
- * (if you replace the string converter, you will probably
- * want to replace the list box's cell renderer also)
- * - the string matcher can also be changed if you would
- * like different pattern matching behavior than that
- * described above
- * - you can specify the maximum size of the list - this may
- * force the user to enter a pattern restrictive enough
- * to result in a list smaller than the maximum size; the
- * default is -1, which disables the restriction
- *
- * This panel is not a typical panel, in the sense that it does not share
- * its model with clients via value models. Instead, this panel's model
- * is set and queried directly because it is designed to be used in a
- * dialog that directs the user's behavior (as opposed to a "normal"
- * window).
- */
-public class FilteringListPanel<T> extends JPanel {
-
- /**
- * The complete list of available choices
- * (as opposed to the partial list held by the list box).
- */
- private Object[] completeList;
-
- /**
- * An adapter used to convert the objects in the list
- * to strings so they can be run through the matcher
- * and displayed in the text field.
- */
- StringConverter<T> stringConverter;
-
- /** The text field. */
- private JTextField textField;
- private JLabel textFieldLabel;
- private DocumentListener textFieldListener;
-
- /** The list box. */
- private JList listBox;
- private JLabel listBoxLabel;
-
- /** The maximum number of entries displayed in the list box. */
- private int maxListSize;
-
- /**
- * The matcher used to filter the list against
- * the pattern entered in the text field. By default,
- * this allows the two wildcard characters described in
- * the class comment.
- */
- private StringMatcher stringMatcher;
-
- /**
- * Performance tweak: We use this buffer instead of
- * a temporary variable during filtering so we don't have
- * to keep re-allocating it.
- */
- private Object[] buffer;
-
- private static final Border TEXT_FIELD_LABEL_BORDER = BorderFactory.createEmptyBorder(0, 0, 5, 0);
- private static final Border LIST_BOX_LABEL_BORDER = BorderFactory.createEmptyBorder(5, 0, 5, 0);
-
-
- // ********** constructors **********
-
- /**
- * Construct a FilteringListPanel with the specified list of choices
- * and initial selection. Use the default string converter to convert the
- * choices and selection to strings (which simply calls #toString() on
- * the objects).
- */
- public FilteringListPanel(Object[] completeList, Object initialSelection) {
- this(completeList, initialSelection, StringConverter.Default.<T>instance());
- }
-
- /**
- * Construct a FilteringListPanel with the specified list of choices
- * and initial selection. Use the specified string converter to convert the
- * choices and selection to strings.
- */
- public FilteringListPanel(Object[] completeList, Object initialSelection, StringConverter<T> stringConverter) {
- super(new BorderLayout());
- this.completeList = completeList;
- this.stringConverter = stringConverter;
- this.initialize(initialSelection);
- }
-
-
- // ********** initialization **********
-
- private void initialize(Object initialSelection) {
- this.maxListSize = this.defaultMaxListSize();
- this.buffer = this.buildBuffer();
-
- this.textFieldListener = this.buildTextFieldListener();
-
- this.stringMatcher = this.buildStringMatcher();
-
- this.initializeLayout(initialSelection);
- }
-
- private Object[] buildBuffer() {
- return new Object[this.max()];
- }
-
- /**
- * Return the current max number of entries allowed in the list box.
- */
- private int max() {
- if (this.maxListSize == -1) {
- return this.completeList.length;
- }
- return Math.min(this.maxListSize, this.completeList.length);
- }
-
- /**
- * Build a listener that will listen to changes in the text field
- * and filter the list appropriately.
- */
- private DocumentListener buildTextFieldListener() {
- return new DocumentListener() {
- public void insertUpdate(DocumentEvent e) {
- FilteringListPanel.this.filterList();
- }
- public void changedUpdate(DocumentEvent e) {
- FilteringListPanel.this.filterList();
- }
- public void removeUpdate(DocumentEvent e) {
- FilteringListPanel.this.filterList();
- }
- @Override
- public String toString() {
- return "text field listener"; //$NON-NLS-1$
- }
- };
- }
-
- private int defaultMaxListSize() {
- return -1;
- }
-
- private StringMatcher buildStringMatcher() {
- return new SimpleStringMatcher<T>();
- }
-
- private void initializeLayout(Object initialSelection) {
- // text field
- JPanel textFieldPanel = new JPanel(new BorderLayout());
- this.textFieldLabel = new JLabel();
- this.textFieldLabel.setBorder(TEXT_FIELD_LABEL_BORDER);
- textFieldPanel.add(this.textFieldLabel, BorderLayout.NORTH);
-
- this.textField = new JTextField();
- this.textField.getDocument().addDocumentListener(this.textFieldListener);
- this.textFieldLabel.setLabelFor(this.textField);
- textFieldPanel.add(this.textField, BorderLayout.CENTER);
-
- this.add(textFieldPanel, BorderLayout.NORTH);
-
- // list box
- JPanel listBoxPanel = new JPanel(new BorderLayout());
- this.listBoxLabel = new JLabel();
- this.listBoxLabel.setBorder(LIST_BOX_LABEL_BORDER);
- listBoxPanel.add(this.listBoxLabel, BorderLayout.NORTH);
-
- this.listBox = new JList();
- this.listBox.setDoubleBuffered(true);
- this.listBox.setModel(this.buildPartialArrayListModel(this.completeList, this.max()));
- this.listBox.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- // performance tweak(?)
- this.listBox.setPrototypeCellValue(this.prototypeCellValue());
- this.listBox.setPrototypeCellValue(null);
- this.listBox.setCellRenderer(this.buildDefaultCellRenderer());
- this.listBoxLabel.setLabelFor(this.listBox);
- // bug 2777802 - scroll bars shouldn't be on the tab sequence
- JScrollPane listBoxScrollPane = new JScrollPane(this.listBox);
- listBoxScrollPane.getHorizontalScrollBar().setFocusable(false);
- listBoxScrollPane.getVerticalScrollBar().setFocusable(false);
- listBoxPanel.add(listBoxScrollPane, BorderLayout.CENTER);
-
- // initialize the widgets
- this.listBox.setSelectedValue(initialSelection, true);
- this.textField.select(0, this.textField.getText().length());
-
- this.add(listBoxPanel, BorderLayout.CENTER);
- }
-
-
- // ********** public API **********
-
- public Object selection() {
- return this.listBox.getSelectedValue();
- }
-
- public void setSelection(Object selection) {
- this.listBox.setSelectedValue(selection, true);
- }
-
- public Object[] completeList() {
- return this.completeList;
- }
-
- /**
- * rebuild the filtering buffer and re-apply the filter
- * to the new list
- */
- public void setCompleteList(Object[] completeList) {
- this.completeList = completeList;
- if (this.buffer.length < this.max()) {
- // the buffer will never shrink - might want to re-consider... ~bjv
- this.buffer = this.buildBuffer();
- }
- this.filterList();
- }
-
- public int maxListSize() {
- return this.maxListSize;
- }
-
- public void setMaxListSize(int maxListSize) {
- this.maxListSize = maxListSize;
- if (this.buffer.length < this.max()) {
- // the buffer will never shrink - might want to re-consider... ~bjv
- this.buffer = this.buildBuffer();
- }
- this.filterList();
- }
-
- public StringConverter<T> stringConverter() {
- return this.stringConverter;
- }
-
- /**
- * apply the new filter to the list
- */
- public void setStringConverter(StringConverter<T> stringConverter) {
- this.stringConverter = stringConverter;
- this.filterList();
- }
-
- /**
- * allow client code to access the text field
- * (so we can set the focus)
- */
- public JTextField textField() {
- return this.textField;
- }
-
- /**
- * allow client code to access the text field label
- */
- public JLabel textFieldLabel() {
- return this.textFieldLabel;
- }
-
- /**
- * convenience method
- */
- public void setTextFieldLabelText(String text) {
- this.textFieldLabel.setText(text);
- }
-
- /**
- * allow client code to access the list box
- * (so we can add mouse listeners for double-clicking)
- */
- public JList listBox() {
- return this.listBox;
- }
-
- /**
- * convenience method
- */
- public void setListBoxCellRenderer(ListCellRenderer renderer) {
- this.listBox.setCellRenderer(renderer);
- }
-
- /**
- * allow client code to access the list box label
- */
- public JLabel listBoxLabel() {
- return this.listBoxLabel;
- }
-
- /**
- * convenience method
- */
- public void setListBoxLabelText(String text) {
- this.listBoxLabel.setText(text);
- }
-
- /**
- * convenience method
- */
- public void setComponentsFont(Font font) {
- this.textFieldLabel.setFont(font);
- this.textField.setFont(font);
- this.listBoxLabel.setFont(font);
- this.listBox.setFont(font);
- }
-
- public StringMatcher stringMatcher() {
- return this.stringMatcher;
- }
-
- /**
- * re-apply the filter to the list
- */
- public void setStringMatcher(StringMatcher stringMatcher) {
- this.stringMatcher = stringMatcher;
- this.filterList();
- }
-
-
- // ********** internal methods **********
-
- /**
- * Allow subclasses to disable performance tweak
- * by returning null here.
- */
- protected String prototypeCellValue() {
- return "==========> A_STRING_THAT_IS_DEFINITELY_LONGER_THAN_EVERY_STRING_IN_THE_LIST <=========="; //$NON-NLS-1$
- }
-
- /**
- * By default, use the string converter to build the text
- * used by the list box's cell renderer.
- */
- protected ListCellRenderer buildDefaultCellRenderer() {
- return new SimpleListCellRenderer() {
- @Override
- @SuppressWarnings("unchecked")
- protected String buildText(Object value) {
- return FilteringListPanel.this.stringConverter.convertToString((T) value);
- }
- };
- }
-
- /**
- * Something has changed that requires us to filter the list.
- *
- * This method is synchronized because a fast typist can
- * generate events quicker than we can filter the list. (? ~bjv)
- */
- synchronized void filterList() {
- // temporarily stop listening to the list box selection, since we will
- // be changing the selection during the filtering and don't want
- // that to affect the text field
- this.filterList(this.textField.getText());
- }
-
- /**
- * Filter the contents of the list box to match the
- * specified pattern.
- */
- private void filterList(String pattern) {
- if (pattern.length() == 0) {
- this.listBox.setModel(this.buildPartialArrayListModel(this.completeList, this.max()));
- } else {
- this.stringMatcher.setPatternString(pattern);
- int j = 0;
- int len = this.completeList.length;
- int max = this.max();
- for (int i = 0; i < len; i++) {
- if (this.stringMatcher.matches(this.stringConverter.convertToString(this.entry(i)))) {
- this.buffer[j++] = this.completeList[i];
- }
- if (j == max) {
- break;
- }
- }
- this.listBox.setModel(this.buildPartialArrayListModel(this.buffer, j));
- }
-
- // after filtering the list, determine the appropriate selection
- if (this.listBox.getModel().getSize() == 0) {
- this.listBox.getSelectionModel().clearSelection();
- } else {
- this.listBox.getSelectionModel().setAnchorSelectionIndex(0);
- this.listBox.getSelectionModel().setLeadSelectionIndex(0);
- this.listBox.ensureIndexIsVisible(0);
- }
- }
-
- /**
- * minimize scope of suppressed warnings
- */
- @SuppressWarnings("unchecked")
- private T entry(int index) {
- return (T) this.completeList[index];
- }
-
- /**
- * Build a list model that wraps only a portion of the specified array.
- * The model will include the array entries from 0 to (size - 1).
- */
- private ListModel buildPartialArrayListModel(final Object[] array, final int size) {
- return new AbstractListModel() {
- public int getSize() {
- return size;
- }
- public Object getElementAt(int index) {
- return array[index];
- }
- };
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/ListChooser.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/ListChooser.java
deleted file mode 100644
index 84bad23fc9..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/ListChooser.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import java.awt.AWTEvent;
-import java.awt.AWTException;
-import java.awt.Component;
-import java.awt.EventQueue;
-import java.awt.Point;
-import java.awt.Robot;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.ListCellRenderer;
-import javax.swing.SwingConstants;
-import javax.swing.event.PopupMenuEvent;
-import javax.swing.event.PopupMenuListener;
-import javax.swing.plaf.basic.BasicComboBoxUI;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-
-/**
- * This component provides a way to handle selecting an item from a
- * list that may grow too large to be handled conveniently by a combo-box.
- * If the list's size is less than the designated "long" list size,
- * the choice list will be displayed in a normal combo-box popup;
- * otherwise, a dialog will be used to prompt the user to choose a selection.
- *
- * To change the browse mechanism, subclasses may
- * - override the method #buildBrowser()
- * - override the method #browse(), in which case the method
- * #buildBrowser() may be ignored.
- */
-public class ListChooser
- extends JComboBox
-{
-
- /** the size of a "long" list - anything smaller is a "short" list */
- int longListSize = DEFAULT_LONG_LIST_SIZE;
-
- /** the default size of a "long" list, which is 20 (to match JOptionPane's behavior) */
- public static final int DEFAULT_LONG_LIST_SIZE = 20;
-
- /** property change associated with long list size */
- public static final String LONG_LIST_SIZE_PROPERTY = "longListSize"; //$NON-NLS-1$
-
- static JLabel prototypeLabel = new JLabel("Prototype", new EmptyIcon(17), SwingConstants.LEADING); //$NON-NLS-1$
-
- /**
- * whether the chooser is choosable. if a chooser is not choosable,
- * it only serves as a display widget. a user may not change its
- * selected value.
- */
- boolean choosable = true;
-
- /** property change associated with choosable */
- public static final String CHOOSABLE_PROPERTY = "choosable"; //$NON-NLS-1$
-
- /** the browser used to make a selection from the long list - typically via a dialog */
- private ListBrowser browser;
-
- private NodeSelector nodeSelector;
-
- /** INTERNAL - The popup is being shown. Used to prevent infinite loop. */
- boolean popupAlreadyInProgress;
-
-
- // **************** Constructors ******************************************
-
- /**
- * Construct a list chooser for the specified model.
- */
- public ListChooser(ComboBoxModel model) {
- this(model, new NodeSelector.DefaultNodeSelector());
- }
-
- public ListChooser(CachingComboBoxModel model) {
- this(model, new NodeSelector.DefaultNodeSelector());
- }
-
- public ListChooser(ComboBoxModel model, NodeSelector nodeSelector) {
- this(new NonCachingComboBoxModel(model), nodeSelector);
- }
-
- public ListChooser(CachingComboBoxModel model, NodeSelector nodeSelector) {
- super(model);
- this.initialize();
- this.nodeSelector = nodeSelector;
- }
- // **************** Initialization ****************************************
-
- protected void initialize() {
- this.addPopupMenuListener(this.buildPopupMenuListener());
- this.setRenderer(new DefaultListCellRenderer());
- this.addKeyListener(buildF3KeyListener());
-
- //These are used to workaround problems with Swing trying to
- //determine the size of a comboBox with a large model
- setPrototypeDisplayValue(prototypeLabel);
- listBox().setPrototypeCellValue(prototypeLabel);
- }
-
-
- private JList listBox() {
- return (JList) ReflectionTools.getFieldValue(this.ui, "listBox"); //$NON-NLS-1$
- }
-
- /**
- * When the popup is about to be shown, the event is consumed, and
- * PopupHandler determines whether to reshow the popup or to show
- * the long list browser.
- */
- private PopupMenuListener buildPopupMenuListener() {
- return new PopupMenuListener() {
- public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
- ListChooser.this.aboutToShowPopup();
- }
- public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
- // do nothing
- }
- public void popupMenuCanceled(PopupMenuEvent e) {
- // do nothing
- }
- @Override
- public String toString() {
- return "pop-up menu listener"; //$NON-NLS-1$
- }
- };
- }
-
- /**
- * If this code is being reached due to the PopupHandler already being in progress,
- * then do nothing. Otherwise, set the flag to true and launch the PopupHandler.
- */
- void aboutToShowPopup() {
- if (this.popupAlreadyInProgress) {
- return;
- }
-
- this.popupAlreadyInProgress = true;
- EventQueue.invokeLater(new PopupHandler());
- }
-
-
- private KeyListener buildF3KeyListener() {
- return new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_F3) {
- goToSelectedItem();
- }
- }
- @Override
- public String toString() {
- return "F3 key listener"; //$NON-NLS-1$
- }
- };
- }
-
- public void goToSelectedItem() {
- if (getSelectedItem() != null) {
- ListChooser.this.nodeSelector.selectNodeFor(getSelectedItem());
- }
- }
-
- // **************** Browsing **********************************************
-
- /**
- * Lazily initialize because subclasses may have further initialization to do
- * before browser can be built.
- */
- protected void browse() {
- if (this.browser == null) {
- this.browser = this.buildBrowser();
- }
-
- this.browser.browse(this);
- }
-
- /**
- * Return the "browser" used to make a selection from the long list,
- * typically via a dialog.
- */
- protected ListChooser.ListBrowser buildBrowser() {
- return new SimpleListBrowser();
- }
-
-
- // **************** Choosable functionality *******************************
-
- /** override behavior - consume selection if chooser is not choosable */
- @Override
- public void setSelectedIndex(int anIndex) {
- if (this.choosable) {
- super.setSelectedIndex(anIndex);
- }
- }
-
- private void updateArrowButton() {
- try {
- BasicComboBoxUI comboBoxUi = (BasicComboBoxUI) ListChooser.this.getUI();
- JButton arrowButton = (JButton) ReflectionTools.getFieldValue(comboBoxUi, "arrowButton"); //$NON-NLS-1$
- arrowButton.setEnabled(this.isEnabled() && this.choosable);
- }
- catch (Exception e) {
- // this is a huge hack to try and make the combo box look right,
- // so if it doesn't work, just swallow the exception
- }
- }
-
-
- // **************** List Caching *******************************
-
- void cacheList() {
- ((CachingComboBoxModel) getModel()).cacheList();
- }
-
- void uncacheList() {
- ((CachingComboBoxModel) getModel()).uncacheList();
- }
-
- boolean listIsCached() {
- return ((CachingComboBoxModel) getModel()).isCached();
- }
-
- // **************** Public ************************************************
-
- public int longListSize() {
- return this.longListSize;
- }
-
- public void setLongListSize(int newLongListSize) {
- int oldLongListSize = this.longListSize;
- this.longListSize = newLongListSize;
- this.firePropertyChange(LONG_LIST_SIZE_PROPERTY, oldLongListSize, newLongListSize);
- }
-
- public boolean isChoosable() {
- return this.choosable;
- }
-
- public void setChoosable(boolean newValue) {
- boolean oldValue = this.choosable;
- this.choosable = newValue;
- this.firePropertyChange(CHOOSABLE_PROPERTY, oldValue, newValue);
- this.updateArrowButton();
- }
-
- // **************** Handle selecting null as a value **********************
-
- private boolean selectedIndexIsNoneSelectedItem(int index) {
- return index == -1 &&
- getModel().getSize() > 0 &&
- getModel().getElementAt(0) == null;
- }
-
- @Override
- public int getSelectedIndex() {
- boolean listNotCached = !listIsCached();
- if (listNotCached) {
- cacheList();
- }
-
- int index = super.getSelectedIndex();
-
- // Use index 0 to show the <none selected> item since the actual value is
- // null and JComboBox does not handle null values
- if (selectedIndexIsNoneSelectedItem(index)) {
- index = 0;
- }
-
- if (listNotCached) {
- uncacheList();
- }
- return index;
- }
-
- //wrap the renderer to deal with the prototypeDisplayValue
- @Override
- public void setRenderer(final ListCellRenderer aRenderer) {
- super.setRenderer(new ListCellRenderer(){
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- if (value == prototypeLabel) {
- return prototypeLabel;
- }
- return aRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- }
- });
- }
-
-
- // **************** Member classes ****************************************
-
- /**
- * Define the API required by this ListChooser when it must
- * prompt the user to select an item from the "long" list.
- */
- public interface ListBrowser
- {
- /**
- * Prompt the user to make a selection from the specified
- * combo-box's model.
- */
- void browse(ListChooser parentChooser);
- }
-
-
- /**
- * Runnable class that consumes popup window and determines whether
- * to reshow popup or to launch browser, based on the size of the list.
- */
- private class PopupHandler
- implements Runnable
- {
- /** The mouse event */
- private MouseEvent lastMouseEvent;
-
- /** The component from which the last mouse event was thrown */
- private JComponent eventComponent;
-
- /** The location of the component at the time the last mouse event was thrown */
- private Point componentLocation;
-
- /** The location of the mouse at the time the last mouse event was thrown */
- private Point mouseLocation;
-
-
- PopupHandler() {
- this.initialize();
- }
-
- private void initialize() {
- AWTEvent event = EventQueue.getCurrentEvent();
-
- if (event instanceof MouseEvent) {
- this.lastMouseEvent = (MouseEvent) event;
- this.eventComponent = (JComponent) this.lastMouseEvent.getSource();
- this.componentLocation = this.eventComponent.getLocationOnScreen();
- this.mouseLocation = this.lastMouseEvent.getPoint();
- }
- else {
- this.eventComponent = null;
- this.componentLocation = null;
- this.mouseLocation = null;
- }
- }
-
- public void run() {
- ListChooser.this.hidePopup();
-
- cacheList();
- if (ListChooser.this.choosable == true) {
- // If the combo box model is of sufficient length, the browser will be shown.
- // Asking the combo box model for its size should be enough to ensure that
- // its size is recalculated.
- if (ListChooser.this.getModel().getSize() > ListChooser.this.longListSize) {
- this.checkComboBoxButton();
- ListChooser.this.browse();
- }
- else {
- ListChooser.this.showPopup();
- this.checkMousePosition();
- }
- }
- if (listIsCached()) {
- uncacheList();
- }
-
- ListChooser.this.popupAlreadyInProgress = false;
- }
-
- /** If this is not done, the button never becomes un-pressed */
- private void checkComboBoxButton() {
- try {
- BasicComboBoxUI comboBoxUi = (BasicComboBoxUI) ListChooser.this.getUI();
- JButton arrowButton = (JButton) ReflectionTools.getFieldValue(comboBoxUi, "arrowButton"); //$NON-NLS-1$
- arrowButton.getModel().setPressed(false);
- }
- catch (Exception ex) {
- // this is a huge hack to try and make the combo box look right,
- // so if it doesn't work, just swallow the exception
- this.handleException(ex);
- }
- }
-
- private void handleException(@SuppressWarnings("unused") Exception ex) {
- // do nothing for now
- }
-
- /**
- * Moves the mouse back to its original position before any jiggery pokery that we've done.
- */
- private void checkMousePosition() {
- if (this.eventComponent == null) {
- return;
- }
-
- final Point newComponentLocation = this.eventComponent.getLocationOnScreen();
- boolean componentMoved =
- newComponentLocation.x - this.componentLocation.x != 0
- || newComponentLocation.y - this.componentLocation.y != 0;
-
- if (componentMoved) {
- try {
- new Robot().mouseMove(
- newComponentLocation.x + this.mouseLocation.x,
- newComponentLocation.y + this.mouseLocation.y
- );
- }
- catch (AWTException ex) {
- // move failed - do nothing
- }
- }
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/NodeSelector.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/NodeSelector.java
deleted file mode 100644
index 64079be527..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/NodeSelector.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-/**
- * This will be called when the user presses F3 or chooses
- * 'Go To' in the context menu
- */
-public interface NodeSelector
-{
- /**
- * Select the appropriate Node in the tree or the editor panel.
- */
- void selectNodeFor(Object item);
-
- /**
- * This NodeSelector will do nothing when selectNodeFor(Object) is called
- */
- class DefaultNodeSelector implements NodeSelector {
-
- public void selectNodeFor(Object item) {
- //default is to do nothing
- }
- }
-} \ No newline at end of file
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/NonCachingComboBoxModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/NonCachingComboBoxModel.java
deleted file mode 100644
index aef9a7c6ed..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/NonCachingComboBoxModel.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import javax.swing.ComboBoxModel;
-import javax.swing.event.ListDataListener;
-
-/**
- * This implementation of the CachingComboBoxModel interface can be used
- * whenever there is no need for caching (i.e. the contents of the selection
- * list can be generated with little latency). All the normal ComboBoxModel
- * behavior is delegated to a client-supplied ComboBoxModel.
- */
-public class NonCachingComboBoxModel implements CachingComboBoxModel {
- private ComboBoxModel wrappedComboBoxModel;
-
- public NonCachingComboBoxModel(ComboBoxModel wrappedComboBoxModel) {
- this.wrappedComboBoxModel = wrappedComboBoxModel;
- }
-
-
- // ********** CachingComboBoxModel implementation **********
-
- public void cacheList() {
- //do nothing
- }
-
- public void uncacheList() {
- //do nothing
- }
-
- public boolean isCached() {
- return false;
- }
-
-
- // ********** ComboBoxModel implementation **********
-
- public void setSelectedItem(Object anItem) {
- this.wrappedComboBoxModel.setSelectedItem(anItem);
- }
-
- public Object getSelectedItem() {
- return this.wrappedComboBoxModel.getSelectedItem();
- }
-
-
- // ********** ListModel implementation **********
-
- public int getSize() {
- return this.wrappedComboBoxModel.getSize();
- }
-
- public Object getElementAt(int index) {
- return this.wrappedComboBoxModel.getElementAt(index);
- }
-
- public void addListDataListener(ListDataListener l) {
- this.wrappedComboBoxModel.addListDataListener(l);
- }
-
- public void removeListDataListener(ListDataListener l) {
- this.wrappedComboBoxModel.removeListDataListener(l);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleDisplayable.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleDisplayable.java
deleted file mode 100644
index d10b6b44db..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleDisplayable.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import javax.swing.Icon;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-
-/**
- * This implementation of Displayable converts any Object
- * to a Displayable. Subclass it to override #displayString() and
- * #icon() if necessary. Change notification will be fired if the
- * object is changed.
- *
- * This can be used for Strings - the display string
- * will simply be the String itself.
- */
-public class SimpleDisplayable
- extends AbstractModel
- implements Displayable
-{
- /** The object to be converted to a Displayable. */
- protected Object object;
-
-
- /**
- * Construct a displayable for the specified object.
- */
- public SimpleDisplayable(Object object) {
- super();
- this.object = object;
- }
-
- public SimpleDisplayable(boolean b) {
- this(Boolean.valueOf(b));
- }
-
- public SimpleDisplayable(char c) {
- this(Character.valueOf(c));
- }
-
- public SimpleDisplayable(byte b) {
- this(Byte.valueOf(b));
- }
-
- public SimpleDisplayable(short s) {
- this(Short.valueOf(s));
- }
-
- public SimpleDisplayable(int i) {
- this(Integer.valueOf(i));
- }
-
- public SimpleDisplayable(long l) {
- this(Long.valueOf(l));
- }
-
- public SimpleDisplayable(float f) {
- this(Float.valueOf(f));
- }
-
- public SimpleDisplayable(double d) {
- this(Double.valueOf(d));
- }
-
-
- // ********** Displayable implementation **********
-
- public String displayString() {
- return this.object.toString();
- }
-
- public Icon icon() {
- return null;
- }
-
-
- // ********** accessors **********
-
- public Object getObject() {
- return this.object;
- }
-
- public void setObject(Object object) {
- String oldDisplayString = this.displayString();
- Icon oldIcon = this.icon();
- this.object = object;
- this.firePropertyChanged(DISPLAY_STRING_PROPERTY, oldDisplayString, this.displayString());
- this.firePropertyChanged(ICON_PROPERTY, oldIcon, this.icon());
- }
-
- public boolean getBoolean() {
- return ((Boolean) this.object).booleanValue();
- }
-
- public void setBoolean(boolean b) {
- this.setObject(Boolean.valueOf(b));
- }
-
- public char getChar() {
- return ((Character) this.object).charValue();
- }
-
- public void setChar(char c) {
- this.setObject(Character.valueOf(c));
- }
-
- public byte getByte() {
- return ((Byte) this.object).byteValue();
- }
-
- public void setByte(byte b) {
- this.setObject(Byte.valueOf(b));
- }
-
- public short getShort() {
- return ((Short) this.object).shortValue();
- }
-
- public void setShort(short s) {
- this.setObject(Short.valueOf(s));
- }
-
- public int getInt() {
- return ((Integer) this.object).intValue();
- }
-
- public void setInt(int i) {
- this.setObject(Integer.valueOf(i));
- }
-
- public long getLong() {
- return ((Long) this.object).longValue();
- }
-
- public void setLong(long l) {
- this.setObject(Long.valueOf(l));
- }
-
- public float getFloat() {
- return ((Float) this.object).floatValue();
- }
-
- public void setFloat(float f) {
- this.setObject(Float.valueOf(f));
- }
-
- public double getDouble() {
- return ((Double) this.object).doubleValue();
- }
-
- public void setDouble(double d) {
- this.setObject(Double.valueOf(d));
- }
-
-
- // ********** override methods **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.object);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleListBrowser.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleListBrowser.java
deleted file mode 100644
index a600532a12..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleListBrowser.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import javax.swing.Icon;
-import javax.swing.JComboBox;
-import javax.swing.JOptionPane;
-import javax.swing.ListModel;
-
-/**
- * This implementation of ListChooser.Browser uses a
- * JOptionPane to prompt the user for the selection. Subclasses
- * can change the dialog's title, message, and/or icon.
- */
-public class SimpleListBrowser
- implements ListChooser.ListBrowser
-{
- /** Default constructor */
- protected SimpleListBrowser() {
- super();
- }
-
- /**
- * Prompt the user using a JOptionPane.
- */
- public void browse(ListChooser chooser) {
- Object selection =
- JOptionPane.showInputDialog(
- chooser,
- this.message(chooser),
- this.title(chooser),
- this.messageType(chooser),
- this.icon(chooser),
- this.selectionValues(chooser),
- this.initialSelectionValue(chooser)
- );
-
- if (selection != null) {
- chooser.getModel().setSelectedItem(selection);
- }
- }
-
- protected Object message(@SuppressWarnings("unused") JComboBox comboBox) {
- return null;
- }
-
- protected String title(@SuppressWarnings("unused") JComboBox comboBox) {
- return null;
- }
-
- protected int messageType(@SuppressWarnings("unused") JComboBox comboBox) {
- return JOptionPane.QUESTION_MESSAGE;
- }
-
- protected Icon icon(@SuppressWarnings("unused") JComboBox comboBox) {
- return null;
- }
-
- protected Object[] selectionValues(JComboBox comboBox) {
- return this.convertToArray(comboBox.getModel());
- }
-
- protected Object initialSelectionValue(JComboBox comboBox) {
- return comboBox.getModel().getSelectedItem();
- }
-
- /**
- * Convert the list of objects in the specified list model
- * into an array.
- */
- protected Object[] convertToArray(ListModel model) {
- int size = model.getSize();
- Object[] result = new Object[size];
- for (int i = 0; i < size; i++) {
- result[i] = model.getElementAt(i);
- }
- return result;
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleListCellRenderer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleListCellRenderer.java
deleted file mode 100644
index 6bbd290d0f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SimpleListCellRenderer.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import java.awt.Component;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.Icon;
-import javax.swing.JList;
-
-/**
- * This renderer should behave the same as the DefaultListCellRenderer;
- * but it slightly refactors the calculation of the icon and text of the list
- * cell so that subclasses can easily override the methods that build
- * the icon and text.
- *
- * In most cases, you need only override:
- * #buildIcon(Object value)
- * #buildText(Object value)
- */
-public class SimpleListCellRenderer
- extends DefaultListCellRenderer
-{
-
- /**
- * Construct a simple renderer.
- */
- public SimpleListCellRenderer() {
- super();
- }
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- // substitute null for the cell value so nothing is drawn initially...
- super.getListCellRendererComponent(list, null, index, isSelected, cellHasFocus);
- this.setOpaque(true);
-
- // ...then set the icon and text manually
- this.setIcon(this.buildIcon(list, value, index, isSelected, cellHasFocus));
- this.setText(this.buildText(list, value, index, isSelected, cellHasFocus));
-
- this.setToolTipText(this.buildToolTipText(list, value, index, isSelected, cellHasFocus));
-
- // the context will be initialized only if a reader is running
- if (this.accessibleContext != null) {
- this.accessibleContext.setAccessibleName(this.buildAccessibleName(list, value, index, isSelected, cellHasFocus));
- }
-
- return this;
- }
-
- /**
- * Return the icon representation of the specified cell
- * value and other settings. (Even more settings are
- * accessible via inherited getters: hasFocus, isEnabled, etc.)
- */
- protected Icon buildIcon(@SuppressWarnings("unused") JList list, Object value, @SuppressWarnings("unused") int index, @SuppressWarnings("unused") boolean isSelected, @SuppressWarnings("unused") boolean cellHasFocus) {
- return this.buildIcon(value);
- }
-
- /**
- * Return the icon representation of the specified cell
- * value. The default is to display no icon at all unless the
- * value itself is an icon.
- */
- protected Icon buildIcon(Object value) {
- // replicate the default behavior
- return (value instanceof Icon) ? (Icon) value : null;
- }
-
- /**
- * Return the textual representation of the specified cell
- * value and other settings. (Even more settings are
- * accessible via inherited getters: hasFocus, isEnabled, etc.)
- */
- protected String buildText(@SuppressWarnings("unused") JList list, Object value, @SuppressWarnings("unused") int index, @SuppressWarnings("unused") boolean isSelected, @SuppressWarnings("unused") boolean cellHasFocus) {
- return this.buildText(value);
- }
-
- /**
- * Return the textual representation of the specified cell
- * value. The default is to display the object's default string
- * representation (as returned by #toString()); unless the
- * value itself is an icon, in which case no text is displayed.
- */
- protected String buildText(Object value) {
- return (value instanceof Icon) ? "" : ((value == null) ? "" : value.toString()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Return the text displayed when the cursor lingers over the specified cell.
- * (Even more settings are accessible via inherited getters: hasFocus, isEnabled, etc.)
- */
- protected String buildToolTipText(@SuppressWarnings("unused") JList list, Object value, @SuppressWarnings("unused") int index, @SuppressWarnings("unused") boolean isSelected, @SuppressWarnings("unused") boolean cellHasFocus) {
- return this.buildToolTipText(value);
- }
-
- /**
- * Return the text displayed when the cursor lingers over the specified cell.
- */
- protected String buildToolTipText(@SuppressWarnings("unused") Object value) {
- return null;
- }
-
- /**
- * Return the accessible name to be given to the component used to render
- * the given value and other settings. (Even more settings are accessible via
- * inherited getters: hasFocus, isEnabled, etc.)
- */
- protected String buildAccessibleName(@SuppressWarnings("unused") JList list, Object value, @SuppressWarnings("unused") int index, @SuppressWarnings("unused") boolean isSelected, @SuppressWarnings("unused") boolean cellHasFocus) {
- return this.buildAccessibleName(value);
- }
-
- /**
- * Return the accessible name to be given to the component used to render
- * the given value.
- */
- protected String buildAccessibleName(@SuppressWarnings("unused") Object value) {
- return null;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SpinnerTableCellRenderer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SpinnerTableCellRenderer.java
deleted file mode 100644
index f97ada2066..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/SpinnerTableCellRenderer.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import java.awt.Color;
-import java.awt.Component;
-import javax.swing.BorderFactory;
-import javax.swing.JComponent;
-import javax.swing.JSpinner;
-import javax.swing.JTable;
-import javax.swing.SpinnerModel;
-import javax.swing.UIManager;
-import javax.swing.border.Border;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-/**
- * Make the cell look like a spinner.
- */
-public class SpinnerTableCellRenderer implements TableCellEditorAdapter.Renderer {
-
- /** the component used to paint the cell */
- protected JSpinner spinner;
-
- /** the listener to be notified on an immediate edit */
- protected TableCellEditorAdapter.ImmediateEditListener immediateEditListener;
-
-
- // ********** constructors/initialization **********
-
- /**
- * Construct a cell renderer that uses the default
- * spinner model, which is a "number" model.
- */
- public SpinnerTableCellRenderer() {
- super();
- this.initialize();
- }
-
- /**
- * Construct a cell renderer that uses the specified
- * spinner model, which will determine how the values are displayed.
- */
- public SpinnerTableCellRenderer(SpinnerModel model) {
- this();
- this.setModel(model);
- }
-
- protected void initialize() {
- this.spinner = this.buildSpinner();
- }
-
- protected JSpinner buildSpinner() {
- JSpinner s = new JSpinner();
- s.addChangeListener(this.buildChangeListener());
- return s;
- }
-
- private ChangeListener buildChangeListener() {
- return new ChangeListener() {
- public void stateChanged(ChangeEvent e) {
- if (SpinnerTableCellRenderer.this.immediateEditListener != null) {
- SpinnerTableCellRenderer.this.immediateEditListener.immediateEdit();
- }
- }
- };
- }
-
-
- // ********** TableCellRenderer implementation **********
-
- public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
- this.spinner.setComponentOrientation(table.getComponentOrientation());
- this.spinner.setFont(table.getFont());
- this.spinner.setEnabled(table.isEnabled());
-
- JComponent editor = this.editor();
- editor.setForeground(this.foregroundColor(table, value, selected, hasFocus, row, column));
- editor.setBackground(this.backgroundColor(table, value, selected, hasFocus, row, column));
- this.spinner.setBorder(this.border(table, value, selected, hasFocus, row, column));
-
- this.setValue(value);
- return this.spinner;
- }
-
- /**
- * Return the cell's foreground color.
- */
- protected Color foregroundColor(JTable table, @SuppressWarnings("unused") Object value, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return UIManager.getColor("Table.focusCellForeground"); //$NON-NLS-1$
- }
- return table.getSelectionForeground();
- }
- return table.getForeground();
- }
-
- /**
- * Return the cell's background color.
- */
- protected Color backgroundColor(JTable table, @SuppressWarnings("unused") Object value, boolean selected, boolean hasFocus, int row, int column) {
- if (selected) {
- if (hasFocus && table.isCellEditable(row, column)) {
- return UIManager.getColor("Table.focusCellBackground"); //$NON-NLS-1$
- }
- return table.getSelectionBackground();
- }
- return table.getBackground();
- }
-
- /**
- * Return the cell's border.
- */
- protected Border border(JTable table, @SuppressWarnings("unused") Object value, boolean selected, boolean hasFocus, @SuppressWarnings("unused") int row, @SuppressWarnings("unused") int column) {
- if (hasFocus) {
- return UIManager.getBorder("Table.focusCellHighlightBorder"); //$NON-NLS-1$
- }
- if (selected) {
- return BorderFactory.createLineBorder(table.getSelectionBackground(), 1);
- }
- return BorderFactory.createLineBorder(table.getBackground(), 1);
- }
-
- /**
- * Return the editor component whose colors should be set
- * by the renderer.
- */
- protected JComponent editor() {
- JComponent editor = this.spinner.getEditor();
- if (editor instanceof JSpinner.DefaultEditor) {
- // typically, the editor will be the default or one of its subclasses...
- editor = ((JSpinner.DefaultEditor) editor).getTextField();
- }
- return editor;
- }
-
- /**
- * Set the spinner's value
- */
- protected void setValue(Object value) {
- // CR#3999318 - This null check needs to be removed once JDK bug is fixed
- if (value == null) {
- value = Integer.valueOf(0);
- }
- this.spinner.setValue(value);
- }
-
-
- // ********** TableCellEditorAdapter.Renderer implementation **********
-
- public Object getValue() {
- return this.spinner.getValue();
- }
-
- public void setImmediateEditListener(TableCellEditorAdapter.ImmediateEditListener listener) {
- this.immediateEditListener = listener;
- }
-
-
- // ********** public API **********
-
- /**
- * Set the spinner's model.
- */
- public void setModel(SpinnerModel model) {
- this.spinner.setModel(model);
- }
-
- /**
- * Return the renderer's preferred height. This allows you
- * to set the row height to something the spinner will look good in....
- */
- public int preferredHeight() {
- // add in space for the border top and bottom
- return (int) this.spinner.getPreferredSize().getHeight() + 2;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/TableCellEditorAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/TableCellEditorAdapter.java
deleted file mode 100644
index bfe82bbf6b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/swing/TableCellEditorAdapter.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.swing;
-
-import java.awt.Component;
-import javax.swing.AbstractCellEditor;
-import javax.swing.JTable;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-
-/**
- * A table cell editor that wraps a table cell renderer.
- */
-public class TableCellEditorAdapter extends AbstractCellEditor implements TableCellEditor {
-
- /** delegate to a renderer */
- private Renderer renderer;
-
-
- // ********** constructors/initialization **********
-
- private TableCellEditorAdapter() {
- super();
- }
-
- /**
- * Construct a cell editor that behaves like the specified renderer.
- */
- public TableCellEditorAdapter(Renderer renderer) {
- this();
- this.initialize(renderer);
- }
-
- protected void initialize(Renderer r) {
- this.renderer = r;
- r.setImmediateEditListener(this.buildImmediateEditListener());
- }
-
- private ImmediateEditListener buildImmediateEditListener() {
- return new ImmediateEditListener() {
- public void immediateEdit() {
- TableCellEditorAdapter.this.stopCellEditing();
- }
- };
- }
-
-
- // ********** CellEditor implementation **********
-
- public Object getCellEditorValue() {
- return this.renderer.getValue();
- }
-
-
- // ********** TableCellEditor implementation **********
-
- public Component getTableCellEditorComponent(JTable table, Object value, boolean selected, int row, int column) {
- return this.renderer.getTableCellRendererComponent(table, value, selected, true, row, column);
- }
-
-
- // ********** Member classes **********************************************
-
- /**
- * This interface defines the methods that must be implemented by a renderer
- * that can be wrapped by a TableCellEditorAdapter.
- */
- public interface Renderer extends TableCellRenderer {
-
- /**
- * Return the current value of the renderer.
- */
- Object getValue();
-
- /**
- * Set the immediate edit listener
- */
- void setImmediateEditListener(ImmediateEditListener listener);
- }
-
-
- public interface ImmediateEditListener {
-
- /**
- * Called when the renderer does an "immediate edit"
- */
- void immediateEdit();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/synchronizers/CallbackSynchronousSynchronizer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/synchronizers/CallbackSynchronousSynchronizer.java
deleted file mode 100644
index c377403a93..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/synchronizers/CallbackSynchronousSynchronizer.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.synchronizers;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-import org.eclipse.jpt.common.utility.synchronizers.CallbackSynchronizer;
-
-/**
- * Extend the synchronous synchronizer to notify listeners
- * when a synchronization "cycle" is complete; i.e. the synchronization has,
- * for the moment, handled every "synchronize" request and quiesced.
- * This notification is <em>not</em> guaranteed to occur with <em>every</em>
- * synchronization "cycle";
- * since other, unrelated, synchronizations can be triggered concurrently.
- * <p>
- * <strong>NB:</strong> If another synchronization is initiated while we are
- * notifying the synchronizer's listeners (i.e. the 'again' flag is set), it will not
- * start until all the listeners are notified.
- * Note also, the synchronizer's listeners can, themselves,
- * trigger another synchronization (by directly or indirectly calling
- * {@link org.eclipse.jpt.common.utility.synchronizers.Synchronizer#synchronize()});
- * but this synchronization will not occur until <em>after</em> all the
- * listeners have been notified.
- */
-public class CallbackSynchronousSynchronizer
- extends SynchronousSynchronizer
- implements CallbackSynchronizer
-{
- private final ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
-
-
- // ********** construction **********
-
- /**
- * Construct a callback synchronous synchronizer that uses the specified
- * command to perform the synchronization.
- */
- public CallbackSynchronousSynchronizer(Command command) {
- super(command);
- }
-
-
- // ********** CallbackSynchronizer implementation **********
-
- public void addListener(Listener listener) {
- this.listenerList.add(listener);
- }
-
- public void removeListener(Listener listener) {
- this.listenerList.remove(listener);
- }
-
- /**
- * Notify our listeners.
- */
- private void synchronizationQuiesced() {
- for (Listener listener : this.listenerList.getListeners()) {
- listener.synchronizationQuiesced(this);
- }
- }
-
-
- // ********** override **********
-
- @Override
- void execute_() {
- super.execute_();
- if (this.state.getValue() != State.REPEAT) {
- // hmmm - we will notify listeners even when we are "stopped";
- // that seems ok... ~bjv
- this.synchronizationQuiesced();
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/synchronizers/SynchronousSynchronizer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/synchronizers/SynchronousSynchronizer.java
deleted file mode 100644
index 13b979661d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/synchronizers/SynchronousSynchronizer.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.internal.synchronizers;
-
-import java.util.Vector;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.CompositeException;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.SynchronizedObject;
-import org.eclipse.jpt.common.utility.synchronizers.Synchronizer;
-
-/**
- * This synchronizer will synchronize immediately and not return until the
- * synchronization and any nested (recursive) synchronizations are complete.
- * In some situations this implementation should be used sparingly, and for as
- * short a time as possible, as it increases the probability of deadlocks. A
- * deadlock can occur when {@link Synchronizer#synchronize()} is called from multiple
- * threads and multiple resources are locked by the synchronization in varying
- * orders.
- * <p>
- * As defined in the {@link Synchronizer} interface, {@link Synchronizer#start()}
- * and {@link Synchronizer#stop()}
- * should be called in the same thread, but it is not required.
- * {@link Synchronizer#synchronize()} should
- * always be called in the same thread (i.e. only recursively, beyond the
- * initial call); although, this too is not required.
- * This thread need not be the same thread that executes
- * {@link Synchronizer#start()} and {@link Synchronizer#stop()}.
- */
-public class SynchronousSynchronizer
- implements Synchronizer
-{
- /**
- * The client-supplied command that performs the synchronization. It may
- * trigger further calls to {@link #synchronize()} (i.e. the
- * synchronization may recurse).
- */
- private final Command command;
-
- /**
- * The synchronizer's current state.
- */
- final SynchronizedObject<State> state;
-
- /**
- * The synchronizer's initial state is {@link #STOPPED}.
- */
- enum State {
- STOPPED,
- READY,
- EXECUTING,
- REPEAT,
- STOPPING
- }
-
- /**
- * A list of the uncaught exceptions thrown by the command.
- */
- final Vector<Throwable> exceptions = new Vector<Throwable>();
-
-
- // ********** construction **********
-
- /**
- * Construct a synchronous synchronizer that uses the specified command to
- * perform the synchronization.
- */
- public SynchronousSynchronizer(Command command) {
- super();
- if (command == null) {
- throw new NullPointerException();
- }
- this.command = command;
- // use the synchronizer as the mutex so it is freed up by the wait in #stop()
- this.state = new SynchronizedObject<State>(State.STOPPED, this);
- }
-
-
- // ********** Synchronizer implementation **********
-
- /**
- * Set the synchronizer's {@link #state} to {@link State#READY READY}
- * and execute the first synchronization. Throw an exception if the
- * synchronizer is not {@link State#STOPPED STOPPED}.
- */
- public synchronized void start() {
- switch (this.state.getValue()) {
- case STOPPED:
- this.state.setValue(State.READY);
- this.synchronize();
- break;
- case READY:
- case EXECUTING:
- case REPEAT:
- case STOPPING:
- throw this.buildISE();
- }
- }
-
- /**
- * It's possible to come back here if the synchronization command recurses
- * and triggers another synchronization.
- */
- public void synchronize() {
- if (this.beginSynchronization()) {
- this.synchronize_();
- }
- }
-
- /**
- * A client has requested a synchronization.
- * Return whether we can begin a new synchronization.
- * If a synchronization is already under way, return <code>false</code>;
- * but set the {@link #state} to {@link State#REPEAT REPEAT}
- * so another synchronization will occur once the current
- * synchronization is complete.
- */
- private synchronized boolean beginSynchronization() {
- switch (this.state.getValue()) {
- case STOPPED:
- // synchronization is not allowed
- return false;
- case READY:
- // begin a new synchronization
- this.state.setValue(State.EXECUTING);
- return true;
- case EXECUTING:
- // set flag so a new synchronization will occur once the current one is finished
- this.state.setValue(State.REPEAT);
- return false;
- case REPEAT:
- // the "repeat" flag is already set
- return false;
- case STOPPING:
- // no further synchronizations are allowed
- return false;
- }
- throw this.buildISE();
- }
-
- /**
- * This method should be called only once per set of "recursing"
- * synchronizations. Any recursive call to {@link #synchronize()} will
- * simply set the {@link #state} to {@link State#REPEAT REPEAT},
- * causing the command to execute again.
- */
- private void synchronize_() {
- do {
- this.execute();
- } while (this.repeatSynchronization());
- }
-
- /**
- * Execute the client-supplied command. Do not allow any unhandled
- * exceptions to kill the thread. Store them up for later pain.
- */
- private void execute() {
- try {
- this.execute_();
- } catch (Throwable ex) {
- this.exceptions.add(ex);
- }
- }
-
- /**
- * By default, just execute the command.
- */
- void execute_() {
- this.command.execute();
- }
-
- /**
- * The current synchronization has finished.
- * Return whether we should begin another synchronization.
- */
- private synchronized boolean repeatSynchronization() {
- switch (this.state.getValue()) {
- case STOPPED:
- case READY:
- throw this.buildISE();
- case EXECUTING:
- // synchronization has finished and there are no outstanding requests for another; return to "ready"
- this.state.setValue(State.READY);
- return false;
- case REPEAT:
- // the "repeat" flag was set; clear it and start another synchronization
- this.state.setValue(State.EXECUTING);
- return true;
- case STOPPING:
- // a client has initiated a "stop"; mark the "stop" complete and perform no more synchronizations
- this.state.setValue(State.STOPPED);
- return false;
- }
- throw this.buildISE();
- }
-
- /**
- * Set the flags so that no further synchronizations occur. If any uncaught
- * exceptions were thrown while the synchronization was executing,
- * wrap them in a composite exception and throw the composite exception.
- */
- public synchronized void stop() {
- switch (this.state.getValue()) {
- case STOPPED:
- throw this.buildISE();
- case READY:
- // simply return to "stopped" state
- this.state.setValue(State.STOPPED);
- break;
- case EXECUTING:
- case REPEAT:
- // set the "stopping" flag and wait until the synchronization has finished
- this.state.setValue(State.STOPPING);
- this.waitUntilStopped();
- break;
- case STOPPING:
- throw this.buildISE();
- }
-
- if (this.exceptions.size() > 0) {
- Throwable[] temp = this.exceptions.toArray(new Throwable[this.exceptions.size()]);
- this.exceptions.clear();
- throw new CompositeException(temp);
- }
- }
-
- /**
- * This wait will free up the synchronizer's synchronized methods
- * (since the synchronizer is the state's mutex).
- */
- private void waitUntilStopped() {
- try {
- this.state.waitUntilValueIs(State.STOPPED);
- } catch (InterruptedException ex) {
- // the thread that called #stop() was interrupted while waiting
- // for the synchronization to finish - ignore;
- // 'state' is still set to 'STOPPING', so the #synchronize_() loop
- // will still stop - we just won't wait around for it...
- }
- }
-
- private IllegalStateException buildISE() {
- return new IllegalStateException("state: " + this.state); //$NON-NLS-1$
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.state);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/Model.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/Model.java
deleted file mode 100644
index 050cb25eb1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/Model.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model;
-
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.TreeChangeListener;
-
-/**
- * Interface to be implemented by models that notify listeners of
- * changes to bound properties, collections, lists, and/or trees.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @see ChangeListener
- * @see StateChangeListener
- * @see PropertyChangeListener
- * @see CollectionChangeListener
- * @see ListChangeListener
- * @see TreeChangeListener
- * @see org.eclipse.jpt.common.utility.internal.model.AbstractModel
- */
-// TODO use objects (IDs?) instead of strings to identify aspects?
-public interface Model {
-
- // ********** change **********
-
- /**
- * Add a listener that listens to all change events.
- * Throw an exception if the same listener is added more than once.
- * The listener cannot be null.
- */
- void addChangeListener(ChangeListener listener);
-
- /**
- * Remove the specified change listener.
- * Throw an exception if the listener is null or if the listener was never added.
- */
- void removeChangeListener(ChangeListener listener);
-
-
- // ********** state change **********
-
- /**
- * Add a listener that listens to all state change events.
- * Throw an exception if the same listener is added more than once.
- * The listener cannot be null.
- */
- void addStateChangeListener(StateChangeListener listener);
-
- /**
- * Remove the specified state change listener.
- * Throw an exception if the listener is null or if the listener was never added.
- */
- void removeStateChangeListener(StateChangeListener listener);
-
-
- // ********** property change **********
-
- /**
- * Add a listener that listens to all property change events with
- * the specified property name.
- * Throw an exception if the same listener is added more than once.
- * The listener cannot be null.
- */
- void addPropertyChangeListener(String propertyName, PropertyChangeListener listener);
-
- /**
- * Remove a listener that listens to all property change events,
- * with the specified property name.
- * Throw an exception if the listener is null or if the listener was never added.
- */
- void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
-
-
- // ********** collection change **********
-
- /**
- * Add a listener that listens to all collection change events with
- * the specified collection name.
- * Throw an exception if the same listener is added more than once.
- * The listener cannot be null.
- */
- void addCollectionChangeListener(String collectionName, CollectionChangeListener listener);
-
- /**
- * Remove a listener that listens to all collection change events,
- * with the specified collection name.
- * Throw an exception if the listener is null or if the listener was never added.
- */
- void removeCollectionChangeListener(String collectionName, CollectionChangeListener listener);
-
-
- // ********** list change **********
-
- /**
- * Add a listener that listens to all list change events with
- * the specified list name.
- * Throw an exception if the same listener is added more than once.
- * The listener cannot be null.
- */
- void addListChangeListener(String listName, ListChangeListener listener);
-
- /**
- * Remove a listener that listens to all list change events,
- * with the specified list name.
- * Throw an exception if the listener is null or if the listener was never added.
- */
- void removeListChangeListener(String listName, ListChangeListener listener);
-
-
- // ********** tree change **********
-
- /**
- * Add a listener that listens to all tree change events with
- * the specified tree name.
- * Throw an exception if the same listener is added more than once.
- * The listener cannot be null.
- */
- void addTreeChangeListener(String treeName, TreeChangeListener listener);
-
- /**
- * Remove a listener that listens to all tree change events,
- * with the specified tree name.
- * Throw an exception if the listener is null or if the listener was never added.
- */
- void removeTreeChangeListener(String treeName, TreeChangeListener listener);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ChangeEvent.java
deleted file mode 100644
index 22247ecfdc..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ChangeEvent.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import java.util.EventObject;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * Abstract class for all the change events that can be fired by models.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public abstract class ChangeEvent extends EventObject {
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a new change event.
- *
- * @param source The object on which the event initially occurred.
- */
- protected ChangeEvent(Model source) {
- super(source);
- }
-
- /**
- * Covariant override.
- */
- @Override
- public Model getSource() {
- return (Model) super.getSource();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- StringTools.appendSimpleToString(sb, this);
- sb.append('(');
- int len = sb.length();
- this.toString(sb);
- if (sb.length() == len) {
- sb.deleteCharAt(len - 1);
- } else {
- sb.append(')');
- }
- return sb.toString();
- }
-
- protected void toString(@SuppressWarnings("unused") StringBuilder sb) {
- // subclasses should override this to do something a bit more helpful
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionAddEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionAddEvent.java
deleted file mode 100644
index c2a2e7bc9c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionAddEvent.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "collection add" event gets delivered whenever a model adds items to a
- * "bound" or "constrained" collection. A <code>CollectionAddEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-/*
- * Design options:
- * - create a collection to wrap a single added or removed item
- * (this is the option we implemented below and in collaborating code)
- * since there is no way to optimize downstream code for
- * single items, we take another performance hit by building
- * a collection each time (@see Collections#singleton(Object))
- * and forcing downstream code to use an iterator every time
- *
- * - fire a separate event for each item added or removed
- * eliminates any potential for optimizations to downstream code
- *
- * - add protocol to support both single items and collections
- * adds conditional logic to downstream code
- */
-public final class CollectionAddEvent extends CollectionEvent {
-
- /** The items added to the collection. */
- private final Object[] items;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new collection add event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the collection that was changed.
- * @param item The item added to the collection.
- */
- public CollectionAddEvent(Model source, String collectionName, Object item) {
- this(source, collectionName, new Object[] {item});
- }
-
- /**
- * Construct a new collection add event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the collection that was changed.
- * @param items The items added to the collection.
- */
- public CollectionAddEvent(Model source, String collectionName, Collection<?> items) {
- this(source, collectionName, items.toArray()); // NPE if 'items' is null
- }
-
- private CollectionAddEvent(Model source, String collectionName, Object[] items) {
- super(source, collectionName);
- this.items = items;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the items added to the collection.
- */
- public Iterable<?> getItems() {
- return new ArrayIterable<Object>(this.items);
- }
-
- /**
- * Return the number of items added to the collection.
- */
- public int getItemsSize() {
- return this.items.length;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(": "); //$NON-NLS-1$
- StringTools.append(sb, this.items);
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public CollectionAddEvent clone(Model newSource) {
- return this.clone(newSource, this.collectionName);
- }
-
- /**
- * Return a copy of the event with the specified source and collection name
- * replacing the current source and collection name.
- */
- public CollectionAddEvent clone(Model newSource, String newCollectionName) {
- return new CollectionAddEvent(newSource, newCollectionName, this.items);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionChangeEvent.java
deleted file mode 100644
index 5c2c75903c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionChangeEvent.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "collection change" event gets delivered whenever a model changes a "bound"
- * or "constrained" collection in a manner that is not easily characterized by
- * the other collection events.
- * A <code>CollectionChangeEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener}.
- * A <code>CollectionChangeEvent</code> is accompanied by the collection name and
- * the current state of the collection.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class CollectionChangeEvent extends CollectionEvent {
-
- /**
- * The the collection in its current state.
- * Clients will need to calculate the necessary changes to synchronize
- * with the collection.
- */
- private final Object[] collection;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new collection change event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the collection that was changed.
- */
- public CollectionChangeEvent(Model source, String collectionName, Collection<?> collection) {
- this(source, collectionName, collection.toArray()); // NPE if 'collection' is null
- }
-
- private CollectionChangeEvent(Model source, String collectionName, Object[] collection) {
- super(source, collectionName);
- this.collection = collection;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the current state of the collection.
- */
- public Iterable<?> getCollection() {
- return new ArrayIterable<Object>(this.collection);
- }
-
- /**
- * Return the number of items in the current state of the collection.
- */
- public int getCollectionSize() {
- return this.collection.length;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(": "); //$NON-NLS-1$
- StringTools.append(sb, this.collection);
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public CollectionChangeEvent clone(Model newSource) {
- return this.clone(newSource, this.collectionName);
- }
-
- /**
- * Return a copy of the event with the specified source and collection name
- * replacing the current source and collection name.
- */
- public CollectionChangeEvent clone(Model newSource, String newCollectionName) {
- return new CollectionChangeEvent(newSource, newCollectionName, this.collection);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionClearEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionClearEvent.java
deleted file mode 100644
index 0fb2adce58..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionClearEvent.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "collection clear" event gets delivered whenever a model clears
- * a "bound" or "constrained" collection. A <code>CollectionClearEvent</code> is sent
- * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class CollectionClearEvent extends CollectionEvent {
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new collection clear event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the collection that was changed.
- */
- public CollectionClearEvent(Model source, String collectionName) {
- super(source, collectionName);
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public CollectionClearEvent clone(Model newSource) {
- return this.clone(newSource, this.collectionName);
- }
-
- /**
- * Return a copy of the event with the specified source and collection name
- * replacing the current source and collection name.
- */
- public CollectionClearEvent clone(Model newSource, String newCollectionName) {
- return new CollectionClearEvent(newSource, newCollectionName);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionEvent.java
deleted file mode 100644
index d3e0bda965..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionEvent.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import org.eclipse.jpt.common.utility.model.Model;
-// TODO add "item/original/nested event" for item changed?
-/**
- * A "collection" event gets delivered whenever a model changes a "bound"
- * or "constrained" collection. A <code>CollectionEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener}.
- * The intent is that any listener
- * can keep itself synchronized with the model's collection via the collection
- * events it receives and need not maintain a reference to the original
- * collection.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public abstract class CollectionEvent extends ChangeEvent {
-
- /** Name of the collection that changed. */
- final String collectionName;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a new collection event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the collection that was changed.
- */
- public CollectionEvent(Model source, String collectionName) {
- super(source);
- if (collectionName == null) {
- throw new NullPointerException();
- }
- this.collectionName = collectionName;
- }
-
- /**
- * Return the programmatic name of the collection that was changed.
- */
- public String getCollectionName() {
- return this.collectionName;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- sb.append(this.collectionName);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionRemoveEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionRemoveEvent.java
deleted file mode 100644
index a12218d9b3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/CollectionRemoveEvent.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "collection remove" event gets delivered whenever a model removes items
- * from a "bound" or "constrained" collection. A <code>CollectionRemoveEvent</code> is sent
- * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-/*
- * See design discussion in CollectionAddEvent
- */
-public final class CollectionRemoveEvent extends CollectionEvent {
-
- /** The items removed from the collection. */
- private final Object[] items;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new collection remove event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the collection that was changed.
- * @param item The item removed from the collection.
- */
- public CollectionRemoveEvent(Model source, String collectionName, Object item) {
- this(source, collectionName, new Object[] {item});
- }
-
- /**
- * Construct a new collection remove event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the collection that was changed.
- * @param items The items removed from the collection.
- */
- public CollectionRemoveEvent(Model source, String collectionName, Collection<?> items) {
- this(source, collectionName, items.toArray()); // NPE if 'items' is null
- }
-
- private CollectionRemoveEvent(Model source, String collectionName, Object[] items) {
- super(source, collectionName);
- this.items = items;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the items removed from the collection.
- */
- public Iterable<?> getItems() {
- return new ArrayIterable<Object>(this.items);
- }
-
- /**
- * Return the number of items removed from the collection.
- */
- public int getItemsSize() {
- return this.items.length;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(": "); //$NON-NLS-1$
- StringTools.append(sb, this.items);
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public CollectionRemoveEvent clone(Model newSource) {
- return this.clone(newSource, this.collectionName);
- }
-
- /**
- * Return a copy of the event with the specified source and collection name
- * replacing the current source and collection name.
- */
- public CollectionRemoveEvent clone(Model newSource, String newCollectionName) {
- return new CollectionRemoveEvent(newSource, newCollectionName, this.items);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListAddEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListAddEvent.java
deleted file mode 100644
index 900740add7..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListAddEvent.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "list add" event gets delivered whenever a model adds items to a
- * "bound" or "constrained" list. A <code>ListAddEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-/*
- * See design discussion in CollectionAddEvent
- */
-public final class ListAddEvent extends ListEvent {
-
- /** The index at which the items were added. */
- private final int index;
-
- /** The items added to the list. */
- private final Object[] items;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new list add event.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- * @param index The index at which the items were added.
- * @param item The item added to the list.
- */
- public ListAddEvent(Model source, String listName, int index, Object item) {
- this(source, listName, index, new Object[] {item});
- }
-
- /**
- * Construct a new list add event.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- * @param index The index at which the items were added.
- * @param items The items added to the list.
- */
- public ListAddEvent(Model source, String listName, int index, List<?> items) {
- this(source, listName, index, items.toArray()); // NPE if 'items' is null
- }
-
- private ListAddEvent(Model source, String listName, int index, Object[] items) {
- super(source, listName);
- this.index = index;
- this.items = items;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the index at which the items were added to the list.
- */
- public int getIndex() {
- return this.index;
- }
-
- /**
- * Return the items added to the list.
- */
- public Iterable<?> getItems() {
- return new ArrayIterable<Object>(this.items);
- }
-
- /**
- * Return the number of items added to the list.
- */
- public int getItemsSize() {
- return this.items.length;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(": "); //$NON-NLS-1$
- StringTools.append(sb, this.items);
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public ListAddEvent clone(Model newSource) {
- return this.clone(newSource, this.listName);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name.
- */
- public ListAddEvent clone(Model newSource, String newListName) {
- return this.clone(newSource, newListName, 0);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name and displacing
- * the index by the specified amount.
- */
- public ListAddEvent clone(Model newSource, String newListName, int offset) {
- return new ListAddEvent(newSource, newListName, this.index + offset, this.items);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListChangeEvent.java
deleted file mode 100644
index ebcf2919c6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListChangeEvent.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "list change" event gets delivered whenever a model changes a "bound"
- * or "constrained" list in a manner that is not easily characterized by
- * the other list events.
- * A <code>ListChangeEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}.
- * A <code>ListChangeEvent</code> is accompanied by the list name and
- * the current state of the list.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class ListChangeEvent extends ListEvent {
-
- /**
- * The the list in its current state.
- * Clients will need to calculate the necessary changes to synchronize
- * with the list.
- */
- private final Object[] list;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new list change event.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- */
- public ListChangeEvent(Model source, String listName, List<?> list) {
- this(source, listName, list.toArray()); // NPE if 'list' is null
- }
-
- private ListChangeEvent(Model source, String listName, Object[] list) {
- super(source, listName);
- this.list = list;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the current state of the list.
- */
- public Iterable<?> getList() {
- return new ArrayIterable<Object>(this.list);
- }
-
- /**
- * Return the number of items in the current state of the list.
- */
- public int getListSize() {
- return this.list.length;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(": "); //$NON-NLS-1$
- StringTools.append(sb, this.list);
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public ListChangeEvent clone(Model newSource) {
- return this.clone(newSource, this.listName);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name.
- */
- public ListChangeEvent clone(Model newSource, String newListName) {
- return new ListChangeEvent(newSource, newListName, this.list);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListClearEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListClearEvent.java
deleted file mode 100644
index 8faf558131..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListClearEvent.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "list clear" event gets delivered whenever a model clears
- * a "bound" or "constrained" list. A <code>ListClearEvent</code> is sent
- * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class ListClearEvent extends ListEvent {
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructor **********
-
- /**
- * Construct a new list clear event.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- */
- public ListClearEvent(Model source, String listName) {
- super(source, listName);
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public ListClearEvent clone(Model newSource) {
- return this.clone(newSource, this.listName);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name.
- */
- public ListClearEvent clone(Model newSource, String newListName) {
- return new ListClearEvent(newSource, newListName);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListEvent.java
deleted file mode 100644
index acd345845c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListEvent.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import org.eclipse.jpt.common.utility.model.Model;
-
-// TODO add "item/original/nested event" for item changed?
-/**
- * A "list" event gets delivered whenever a model changes a "bound"
- * or "constrained" list. A <code>ListEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}.
- * The intent is that any listener
- * can keep itself synchronized with the model's list via the list
- * events it receives and need not maintain a reference to the original
- * list.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class ListEvent extends ChangeEvent {
-
- /** Name of the list that changed. */
- final String listName;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a new list event.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- */
- public ListEvent(Model source, String listName) {
- super(source);
- if (listName == null) {
- throw new NullPointerException();
- }
- this.listName = listName;
- }
-
- /**
- * Return the programmatic name of the list that was changed.
- */
- public String getListName() {
- return this.listName;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- sb.append(this.listName);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListMoveEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListMoveEvent.java
deleted file mode 100644
index 4627edb5b3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListMoveEvent.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "list move" event gets delivered whenever a model moves the elements in
- * a "bound" or "constrained" list. A <code>ListMoveEvent</code> is sent
- * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class ListMoveEvent extends ListEvent {
-
- /** The index to which the items were moved. */
- private final int targetIndex;
-
- /** The index from which the items were moved. */
- private final int sourceIndex;
-
- /** The number of items moved. */
- private final int length;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructor **********
-
- /**
- * Construct a new list move event.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- * @param targetIndex The index to which the items were moved.
- * @param sourceIndex The index from which the items were moved.
- * @param length The number of items moved.
- */
- public ListMoveEvent(Model source, String listName, int targetIndex, int sourceIndex, int length) {
- super(source, listName);
- this.targetIndex = targetIndex;
- this.sourceIndex = sourceIndex;
- this.length = length;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the index to which the items were moved.
- */
- public int getTargetIndex() {
- return this.targetIndex;
- }
-
- /**
- * Return the index from which the items were moved.
- */
- public int getSourceIndex() {
- return this.sourceIndex;
- }
-
- /**
- * Return the number of items moved.
- */
- public int getLength() {
- return this.length;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(": "); //$NON-NLS-1$
- sb.append(this.sourceIndex);
- sb.append(" => "); //$NON-NLS-1$
- sb.append(this.targetIndex);
- sb.append(" length="); //$NON-NLS-1$
- sb.append(this.length);
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public ListMoveEvent clone(Model newSource) {
- return this.clone(newSource, this.listName);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name.
- */
- public ListMoveEvent clone(Model newSource, String newListName) {
- return this.clone(newSource, newListName, 0);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name and displacing
- * the index by the specified amount.
- */
- public ListMoveEvent clone(Model newSource, String newListName, int offset) {
- return new ListMoveEvent(newSource, newListName, this.targetIndex + offset, this.sourceIndex + offset, this.length);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListRemoveEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListRemoveEvent.java
deleted file mode 100644
index 41b82d8ca6..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListRemoveEvent.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "list remove" event gets delivered whenever a model removes items
- * from a "bound" or "constrained" list. A <code>ListRemoveEvent</code> is sent
- * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-/*
- * See design discussion in CollectionAddEvent
- */
-public final class ListRemoveEvent extends ListEvent {
-
- /** The index at which the items were removed. */
- private final int index;
-
- /** The items removed from the list. */
- private final Object[] items;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new list remove event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the list that was changed.
- * @param index The index at which the items were removed.
- * @param item The item removed from the list.
- */
- public ListRemoveEvent(Model source, String listName, int index, Object item) {
- this(source, listName, index, new Object[] {item});
- }
-
- /**
- * Construct a new list remove event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the list that was changed.
- * @param index The index at which the items were removed.
- * @param items The items removed from the list.
- */
- public ListRemoveEvent(Model source, String listName, int index, Collection<?> items) {
- this(source, listName, index, items.toArray()); // NPE if 'items' is null
- }
-
- private ListRemoveEvent(Model source, String listName, int index, Object[] items) {
- super(source, listName);
- this.index = index;
- this.items = items;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the index at which the items were removed from the list.
- */
- public int getIndex() {
- return this.index;
- }
-
- /**
- * Return the items removed from the list.
- */
- public Iterable<?> getItems() {
- return new ArrayIterable<Object>(this.items);
- }
-
- /**
- * Return the number of items removed from the list.
- */
- public int getItemsSize() {
- return this.items.length;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(": "); //$NON-NLS-1$
- StringTools.append(sb, this.items);
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public ListRemoveEvent clone(Model newSource) {
- return this.clone(newSource, this.listName);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name.
- */
- public ListRemoveEvent clone(Model newSource, String newListName) {
- return this.clone(newSource, newListName, 0);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name and displacing
- * the index by the specified amount.
- */
- public ListRemoveEvent clone(Model newSource, String newListName, int offset) {
- return new ListRemoveEvent(newSource, newListName, this.index + offset, this.items);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListReplaceEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListReplaceEvent.java
deleted file mode 100644
index dd6f3760e0..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/ListReplaceEvent.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "list replace" event gets delivered whenever a model replaces items in a
- * "bound" or "constrained" list. A <code>ListReplaceEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.ListChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class ListReplaceEvent extends ListEvent {
-
- /** The index at which the items were replaced. */
- private final int index;
-
- /** The new items that replaced the old items in the list. */
- private final Object[] newItems;
-
- /** The old items that were replaced by the new items in the list. */
- private final Object[] oldItems;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new list replace event for a list of replaced items.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- * @param index The index at which the item in the list was replaced.
- * @param newItem The new item in the list.
- * @param oldItem The old item in the list that were replaced.
- */
- public ListReplaceEvent(Model source, String listName, int index, Object newItem, Object oldItem) {
- this(source, listName, index, new Object[] {newItem}, new Object[] {oldItem});
- }
-
- /**
- * Construct a new list replace event for a list of replaced items.
- *
- * @param source The object on which the event initially occurred.
- * @param listName The programmatic name of the list that was changed.
- * @param index The index at which the items in the list were replaced.
- * @param newItems The new items in the list.
- * @param oldItems The old items in the list that were replaced.
- */
- public ListReplaceEvent(Model source, String listName, int index, List<?> newItems, List<?> oldItems) {
- this(source, listName, index, newItems.toArray(), oldItems.toArray()); // NPE if either 'newItems' or 'oldItems' is null
- }
-
- private ListReplaceEvent(Model source, String listName, int index, Object[] newItems, Object[] oldItems) {
- super(source, listName);
- if (newItems.length != oldItems.length) {
- throw new IllegalArgumentException("sizes must match - new items size: " + newItems.length //$NON-NLS-1$
- + " old items size: " + oldItems.length); //$NON-NLS-1$
- }
- this.index = index;
- this.newItems = newItems;
- this.oldItems = oldItems;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the index at which the items were replaced in the list.
- */
- public int getIndex() {
- return this.index;
- }
-
- /**
- * Return the new items that replaced the old items in the list.
- */
- public Iterable<?> getNewItems() {
- return new ArrayIterable<Object>(this.newItems);
- }
-
- /**
- * Return the old items that were replaced by the new items in the list.
- */
- public Iterable<?> getOldItems() {
- return new ArrayIterable<Object>(this.oldItems);
- }
-
- /**
- * Return the number of items that were replaced.
- */
- public int getItemsSize() {
- return this.newItems.length;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(": "); //$NON-NLS-1$
- StringTools.append(sb, this.oldItems);
- sb.append(" => "); //$NON-NLS-1$
- StringTools.append(sb, this.newItems);
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public ListReplaceEvent clone(Model newSource) {
- return this.clone(newSource, this.listName);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name.
- */
- public ListReplaceEvent clone(Model newSource, String newListName) {
- return this.clone(newSource, newListName, 0);
- }
-
- /**
- * Return a copy of the event with the specified source and list name
- * replacing the current source and list name and displacing
- * the index by the specified amount.
- */
- public ListReplaceEvent clone(Model newSource, String newListName, int offset) {
- return new ListReplaceEvent(newSource, newListName, this.index + offset, this.newItems, this.oldItems);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/PropertyChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/PropertyChangeEvent.java
deleted file mode 100644
index 55c7475e85..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/PropertyChangeEvent.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "property change" event gets delivered whenever a model changes a "bound"
- * or "constrained" property. A <code>PropertyChangeEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener}.
- * A <code>PropertyChangeEvent</code> is accompanied by the old and new values
- * of the property.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class PropertyChangeEvent extends ChangeEvent {
-
- /** Name of the property that changed. */
- private final String propertyName;
-
- /** The property's old value, before the change. */
- private final Object oldValue;
-
- /** The property's new value, after the change. */
- private final Object newValue;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new property change event.
- *
- * @param source The object on which the event initially occurred.
- * @param propertyName The programmatic name of the property that was changed.
- * @param oldValue The old value of the property.
- * @param newValue The new value of the property.
- */
- public PropertyChangeEvent(Model source, String propertyName, Object oldValue, Object newValue) {
- super(source);
- if (propertyName == null) {
- throw new NullPointerException();
- }
- this.propertyName = propertyName;
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the programmatic name of the property that was changed.
- */
- public String getPropertyName() {
- return this.propertyName;
- }
-
- /**
- * Return the old value of the property.
- */
- public Object getOldValue() {
- return this.oldValue;
- }
-
- /**
- * Return the new value of the property.
- */
- public Object getNewValue() {
- return this.newValue;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- sb.append(this.propertyName);
- sb.append(": "); //$NON-NLS-1$
- sb.append(this.oldValue);
- sb.append(" => "); //$NON-NLS-1$
- sb.append(this.newValue);
- }
-
-
- // ********** cloning **********
-
- public PropertyChangeEvent clone(Model newSource) {
- return new PropertyChangeEvent(newSource, this.propertyName, this.oldValue, this.newValue);
- }
-
- /**
- * Return a copy of the event with the specified source and property name
- * replacing the current source and property name.
- */
- public PropertyChangeEvent clone(Model newSource, String newPropertyName) {
- return new PropertyChangeEvent(newSource, newPropertyName, this.oldValue, this.newValue);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/StateChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/StateChangeEvent.java
deleted file mode 100644
index fdac399c4b..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/StateChangeEvent.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A generic "state change" event gets delivered whenever a model changes to
- * such extent that it cannot be delineated all aspects of it that have changed.
- * Any listener can synchronize with the model as necessary since the model is
- * available as the event's 'source'.
- * A <code>StateChangeEvent</code> is sent as an argument to the
- * {@link org.eclipse.jpt.common.utility.model.listener.StateChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class StateChangeEvent extends ChangeEvent {
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new state change event.
- *
- * @param source The object on which the event initially occurred.
- */
- public StateChangeEvent(Model source) {
- super(source);
- }
-
-
- // ********** cloning **********
-
- public StateChangeEvent clone(Model newSource) {
- return new StateChangeEvent(newSource);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeAddEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeAddEvent.java
deleted file mode 100644
index 0550271a5d..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeAddEvent.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "tree add" event gets delivered whenever a model adds a node to a "bound"
- * or "constrained" tree. A <code>TreeChangeEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.TreeChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class TreeAddEvent extends TreeEvent {
-
- /**
- * Path to the node added to the tree.
- */
- protected final Object[] path;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new tree add event.
- *
- * @param source The object on which the event initially occurred.
- * @param treeName The programmatic name of the tree that was changed.
- * @param path The path to the part of the tree that was added.
- */
- public TreeAddEvent(Model source, String treeName, List<?> path) {
- this(source, treeName, path.toArray()); // NPE if 'path' is null
- }
-
- private TreeAddEvent(Model source, String treeName, Object[] path) {
- super(source, treeName);
- this.path = path;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the path to the part of the tree that was added.
- */
- public Iterable<?> getPath() {
- return new ArrayIterable<Object>(this.path);
- }
-
-
- // ********** cloning **********
-
- public TreeAddEvent clone(Model newSource) {
- return this.clone(newSource, this.treeName);
- }
-
- /**
- * Return a copy of the event with the specified source and tree name
- * replacing the current source and tree name.
- */
- public TreeAddEvent clone(Model newSource, String newTreeName) {
- return new TreeAddEvent(newSource, newTreeName, this.path);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeChangeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeChangeEvent.java
deleted file mode 100644
index 7ad7e03db5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeChangeEvent.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import java.util.Collection;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "tree change" event gets delivered whenever a model changes a "bound"
- * or "constrained" tree in a manner that is not easily characterized by
- * the other tree events.
- * A <code>TreeChangeEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.TreeChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class TreeChangeEvent extends TreeEvent {
-
- /**
- * The current nodes in the changed tree.
- */
- protected final Object[] nodes;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructor **********
-
- /**
- * Construct a new tree change event.
- *
- * @param source The object on which the event initially occurred.
- * @param treeName The programmatic name of the tree that was changed.
- * @param nodes The current nodes in the changed tree.
- */
- public TreeChangeEvent(Model source, String treeName, Collection<?> nodes) {
- this(source, treeName, nodes.toArray()); // NPE if 'nodes' is null
- }
-
- private TreeChangeEvent(Model source, String treeName, Object[] nodes) {
- super(source, treeName);
- this.nodes = nodes;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the current nodes in the changed tree.
- */
- public Iterable<?> getNodes() {
- return new ArrayIterable<Object>(this.nodes);
- }
-
- /**
- * Return the current nodes in the changed tree.
- */
- public int getNodesSize() {
- return this.nodes.length;
- }
-
-
- // ********** cloning **********
-
- public TreeChangeEvent clone(Model newSource) {
- return this.clone(newSource, this.treeName);
- }
-
- /**
- * Return a copy of the event with the specified source and tree name
- * replacing the current source and tree name.
- */
- public TreeChangeEvent clone(Model newSource, String newTreeName) {
- return new TreeChangeEvent(newSource, newTreeName, this.nodes);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeClearEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeClearEvent.java
deleted file mode 100644
index 6d96568a7f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeClearEvent.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "tree clear" event gets delivered whenever a model clears
- * a "bound" or "constrained" tree. A <code>TreeClearEvent</code> is sent
- * as an argument to the {@link org.eclipse.jpt.common.utility.model.listener.TreeChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class TreeClearEvent extends TreeEvent {
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new tree clear event.
- *
- * @param source The object on which the event initially occurred.
- * @param collectionName The programmatic name of the tree that was changed.
- */
- public TreeClearEvent(Model source, String treeName) {
- super(source, treeName);
- }
-
-
- // ********** cloning **********
-
- /**
- * Return a copy of the event with the specified source
- * replacing the current source.
- */
- public TreeClearEvent clone(Model newSource) {
- return this.clone(newSource, this.treeName);
- }
-
- /**
- * Return a copy of the event with the specified source and collection name
- * replacing the current source and collection name.
- */
- public TreeClearEvent clone(Model newSource, String newCollectionName) {
- return new TreeClearEvent(newSource, newCollectionName);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeEvent.java
deleted file mode 100644
index e57777aef1..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeEvent.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "tree" event gets delivered whenever a model changes a "bound"
- * or "constrained" tree. A <code>TreeEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.TreeChangeListener}.
- * The intent is that any listener
- * can keep itself synchronized with the model's tree via the tree events
- * it receives and need not maintain a reference to the original tree.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public abstract class TreeEvent extends ChangeEvent {
-
- /** Name of the tree that changed. */
- final String treeName;
-
- private static final long serialVersionUID = 1L;
-
-
- /**
- * Construct a new tree event.
- *
- * @param source The object on which the event initially occurred.
- * @param treeName The programmatic name of the tree that was changed.
- */
- public TreeEvent(Model source, String treeName) {
- super(source);
- if (treeName == null) {
- throw new NullPointerException();
- }
- this.treeName = treeName;
- }
-
- /**
- * Return the programmatic name of the tree that was changed.
- */
- public String getTreeName() {
- return this.treeName;
- }
-
- @Override
- protected void toString(StringBuilder sb) {
- sb.append(this.treeName);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeRemoveEvent.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeRemoveEvent.java
deleted file mode 100644
index afa3157678..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/event/TreeRemoveEvent.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.event;
-
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * A "tree remove" event gets delivered whenever a model removes a node rom a
- * "bound" or "constrained" tree. A <code>TreeChangeEvent</code> is sent as an
- * argument to the {@link org.eclipse.jpt.common.utility.model.listener.TreeChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public final class TreeRemoveEvent extends TreeEvent {
-
- /**
- * Path to the node removed from the tree.
- */
- protected final Object[] path;
-
- private static final long serialVersionUID = 1L;
-
-
- // ********** constructors **********
-
- /**
- * Construct a new tree remove event.
- *
- * @param source The object on which the event initially occurred.
- * @param treeName The programmatic name of the tree that was changed.
- * @param path The path to the part of the tree that was removed.
- */
- public TreeRemoveEvent(Model source, String treeName, List<?> path) {
- this(source, treeName, path.toArray()); // NPE if 'path' is null
- }
-
- private TreeRemoveEvent(Model source, String treeName, Object[] path) {
- super(source, treeName);
- this.path = path;
- }
-
-
- // ********** standard state **********
-
- /**
- * Return the path to the part of the tree that was removed.
- */
- public Iterable<?> getPath() {
- return new ArrayIterable<Object>(this.path);
- }
-
-
- // ********** cloning **********
-
- public TreeRemoveEvent clone(Model newSource) {
- return this.clone(newSource, this.treeName);
- }
-
- /**
- * Return a copy of the event with the specified source and tree name
- * replacing the current source and tree name.
- */
- public TreeRemoveEvent clone(Model newSource, String newTreeName) {
- return new TreeRemoveEvent(newSource, newTreeName, this.path);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/AbstractChangeListener.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/AbstractChangeListener.java
deleted file mode 100644
index 45ff18ecc2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/AbstractChangeListener.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.ChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-
-/**
- * Convenience abstract implementation of {@link ChangeListener}.
- * All change notifications are funneled through a single method.
- * This class can be used by
- * subclassing it and overriding either {@link #modelChanged(ChangeEvent)}
- * (if access to the event is required) or {@link #modelChanged()} (if access
- * to the event is not required).
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public abstract class AbstractChangeListener
- implements ChangeListener
-{
- public AbstractChangeListener() {
- super();
- }
-
- public void stateChanged(StateChangeEvent event) {
- this.modelChanged(event);
- }
-
- public void propertyChanged(PropertyChangeEvent event) {
- this.modelChanged(event);
- }
-
- public void collectionChanged(CollectionChangeEvent event) {
- this.modelChanged(event);
- }
-
- public void collectionCleared(CollectionClearEvent event) {
- this.modelChanged(event);
- }
-
- public void itemsAdded(CollectionAddEvent event) {
- this.modelChanged(event);
- }
-
- public void itemsRemoved(CollectionRemoveEvent event) {
- this.modelChanged(event);
- }
-
- public void itemsAdded(ListAddEvent event) {
- this.modelChanged(event);
- }
-
- public void itemsMoved(ListMoveEvent event) {
- this.modelChanged(event);
- }
-
- public void itemsRemoved(ListRemoveEvent event) {
- this.modelChanged(event);
- }
-
- public void itemsReplaced(ListReplaceEvent event) {
- this.modelChanged(event);
- }
-
- public void listChanged(ListChangeEvent event) {
- this.modelChanged(event);
- }
-
- public void listCleared(ListClearEvent event) {
- this.modelChanged(event);
- }
-
- public void nodeAdded(TreeAddEvent event) {
- this.modelChanged(event);
- }
-
- public void nodeRemoved(TreeRemoveEvent event) {
- this.modelChanged(event);
- }
-
- public void treeChanged(TreeChangeEvent event) {
- this.modelChanged(event);
- }
-
- public void treeCleared(TreeClearEvent event) {
- this.modelChanged(event);
- }
-
- /**
- * The model has notified the listener of the change described by the
- * specified change event. By default the listener executes {@link #modelChanged()}.
- */
- protected void modelChanged(@SuppressWarnings("unused") ChangeEvent event) {
- this.modelChanged();
- }
-
- /**
- * The model has notified the listener of a change.
- * By default the listener throws an exception.
- */
- protected void modelChanged() {
- throw new RuntimeException("This method was not overridden."); //$NON-NLS-1$
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ChangeAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ChangeAdapter.java
deleted file mode 100644
index 1567b90b9c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ChangeAdapter.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-
-/**
- * Convenience implementation of {@link ChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class ChangeAdapter
- implements ChangeListener
-{
- public ChangeAdapter() {
- super();
- }
-
- // ***** state
- public void stateChanged(StateChangeEvent event) {
- // do nothing
- }
-
- // ***** property
- public void propertyChanged(PropertyChangeEvent event) {
- // do nothing
- }
-
- // ***** collection
- public void itemsAdded(CollectionAddEvent event) {
- // do nothing
- }
-
- public void itemsRemoved(CollectionRemoveEvent event) {
- // do nothing
- }
-
- public void collectionCleared(CollectionClearEvent event) {
- // do nothing
- }
-
- public void collectionChanged(CollectionChangeEvent event) {
- // do nothing
- }
-
- // ***** list
- public void itemsAdded(ListAddEvent event) {
- // do nothing
- }
-
- public void itemsRemoved(ListRemoveEvent event) {
- // do nothing
- }
-
- public void itemsReplaced(ListReplaceEvent event) {
- // do nothing
- }
-
- public void itemsMoved(ListMoveEvent event) {
- // do nothing
- }
-
- public void listCleared(ListClearEvent event) {
- // do nothing
- }
-
- public void listChanged(ListChangeEvent event) {
- // do nothing
- }
-
- // ***** tree
- public void nodeAdded(TreeAddEvent event) {
- // do nothing
- }
-
- public void nodeRemoved(TreeRemoveEvent event) {
- // do nothing
- }
-
- public void treeCleared(TreeClearEvent event) {
- // do nothing
- }
-
- public void treeChanged(TreeChangeEvent event) {
- // do nothing
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ChangeListener.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ChangeListener.java
deleted file mode 100644
index c5c6203fac..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ChangeListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-/**
- * General purpose change listener.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ChangeListener
- extends StateChangeListener, PropertyChangeListener, CollectionChangeListener, ListChangeListener, TreeChangeListener
-{
- // combine the other listener interfaces
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CollectionChangeAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CollectionChangeAdapter.java
deleted file mode 100644
index 516f5551ab..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CollectionChangeAdapter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-
-/**
- * Convenience implementation of {@link CollectionChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class CollectionChangeAdapter
- implements CollectionChangeListener
-{
- public CollectionChangeAdapter() {
- super();
- }
-
- public void itemsAdded(CollectionAddEvent event) {
- // do nothing
- }
-
- public void itemsRemoved(CollectionRemoveEvent event) {
- // do nothing
- }
-
- public void collectionCleared(CollectionClearEvent event) {
- // do nothing
- }
-
- public void collectionChanged(CollectionChangeEvent event) {
- // do nothing
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CollectionChangeListener.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CollectionChangeListener.java
deleted file mode 100644
index a8ff66487c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CollectionChangeListener.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import java.util.EventListener;
-
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-
-/**
- * A "collection change" event gets fired whenever a model changes a "bound"
- * collection. You can register a <code>CollectionChangeListener</code> with a source
- * model so as to be notified of any bound collection updates.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface CollectionChangeListener extends EventListener {
-
- /**
- * This method gets called when items are added to a bound collection.
- *
- * @param event An event describing the event source,
- * the collection that changed, and the items that were added.
- */
- void itemsAdded(CollectionAddEvent event);
-
- /**
- * This method gets called when items are removed from a bound collection.
- *
- * @param event An event describing the event source,
- * the collection that changed, and the items that were removed.
- */
- void itemsRemoved(CollectionRemoveEvent event);
-
- /**
- * This method gets called when a bound collection is cleared.
- *
- * @param event An event describing the event source
- * and the collection that changed.
- */
- void collectionCleared(CollectionClearEvent event);
-
- /**
- * This method gets called when a bound collection is changed in a manner
- * that is not easily characterized by the other methods in this interface.
- *
- * @param event An event describing the event source
- * and the collection that changed.
- */
- void collectionChanged(CollectionChangeEvent event);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CommandChangeListener.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CommandChangeListener.java
deleted file mode 100644
index 8d601eb571..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/CommandChangeListener.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import org.eclipse.jpt.common.utility.command.Command;
-
-/**
- * Convenience implementation of {@link ChangeListener}.
- * All change notifications are funneled through a single command.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class CommandChangeListener
- extends AbstractChangeListener
-{
- protected final Command command;
-
- /**
- * Construct a change listener that executes the specified command whenever
- * it receives any change notification from the model to which it is added
- * as a listener.
- */
- public CommandChangeListener(Command command) {
- super();
- this.command = command;
- }
-
- @Override
- protected void modelChanged() {
- this.command.execute();
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ListChangeAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ListChangeAdapter.java
deleted file mode 100644
index bff54138bf..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ListChangeAdapter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-
-/**
- * Convenience implementation of {@link ListChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class ListChangeAdapter
- implements ListChangeListener
-{
- public ListChangeAdapter() {
- super();
- }
-
- public void itemsAdded(ListAddEvent event) {
- // do nothing
- }
-
- public void itemsRemoved(ListRemoveEvent event) {
- // do nothing
- }
-
- public void itemsReplaced(ListReplaceEvent event) {
- // do nothing
- }
-
- public void itemsMoved(ListMoveEvent event) {
- // do nothing
- }
-
- public void listCleared(ListClearEvent event) {
- // do nothing
- }
-
- public void listChanged(ListChangeEvent event) {
- // do nothing
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ListChangeListener.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ListChangeListener.java
deleted file mode 100644
index 0680c551bb..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ListChangeListener.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import java.util.EventListener;
-
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-
-/**
- * A "list change" event gets fired whenever a model changes a "bound"
- * list. You can register a <code>ListChangeListener</code> with a source
- * model so as to be notified of any bound list updates.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface ListChangeListener extends EventListener {
-
- /**
- * This method gets called when items are added to a bound list.
- *
- * @param event An event describing the event source,
- * the list that changed, the items that were added, and the index
- * at which the items were added.
- */
- void itemsAdded(ListAddEvent event);
-
- /**
- * This method gets called when items are removed from a bound list.
- *
- * @param event An event describing the event source,
- * the list that changed, the items that were removed, and the index
- * at which the items were removed.
- */
- void itemsRemoved(ListRemoveEvent event);
-
- /**
- * This method gets called when items in a bound list are replaced.
- *
- * @param event An event describing the event source,
- * the list that changed, the items that were added, the items that were
- * replaced, and the index at which the items were replaced.
- */
- void itemsReplaced(ListReplaceEvent event);
-
- /**
- * This method gets called when items in a bound list are moved.
- *
- * @param event An event describing the event source,
- * the list that changed, and the indices of where items were moved
- * from and to.
- */
- void itemsMoved(ListMoveEvent event);
-
- /**
- * This method gets called when a bound list is cleared.
- *
- * @param event A ListClearEvent object describing the event source
- * and the list that changed.
- */
- void listCleared(ListClearEvent event);
-
- /**
- * This method gets called when a bound list is changed in a manner
- * that is not easily characterized by the other methods in this interface.
- *
- * @param event A ListChangeEvent object describing the event source
- * and the list that changed.
- */
- void listChanged(ListChangeEvent event);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/MultiMethodReflectiveChangeListener.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/MultiMethodReflectiveChangeListener.java
deleted file mode 100644
index 45762bf06c..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/MultiMethodReflectiveChangeListener.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-
-/**
- * This class is used by {@link ReflectiveChangeListener} when the requested listener
- * needs to implement multiple methods (i.e. {@link CollectionChangeListener},
- * {@link ListChangeListener}, or {@link TreeChangeListener}).
- */
-class MultiMethodReflectiveChangeListener
- extends ReflectiveChangeListener
- implements CollectionChangeListener, ListChangeListener, TreeChangeListener
-{
- /** the methods we will invoke on the target object */
- private final Method addMethod;
- private final Method removeMethod;
- private final Method replaceMethod; // this can be null
- private final Method moveMethod; // this can be null
- private final Method clearMethod;
- private final Method changeMethod;
-
-
- /**
- * The "replace" and "move" methods are optional.
- */
- MultiMethodReflectiveChangeListener(Object target, Method addMethod, Method removeMethod, Method replaceMethod, Method moveMethod, Method clearMethod, Method changeMethod) {
- super(target);
- this.addMethod = addMethod;
- this.removeMethod = removeMethod;
- this.replaceMethod = replaceMethod;
- this.moveMethod = moveMethod;
- this.clearMethod = clearMethod;
- this.changeMethod = changeMethod;
- }
-
- /**
- * No "replace" or "move" methods.
- */
- MultiMethodReflectiveChangeListener(Object target, Method addMethod, Method removeMethod, Method clearMethod, Method changeMethod) {
- this(target, addMethod, removeMethod, null, null, clearMethod, changeMethod);
- }
-
-
- // ********** CollectionChangeListener implementation **********
-
- private void invoke(Method method, CollectionEvent event) {
- if (method.getParameterTypes().length == 0) {
- ReflectionTools.executeMethod(method, this.target, EMPTY_OBJECT_ARRAY);
- } else {
- ReflectionTools.executeMethod(method, this.target, new CollectionEvent[] {event});
- }
- }
-
- public void itemsAdded(CollectionAddEvent event) {
- this.invoke(this.addMethod, event);
- }
-
- public void itemsRemoved(CollectionRemoveEvent event) {
- this.invoke(this.removeMethod, event);
- }
-
- public void collectionCleared(CollectionClearEvent event) {
- this.invoke(this.clearMethod, event);
- }
-
- public void collectionChanged(CollectionChangeEvent event) {
- this.invoke(this.changeMethod, event);
- }
-
-
- // ********** ListChangeListener implementation **********
-
- private void invoke(Method method, ListEvent event) {
- if (method.getParameterTypes().length == 0) {
- ReflectionTools.executeMethod(method, this.target, EMPTY_OBJECT_ARRAY);
- } else {
- ReflectionTools.executeMethod(method, this.target, new ListEvent[] {event});
- }
- }
-
- public void itemsAdded(ListAddEvent event) {
- this.invoke(this.addMethod, event);
- }
-
- public void itemsRemoved(ListRemoveEvent event) {
- this.invoke(this.removeMethod, event);
- }
-
- public void itemsReplaced(ListReplaceEvent event) {
- this.invoke(this.replaceMethod, event);
- }
-
- public void itemsMoved(ListMoveEvent event) {
- this.invoke(this.moveMethod, event);
- }
-
- public void listCleared(ListClearEvent event) {
- this.invoke(this.clearMethod, event);
- }
-
- public void listChanged(ListChangeEvent event) {
- this.invoke(this.changeMethod, event);
- }
-
-
- // ********** TreeChangeListener implementation **********
-
- private void invoke(Method method, TreeEvent event) {
- if (method.getParameterTypes().length == 0) {
- ReflectionTools.executeMethod(method, this.target, EMPTY_OBJECT_ARRAY);
- } else {
- ReflectionTools.executeMethod(method, this.target, new TreeEvent[] {event});
- }
- }
-
- public void nodeAdded(TreeAddEvent event) {
- this.invoke(this.addMethod, event);
- }
-
- public void nodeRemoved(TreeRemoveEvent event) {
- this.invoke(this.removeMethod, event);
- }
-
- public void treeCleared(TreeClearEvent event) {
- this.invoke(this.clearMethod, event);
- }
-
- public void treeChanged(TreeChangeEvent event) {
- this.invoke(this.changeMethod, event);
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/PropertyChangeAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/PropertyChangeAdapter.java
deleted file mode 100644
index 01f54eab3f..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/PropertyChangeAdapter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-
-/**
- * Convenience implementation of {@link PropertyChangeListener}.
- * This is probably of limited use, since there only a single method to implement;
- * maybe it is useful as a null implementation. One minor benefit is the
- * implementation of {@link #toString()}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class PropertyChangeAdapter
- implements PropertyChangeListener
-{
- public PropertyChangeAdapter() {
- super();
- }
-
- public void propertyChanged(PropertyChangeEvent event) {
- // do nothing
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/PropertyChangeListener.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/PropertyChangeListener.java
deleted file mode 100644
index 4bb488f14a..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/PropertyChangeListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import java.util.EventListener;
-
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-
-/**
- * A "property change" event gets fired whenever a model changes a "bound"
- * property. You can register a <code>PropertyChangeListener</code> with a source
- * model so as to be notified of any bound property updates.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface PropertyChangeListener extends EventListener {
-
- /**
- * This method gets called when a model has changed a bound property.
- *
- * @param event An event describing the event source
- * and the property's old and new values.
- */
- void propertyChanged(PropertyChangeEvent event);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ReflectiveChangeListener.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ReflectiveChangeListener.java
deleted file mode 100644
index 8a24cd5073..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/ReflectiveChangeListener.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import java.lang.reflect.Method;
-
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.model.event.ChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-
-/**
- * This factory builds listeners that reflectively forward change events.
- * If you are worried about having too many little classes that have to be
- * loaded and maintained by the class loader, you can use one of these.
- * Of course, this comes with the additional overhead of reflection....
- * Also note that the validity of the method name is not checked at compile
- * time, but at runtime; although we <em>do</em> check the method as soon as the
- * listener is instantiated.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public abstract class ReflectiveChangeListener {
-
- /** the target object on which we will invoke the method */
- protected final Object target;
-
-
- protected static final Class<StateChangeEvent> STATE_CHANGE_EVENT_CLASS = StateChangeEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<StateChangeEvent>[] STATE_CHANGE_EVENT_CLASS_ARRAY = new Class[] {STATE_CHANGE_EVENT_CLASS};
-
-
- protected static final Class<PropertyChangeEvent> PROPERTY_CHANGE_EVENT_CLASS = PropertyChangeEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<PropertyChangeEvent>[] PROPERTY_CHANGE_EVENT_CLASS_ARRAY = new Class[] {PROPERTY_CHANGE_EVENT_CLASS};
-
-
- protected static final Class<CollectionEvent> COLLECTION_EVENT_CLASS = CollectionEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<CollectionEvent>[] COLLECTION_EVENT_CLASS_ARRAY = new Class[] {COLLECTION_EVENT_CLASS};
-
- protected static final Class<CollectionAddEvent> COLLECTION_ADD_EVENT_CLASS = CollectionAddEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<CollectionAddEvent>[] COLLECTION_ADD_EVENT_CLASS_ARRAY = new Class[] {COLLECTION_ADD_EVENT_CLASS};
-
- protected static final Class<CollectionRemoveEvent> COLLECTION_REMOVE_EVENT_CLASS = CollectionRemoveEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<CollectionRemoveEvent>[] COLLECTION_REMOVE_EVENT_CLASS_ARRAY = new Class[] {COLLECTION_REMOVE_EVENT_CLASS};
-
- protected static final Class<CollectionClearEvent> COLLECTION_CLEAR_EVENT_CLASS = CollectionClearEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<CollectionClearEvent>[] COLLECTION_CLEAR_EVENT_CLASS_ARRAY = new Class[] {COLLECTION_CLEAR_EVENT_CLASS};
-
- protected static final Class<CollectionChangeEvent> COLLECTION_CHANGE_EVENT_CLASS = CollectionChangeEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<CollectionChangeEvent>[] COLLECTION_CHANGE_EVENT_CLASS_ARRAY = new Class[] {COLLECTION_CHANGE_EVENT_CLASS};
-
-
- protected static final Class<ListEvent> LIST_EVENT_CLASS = ListEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<ListEvent>[] LIST_EVENT_CLASS_ARRAY = new Class[] {LIST_EVENT_CLASS};
-
- protected static final Class<ListAddEvent> LIST_ADD_EVENT_CLASS = ListAddEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<ListAddEvent>[] LIST_ADD_EVENT_CLASS_ARRAY = new Class[] {LIST_ADD_EVENT_CLASS};
-
- protected static final Class<ListRemoveEvent> LIST_REMOVE_EVENT_CLASS = ListRemoveEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<ListRemoveEvent>[] LIST_REMOVE_EVENT_CLASS_ARRAY = new Class[] {LIST_REMOVE_EVENT_CLASS};
-
- protected static final Class<ListReplaceEvent> LIST_REPLACE_EVENT_CLASS = ListReplaceEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<ListReplaceEvent>[] LIST_REPLACE_EVENT_CLASS_ARRAY = new Class[] {LIST_REPLACE_EVENT_CLASS};
-
- protected static final Class<ListMoveEvent> LIST_MOVE_EVENT_CLASS = ListMoveEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<ListMoveEvent>[] LIST_MOVE_EVENT_CLASS_ARRAY = new Class[] {LIST_MOVE_EVENT_CLASS};
-
- protected static final Class<ListClearEvent> LIST_CLEAR_EVENT_CLASS = ListClearEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<ListClearEvent>[] LIST_CLEAR_EVENT_CLASS_ARRAY = new Class[] {LIST_CLEAR_EVENT_CLASS};
-
- protected static final Class<ListChangeEvent> LIST_CHANGE_EVENT_CLASS = ListChangeEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<ListChangeEvent>[] LIST_CHANGE_EVENT_CLASS_ARRAY = new Class[] {LIST_CHANGE_EVENT_CLASS};
-
-
- protected static final Class<TreeEvent> TREE_EVENT_CLASS = TreeEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<TreeEvent>[] TREE_EVENT_CLASS_ARRAY = new Class[] {TREE_EVENT_CLASS};
-
- protected static final Class<TreeAddEvent> TREE_ADD_EVENT_CLASS = TreeAddEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<TreeAddEvent>[] TREE_ADD_EVENT_CLASS_ARRAY = new Class[] {TREE_ADD_EVENT_CLASS};
-
- protected static final Class<TreeRemoveEvent> TREE_REMOVE_EVENT_CLASS = TreeRemoveEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<TreeRemoveEvent>[] TREE_REMOVE_EVENT_CLASS_ARRAY = new Class[] {TREE_REMOVE_EVENT_CLASS};
-
- protected static final Class<TreeClearEvent> TREE_CLEAR_EVENT_CLASS = TreeClearEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<TreeClearEvent>[] TREE_CLEAR_EVENT_CLASS_ARRAY = new Class[] {TREE_CLEAR_EVENT_CLASS};
-
- protected static final Class<TreeChangeEvent> TREE_CHANGE_EVENT_CLASS = TreeChangeEvent.class;
- @SuppressWarnings("unchecked")
- protected static final Class<TreeChangeEvent>[] TREE_CHANGE_EVENT_CLASS_ARRAY = new Class[] {TREE_CHANGE_EVENT_CLASS};
-
- protected static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
-
-
- // ********** helper methods **********
-
- /**
- * Find and return a method implemented by the target that can be invoked
- * reflectively when a change event occurs.
- */
- private static Method findChangeListenerMethod(Object target, String methodName, Class<? extends ChangeEvent>[] eventClassArray) {
- try {
- return ReflectionTools.getMethod(target, methodName, eventClassArray);
- } catch (RuntimeException ex1) {
- return ReflectionTools.getMethod(target, methodName);
- }
- }
-
- /**
- * Check whether the specified method is suitable for being invoked when a
- * change event has occurred. Throw an exception if it is not suitable.
- */
- private static void checkChangeListenerMethod(Method method, Class<? extends ChangeEvent> eventClass) {
- Class<?>[] parmTypes = method.getParameterTypes();
- int parmTypesLength = parmTypes.length;
- if (parmTypesLength == 0) {
- return;
- }
- if ((parmTypesLength == 1) && parmTypes[0].isAssignableFrom(eventClass)) {
- return;
- }
- throw new IllegalArgumentException(method.toString());
- }
-
-
- // ********** factory methods: StateChangeListener **********
-
- /**
- * Construct a state change listener that will invoke the specified method
- * on the specified target.
- */
- public static StateChangeListener buildStateChangeListener(Object target, Method method) {
- checkChangeListenerMethod(method, STATE_CHANGE_EVENT_CLASS);
- return new SingleMethodReflectiveChangeListener(target, method);
- }
-
- /**
- * Construct a state change listener that will invoke the specified method
- * on the specified target. If a single-argument method with the specified
- * name and appropriate argument is found, it will be invoked; otherwise,
- * a zero-argument method with the specified name will be invoked.
- */
- public static StateChangeListener buildStateChangeListener(Object target, String methodName) {
- return buildStateChangeListener(target, findChangeListenerMethod(target, methodName, STATE_CHANGE_EVENT_CLASS_ARRAY));
- }
-
-
- // ********** factory methods: PropertyChangeListener **********
-
- /**
- * Construct a property change listener that will invoke the specified method
- * on the specified target.
- */
- public static PropertyChangeListener buildPropertyChangeListener(Object target, Method method) {
- checkChangeListenerMethod(method, PROPERTY_CHANGE_EVENT_CLASS);
- return new SingleMethodReflectiveChangeListener(target, method);
- }
-
- /**
- * Construct a property change listener that will invoke the specified method
- * on the specified target. If a single-argument method with the specified
- * name and appropriate argument is found, it will be invoked; otherwise,
- * a zero-argument method with the specified name will be invoked.
- */
- public static PropertyChangeListener buildPropertyChangeListener(Object target, String methodName) {
- return buildPropertyChangeListener(target, findChangeListenerMethod(target, methodName, PROPERTY_CHANGE_EVENT_CLASS_ARRAY));
- }
-
-
- // ********** factory methods: CollectionChangeListener **********
-
- /**
- * Construct a collection change listener that will invoke the specified methods
- * on the specified target.
- */
- public static CollectionChangeListener buildCollectionChangeListener(Object target, Method addMethod, Method removeMethod, Method clearMethod, Method changeMethod) {
- checkChangeListenerMethod(addMethod, COLLECTION_ADD_EVENT_CLASS);
- checkChangeListenerMethod(removeMethod, COLLECTION_REMOVE_EVENT_CLASS);
- checkChangeListenerMethod(clearMethod, COLLECTION_CLEAR_EVENT_CLASS);
- checkChangeListenerMethod(changeMethod, COLLECTION_CHANGE_EVENT_CLASS);
- return new MultiMethodReflectiveChangeListener(target, addMethod, removeMethod, clearMethod, changeMethod);
- }
-
- /**
- * Construct a collection change listener that will invoke the specified method
- * on the specified target for any change event.
- */
- public static CollectionChangeListener buildCollectionChangeListener(Object target, Method method) {
- return buildCollectionChangeListener(target, method, method, method, method);
- }
-
- /**
- * Construct a collection change listener that will invoke the specified methods
- * on the specified target for change events. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static CollectionChangeListener buildCollectionChangeListener(Object target, String addMethodName, String removeMethodName, String clearMethodName, String changeMethodName) {
- return buildCollectionChangeListener(
- target,
- findChangeListenerMethod(target, addMethodName, COLLECTION_ADD_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, removeMethodName, COLLECTION_REMOVE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, clearMethodName, COLLECTION_CLEAR_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, changeMethodName, COLLECTION_CHANGE_EVENT_CLASS_ARRAY)
- );
- }
-
- /**
- * Construct a collection change listener that will invoke the specified method
- * on the specified target for any change event. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static CollectionChangeListener buildCollectionChangeListener(Object target, String methodName) {
- return buildCollectionChangeListener(target, findChangeListenerMethod(target, methodName, COLLECTION_EVENT_CLASS_ARRAY));
- }
-
-
- // ********** factory methods: ListChangeListener **********
-
- /**
- * Construct a list change listener that will invoke the specified methods
- * on the specified target.
- */
- public static ListChangeListener buildListChangeListener(Object target, Method addMethod, Method removeMethod, Method replaceMethod, Method moveMethod, Method clearMethod, Method changeMethod) {
- checkChangeListenerMethod(addMethod, LIST_ADD_EVENT_CLASS);
- checkChangeListenerMethod(removeMethod, LIST_REMOVE_EVENT_CLASS);
- checkChangeListenerMethod(replaceMethod, LIST_REPLACE_EVENT_CLASS);
- checkChangeListenerMethod(moveMethod, LIST_MOVE_EVENT_CLASS);
- checkChangeListenerMethod(clearMethod, LIST_CLEAR_EVENT_CLASS);
- checkChangeListenerMethod(changeMethod, LIST_CHANGE_EVENT_CLASS);
- return new MultiMethodReflectiveChangeListener(target, addMethod, removeMethod, replaceMethod, moveMethod, clearMethod, changeMethod);
- }
-
- /**
- * Construct a list change listener that will invoke the specified method
- * on the specified target for any change event.
- */
- public static ListChangeListener buildListChangeListener(Object target, Method method) {
- return buildListChangeListener(target, method, method, method, method, method, method);
- }
-
- /**
- * Construct a list change listener that will invoke the specified methods
- * on the specified target for change events. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static ListChangeListener buildListChangeListener(Object target, String addMethodName, String removeMethodName, String replaceMethodName, String moveMethodName, String clearMethodName, String changeMethodName) {
- return buildListChangeListener(
- target,
- findChangeListenerMethod(target, addMethodName, LIST_ADD_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, removeMethodName, LIST_REMOVE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, replaceMethodName, LIST_REPLACE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, moveMethodName, LIST_MOVE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, clearMethodName, LIST_CLEAR_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, changeMethodName, LIST_CHANGE_EVENT_CLASS_ARRAY)
- );
- }
-
- /**
- * Construct a list change listener that will invoke the specified method
- * on the specified target for any change event. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static ListChangeListener buildListChangeListener(Object target, String methodName) {
- return buildListChangeListener(target, findChangeListenerMethod(target, methodName, LIST_EVENT_CLASS_ARRAY));
- }
-
-
- // ********** factory methods: TreeChangeListener **********
-
- /**
- * Construct a tree change listener that will invoke the specified methods
- * on the specified target.
- */
- public static TreeChangeListener buildTreeChangeListener(Object target, Method addMethod, Method removeMethod, Method clearMethod, Method changeMethod) {
- checkChangeListenerMethod(addMethod, TREE_ADD_EVENT_CLASS);
- checkChangeListenerMethod(removeMethod, TREE_REMOVE_EVENT_CLASS);
- checkChangeListenerMethod(clearMethod, TREE_CLEAR_EVENT_CLASS);
- checkChangeListenerMethod(changeMethod, TREE_CHANGE_EVENT_CLASS);
- return new MultiMethodReflectiveChangeListener(target, addMethod, removeMethod, clearMethod, changeMethod);
- }
-
- /**
- * Construct a tree change listener that will invoke the specified method
- * on the specified target for any change event.
- */
- public static TreeChangeListener buildTreeChangeListener(Object target, Method method) {
- return buildTreeChangeListener(target, method, method, method, method);
- }
-
- /**
- * Construct a tree change listener that will invoke the specified methods
- * on the specified target for change events. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static TreeChangeListener buildTreeChangeListener(Object target, String addMethodName, String removeMethodName, String clearMethodName, String changeMethodName) {
- return buildTreeChangeListener(
- target,
- findChangeListenerMethod(target, addMethodName, TREE_ADD_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, removeMethodName, TREE_REMOVE_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, clearMethodName, TREE_CLEAR_EVENT_CLASS_ARRAY),
- findChangeListenerMethod(target, changeMethodName, TREE_CHANGE_EVENT_CLASS_ARRAY)
- );
- }
-
- /**
- * Construct a tree change listener that will invoke the specified method
- * on the specified target for any change event. If a single-argument method
- * with the specified name and appropriate argument is found, it will be invoked;
- * otherwise, a zero-argument method with the specified name will be invoked.
- */
- public static TreeChangeListener buildTreeChangeListener(Object target, String methodName) {
- return buildTreeChangeListener(target, findChangeListenerMethod(target, methodName, TREE_EVENT_CLASS_ARRAY));
- }
-
-
- // ********** constructor **********
-
- /**
- * Construct a listener that will invoke the specified method
- * on the specified target.
- */
- protected ReflectiveChangeListener(Object target) {
- super();
- this.target = target;
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/SingleMethodReflectiveChangeListener.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/SingleMethodReflectiveChangeListener.java
deleted file mode 100644
index 146e75ffd3..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/SingleMethodReflectiveChangeListener.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import java.lang.reflect.Method;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-
-/**
- * This class is used by {@link ReflectiveChangeListener} when the requested listener
- * need only implement a single method (i.e. {@link StateChangeListener} or
- * {@link PropertyChangeListener}).
- */
-class SingleMethodReflectiveChangeListener
- extends ReflectiveChangeListener
- implements StateChangeListener, PropertyChangeListener
-{
-
- /** the method we will invoke on the target object */
- private final Method method;
- /** cache the number of arguments */
- private final boolean methodIsZeroArgument;
-
- SingleMethodReflectiveChangeListener(Object target, Method method) {
- super(target);
- this.method = method;
- this.methodIsZeroArgument = method.getParameterTypes().length == 0;
- }
-
-
- // ********** StateChangeListener implementation **********
-
- public void stateChanged(StateChangeEvent event) {
- if (this.methodIsZeroArgument) {
- ReflectionTools.executeMethod(this.method, this.target, EMPTY_OBJECT_ARRAY);
- } else {
- ReflectionTools.executeMethod(this.method, this.target, new StateChangeEvent[] {event});
- }
- }
-
-
- // ********** PropertyChangeListener implementation **********
-
- public void propertyChanged(PropertyChangeEvent event) {
- if (this.methodIsZeroArgument) {
- ReflectionTools.executeMethod(this.method, this.target, EMPTY_OBJECT_ARRAY);
- } else {
- ReflectionTools.executeMethod(this.method, this.target, new PropertyChangeEvent[] {event});
- }
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/StateChangeAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/StateChangeAdapter.java
deleted file mode 100644
index 3cc5f185f2..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/StateChangeAdapter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-
-/**
- * Convenience implementation of {@link StateChangeListener}.
- * This is probably of limited use, since there only a single method to implement;
- * maybe as a null implementation.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class StateChangeAdapter implements StateChangeListener {
-
- public void stateChanged(StateChangeEvent event) {
- // do nothing
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/StateChangeListener.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/StateChangeListener.java
deleted file mode 100644
index f9c599edee..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/StateChangeListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import java.util.EventListener;
-
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-
-/**
- * A generic "state change" event gets delivered whenever a model changes to
- * such extent that it cannot be delineated all aspects of it that have changed.
- * You can register a <code>StateChangeListener</code> with a source model so as to be notified
- * of any such changes.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface StateChangeListener extends EventListener {
-
- /**
- * This method gets called when a model has changed in some general fashion.
- *
- * @param event An event describing the event source.
- */
- void stateChanged(StateChangeEvent event);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/TreeChangeAdapter.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/TreeChangeAdapter.java
deleted file mode 100644
index 8d7ccee3d4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/TreeChangeAdapter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-
-/**
- * Convenience implementation of {@link TreeChangeListener}.
- * <p>
- * Provisional API: This class is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public class TreeChangeAdapter implements TreeChangeListener {
-
- /**
- * Default constructor.
- */
- public TreeChangeAdapter() {
- super();
- }
-
- public void nodeAdded(TreeAddEvent event) {
- // do nothing
- }
-
- public void nodeRemoved(TreeRemoveEvent event) {
- // do nothing
- }
-
- public void treeCleared(TreeClearEvent event) {
- // do nothing
- }
-
- public void treeChanged(TreeChangeEvent event) {
- // do nothing
- }
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/TreeChangeListener.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/TreeChangeListener.java
deleted file mode 100644
index de8c898fb5..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/listener/TreeChangeListener.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.listener;
-
-import java.util.EventListener;
-
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-
-/**
- * A "tree change" event gets fired whenever a model changes a "bound"
- * tree. You can register a <code>TreeChangeListener</code> with a source
- * model so as to be notified of any bound tree updates.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- */
-public interface TreeChangeListener extends EventListener {
-
- /**
- * This method gets called when a node is added to a bound tree.
- *
- * @param event An event describing the event source,
- * the tree that changed, and the path to the node that was added.
- */
- void nodeAdded(TreeAddEvent event);
-
- /**
- * This method gets called when a node is removed from a bound tree.
- *
- * @param event An event describing the event source,
- * the tree that changed, and the path to the node that was removed.
- */
- void nodeRemoved(TreeRemoveEvent event);
-
- /**
- * This method gets called when a bound tree is cleared.
- *
- * @param event An event describing the event source,
- * the tree that changed, and an empty path.
- */
- void treeCleared(TreeClearEvent event);
-
- /**
- * This method gets called when a portion of a bound tree is changed in
- * a manner that is not easily characterized by the other methods in this
- * interface.
- *
- * @param event An event describing the event source,
- * the tree that changed, and the current state of the
- * tree that changed.
- */
- void treeChanged(TreeChangeEvent event);
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/CollectionValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/CollectionValueModel.java
deleted file mode 100644
index d7adf509aa..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/CollectionValueModel.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.value;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * Interface used to abstract collection accessing and
- * change notification and make it more pluggable.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <E> the type of values held by the model
- */
-public interface CollectionValueModel<E>
- extends Model, Iterable<E>
-{
-
- /**
- * Return the collection's values.
- */
- Iterator<E> iterator();
- String VALUES = "values"; //$NON-NLS-1$
-
- /**
- * Return the size of the collection.
- */
- int size();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ListValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ListValueModel.java
deleted file mode 100644
index 16d88283b8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ListValueModel.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.value;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * Interface used to abstract list accessing and
- * change notification and make it more pluggable.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <E> the type of values held by the list model
- */
-public interface ListValueModel<E>
- extends Model, Iterable<E>
-{
- /**
- * Return the list's values.
- */
- Iterator<E> iterator();
- String LIST_VALUES = "list values"; //$NON-NLS-1$
-
- /**
- * Return the list's values.
- */
- ListIterator<E> listIterator();
-
- /**
- * Return the size of the list.
- */
- int size();
-
- /**
- * Return the item at the specified index of the list.
- */
- E get(int index);
-
- /**
- * Return the list's values.
- */
- Object[] toArray();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiableCollectionValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiableCollectionValueModel.java
deleted file mode 100644
index c6558dcbda..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiableCollectionValueModel.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.value;
-
-/**
- * Extend {@link CollectionValueModel} to allow the setting of the
- * collection's values.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <E> the type of values held by the model
- */
-public interface ModifiableCollectionValueModel<E>
- extends CollectionValueModel<E>
-{
- /**
- * Set the values and fire a collection change notification.
- * @see CollectionValueModel#VALUES
- */
- void setValues(Iterable<E> values);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiableListValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiableListValueModel.java
deleted file mode 100644
index e771387358..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiableListValueModel.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.value;
-
-/**
- * Extend {@link ListValueModel} to allow the setting of the
- * list's values.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <E> the type of values held by the model
- */
-public interface ModifiableListValueModel<E>
- extends ListValueModel<E>
-{
- /**
- * Set the list values and fire a list change notification.
- * @see ListValueModel#LIST_VALUES
- */
- void setListValues(Iterable<E> values);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiablePropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiablePropertyValueModel.java
deleted file mode 100644
index 9afe050da4..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/ModifiablePropertyValueModel.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.value;
-
-/**
- * Extend {@link PropertyValueModel} to allow the setting of the property's value.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <V> the type of value held by the model
- */
-public interface ModifiablePropertyValueModel<V>
- extends PropertyValueModel<V>
-{
- /**
- * Set the value and fire a property change notification.
- * @see PropertyValueModel#VALUE
- */
- void setValue(V value);
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/PropertyValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/PropertyValueModel.java
deleted file mode 100644
index c098c884de..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/PropertyValueModel.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.value;
-
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * Interface used to abstract property accessing and
- * change notification and make it more pluggable.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <V> the type of value held by the model
- */
-public interface PropertyValueModel<V>
- extends Model
-{
- /**
- * Return the model's value.
- */
- V getValue();
- String VALUE = "value"; //$NON-NLS-1$
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/TreeNodeValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/TreeNodeValueModel.java
deleted file mode 100644
index 01dc2632f8..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/TreeNodeValueModel.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.value;
-
-/**
- * Extend {@link ModifiablePropertyValueModel} to better support
- * {@link org.eclipse.jpt.common.utility.internal.model.value.swing.TreeModelAdapter}.
- * <p>
- * Implementors of this interface should fire a "state change" event
- * whenever the node's internal state changes in a way that the
- * tree listeners should be notified.
- * <p>
- * Implementors of this interface should also fire a "value property change"
- * event whenever the node's value changes. Typically, only nodes that
- * hold "primitive" data will fire this event.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <T> the type of values held by the model
- *
- * @see org.eclipse.jpt.common.utility.internal.model.value.AbstractTreeNodeValueModel
- */
-public interface TreeNodeValueModel<T>
- extends ModifiablePropertyValueModel<T>
-{
-
- /**
- * Return the node's parent node; null if the node
- * is the root.
- */
- TreeNodeValueModel<T> parent();
-
- /**
- * Return the path to the node.
- */
- TreeNodeValueModel<T>[] path();
-
- /**
- * Return a list value model of the node's child nodes.
- */
- ListValueModel<TreeNodeValueModel<T>> childrenModel();
-
- /**
- * Return the node's child at the specified index.
- */
- TreeNodeValueModel<T> child(int index);
-
- /**
- * Return the size of the node's list of children.
- */
- int childrenSize();
-
- /**
- * Return the index in the node's list of children of the specified child.
- */
- int indexOfChild(TreeNodeValueModel<T> child);
-
- /**
- * Return whether the node is a leaf (i.e. it has no children)
- */
- boolean isLeaf();
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/TreeValueModel.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/TreeValueModel.java
deleted file mode 100644
index 7a3e44d765..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/model/value/TreeValueModel.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.model.value;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.model.Model;
-
-/**
- * Interface used to abstract tree accessing and
- * change notification and make it more pluggable.
- * <p>
- * Provisional API: This interface is part of an interim API that is still
- * under development and expected to change significantly before reaching
- * stability. It is available at this early stage to solicit feedback from
- * pioneering adopters on the understanding that any code that uses this API
- * will almost certainly be broken (repeatedly) as the API evolves.
- *
- * @param <E> the type of values held by the model
- */
-public interface TreeValueModel<E>
- extends Model
-{
- /**
- * Return the tree's nodes.
- */
- Iterator<E> nodes();
- String NODES = "nodes"; //$NON-NLS-1$
-
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/CallbackSynchronizer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/CallbackSynchronizer.java
deleted file mode 100644
index af1662a4bb..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/CallbackSynchronizer.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.synchronizers;
-
-import java.io.Serializable;
-import java.util.EventListener;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * Extend {@link Synchronizer} to notify listeners
- * when a synchronization "cycle" is complete; i.e. the synchronization has,
- * for the moment, quiesced.
- */
-public interface CallbackSynchronizer
- extends Synchronizer
-{
- /**
- * Add the specified listener to be notified whenever the synchronizer has
- * quiesced.
- * @see #removeListener(Listener)
- */
- void addListener(Listener listener);
-
- /**
- * Remove the specified listener.
- * @see #addListener(Listener)
- */
- void removeListener(Listener listener);
-
-
- // ********** listener **********
-
- /**
- * Interface implemented by listeners to be notified whenever the
- * synchronizer has quiesced.
- */
- public interface Listener
- extends EventListener
- {
- /**
- * The specified synchronizer has quiesced.
- */
- void synchronizationQuiesced(CallbackSynchronizer synchronizer);
- }
-
-
- /**
- * Singleton implementation of the {@link CallbackSynchronizer} interface that will do
- * nothing.
- */
- final class Null
- implements CallbackSynchronizer, Serializable
- {
- public static final CallbackSynchronizer INSTANCE = new Null();
- public static CallbackSynchronizer instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void start() {
- // do nothing
- }
- public void synchronize() {
- // do nothing
- }
- public void stop() {
- // do nothing
- }
- public void addListener(Listener listener) {
- // do nothing
- }
- public void removeListener(Listener listener) {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/Synchronizer.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/Synchronizer.java
deleted file mode 100644
index df45d78230..0000000000
--- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/synchronizers/Synchronizer.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.synchronizers;
-
-import java.io.Serializable;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-/**
- * This interface defines the protocol for starting, stopping, and executing a
- * long-running, repeatable, and possibly recursive "synchronization" process.
- * The intent is for the synchronizer to synchronize a "secondary" model with
- * a "primary" model. Any change to the "primary" model will trigger the
- * synchronization. The synchronizer implementation will determine whether the
- * "secondary" model remains in sync synchronously or asynchronously.
- * <p>
- * The assumption is that the {@link #start()} and {@link #stop()} methods will be called from
- * a single master thread that would control the synchronizer's lifecycle and
- * the {@link #synchronize()} method will be called multiple times, possibly from
- * multiple threads.
- */
-public interface Synchronizer {
-
- /**
- * Enable the synchronizer to allow future synchronizations as requested
- * by calls to {@link #synchronize()}.
- */
- void start();
-
- /**
- * Synchronize the dependent model with the primary model. Do nothing if
- * {@link #start()} has not previously been called. Do nothing if {@link #stop}
- * has been called (without any intermediate call to {@link #start()}.
- */
- void synchronize();
-
- /**
- * Stop the synchronizer immediately or, if a synchronization is currently
- * in progress, when it completes. Return when the synchronizer is stopped.
- * No further synchonizations will performed until {@link #start()} is called.
- */
- void stop();
-
-
- /**
- * Singleton implementation of the {@link Synchronizer} interface that will do
- * nothing.
- */
- final class Null
- implements Synchronizer, Serializable
- {
- public static final Synchronizer INSTANCE = new Null();
- public static Synchronizer instance() {
- return INSTANCE;
- }
- // ensure single instance
- private Null() {
- super();
- }
- public void start() {
- // do nothing
- }
- public void synchronize() {
- // do nothing
- }
- public void stop() {
- // do nothing
- }
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/.classpath b/common/tests/org.eclipse.jpt.common.core.tests/.classpath
deleted file mode 100644
index 1e530394ab..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/.classpath
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/common/core/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/common/utility/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/wst/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/.cvsignore b/common/tests/org.eclipse.jpt.common.core.tests/.cvsignore
deleted file mode 100644
index ba077a4031..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/.project b/common/tests/org.eclipse.jpt.common.core.tests/.project
deleted file mode 100644
index 0839d137f9..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.core.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/.settings/org.eclipse.jdt.core.prefs b/common/tests/org.eclipse.jpt.common.core.tests/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 294090b50a..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Tue Mar 08 12:06:24 EST 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
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/META-INF/MANIFEST.MF b/common/tests/org.eclipse.jpt.common.core.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index 1d370da61b..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,21 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.common.core.tests;singleton:=true
-Bundle-Version: 1.2.0.qualifier
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Bundle-ActivationPolicy: lazy
-Require-Bundle: org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jdt.core;bundle-version="[3.4.0,4.0.0)",
- org.eclipse.jpt.common.core;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.jpt.common.utility;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jpt.common.utility.tests;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.wst.common.project.facet.core;bundle-version="[1.3.0,2.0.0)",
- org.junit;bundle-version="[4.0.0,5.0.0)"
-Export-Package: org.eclipse.jpt.common.core.tests.internal;x-internal:=true,
- org.eclipse.jpt.common.core.tests.internal.projects;x-internal:=true,
- org.eclipse.jpt.common.core.tests.internal.resource.java;x-internal:=true,
- org.eclipse.jpt.common.core.tests.internal.utility.jdt;x-internal:=true
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/about.html b/common/tests/org.eclipse.jpt.common.core.tests/about.html
deleted file mode 100644
index be534ba44f..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>May 02, 2008</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/build.properties b/common/tests/org.eclipse.jpt.common.core.tests/build.properties
deleted file mode 100644
index 9cd29bcb38..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/build.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-################################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-bin.includes = .,\
- META-INF/,\
- about.html,\
- test.xml,\
- plugin.properties
-source.. = src/
-output.. = bin/
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/plugin.properties b/common/tests/org.eclipse.jpt.common.core.tests/plugin.properties
deleted file mode 100644
index b22b820267..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/plugin.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-################################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName=Dali Java Persistence Tools - Common Core Tests
-providerName=Eclipse Web Tools Platform
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/JptCommonCoreTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/JptCommonCoreTests.java
deleted file mode 100644
index b53253a105..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/JptCommonCoreTests.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.common.core.tests.internal.resource.java.JptCommonCoreResourceJavaTests;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.JptCommonCoreUtilityJdtTests;
-
-public class JptCommonCoreTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptCommonCoreTests.class.getPackage().getName());
- suite.addTest(JptCommonCoreResourceJavaTests.suite());
- suite.addTest(JptCommonCoreUtilityJdtTests.suite());
- return suite;
- }
-
- private JptCommonCoreTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestFacetedProject.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestFacetedProject.java
deleted file mode 100644
index a2ba74b0b3..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestFacetedProject.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.projects;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-
-/**
- * This builds and holds a "faceted" project.
- * Support for installing facets.
- */
-public class TestFacetedProject extends TestPlatformProject {
- private final IFacetedProject facetedProject;
-
-
- // ********** builders *****************************
-
- public static TestFacetedProject buildFacetedProject(String baseProjectName, boolean autoBuild)
- throws CoreException {
- return new TestFacetedProject(baseProjectName, autoBuild);
- }
-
-
- // ********** constructors/initialization **********
-
- public TestFacetedProject(String projectName) throws CoreException {
- this(projectName, true);
- }
-
- public TestFacetedProject(String projectName, boolean autoBuild) throws CoreException {
- super(projectName, autoBuild);
- this.facetedProject = this.createFacetedProject();
- }
-
- private IFacetedProject createFacetedProject() throws CoreException {
- return ProjectFacetsManager.create(this.getProject(), true, null); // true = "convert if necessary"
- }
-
-
- // ********** public methods **********
-
- public IFacetedProject getFacetedProject() {
- return this.facetedProject;
- }
-
- public void installFacet(String facetName, String versionName) throws CoreException {
- this.installFacet(facetName, versionName, null);
- }
-
- public void uninstallFacet(String facetName, String versionName) throws CoreException {
- this.uninstallFacet(facetName, versionName, null);
- }
-
- /**
- * if 'config' is null (and 'facetName' is "jpt.jpa"), the JPA project will be built with the defaults
- * defined in JpaFacetInstallDataModelProvider#getDefaultProperty(String)
- * In JPA the config object will be an IDataModel
- * In JAXB the config object will be a JaxbFacetInstallConfig
- */
- public void installFacet(String facetName, String versionName, Object config) throws CoreException {
- this.facetedProject.installProjectFacet(this.facetVersion(facetName, versionName), config, null);
- }
-
- /**
- * In JPA the config object will be an IDataModel
- * In JAXB the config object will be a JaxbFacetUninstallConfig
- */
- public void uninstallFacet(String facetName, String versionName, Object config) throws CoreException {
- this.facetedProject.uninstallProjectFacet(this.facetVersion(facetName, versionName), config, null);
- }
-
- private IProjectFacetVersion facetVersion(String facetName, String versionName) {
- return ProjectFacetsManager.getProjectFacet(facetName).getVersion(versionName);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestJavaProject.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestJavaProject.java
deleted file mode 100644
index 7ea7e3813a..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestJavaProject.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.projects;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-
-/**
- * This builds and holds a "Java" project.
- * Support for adding packages and types.
- *
- * "Java" projects aren't required to be "faceted" projects, but for JPA
- * testing they are.
- */
-@SuppressWarnings("nls")
-public class TestJavaProject extends TestFacetedProject {
- private final IJavaProject javaProject;
- private final IPackageFragmentRoot sourceFolder;
-
-
- // ********** builders *****************************
-
- public static TestJavaProject buildJavaProject(String baseProjectName, boolean autoBuild)
- throws CoreException {
- return new TestJavaProject(baseProjectName, autoBuild);
- }
-
-
- // ********** constructors/initialization **********
-
- public TestJavaProject(String projectName) throws CoreException {
- this(projectName, false);
- }
-
- public TestJavaProject(String projectName, boolean autoBuild) throws CoreException {
- super(projectName, autoBuild);
- this.installFacet("jst.java", "5.0");
- this.javaProject = JavaCore.create(this.getProject());
- this.sourceFolder = this.javaProject.getPackageFragmentRoot(this.getProject().getFolder("src"));
- }
-
- public void addJar(String jarPath) throws JavaModelException {
- this.addClasspathEntry(JavaCore.newLibraryEntry(new Path(jarPath), null, null));
- }
-
- private void addClasspathEntry(IClasspathEntry entry) throws JavaModelException {
- this.javaProject.setRawClasspath(ArrayTools.add(this.javaProject.getRawClasspath(), entry), null);
- }
-
-
- // ********** public methods **********
-
- public IJavaProject getJavaProject() {
- return this.javaProject;
- }
-
- public IPackageFragment createPackage(String packageName) throws CoreException {
- return this.sourceFolder.createPackageFragment(packageName, false, null); // false = "no force"
- }
-
- /**
- * The source should NOT contain a package declaration;
- * it will be added here.
- */
- public ICompilationUnit createCompilationUnit(String packageName, String compilationUnitName, String source) throws CoreException {
- return this.createCompilationUnit(this.createPackage(packageName), compilationUnitName, new SimpleSourceWriter(source));
- }
-
- /**
- * The source should NOT contain a package declaration;
- * it will be added here.
- */
- public ICompilationUnit createCompilationUnit(String packageName, String compilationUnitName, SourceWriter sourceWriter) throws CoreException {
- return this.createCompilationUnit(this.createPackage(packageName), compilationUnitName, sourceWriter);
- }
-
- /**
- * The source should NOT contain a package declaration;
- * it will be added here.
- */
- public ICompilationUnit createCompilationUnit(IPackageFragment packageFragment, String compilationUnitName, SourceWriter sourceWriter) throws CoreException {
- StringBuilder sb = new StringBuilder(2000);
- sourceWriter.appendSourceTo(sb);
- String source = sb.toString();
- return packageFragment.createCompilationUnit(compilationUnitName, source, false, null); // false = "no force"
- }
-
-
- // ********** member classes **********
-
- public interface SourceWriter {
- void appendSourceTo(StringBuilder sb);
- }
-
- public class SimpleSourceWriter implements SourceWriter {
- private final String source;
- public SimpleSourceWriter(String source) {
- super();
- this.source = source;
- }
- public void appendSourceTo(StringBuilder sb) {
- sb.append(this.source);
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestPlatformProject.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestPlatformProject.java
deleted file mode 100644
index 22ea400073..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/projects/TestPlatformProject.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.projects;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.tests.internal.TestCommand;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-/**
- * This builds and holds a "general" Eclipse project.
- * Support for adding natures, folders, and files.
- */
-public class TestPlatformProject {
- private final IProject project;
-
- /** carriage return */
- public static final String CR = StringTools.CR;
-
-
- // ********** builders **********
-
- public static TestPlatformProject buildPlatformProject(String baseProjectName, boolean autoBuild)
- throws CoreException {
- return new TestPlatformProject(baseProjectName, autoBuild);
- }
-
-
- // ********** constructors/initialization **********
-
- public TestPlatformProject(String projectName, boolean autoBuild) throws CoreException {
- super();
- this.setAutoBuild(autoBuild); // workspace-wide setting
- this.project = this.buildPlatformProject(projectName);
- }
-
- private void setAutoBuild(boolean autoBuild) throws CoreException {
- IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription();
- description.setAutoBuilding(autoBuild);
- ResourcesPlugin.getWorkspace().setDescription(description);
- }
-
- private IProject buildPlatformProject(String projectName) throws CoreException {
- IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- this.createProject(p);
- p.open(null);
- return p;
- }
-
- private void createProject(IProject p) {
- TestTools.execute(new CreateProjectCommand(p), 4);
- }
-
- protected static class CreateProjectCommand
- implements TestCommand
- {
- private final IProject project;
- protected CreateProjectCommand(IProject project) {
- super();
- this.project = project;
- }
- public void execute() throws Exception {
- this.project.create(null);
- }
- }
-
-
- // ********** public methods **********
-
- public IProject getProject() {
- return this.project;
- }
-
- public void addProjectNature(String natureID) throws CoreException {
- IProjectDescription description = this.project.getDescription();
- description.setNatureIds(ArrayTools.add(description.getNatureIds(), natureID));
- this.project.setDescription(description, null);
- }
-
- public void removeProjectNature(String natureID) throws CoreException {
- IProjectDescription description = this.project.getDescription();
- description.setNatureIds(ArrayTools.removeAllOccurrences(description.getNatureIds(), natureID));
- this.project.setDescription(description, null);
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/JavaResourceModelTestCase.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/JavaResourceModelTestCase.java
deleted file mode 100644
index 6f952c5ff5..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/JavaResourceModelTestCase.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.resource.java;
-
-import org.eclipse.jdt.core.ElementChangedEvent;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IElementChangedListener;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IJavaElementDelta;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jpt.common.core.AnnotationProvider;
-import org.eclipse.jpt.common.core.GenericAnnotationProvider;
-import org.eclipse.jpt.common.core.internal.resource.java.source.SourcePackageInfoCompilationUnit;
-import org.eclipse.jpt.common.core.internal.resource.java.source.SourceTypeCompilationUnit;
-import org.eclipse.jpt.common.core.internal.utility.jdt.NullAnnotationEditFormatter;
-import org.eclipse.jpt.common.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnum;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceEnumConstant;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceMethod;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackage;
-import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageInfoCompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotationDefinition;
-import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.internal.BitTools;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-@SuppressWarnings("nls")
-public abstract class JavaResourceModelTestCase
- extends AnnotationTestCase {
-
- private JavaElementChangeListener javaElementChangeListener;
- protected JavaResourceCompilationUnit javaResourceCompilationUnit;
-
-
- public JavaResourceModelTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.javaElementChangeListener = new JavaElementChangeListener();
- JavaCore.addElementChangedListener(this.javaElementChangeListener);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- JavaCore.removeElementChangedListener(this.javaElementChangeListener);
- this.javaElementChangeListener = null;
- }
-
- private class JavaElementChangeListener
- implements IElementChangedListener {
-
- JavaElementChangeListener() {
- super();
- }
-
- public void elementChanged(ElementChangedEvent event) {
- JavaResourceModelTestCase.this.javaElementChanged(event);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this);
- }
- }
-
- void javaElementChanged(ElementChangedEvent event) {
- if (this.javaResourceCompilationUnit == null) {
- return;
- }
- this.syncWithJavaDelta(event.getDelta());
- }
-
- /**
- * NB: this is copied from GenericJpaProject, so it might need to be
- * kept in synch with that code if it changes... yech...
- */
- protected void syncWithJavaDelta(IJavaElementDelta delta) {
- switch (delta.getElement().getElementType()) {
- case IJavaElement.JAVA_MODEL :
- case IJavaElement.JAVA_PROJECT :
- case IJavaElement.PACKAGE_FRAGMENT_ROOT :
- case IJavaElement.PACKAGE_FRAGMENT :
- this.syncWithJavaDeltaChildren(delta);
- break;
- case IJavaElement.COMPILATION_UNIT :
- this.javaCompilationUnitChanged(delta);
- break;
- default :
- break; // ignore the elements inside a compilation unit
- }
- }
-
- protected void syncWithJavaDeltaChildren(IJavaElementDelta delta) {
- for (IJavaElementDelta child : delta.getAffectedChildren()) {
- this.syncWithJavaDelta(child); // recurse
- }
- }
-
- protected void javaCompilationUnitChanged(IJavaElementDelta delta) {
- if (this.deltaIsRelevant(delta)) {
- this.javaResourceCompilationUnit.synchronizeWithJavaSource();
- }
- }
-
- protected boolean deltaIsRelevant(IJavaElementDelta delta) {
- if (BitTools.onlyFlagIsSet(delta.getFlags(), IJavaElementDelta.F_PRIMARY_WORKING_COPY)) {
- return false;
- }
- return delta.getKind() == IJavaElementDelta.CHANGED;
- }
-
- protected ICompilationUnit createAnnotationAndMembers(String packageName, String annotationName, String annotationBody) throws Exception {
- return this.javaProject.createCompilationUnit(packageName, annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- protected ICompilationUnit createEnumAndMembers(String packageName, String enumName, String enumBody) throws Exception {
- return this.javaProject.createCompilationUnit(packageName, enumName + ".java", "public enum " + enumName + " { " + enumBody + " }");
- }
-
- protected JavaResourcePackage buildJavaResourcePackage(ICompilationUnit cu) {
- JavaResourcePackageInfoCompilationUnit pkgCu =
- new SourcePackageInfoCompilationUnit(
- cu,
- this.buildAnnotationProvider(),
- NullAnnotationEditFormatter.instance(),
- CommandExecutor.Default.instance());
- this.javaResourceCompilationUnit = pkgCu;
- return pkgCu.getPackage();
- }
-
- protected JavaResourceType buildJavaResourceType(ICompilationUnit cu) {
- return (JavaResourceType) this.buildJavaResourceType_(cu);
- }
-
- protected JavaResourceEnum buildJavaResourceEnum(ICompilationUnit cu) {
- return (JavaResourceEnum) this.buildJavaResourceType_(cu);
- }
-
- private JavaResourceAbstractType buildJavaResourceType_(ICompilationUnit cu) {
- this.javaResourceCompilationUnit = this.buildJavaResourceCompilationUnit(cu);
- this.javaResourceCompilationUnit.resolveTypes();
- return this.hackJavaResourceType();
- }
-
- protected JavaResourceField getField(JavaResourceType type, int index) {
- return CollectionTools.get(type.getFields(), index);
- }
-
- protected JavaResourceMethod getMethod(JavaResourceType type, int index) {
- return CollectionTools.get(type.getMethods(), index);
- }
-
- protected JavaResourceEnumConstant getEnumConstant(JavaResourceEnum resourceEnum, int index) {
- return CollectionTools.get(resourceEnum.getEnumConstants(), index);
- }
-
- protected JavaResourceAbstractType hackJavaResourceType() {
- return (JavaResourceAbstractType) ReflectionTools.getFieldValue(this.javaResourceCompilationUnit, "primaryType");
- }
-
- protected JavaResourceCompilationUnit buildJavaResourceCompilationUnit(ICompilationUnit cu) {
- if (this.javaResourceCompilationUnit != null) {
- throw new IllegalStateException();
- }
- return new SourceTypeCompilationUnit(
- cu,
- this.buildAnnotationProvider(),
- NullAnnotationEditFormatter.instance(),
- CommandExecutor.Default.instance());
- }
-
- protected AnnotationProvider buildAnnotationProvider() {
- return new GenericAnnotationProvider(this.annotationDefinitions(), this.nestableAnnotationDefinitions());
- }
-
- protected abstract AnnotationDefinition[] annotationDefinitions();
-
- protected abstract NestableAnnotationDefinition[] nestableAnnotationDefinitions();
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/JptCommonCoreResourceJavaTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/JptCommonCoreResourceJavaTests.java
deleted file mode 100644
index 34f6a682ab..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/JptCommonCoreResourceJavaTests.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.resource.java;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-public class JptCommonCoreResourceJavaTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptCommonCoreResourceJavaTests.class.getPackage().getName());
- suite.addTestSuite(SourceAttributeTests.class);
- return suite;
- }
-
- private JptCommonCoreResourceJavaTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/SourceAttributeTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/SourceAttributeTests.java
deleted file mode 100644
index d5cfc8908c..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/resource/java/SourceAttributeTests.java
+++ /dev/null
@@ -1,135 +0,0 @@
-package org.eclipse.jpt.common.core.tests.internal.resource.java;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.resource.java.AnnotationDefinition;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceField;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotationDefinition;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-
-
-public class SourceAttributeTests
- extends JavaResourceModelTestCase {
-
- private static String TEST_CLASS_NAME = "TestClass";
-
-
- public SourceAttributeTests(String name) {
- super(name);
- }
-
-
- @Override
- protected AnnotationDefinition[] annotationDefinitions() {
- return new AnnotationDefinition[0];
- }
-
- @Override
- protected NestableAnnotationDefinition[] nestableAnnotationDefinitions() {
- return new NestableAnnotationDefinition[0];
- }
-
-
- private ICompilationUnit createTestClassWithVariousAttributes() throws CoreException {
- SourceWriter sourceWriter = new SourceWriter() {
- public void appendSourceTo(StringBuilder sb) {
- sb.append(CR);
- sb.append("import java.util.List;").append(CR);
- sb.append(CR);
- sb.append("public class ").append(TEST_CLASS_NAME).append("<T extends Number> ").append("{").append(CR);
- sb.append(" public String string;").append(CR);
- sb.append(" public List<String> stringList;").append(CR);
- sb.append(" public String[] stringArray;").append(CR);
- sb.append(" public String[][] stringDoubleArray;").append(CR);
- sb.append(" public T generic;").append(CR);
- sb.append(" public List<T> genericList;").append(CR);
- sb.append(" public T[] genericArray;").append(CR);
- sb.append(" public List<?> wildcardList;").append(CR);
- sb.append("}").append(CR);
- }
- };
- return this.javaProject.createCompilationUnit(PACKAGE_NAME, TEST_CLASS_NAME + ".java", sourceWriter);
- }
-
-
- public void testAttributeTypes() throws Exception {
- ICompilationUnit testClassCU = createTestClassWithVariousAttributes();
- JavaResourceType testClass = buildJavaResourceType(testClassCU);
-
- // String string
- JavaResourceField att = getField(testClass, 0);
- assertEquals("string", att.getName());
- assertEquals("java.lang.String", att.getTypeName());
- assertEquals(false, att.typeIsArray());
- assertEquals(null, att.getTypeArrayComponentTypeName());
- assertEquals(0, att.getTypeArrayDimensionality());
- assertEquals(0, att.getTypeTypeArgumentNamesSize());
-
- // List<String> stringList
- att = getField(testClass, 1);
- assertEquals("stringList", att.getName());
- assertEquals("java.util.List", att.getTypeName());
- assertEquals(false, att.typeIsArray());
- assertEquals(null, att.getTypeArrayComponentTypeName());
- assertEquals(0, att.getTypeArrayDimensionality());
- assertEquals(1, att.getTypeTypeArgumentNamesSize());
- assertEquals("java.lang.String", att.getTypeTypeArgumentName(0));
-
- // String[] stringArray
- att = getField(testClass, 2);
- assertEquals("stringArray", att.getName());
- assertEquals("java.lang.String[]", att.getTypeName());
- assertEquals(true, att.typeIsArray());
- assertEquals("java.lang.String", att.getTypeArrayComponentTypeName());
- assertEquals(1, att.getTypeArrayDimensionality());
- assertEquals(0, att.getTypeTypeArgumentNamesSize());
-
- // String[] stringDoubleArray
- att = getField(testClass, 3);
- assertEquals("stringDoubleArray", att.getName());
- assertEquals("java.lang.String[][]", att.getTypeName());
- assertEquals(true, att.typeIsArray());
- assertEquals("java.lang.String", att.getTypeArrayComponentTypeName());
- assertEquals(2, att.getTypeArrayDimensionality());
- assertEquals(0, att.getTypeTypeArgumentNamesSize());
-
- // T generic
- att = getField(testClass, 4);
- assertEquals("generic", att.getName());
- assertEquals("java.lang.Number", att.getTypeName());
- assertEquals(false, att.typeIsArray());
- assertEquals(null, att.getTypeArrayComponentTypeName());
- assertEquals(0, att.getTypeArrayDimensionality());
- assertEquals(0, att.getTypeTypeArgumentNamesSize());
-
- // List<T> genericList
- att = getField(testClass, 5);
- assertEquals("genericList", att.getName());
- assertEquals("java.util.List", att.getTypeName());
- assertEquals(false, att.typeIsArray());
- assertEquals(null, att.getTypeArrayComponentTypeName());
- assertEquals(0, att.getTypeArrayDimensionality());
- assertEquals(1, att.getTypeTypeArgumentNamesSize());
- assertEquals("java.lang.Number", att.getTypeTypeArgumentName(0));
-
- // T[] genericArray
- att = getField(testClass, 6);
- assertEquals("genericArray", att.getName());
- assertEquals("java.lang.Number[]", att.getTypeName());
- assertEquals(true, att.typeIsArray());
- assertEquals("java.lang.Number", att.getTypeArrayComponentTypeName());
- assertEquals(1, att.getTypeArrayDimensionality());
- assertEquals(0, att.getTypeTypeArgumentNamesSize());
-
- // List<?> wildcardList
- att = getField(testClass, 7);
- assertEquals("wildcardList", att.getName());
- assertEquals("java.util.List", att.getTypeName());
- assertEquals(false, att.typeIsArray());
- assertEquals(null, att.getTypeArrayComponentTypeName());
- assertEquals(0, att.getTypeArrayDimensionality());
- assertEquals(1, att.getTypeTypeArgumentNamesSize());
- assertEquals("java.lang.Object", att.getTypeTypeArgumentName(0));
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/ASTToolsTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/ASTToolsTests.java
deleted file mode 100644
index e8d26126ed..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/ASTToolsTests.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools;
-import org.eclipse.jpt.common.core.internal.utility.jdt.AnnotationStringArrayExpressionConverter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.JDTFieldAttribute;
-import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-
-@SuppressWarnings("nls")
-public class ASTToolsTests
- extends AnnotationTestCase {
-
- public ASTToolsTests(String name) {
- super(name);
- }
-
-
- private void createClassAndMembers(String className, String classBody) throws Exception {
- this.javaProject.createCompilationUnit("clazz", className + ".java", "public class " + className + " { " + classBody + " }");
- }
-
- private void createEnumAndMembers(String enumName, String enumBody) throws Exception {
- this.javaProject.createCompilationUnit("enums", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }");
- }
-
- private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- this.javaProject.createCompilationUnit("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- private ICompilationUnit createTestType(final Iterator<String> imports, final String idFieldAnnotation)
- throws Exception {
- return createTestType(
- new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return imports;
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(idFieldAnnotation);
- }
- });
- }
-
- public void testResolveEnum1() throws Exception {
- this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ");
- this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();");
-
- ICompilationUnit cu = this.createTestType("@annot.TestAnnotation(foo=enums.TestEnum.BAZ)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
- JDTFieldAttribute field = this.idField(cu);
-
- String actual = ASTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.buildASTRoot(cu))));
- assertEquals("enums.TestEnum.BAZ", actual);
- }
-
- public void testResolveEnum2() throws Exception {
- this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ");
- this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();");
-
- ICompilationUnit cu = this.createTestType("static enums.TestEnum.BAZ", "@annot.TestAnnotation(foo=BAZ)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
- JDTFieldAttribute field = this.idField(cu);
-
- String actual = ASTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.buildASTRoot(cu))));
- assertEquals("enums.TestEnum.BAZ", actual);
- }
-
- public void testResolveEnum3() throws Exception {
- this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ");
- this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();");
-
- ICompilationUnit cu = this.createTestType("static enums.TestEnum.*", "@annot.TestAnnotation(foo=BAZ)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
- JDTFieldAttribute field = this.idField(cu);
-
- String actual = ASTTools.resolveEnum((Name)daea.getExpression(field.getModifiedDeclaration(this.buildASTRoot(cu))));
- assertEquals("enums.TestEnum.BAZ", actual);
- }
-
- public void testResolveEnum4() throws Exception {
- this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ");
- this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();");
-
- ICompilationUnit cu = this.createTestType("enums.TestEnum", "@annot.TestAnnotation(foo=TestEnum.BAZ)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo");
- JDTFieldAttribute field = this.idField(cu);
-
- String actual = ASTTools.resolveEnum((Name) daea.getExpression(field.getModifiedDeclaration(this.buildASTRoot(cu))));
- assertEquals("enums.TestEnum.BAZ", actual);
- }
-
- public void testResolveFullyQualifiedNames() throws Exception {
- final String otherClassName = "OtherClass";
- final String otherClassName2 = "OtherClass2";
- final String fqOtherClassName = "clazz.OtherClass";
- final String fqOtherClassName2 = "clazz.OtherClass2";
- final String annotationName = "TestAnnotation";
- final String fqAnnotationName = "annot.TestAnnotation";
-
- createClassAndMembers(otherClassName, "");
- createClassAndMembers(otherClassName2, "");
- createAnnotationAndMembers(annotationName, "Class[] foo();");
-
- ICompilationUnit cu = createTestType(
- new ArrayIterator<String>(new String[] {fqOtherClassName, fqOtherClassName2, fqAnnotationName}),
- "@TestAnnotation(foo={" + otherClassName + ".class, " + otherClassName2 + ".class})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter(fqAnnotationName);
- DeclarationAnnotationElementAdapter<String[]> daea =
- new ConversionDeclarationAnnotationElementAdapter<String[]>(
- daa, "foo", AnnotationStringArrayExpressionConverter.forTypes());
- JDTFieldAttribute field = idField(cu);
-
- Iterable<String> actual = ASTTools.resolveFullyQualifiedNames(daea.getExpression(field.getModifiedDeclaration(this.buildASTRoot(cu))));
-
- assertEquals(
- CollectionTools.list(new String[] {fqOtherClassName, fqOtherClassName2}),
- CollectionTools.list(actual));
- }
-
- public void testResolveFullyQualifiedNames2() throws Exception {
- final String otherClassName = "OtherClass";
- final String otherClassName2 = "OtherClass2";
- final String fqOtherClassName = "clazz.OtherClass";
- final String fqOtherClassName2 = "clazz.OtherClass2";
- final String annotationName = "TestAnnotation";
- final String fqAnnotationName = "annot.TestAnnotation";
-
- createClassAndMembers(otherClassName, "");
- createClassAndMembers(otherClassName2, "");
- createAnnotationAndMembers(annotationName, "Class[] foo();");
-
- ICompilationUnit cu = createTestType(
- new ArrayIterator<String>(new String[] {fqOtherClassName, fqOtherClassName2, fqAnnotationName}),
- "@TestAnnotation(foo={1, " + otherClassName + ".class})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter(fqAnnotationName);
- DeclarationAnnotationElementAdapter<String[]> daea =
- new ConversionDeclarationAnnotationElementAdapter<String[]>(
- daa, "foo", AnnotationStringArrayExpressionConverter.forTypes());
- JDTFieldAttribute field = idField(cu);
-
- Iterable<String> actual = ASTTools.resolveFullyQualifiedNames(daea.getExpression(field.getModifiedDeclaration(this.buildASTRoot(cu))));
-
- assertEquals(
- CollectionTools.list(new String[] {null, fqOtherClassName}),
- CollectionTools.list(actual));
- }
-
- public void testResolveFullyQualifiedNames3() throws Exception {
- final String otherClassName = "OtherClass";
- final String otherClassName2 = "OtherClass2";
- final String fqOtherClassName = "clazz.OtherClass";
- final String fqOtherClassName2 = "clazz.OtherClass2";
- final String annotationName = "TestAnnotation";
- final String fqAnnotationName = "annot.TestAnnotation";
-
- createClassAndMembers(otherClassName, "");
- createClassAndMembers(otherClassName2, "");
- createAnnotationAndMembers(annotationName, "Class[] foo();");
-
- ICompilationUnit cu = createTestType(
- new ArrayIterator<String>(new String[] {fqOtherClassName, fqOtherClassName2, fqAnnotationName}),
- "@TestAnnotation(foo={@TestAnnotation(), " + otherClassName + ".class}");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter(fqAnnotationName);
- DeclarationAnnotationElementAdapter<String[]> daea =
- new ConversionDeclarationAnnotationElementAdapter<String[]>(
- daa, "foo", AnnotationStringArrayExpressionConverter.forTypes());
- JDTFieldAttribute field = idField(cu);
-
- Iterable<String> actual = ASTTools.resolveFullyQualifiedNames(daea.getExpression(field.getModifiedDeclaration(this.buildASTRoot(cu))));
-
- assertEquals(
- CollectionTools.list(new String[] {null, fqOtherClassName}),
- CollectionTools.list(actual));
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/AnnotationTestCase.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/AnnotationTestCase.java
deleted file mode 100644
index 7eca5e2f1b..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/AnnotationTestCase.java
+++ /dev/null
@@ -1,1099 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import junit.framework.TestCase;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.dom.AST;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.ArrayInitializer;
-import org.eclipse.jdt.core.dom.BodyDeclaration;
-import org.eclipse.jdt.core.dom.BooleanLiteral;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.EnumConstantDeclaration;
-import org.eclipse.jdt.core.dom.EnumDeclaration;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.IExtendedModifier;
-import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.Name;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.NumberLiteral;
-import org.eclipse.jdt.core.dom.PackageDeclaration;
-import org.eclipse.jdt.core.dom.SimpleName;
-import org.eclipse.jdt.core.dom.SimpleType;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jdt.core.dom.TypeLiteral;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools;
-import org.eclipse.jpt.common.core.internal.utility.jdt.JDTFieldAttribute;
-import org.eclipse.jpt.common.core.internal.utility.jdt.JDTMethodAttribute;
-import org.eclipse.jpt.common.core.internal.utility.jdt.JDTType;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject;
-import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-import org.eclipse.jpt.common.core.utility.jdt.Type;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-/**
- * Provide an easy(?) way to build an annotated source file.
- * The type must be created by calling one of the {@link #createTestType()}
- * methods before calling any of the various helper methods (i.e. the type is
- * <em>not</em> created during {@link #setUp()}).
- */
-@SuppressWarnings("nls")
-public abstract class AnnotationTestCase
- extends TestCase
-{
- protected TestJavaProject javaProject;
-
- public static final String CR = System.getProperty("line.separator");
- public static final String SEP = File.separator;
- public static final String PROJECT_NAME = "AnnotationTestProject";
- public static final String PACKAGE_NAME = "test";
- public static final String PACKAGE_NAME_ = PACKAGE_NAME + '.';
- public static final String PACKAGE_INFO_FILE_NAME = "package-info.java";
- public static final IPath PACKAGE_INFO_FILE_PATH = new Path("src" + SEP + PACKAGE_NAME + SEP + PACKAGE_INFO_FILE_NAME);
- public static final String TYPE_NAME = "AnnotationTestType";
- public static final String FULLY_QUALIFIED_TYPE_NAME = PACKAGE_NAME_ + TYPE_NAME;
- public static final String FILE_NAME = TYPE_NAME + ".java";
- public static final IPath FILE_PATH = new Path("src" + SEP + PACKAGE_NAME + SEP + FILE_NAME);
-
- public static final String[] EMPTY_STRING_ARRAY = new String[0];
-
-
- // ********** TestCase behavior **********
-
- protected AnnotationTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.javaProject = this.buildJavaProject(false); // false = no auto-build
- }
-
- protected TestJavaProject buildJavaProject(boolean autoBuild) throws Exception {
- return this.buildJavaProject(PROJECT_NAME, autoBuild);
- }
-
- protected TestJavaProject buildJavaProject(String projectName, boolean autoBuild) throws Exception {
- return new TestJavaProject(projectName, autoBuild);
- }
-
- @Override
- protected void tearDown() throws Exception {
-// this.dumpSource();
- this.deleteProject();
- TestTools.clear(this);
- super.tearDown();
- }
-
- protected void deleteProject() throws Exception {
- int i = 1;
- boolean deleted = false;
- while ( ! deleted) {
- try {
- this.javaProject.getProject().delete(true, true, null);
- deleted = true;
- } catch (CoreException ex) {
- if (i == 4) {
- throw new RuntimeException(this.getName() + " - unable to delete project", ex);
- }
- Thread.sleep(1000);
- i++;
- }
- }
- }
-
- protected void dumpSource(ICompilationUnit cu) throws Exception {
- System.out.println("*** " + this.getName() + " ****");
- System.out.println(this.getSource(cu));
- System.out.println();
- }
-
-
- // ********** package creation *********
-
- /**
- * create an un-annotated package-info
- */
- protected ICompilationUnit createTestPackageInfo() throws CoreException {
- return this.createTestPackageInfo(new DefaultAnnotationWriter());
- }
-
- /**
- * create an un-annotated package-info in a package the given name
- */
- protected ICompilationUnit createTestPackageInfo(String packageName) throws CoreException {
- return this.createTestPackageInfo(packageName, new DefaultAnnotationWriter());
- }
-
- /**
- * shortcut for simply adding an annotation to the package declaration
- */
- protected ICompilationUnit createTestPackageInfo(
- final String packageAnnotation, final String ... imports)
- throws CoreException {
-
- return createTestPackageInfo(
- new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return new ArrayIterator<String>(imports);
- }
-
- @Override
- public void appendPackageAnnotationTo(StringBuilder sb) {
- sb.append(packageAnnotation);
- }
- });
- }
-
- protected ICompilationUnit createTestPackageInfo(AnnotationWriter annotationWriter) throws CoreException {
- return this.createTestPackageInfo(PACKAGE_NAME, annotationWriter);
- }
-
- protected ICompilationUnit createTestPackageInfo(String packageName, AnnotationWriter annotationWriter) throws CoreException {
- return this.javaProject.createCompilationUnit(
- packageName, PACKAGE_INFO_FILE_NAME, this.createSourceWriter(annotationWriter, packageName, null));
- }
-
-
- // ********** type creation **********
-
- /**
- * create an un-annotated type
- */
- protected ICompilationUnit createTestType() throws CoreException {
- return this.createTestType(new DefaultAnnotationWriter());
- }
-
- /**
- * shortcut for simply adding an annotation to the 'id' field
- */
- protected ICompilationUnit createTestType(final String annotationImport, final String idFieldAnnotation) throws CoreException {
- return this.createTestType(new DefaultAnnotationWriter() {
- @Override
- public Iterator<String> imports() {
- return (annotationImport == null) ?
- EmptyIterator.<String>instance() :
- new SingleElementIterator<String>(annotationImport);
- }
- @Override
- public void appendIdFieldAnnotationTo(StringBuilder sb) {
- sb.append(idFieldAnnotation);
- }
- });
- }
-
- /**
- * shortcut for simply adding a fully-qualified annotation to the 'id' field
- */
- protected ICompilationUnit createTestType(final String idFieldAnnotation) throws CoreException {
- return this.createTestType(null, idFieldAnnotation);
- }
-
- protected ICompilationUnit createTestType(AnnotationWriter annotationWriter) throws CoreException {
- return this.javaProject.createCompilationUnit(PACKAGE_NAME, FILE_NAME, this.createSourceWriter(annotationWriter));
- }
-
- protected ICompilationUnit createTestType(String typeName, AnnotationWriter annotationWriter) throws CoreException {
- return this.javaProject.createCompilationUnit(PACKAGE_NAME, typeName + ".java", createSourceWriter(annotationWriter, typeName));
- }
-
- protected ICompilationUnit createTestType(String packageName, String fileName, String typeName, AnnotationWriter annotationWriter) throws CoreException {
- return this.javaProject.createCompilationUnit(packageName, fileName, this.createSourceWriter(annotationWriter, typeName));
- }
-
- protected SourceWriter createSourceWriter(AnnotationWriter annotationWriter) {
- return new AnnotatedSourceWriter(annotationWriter);
- }
-
- protected SourceWriter createSourceWriter(AnnotationWriter annotationWriter, String typeName) {
- return new AnnotatedSourceWriter(annotationWriter, typeName);
- }
-
- protected SourceWriter createSourceWriter(AnnotationWriter annotationWriter, String packageName, String typeName) {
- return new AnnotatedSourceWriter(annotationWriter, packageName, typeName);
- }
-
- protected ICompilationUnit createTestEnum(EnumAnnotationWriter annotationWriter) throws CoreException {
- return this.javaProject.createCompilationUnit(PACKAGE_NAME, FILE_NAME, this.createEnumSourceWriter(annotationWriter));
- }
-
- protected ICompilationUnit createTestEnum(String packageName, String fileName, String enumName, EnumAnnotationWriter annotationWriter) throws CoreException {
- return this.javaProject.createCompilationUnit(packageName, fileName, this.createEnumSourceWriter(annotationWriter, enumName));
- }
-
- protected SourceWriter createEnumSourceWriter(EnumAnnotationWriter annotationWriter) {
- return new EnumAnnotatedSourceWriter(annotationWriter);
- }
-
- protected SourceWriter createEnumSourceWriter(EnumAnnotationWriter annotationWriter, String enumName) {
- return new EnumAnnotatedSourceWriter(annotationWriter, enumName);
- }
-
- protected SourceWriter createEnumSourceWriter(EnumAnnotationWriter annotationWriter, String packageName, String enumName) {
- return new EnumAnnotatedSourceWriter(annotationWriter, packageName, enumName);
- }
-
- protected ICompilationUnit createAnnotatedEnumAndMembers(String enumName, String enumBody) throws Exception {
- StringBuilder sb = new StringBuilder();
- sb.append("package ").append(PACKAGE_NAME).append(";").append(CR);
- sb.append(CR);
- sb.append("import javax.xml.bind.annotation.XmlEnum;");
- sb.append(CR);
- sb.append(CR);
- sb.append("@XmlEnum");
- sb.append(CR);
- sb.append("public enum ").append(enumName).append(" { ").append(enumBody).append(" }");
-
- return this.javaProject.createCompilationUnit(PACKAGE_NAME, enumName + ".java", sb.toString());
- }
-
- /**
- * writes source for package-info java files
- */
- protected void appendSourceTo(
- StringBuilder sb, AnnotationWriter annotationWriter, String packageName) {
-
- annotationWriter.appendPackageAnnotationTo(sb);
- sb.append(CR);
- sb.append("package ").append(packageName).append(";").append(CR);
- sb.append(CR);
- for (Iterator<String> stream = annotationWriter.imports(); stream.hasNext(); ) {
- sb.append("import ").append(stream.next()).append(";").append(CR);
- }
- }
-
- /**
- * writes source for typical java files
- */
- protected void appendSourceTo(
- StringBuilder sb, AnnotationWriter annotationWriter,
- String packageName, String typeName) {
-
- sb.append("package ").append(packageName).append(";").append(CR);
- sb.append(CR);
- for (Iterator<String> stream = annotationWriter.imports(); stream.hasNext(); ) {
- sb.append("import ");
- sb.append(stream.next());
- sb.append(";");
- sb.append(CR);
- }
- sb.append(CR);
- annotationWriter.appendTypeAnnotationTo(sb);
- sb.append(CR);
- sb.append("public class ").append(typeName).append(" ");
- annotationWriter.appendExtendsImplementsTo(sb);
- sb.append("{").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendIdFieldAnnotationTo(sb);
- sb.append(CR);
- sb.append(" private int id;").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendNameFieldAnnotationTo(sb);
- sb.append(CR);
- sb.append(" private String name;").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendGetIdMethodAnnotationTo(sb);
- sb.append(CR);
- sb.append(" public int getId() {").append(CR);
- sb.append(" return this.id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendSetIdMethodAnnotationTo(sb);
- sb.append(CR);
- sb.append(" public void setId(int id) {").append(CR);
- sb.append(" this.id = id;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendGetNameMethodAnnotationTo(sb);
- sb.append(CR);
- sb.append(" public String getName() {").append(CR);
- sb.append(" return this.name;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendSetNameMethodAnnotationTo(sb);
- sb.append(CR);
- sb.append(" public void setTestField(String testField) {").append(CR);
- sb.append(" this.testField = testField;").append(CR);
- sb.append(" }").append(CR);
- sb.append(CR);
- annotationWriter.appendMemberTypeTo(sb);
- sb.append(CR);
- sb.append("}").append(CR);
- annotationWriter.appendTopLevelTypesTo(sb);
- sb.append(CR);
- }
-
-
- /**
- * writes source for typical java enum files
- */
- protected void appendEnumSourceTo(
- StringBuilder sb, EnumAnnotationWriter annotationWriter,
- String packageName, String enumName) {
-
- sb.append("package ").append(packageName).append(";").append(CR);
- sb.append(CR);
- for (Iterator<String> stream = annotationWriter.imports(); stream.hasNext(); ) {
- sb.append("import ");
- sb.append(stream.next());
- sb.append(";");
- sb.append(CR);
- }
- sb.append(CR);
- annotationWriter.appendEnumAnnotationTo(sb);
- sb.append(CR);
- sb.append("public enum ").append(enumName).append(" {").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendSundayEnumConstantAnnotationTo(sb);
- sb.append(CR);
- sb.append(" SUNDAY, ").append(CR);
- sb.append(CR);
- sb.append(" ");
- annotationWriter.appendMondayEnumConstantAnnotationTo(sb);
- sb.append(CR);
- sb.append(" MONDAY").append(CR);
- sb.append(CR);
- sb.append("}").append(CR);
- sb.append(CR);
- }
-
-
- // ********** queries **********
-
- protected TestJavaProject getJavaProject() {
- return this.javaProject;
- }
-
- protected JDTType testType(ICompilationUnit cu) {
- return this.buildType(TYPE_NAME, cu);
- }
-
- protected JDTType buildType(String name, ICompilationUnit cu) {
- return this.buildType(name, 1, cu);
- }
-
- protected JDTType buildType(String name, int occurrence, ICompilationUnit cu) {
- return this.buildType(null, name, occurrence, cu);
- }
-
- protected JDTType buildType(Type declaringType, String name, int occurrence, ICompilationUnit cu) {
- return new JDTType(declaringType, name, occurrence, cu);
- }
-
- protected JDTFieldAttribute idField(ICompilationUnit cu) {
- return this.buildField("id", cu);
- }
-
- protected JDTFieldAttribute nameField(ICompilationUnit cu) {
- return this.buildField("name", cu);
- }
-
- protected JDTFieldAttribute buildField(String name, ICompilationUnit cu) {
- return this.buildField(name, 1, cu);
- }
-
- protected JDTFieldAttribute buildField(String name, int occurrence, ICompilationUnit cu) {
- return this.buildField(this.testType(cu), name, occurrence, cu);
- }
-
- protected JDTFieldAttribute buildField(Type declaringType, String name, int occurrence, ICompilationUnit cu) {
- return new JDTFieldAttribute(declaringType, name, occurrence, cu);
- }
-
- protected JDTMethodAttribute idGetMethod(ICompilationUnit cu) {
- return this.buildMethod("getId", cu);
- }
-
- protected JDTMethodAttribute idSetMethod(ICompilationUnit cu) {
- return this.buildMethod("setId", new String[] {"int"}, cu);
- }
-
- protected JDTMethodAttribute nameGetMethod(ICompilationUnit cu) {
- return this.buildMethod("getName", cu);
- }
-
- protected JDTMethodAttribute buildMethod(String name, ICompilationUnit cu) {
- return this.buildMethod(name, EMPTY_STRING_ARRAY, cu);
- }
-
- protected JDTMethodAttribute buildMethod(String name, String[] parameterTypeNames, ICompilationUnit cu) {
- return this.buildMethod(name, parameterTypeNames, 1, cu);
- }
-
- protected JDTMethodAttribute buildMethod(String name, String[] parameterTypeNames, int occurrence, ICompilationUnit cu) {
- return new JDTMethodAttribute(this.testType(cu), name, parameterTypeNames, occurrence, cu);
- }
-
- protected JDTMethodAttribute buildMethod(Type declaringType, String name, String[] parameterTypeNames, int occurrence, ICompilationUnit cu) {
- return new JDTMethodAttribute(declaringType, name, parameterTypeNames, occurrence, cu);
- }
-
- protected String getSource(ICompilationUnit cu) throws JavaModelException {
- return cu.getBuffer().getContents();
- }
-
- protected CompilationUnit buildASTRoot(ICompilationUnit cu) {
- return ASTTools.buildASTRoot(cu);
- }
-
-
- // ********** test validation **********
-
- protected void assertSourceContains(String s, ICompilationUnit cu) throws JavaModelException {
- String source = this.getSource(cu);
- boolean found = source.indexOf(s) > -1;
- if ( ! found) {
- String msg = "source does not contain the expected string: " + s + " (see System console)";
- System.out.println("*** " + this.getName() + " ****");
- System.out.println(msg);
- System.out.println(source);
- System.out.println();
- fail(msg);
- }
- }
-
- protected void assertSourceDoesNotContain(String s, ICompilationUnit cu) throws JavaModelException {
- String source = this.getSource(cu);
- int pos = source.indexOf(s);
- if (pos != -1) {
- String msg = "unexpected string in source (position: " + pos + "): " + s + " (see System console)";
- System.out.println("*** " + this.getName() + " ****");
- System.out.println(msg);
- System.out.println(source);
- System.out.println();
- fail(msg);
- }
- }
-
-
- // ********** manipulate annotations **********
-
- /**
- * Return the *first* member value pair for the specified annotation element
- * with the specified name.
- * Return null if the annotation has no such element.
- */
- protected MemberValuePair memberValuePair(NormalAnnotation annotation, String elementName) {
- for (MemberValuePair pair : this.values(annotation)) {
- if (pair.getName().getFullyQualifiedName().equals(elementName)) {
- return pair;
- }
- }
- return null;
- }
-
- /**
- * minimize the scope of the suppressed warnings
- */
- @SuppressWarnings("unchecked")
- protected List<MemberValuePair> values(NormalAnnotation na) {
- return na.values();
- }
-
- /**
- * minimize the scope of the suppressed warnings
- */
- @SuppressWarnings("unchecked")
- protected List<EnumConstantDeclaration> enumConstants(EnumDeclaration ed) {
- return ed.enumConstants();
- }
-
- /**
- * check for null member value pair
- */
- protected Expression value_(MemberValuePair pair) {
- return (pair == null) ? null : pair.getValue();
- }
-
- /**
- * Return the value of the *first* annotation element
- * with the specified name.
- * Return null if the annotation has no such element.
- */
- protected Expression annotationElementValue(NormalAnnotation annotation, String elementName) {
- return this.value_(this.memberValuePair(annotation, elementName));
- }
-
- /**
- * Return the value of the *first* annotation element
- * with the specified name.
- * Return null if the annotation has no such element.
- */
- protected Expression annotationElementValue(SingleMemberAnnotation annotation, String elementName) {
- return elementName.equals("value") ? annotation.getValue() : null;
- }
-
- /**
- * Return the value of the *first* annotation element
- * with the specified name.
- * Return null if the annotation has no such element.
- * (An element name of "value" will return the value of a single
- * member annotation.)
- */
- protected Expression annotationElementValue(Annotation annotation, String elementName) {
- if (annotation.isNormalAnnotation()) {
- return this.annotationElementValue((NormalAnnotation) annotation, elementName);
- }
- if (annotation.isSingleMemberAnnotation()) {
- return this.annotationElementValue((SingleMemberAnnotation) annotation, elementName);
- }
- return null;
- }
-
- protected ArrayInitializer newArrayInitializer(AST ast, Expression... expressions) {
- ArrayInitializer arrayInitializer = ast.newArrayInitializer();
- for (Expression expression : expressions) {
- arrayInitializer.expressions().add(expression);
- }
- return arrayInitializer;
- }
-
- /**
- * Build a number literal and set its initial value to the specified literal.
- */
- protected NumberLiteral newNumberLiteral(AST ast, int value) {
- return ast.newNumberLiteral(Integer.toString(value));
- }
-
- /**
- * Build a number literal and set its initial value to the specified literal.
- */
- protected BooleanLiteral newBooleanLiteral(AST ast, boolean value) {
- return ast.newBooleanLiteral(value);
- }
-
- /**
- * Build a string literal and set its initial value.
- */
- protected StringLiteral newStringLiteral(AST ast, String value) {
- StringLiteral stringLiteral = ast.newStringLiteral();
- stringLiteral.setLiteralValue(value);
- return stringLiteral;
- }
-
- protected TypeLiteral newTypeLiteral(AST ast, String typeName) {
- TypeLiteral typeLiteral = ast.newTypeLiteral();
- typeLiteral.setType(this.newSimpleType(ast, typeName));
- return typeLiteral;
- }
-
- protected SimpleType newSimpleType(AST ast, String typeName) {
- return this.newSimpleType(ast, ast.newName(typeName));
- }
-
- protected SimpleType newSimpleType(AST ast, Name typeName) {
- return ast.newSimpleType(typeName);
- }
-
- protected MemberValuePair newMemberValuePair(AST ast, SimpleName name, Expression value) {
- MemberValuePair pair = ast.newMemberValuePair();
- pair.setName(name);
- pair.setValue(value);
- return pair;
- }
-
- protected MemberValuePair newMemberValuePair(AST ast, String name, Expression value) {
- return this.newMemberValuePair(ast, ast.newSimpleName(name), value);
- }
-
- protected MemberValuePair newMemberValuePair(AST ast, String name, String value) {
- return this.newMemberValuePair(ast, name, this.newStringLiteral(ast, value));
- }
-
- protected MemberValuePair newMemberValuePair(AST ast, String name, int value) {
- return this.newMemberValuePair(ast, name, this.newNumberLiteral(ast, value));
- }
-
- protected MemberValuePair newMemberValuePair(AST ast, String name, boolean value) {
- return this.newMemberValuePair(ast, name, this.newBooleanLiteral(ast, value));
- }
-
- protected EnumConstantDeclaration newEnumConstantDeclaration(AST ast, String enumConstantName) {
- EnumConstantDeclaration enumConstantDeclaration = ast.newEnumConstantDeclaration();
- enumConstantDeclaration.setName(ast.newSimpleName(enumConstantName));
- return enumConstantDeclaration;
- }
- /**
- * Add the specified member value pair to the specified annotation.
- * Return the resulting annotation.
- */
- protected NormalAnnotation addMemberValuePair(NormalAnnotation annotation, MemberValuePair pair) {
- this.values(annotation).add(pair);
- return annotation;
- }
-
- /**
- * Add the specified member value pair to the specified annotation.
- * Return the resulting annotation.
- */
- protected NormalAnnotation addMemberValuePair(NormalAnnotation annotation, String name, int value) {
- return this.addMemberValuePair(annotation, this.newMemberValuePair(annotation.getAST(), name, value));
- }
-
- /**
- * Add the specified member value pair to the specified annotation.
- * Return the resulting annotation.
- */
- protected NormalAnnotation addMemberValuePair(NormalAnnotation annotation, String name, String value) {
- return this.addMemberValuePair(annotation, this.newMemberValuePair(annotation.getAST(), name, value));
- }
-
- /**
- * Add the specified member value pair to the marker annotation
- * by first replacing it with a normal annotation.
- * Return the resulting normal annotation.
- */
- protected NormalAnnotation addMemberValuePair(MarkerAnnotation annotation, String name, String value) {
- NormalAnnotation normalAnnotation = this.replaceMarkerAnnotation(annotation);
- this.addMemberValuePair(normalAnnotation, this.newMemberValuePair(annotation.getAST(), name, value));
- return normalAnnotation;
- }
-
- protected NormalAnnotation addMemberValuePair(MarkerAnnotation annotation, String name, boolean value) {
- NormalAnnotation normalAnnotation = this.replaceMarkerAnnotation(annotation);
- this.addMemberValuePair(normalAnnotation, this.newMemberValuePair(annotation.getAST(), name, value));
- return normalAnnotation;
- }
-
- /**
- * Add the specified member value pair to the marker annotation
- * by first replacing it with a normal annotation.
- * Return the resulting normal annotation.
- */
- protected NormalAnnotation addMemberValuePair(MarkerAnnotation annotation, MemberValuePair pair) {
- NormalAnnotation normalAnnotation = this.replaceMarkerAnnotation(annotation);
- return this.addMemberValuePair(normalAnnotation, pair);
- }
-
- protected void setMemberValuePair(ModifiedDeclaration declaration, String annotationName, String value) {
- setMemberValuePair(declaration, annotationName, "value", value);
- }
-
- protected void setMemberValuePair(ModifiedDeclaration declaration, String annotationName, String elementName, String value) {
- Annotation annotation = declaration.getAnnotationNamed(annotationName);
- if (annotation == null) {
- annotation = addNormalAnnotation(declaration.getDeclaration(), annotationName);
- }
- else if (annotation instanceof MarkerAnnotation) {
- annotation = replaceMarkerAnnotation((MarkerAnnotation) annotation);
- }
- setMemberValuePair((NormalAnnotation) annotation, elementName, value);
- }
-
- protected void setMemberValuePair(NormalAnnotation annotation, String elementName, String value) {
- MemberValuePair memberValuePair = this.memberValuePair(annotation, elementName);
- if (memberValuePair == null) {
- addMemberValuePair(annotation, elementName, value);
- }
- else {
- memberValuePair.setValue(newStringLiteral(annotation.getAST(), value));
- }
- }
-
- protected void removeMemberValuePair(ModifiedDeclaration declaration, String annotationName) {
- removeMemberValuePair(declaration, annotationName, "value");
- }
-
- protected void removeMemberValuePair(ModifiedDeclaration declaration, String annotationName, String elementName) {
- NormalAnnotation annotation = (NormalAnnotation) declaration.getAnnotationNamed(annotationName);
- values(annotation).remove(memberValuePair(annotation, elementName));
- }
-
- protected void setEnumMemberValuePair(ModifiedDeclaration declaration, String annotationName, String enumValue) {
- NormalAnnotation annotation = (NormalAnnotation) declaration.getAnnotationNamed(annotationName);
- if (annotation == null) {
- annotation = addNormalAnnotation(declaration.getDeclaration(), annotationName);
- }
- this.setEnumMemberValuePair(annotation, "value", enumValue);
- }
-
- protected void setEnumMemberValuePair(NormalAnnotation annotation, String elementName, String enumValue) {
- MemberValuePair memberValuePair = this.memberValuePair(annotation, elementName);
- if (memberValuePair == null) {
- this.addEnumMemberValuePair(annotation, elementName, enumValue);
- }
- else {
- memberValuePair.setValue(annotation.getAST().newName(enumValue));
- }
- }
-
- protected void addEnumMemberValuePair(MarkerAnnotation markerAnnotation, String elementName, String value) {
- this.addEnumMemberValuePair(this.replaceMarkerAnnotation(markerAnnotation), elementName, value);
- }
-
- protected void addEnumMemberValuePair(NormalAnnotation annotation, String elementName, String value) {
- this.addMemberValuePair(annotation, elementName, annotation.getAST().newName(value));
- }
-
- protected void addMemberValuePair(NormalAnnotation annotation, String elementName, Expression value) {
- MemberValuePair memberValuePair = this.newMemberValuePair(annotation.getAST(), elementName, value);
- this.addMemberValuePair(annotation, memberValuePair);
- }
-
- protected void addMemberValuePair(MarkerAnnotation annotation, String elementName, Expression value) {
- MemberValuePair memberValuePair = this.newMemberValuePair(annotation.getAST(), elementName, value);
- this.addMemberValuePair(annotation, memberValuePair);
- }
-
- protected void addEnumConstant(EnumDeclaration enumDeclaration, String enumConstantName) {
- EnumConstantDeclaration enumConstantDeclaration = this.newEnumConstantDeclaration(enumDeclaration.getAST(), enumConstantName);
- this.enumConstants(enumDeclaration).add(enumConstantDeclaration);
- }
-
- protected void removeEnumConstant(EnumDeclaration enumDeclaration, String enumConstantName) {
- List<EnumConstantDeclaration> enumConstantsList = this.enumConstants(enumDeclaration);
- for (EnumConstantDeclaration constant : enumConstantsList) {
- if (constant.getName().getFullyQualifiedName().equals(enumConstantName)) {
- enumConstantsList.remove(constant);
- break;
- }
- }
- }
-
- protected void changeEnumConstantName(EnumDeclaration enumDeclaration, String oldEnumConstantName, String newEnumConstantName) {
- List<EnumConstantDeclaration> enumConstantsList = this.enumConstants(enumDeclaration);
- for (EnumConstantDeclaration constant : enumConstantsList) {
- if (constant.getName().getFullyQualifiedName().equals(oldEnumConstantName)) {
- this.changeEnumConstantName(constant, newEnumConstantName);
- break;
- }
- }
- }
-
- protected void changeEnumConstantName(EnumConstantDeclaration enumConstantDeclaration, String newEnumConstantName) {
- enumConstantDeclaration.setName(enumConstantDeclaration.getAST().newSimpleName(newEnumConstantName));
- }
-
- /**
- * Add the array element to an annotation that is either a normal annotation or a marker annotation.
- * If it is a marker annotation first make it a normal annotation.
- */
- protected void addArrayElement(ModifiedDeclaration declaration, String annotationName, int index, String elementName, Expression arrayElement) {
- Annotation annotation = declaration.getAnnotationNamed(annotationName);
- NormalAnnotation normalAnnotation;
- if (annotation == null) {
- normalAnnotation = this.addNormalAnnotation(declaration.getDeclaration(), annotationName);
- }
- else if (annotation.getNodeType() == ASTNode.MARKER_ANNOTATION) {
- normalAnnotation = this.replaceMarkerAnnotation((MarkerAnnotation) annotation);
- }
- else {
- normalAnnotation = (NormalAnnotation) annotation;
- }
- this.addArrayElement(normalAnnotation, index, elementName, arrayElement);
- }
-
- /**
- * Add the array element to the given normal annotation's element named elementName.
- * Add a new member value pair if one does not exist.
- * If the member value pair exists but the value is not yet an array, make it an array.
- */
- protected void addArrayElement(NormalAnnotation annotation, int index, String elementName, Expression arrayElement) {
- MemberValuePair pair = this.memberValuePair(annotation, elementName);
- if (pair == null) {
- pair = this.newMemberValuePair(annotation.getAST(), elementName, arrayElement);
- this.addMemberValuePair(annotation, pair);
- }
- else {
- Expression value = pair.getValue();
- if (value.getNodeType() == ASTNode.ARRAY_INITIALIZER) {
- this.expressions((ArrayInitializer) value).add(index, arrayElement);
- }
- else {
- ArrayInitializer arrayInitializer = annotation.getAST().newArrayInitializer();
- pair.setValue(arrayInitializer);
- this.expressions(arrayInitializer).add(value);
- this.expressions(arrayInitializer).add(index, arrayElement);
- }
- }
- }
-
- /**
- * This assumes an element with name elementName exists with an array as its value.
- * Move the array element at sourceIndex to the targetIndex
- */
- protected void moveArrayElement(NormalAnnotation annotation, String elementName, int targetIndex, int sourceIndex) {
- MemberValuePair pair = this.memberValuePair(annotation, elementName);
- ArrayInitializer array = (ArrayInitializer) pair.getValue();
- CollectionTools.move(this.expressions(array), targetIndex, sourceIndex);
- }
-
- /**
- * This assumes an element with name elementName exists with potentially an array as its value.
- * If the value is not an array, then the member value pair is removed.
- * If the array element is removed and there is only 1 array element left, the array itself is removed
- * and the remaining element is set as the value of the member value pair
- */
- protected void removeArrayElement(NormalAnnotation annotation, String elementName, int index) {
- MemberValuePair pair = this.memberValuePair(annotation, elementName);
- if (pair.getValue().getNodeType() == ASTNode.ARRAY_INITIALIZER) {
- ArrayInitializer array = (ArrayInitializer) pair.getValue();
- this.expressions(array).remove(index);
- if (this.expressions(array).size() == 1) {
- pair.setValue(this.expressions(array).remove(0));
- }
- }
- else {
- this.values(annotation).remove(pair);
- }
- }
-
- /**
- * Replace the given marker annotation with a normal annotation.
- * Return the resulting normal annotation.
- */
- protected NormalAnnotation replaceMarkerAnnotation(MarkerAnnotation annotation) {
- List<IExtendedModifier> annotations = this.annotations(annotation.getParent());
- int index = annotations.indexOf(annotation);
- NormalAnnotation normalAnnotation = newNormalAnnotation(annotation.getAST(), annotation.getTypeName().getFullyQualifiedName());
- annotations.set(index, normalAnnotation);
- return normalAnnotation;
- }
-
- /**
- * Build a normal annotation and set its name.
- */
- protected NormalAnnotation newNormalAnnotation(AST ast, String name) {
- NormalAnnotation annotation = ast.newNormalAnnotation();
- annotation.setTypeName(ast.newName(name));
- return annotation;
- }
-
- /**
- * Add the normal annotation to the given AST node.
- * This should be a PackageDeclaration or a BodyDeclaration.
- * Return the resulting normal annotation.
- */
- protected NormalAnnotation addNormalAnnotation(ASTNode astNode, String name) {
- NormalAnnotation annotation = this.newNormalAnnotation(astNode.getAST(), name);
- this.addAnnotation(astNode, annotation);
- return annotation;
- }
-
- /**
- * Add the annotation to the given AST node.
- * This should be a PackageDeclaration or a BodyDeclaration.
- */
- protected void addAnnotation(ASTNode astNode, Annotation annotation) {
- this.annotations(astNode).add(annotation);
- }
-
- /**
- * Build a marker annotation and set its name.
- */
- protected MarkerAnnotation newMarkerAnnotation(AST ast, String name) {
- MarkerAnnotation annotation = ast.newMarkerAnnotation();
- annotation.setTypeName(ast.newName(name));
- return annotation;
- }
-
- /**
- * Add the normal annotation to the given AST node.
- * This should be a PackageDeclaration or a BodyDeclaration.
- * Return the resulting normal annotation.
- */
- protected MarkerAnnotation addMarkerAnnotation(ASTNode astNode, String name) {
- MarkerAnnotation annotation = this.newMarkerAnnotation(astNode.getAST(), name);
- this.addAnnotation(astNode, annotation);
- return annotation;
- }
-
- /**
- * Remove the annotation with the specified name
- */
- protected void removeAnnotation(ModifiedDeclaration declaration, String name) {
- this.removeAnnotation(declaration.getDeclaration(), declaration.getAnnotationNamed(name));
- }
-
- /**
- * Remove the specified annotation from the AST node.
- * This should be a PackageDeclaration or a BodyDeclaration.
- */
- protected void removeAnnotation(ASTNode astNode, Annotation annotation) {
- this.annotations(astNode).remove(annotation);
- }
-
- /**
- * minimize the scope of the suppressed warnings
- */
- @SuppressWarnings("unchecked")
- protected List<IExtendedModifier> annotations(ASTNode astNode) {
- if (astNode instanceof BodyDeclaration) {
- return ((BodyDeclaration) astNode).modifiers();
- }
- else if (astNode instanceof PackageDeclaration) {
- return ((PackageDeclaration) astNode).annotations();
- }
- return Collections.emptyList();
- }
-
- /**
- * minimize the scope of the suppressed warnings
- */
- @SuppressWarnings("unchecked")
- protected List<Expression> expressions(ArrayInitializer arrayInitializer) {
- return arrayInitializer.expressions();
- }
-
-
- // ********** member classes **********
-
- public interface AnnotationWriter {
- Iterator<String> imports();
- void appendPackageAnnotationTo(StringBuilder sb);
- void appendTypeAnnotationTo(StringBuilder sb);
- void appendExtendsImplementsTo(StringBuilder sb);
- void appendIdFieldAnnotationTo(StringBuilder sb);
- void appendNameFieldAnnotationTo(StringBuilder sb);
- void appendGetIdMethodAnnotationTo(StringBuilder sb);
- void appendSetIdMethodAnnotationTo(StringBuilder sb);
- void appendGetNameMethodAnnotationTo(StringBuilder sb);
- void appendSetNameMethodAnnotationTo(StringBuilder sb);
- void appendMemberTypeTo(StringBuilder sb);
- void appendTopLevelTypesTo(StringBuilder sb);
- }
-
- public static class DefaultAnnotationWriter implements AnnotationWriter {
- public Iterator<String> imports() {return EmptyIterator.instance();}
- public void appendPackageAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendTypeAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendExtendsImplementsTo(StringBuilder sb) {/* do nothing */}
- public void appendIdFieldAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendNameFieldAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendSetIdMethodAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendGetNameMethodAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendSetNameMethodAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendMemberTypeTo(StringBuilder sb) {/* do nothing */}
- public void appendTopLevelTypesTo(StringBuilder sb) {/* do nothing */}
- }
-
- public static class AnnotationWriterWrapper implements AnnotationWriter {
- private final AnnotationWriter aw;
- public AnnotationWriterWrapper(AnnotationWriter aw) {
- super();
- this.aw = aw;
- }
- public Iterator<String> imports() {return this.aw.imports();}
- public void appendPackageAnnotationTo(StringBuilder sb) {this.aw.appendPackageAnnotationTo(sb);}
- public void appendTypeAnnotationTo(StringBuilder sb) {this.aw.appendTypeAnnotationTo(sb);}
- public void appendExtendsImplementsTo(StringBuilder sb) {this.aw.appendExtendsImplementsTo(sb);}
- public void appendIdFieldAnnotationTo(StringBuilder sb) {this.aw.appendIdFieldAnnotationTo(sb);}
- public void appendNameFieldAnnotationTo(StringBuilder sb) {this.aw.appendNameFieldAnnotationTo(sb);}
- public void appendGetIdMethodAnnotationTo(StringBuilder sb) {this.aw.appendGetIdMethodAnnotationTo(sb);}
- public void appendSetIdMethodAnnotationTo(StringBuilder sb) {this.aw.appendSetIdMethodAnnotationTo(sb);}
- public void appendGetNameMethodAnnotationTo(StringBuilder sb) {this.aw.appendGetNameMethodAnnotationTo(sb);}
- public void appendSetNameMethodAnnotationTo(StringBuilder sb) {this.aw.appendSetNameMethodAnnotationTo(sb);}
- public void appendMemberTypeTo(StringBuilder sb) {this.aw.appendMemberTypeTo(sb);}
- public void appendTopLevelTypesTo(StringBuilder sb) {this.aw.appendTopLevelTypesTo(sb);}
- }
-
- public class AnnotatedSourceWriter
- implements SourceWriter {
-
- private AnnotationWriter annotationWriter;
- private String packageName;
- private String typeName;
-
- public AnnotatedSourceWriter(AnnotationWriter annotationWriter) {
- this(annotationWriter, TYPE_NAME);
- }
-
- public AnnotatedSourceWriter(AnnotationWriter annotationWriter, String typeName) {
- this(annotationWriter, PACKAGE_NAME, typeName);
- }
-
- public AnnotatedSourceWriter(AnnotationWriter annotationWriter, String packageName, String typeName) {
- super();
- this.annotationWriter = annotationWriter;
- this.packageName = packageName;
- this.typeName = typeName;
- }
-
- public void appendSourceTo(StringBuilder sb) {
- if (this.typeName != null) {
- AnnotationTestCase.this.appendSourceTo(sb, this.annotationWriter, this.packageName, this.typeName);
- }
- else {
- AnnotationTestCase.this.appendSourceTo(sb, this.annotationWriter, this.packageName);
- }
- }
- }
-
- public interface EnumAnnotationWriter {
- Iterator<String> imports();
- void appendPackageAnnotationTo(StringBuilder sb);
- void appendEnumAnnotationTo(StringBuilder sb);
- void appendSundayEnumConstantAnnotationTo(StringBuilder sb);
- void appendMondayEnumConstantAnnotationTo(StringBuilder sb);
- }
-
- public static class DefaultEnumAnnotationWriter implements EnumAnnotationWriter {
- public Iterator<String> imports() {return EmptyIterator.instance();}
- public void appendPackageAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendEnumAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendSundayEnumConstantAnnotationTo(StringBuilder sb) {/* do nothing */}
- public void appendMondayEnumConstantAnnotationTo(StringBuilder sb) {/* do nothing */}
- }
-
- public class EnumAnnotatedSourceWriter
- implements SourceWriter {
-
- private EnumAnnotationWriter annotationWriter;
- private String packageName;
- private String enumName;
-
- public EnumAnnotatedSourceWriter(EnumAnnotationWriter annotationWriter) {
- this(annotationWriter, TYPE_NAME);
- }
-
- public EnumAnnotatedSourceWriter(EnumAnnotationWriter annotationWriter, String enumName) {
- this(annotationWriter, PACKAGE_NAME, enumName);
- }
-
- public EnumAnnotatedSourceWriter(EnumAnnotationWriter annotationWriter, String packageName, String enumName) {
- super();
- this.annotationWriter = annotationWriter;
- this.packageName = packageName;
- this.enumName = enumName;
- }
-
- public void appendSourceTo(StringBuilder sb) {
- AnnotationTestCase.this.appendEnumSourceTo(sb, this.annotationWriter, this.packageName, this.enumName);
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java
deleted file mode 100644
index b4f92fa9a7..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/CombinationIndexedDeclarationAnnotationAdapterTests.java
+++ /dev/null
@@ -1,744 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jpt.common.core.internal.utility.jdt.CombinationIndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ElementAnnotationAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ElementIndexedAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.osgi.framework.Version;
-
-@SuppressWarnings("nls")
-public class CombinationIndexedDeclarationAnnotationAdapterTests extends AnnotationTestCase {
-
- public CombinationIndexedDeclarationAnnotationAdapterTests(String name) {
- super(name);
- }
-
- private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- this.javaProject.createCompilationUnit("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- public void testAnnotation1() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 0);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
- assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isNormalAnnotation());
- }
-
- public void testAnnotation2() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotation3() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 0);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
- assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isNormalAnnotation());
- }
-
- public void testAnnotation4() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotation5() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
- assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isNormalAnnotation());
- String value = ((StringLiteral) this.values((NormalAnnotation) annotation).get(0).getValue()).getLiteralValue();
- assertEquals("ADDRESS_ID2", value);
- }
-
- public void testAnnotation6() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotation7() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
- assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isNormalAnnotation());
- String value = ((StringLiteral) this.values(((NormalAnnotation) annotation)).get(0).getValue()).getLiteralValue();
- assertEquals("ADDRESS_ID2", value);
- }
-
- public void testAnnotation8() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testRemoveAnnotation1() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 0);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("JoinColumn", cu);
- }
-
- public void testRemoveAnnotation2() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 0);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("ADDRESS_ID", cu);
- }
-
- public void testRemoveAnnotation3() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("JoinColumns", cu);
- this.assertSourceDoesNotContain("ADDRESS_ID2", cu);
- this.assertSourceContains("@JoinColumn(name=\"ADDRESS_ID1\")", cu);
- }
-
- public void testRemoveAnnotation4() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("JoinColumns", cu);
- this.assertSourceDoesNotContain("ADDRESS_ID2", cu);
- this.assertSourceContains("@JoinColumn(name=\"ADDRESS_ID1\")", cu);
- }
-
- public void testRemoveAnnotation5() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "String comment(); JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(comment=\"test\",columns={@annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.removeAnnotation();
- this.assertSourceContains("@annot.JoinColumns(comment=\"test\",columns=@annot.JoinColumn(name=\"ADDRESS_ID1\"))", cu);
- }
-
- public void testRemoveAnnotation6() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(null)");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", 0);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.removeAnnotation();
- this.assertSourceContains("@annot.JoinColumns(null)", cu);
- }
-
- public void testRemoveAnnotation12() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID0\")";
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(expected, cu);
- this.assertSourceDoesNotContain("JoinColumns", cu);
- }
-
- public void testRemoveAnnotation13() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({null, @annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- this.assertSourceContains("@annot.JoinColumn", cu);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("ADDRESS_ID", cu);
- }
-
- public void testRemoveAnnotation14() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), null})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID0\")";
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation15() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})");
- String expected = "@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, null, @annot.JoinColumn(name=\"ADDRESS_ID3\")})";
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation16() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})");
- String expected = "@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})";
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 3);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation17() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({null, null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- this.assertSourceContains("@annot.JoinColumn", cu);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("ADDRESS_ID2", cu);
- }
-
- public void testNewMarkerAnnotation1() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("JoinColumn", cu);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("JoinColumn", cu);
- this.assertSourceDoesNotContain("JoinColumns", cu);
- }
-
- public void testNewMarkerAnnotation2() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumn");
- this.assertSourceDoesNotContain("JoinColumns", cu);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@JoinColumns(columns = { @JoinColumn, @JoinColumn })", cu);
- }
-
- public void testNewMarkerAnnotation3() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn, @annot.JoinColumn})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 2);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn, @annot.JoinColumn," + CR + " @JoinColumn})", cu);
- }
-
- public void testNewMarkerAnnotation4() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumn(77)");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("JoinColumn", cu);
- this.assertSourceDoesNotContain("JoinColumns", cu);
- this.assertSourceDoesNotContain("77", cu);
- }
-
- public void testNewMarkerAnnotation5() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns=@annot.JoinColumn(77))");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.JoinColumns(columns=@JoinColumn)", cu);
- this.assertSourceDoesNotContain("77", cu);
- }
-
- public void testNewMarkerAnnotation6() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns=@annot.JoinColumn(77))");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn(77),@JoinColumn})", cu);
- }
-
- public void testNewMarkerAnnotation7() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumn(77)");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@JoinColumns(columns = { @JoinColumn(77), @JoinColumn })", cu);
- }
-
- public void testNewMarkerAnnotation8() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(77),@annot.JoinColumn(88)})");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn(77),@JoinColumn})", cu);
- }
-
- public void testNewMarkerAnnotation9() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)");
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@JoinColumns(columns = { @JoinColumn(text = \"blah\", num = 42), @JoinColumn })", cu);
- }
-
- public void testNewMarkerAnnotation23() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumn(text=\"b\",num=4)");
- String expected1 = "@JoinColumns(columns = { @JoinColumn(text = \"b\", num = 4), null,";
- String expected2 = "@JoinColumn })";
- this.assertSourceDoesNotContain(expected1, cu);
- this.assertSourceDoesNotContain(expected2, cu);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 2);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1, cu);
- this.assertSourceContains(expected2, cu);
- }
-
- public void testNewMarkerAnnotation24() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)");
-
- //Use old formatting if jdt core version is 3.5 or below - see bug 285604
- Version version = Platform.getBundle("org.eclipse.jdt.core").getVersion();
- int majorVersion = version.getMajor();
- int minorVersion = version.getMinor();
- //This condition should be removed and test updated after Dali 3.0 branches
- String expected1;
- if (majorVersion == 3 && minorVersion <= 5) {
- expected1 = "@JoinColumns( {";
- }
- else expected1 = "@JoinColumns({";
-
- String expected2 = "@JoinColumn(text = \"blah\", num = 42), null,";
- String expected3 = "@JoinColumn " + CR + " })";
- this.assertSourceDoesNotContain(expected1, cu);
- this.assertSourceDoesNotContain(expected2, cu);
- this.assertSourceDoesNotContain(expected3, cu);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1, cu);
- this.assertSourceContains(expected2, cu);
- this.assertSourceContains(expected3, cu);
- }
-
- public void testNewMarkerAnnotation25() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected1 = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, null,"; // the line gets split
- String expected2 = "@JoinColumn})";
- this.assertSourceDoesNotContain(expected1, cu);
- this.assertSourceDoesNotContain(expected2, cu);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 4);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1, cu);
- this.assertSourceContains(expected2, cu);
- }
-
- public void testNewMarkerAnnotation26() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected1 = "@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, null,"; // the line gets split
- String expected2 = "@JoinColumn})";
- this.assertSourceDoesNotContain(expected1, cu);
- this.assertSourceDoesNotContain(expected2, cu);
- DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 4);
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1, cu);
- this.assertSourceContains(expected2, cu);
- }
-
- public void testMoveAnnotation1() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID0\")");
- String expected = "@JoinColumns(columns = { null, @JoinColumn(name = \"ADDRESS_ID0\") })";
- this.assertSourceDoesNotContain(expected, cu);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(1);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation2() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={null,@annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID1\")";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- this.assertSourceDoesNotContain("JoinColumns", cu);
- }
-
- public void testMoveAnnotation2a() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({null,@annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID1\")";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 1);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- this.assertSourceDoesNotContain("JoinColumns", cu);
- }
-
- public void testMoveAnnotation3() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\")})");
- String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})";
- this.assertSourceDoesNotContain(expected, cu);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 3);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation4() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID4\")})");
- String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), null, @annot.JoinColumn(name=\"ADDRESS_ID4\")})";
- this.assertSourceDoesNotContain(expected, cu);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 3);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation5() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})";
- this.assertSourceDoesNotContain(expected, cu);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 2);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation6() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), @annot.JoinColumn(name=\"ADDRESS_ID0\")})";
- this.assertSourceDoesNotContain(expected, cu);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation7() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})";
- this.assertSourceDoesNotContain(expected, cu);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 3);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation8() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), null, @annot.JoinColumn(name=\"ADDRESS_ID4\")})");
- String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\"), null, @annot.JoinColumn(name=\"ADDRESS_ID4\")})";
- this.assertSourceDoesNotContain(expected, cu);
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 3);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation9() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- String expected = "@annot.JoinColumns(columns={null, @annot.JoinColumn(name=\"ADDRESS_ID1\"), @annot.JoinColumn(name=\"ADDRESS_ID2\")})";
- ICompilationUnit cu = this.createTestType(expected); // the source should be unchanged
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 0);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation10() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID0\")";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 2);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- iaa.moveAnnotation(1);
- this.assertSourceContains(expected, cu);
- this.assertSourceDoesNotContain("@annot.JoinColumns", cu);
- }
-
- public void testMoveAnnotation10a() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns({@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID0\")";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "value", 2);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- iaa.moveAnnotation(1);
- this.assertSourceContains(expected, cu);
- this.assertSourceDoesNotContain("@annot.JoinColumns", cu);
- }
-
- public void testMoveAnnotation11() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID0\")");
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 1);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceDoesNotContain("JoinColumn", cu);
- }
-
- public void testMoveAnnotation12() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})");
- String expected = "@JoinColumn(name=\"ADDRESS_ID2\")";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 2);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- this.assertSourceDoesNotContain("@annot.JoinColumns", cu);
- }
-
- public void testMoveAnnotation13() throws Exception {
- this.createAnnotationAndMembers("JoinColumn", "String name();");
- this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();");
- ICompilationUnit cu = this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID0\"), @annot.JoinColumn(name=\"ADDRESS_ID1\"), null, @annot.JoinColumn(name=\"ADDRESS_ID3\")})");
- String expected = "@annot.JoinColumns(columns={@annot.JoinColumn(name=\"ADDRESS_ID3\"), @annot.JoinColumn(name=\"ADDRESS_ID1\")})";
- IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter(
- "annot.JoinColumn", "annot.JoinColumns", "columns", 3);
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), cidaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/DefaultAnnotationEditFormatterTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/DefaultAnnotationEditFormatterTests.java
deleted file mode 100644
index 1237cc9bf1..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/DefaultAnnotationEditFormatterTests.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import org.eclipse.jpt.common.core.internal.utility.jdt.DefaultAnnotationEditFormatter;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-
-@SuppressWarnings("nls")
-public class DefaultAnnotationEditFormatterTests extends AnnotationTestCase {
-
-
- // ********** TestCase behavior **********
-
- public DefaultAnnotationEditFormatterTests(String name) {
- super(name);
- }
-
-
- // ********** tests **********
-
- public void testCommaLength() throws Exception {
- assertEquals(1, this.commaLength(","));
- assertEquals(1, this.commaLength(", "));
- assertEquals(1, this.commaLength(", "));
-
- assertEquals(2, this.commaLength(" ,"));
- assertEquals(2, this.commaLength(" , "));
- assertEquals(2, this.commaLength(" , "));
-
- assertEquals(3, this.commaLength(" ,"));
- assertEquals(3, this.commaLength(" , "));
- assertEquals(3, this.commaLength(" , "));
-
- assertEquals(0, this.commaLength(" ,,,"));
- assertEquals(0, this.commaLength(" ,,, "));
- assertEquals(0, this.commaLength(" , ,"));
-
- assertEquals(0, this.commaLength(" ,x"));
- assertEquals(0, this.commaLength(" ,x "));
- assertEquals(0, this.commaLength(" , x"));
-
- assertEquals(0, this.commaLength("x ,"));
- assertEquals(0, this.commaLength("x , "));
- assertEquals(0, this.commaLength("x , "));
- }
-
- private int commaLength(String s) {
- Integer len = (Integer) ReflectionTools.executeMethod(DefaultAnnotationEditFormatter.instance(), "commaLength", String.class, s);
- return len.intValue();
- }
-
- public void testStringIsAnnotation() throws Exception {
- assertTrue(this.stringIsAnnotation("@F"));
- assertTrue(this.stringIsAnnotation("@Foo"));
- assertTrue(this.stringIsAnnotation("@org.bar.Foo"));
-
- assertFalse(this.stringIsAnnotation(""));
- assertFalse(this.stringIsAnnotation("@"));
- assertFalse(this.stringIsAnnotation("Foo"));
- assertFalse(this.stringIsAnnotation("Foo@"));
- }
-
- private boolean stringIsAnnotation(String s) {
- Boolean b = (Boolean) ReflectionTools.executeMethod(DefaultAnnotationEditFormatter.instance(), "stringIsAnnotation", String.class, s);
- return b.booleanValue();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JDTToolsTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JDTToolsTests.java
deleted file mode 100644
index 0fddcce6f7..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JDTToolsTests.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import java.util.AbstractCollection;
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.Vector;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jpt.common.core.internal.utility.JDTTools;
-
-
-public class JDTToolsTests
- extends AnnotationTestCase {
-
- public JDTToolsTests(String name) {
- super(name);
- }
-
-
- public void testTypeIsSubtype() throws Exception {
- IJavaProject jProj = getJavaProject().getJavaProject();
-
- // same type
- assertTrue(JDTTools.typeIsSubType(jProj, ArrayList.class.getName(), ArrayList.class.getName()));
- assertTrue(JDTTools.typeIsSubType(jProj, List.class.getName(), List.class.getName()));
-
- // concrete type is subtype of interface
- assertTrue(JDTTools.typeIsSubType(jProj, ArrayList.class.getName(), List.class.getName()));
- assertTrue(JDTTools.typeIsSubType(jProj, TreeSet.class.getName(), Iterable.class.getName()));
-
- // concrete type is not subtype of interface
- assertFalse(JDTTools.typeIsSubType(jProj, ArrayList.class.getName(), Map.class.getName()));
- assertFalse(JDTTools.typeIsSubType(jProj, TreeSet.class.getName(), Map.class.getName()));
-
- // interface is subtype of interface
- assertTrue(JDTTools.typeIsSubType(jProj, List.class.getName(), Collection.class.getName()));
- assertTrue(JDTTools.typeIsSubType(jProj, SortedSet.class.getName(), Iterable.class.getName()));
-
- // interface is not subtype of interface
- assertFalse(JDTTools.typeIsSubType(jProj, List.class.getName(), Map.class.getName()));
- assertFalse(JDTTools.typeIsSubType(jProj, SortedSet.class.getName(), Map.class.getName()));
-
- // concrete type is subtype of concrete type
- assertTrue(JDTTools.typeIsSubType(jProj, ArrayList.class.getName(), AbstractList.class.getName()));
- assertTrue(JDTTools.typeIsSubType(jProj, LinkedList.class.getName(), AbstractCollection.class.getName()));
-
- // concrete type is not subtype of concrete type
- assertFalse(JDTTools.typeIsSubType(jProj, ArrayList.class.getName(), Vector.class.getName()));
- assertFalse(JDTTools.typeIsSubType(jProj, LinkedList.class.getName(), Vector.class.getName()));
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JptCommonCoreUtilityJdtTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JptCommonCoreUtilityJdtTests.java
deleted file mode 100644
index 0f485953b4..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/JptCommonCoreUtilityJdtTests.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptCommonCoreUtilityJdtTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptCommonCoreUtilityJdtTests.class.getPackage().getName());
- suite.addTestSuite(CombinationIndexedDeclarationAnnotationAdapterTests.class);
- suite.addTestSuite(DefaultAnnotationEditFormatterTests.class);
- suite.addTestSuite(ASTToolsTests.class);
- suite.addTestSuite(JDTToolsTests.class);
- suite.addTestSuite(MemberAnnotationElementAdapterTests.class);
- suite.addTestSuite(NestedDeclarationAnnotationAdapterTests.class);
- suite.addTestSuite(NestedIndexedDeclarationAnnotationAdapterTests.class);
- suite.addTestSuite(SimpleDeclarationAnnotationAdapterTests.class);
- suite.addTestSuite(TypeTests.class);
- return suite;
- }
-
- private JptCommonCoreUtilityJdtTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java
deleted file mode 100644
index b4f2fa7afa..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/MemberAnnotationElementAdapterTests.java
+++ /dev/null
@@ -1,1298 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import java.util.Arrays;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools;
-import org.eclipse.jpt.common.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.AnnotationStringArrayExpressionConverter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.BooleanExpressionConverter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.CharacterStringExpressionConverter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.EnumArrayDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.IndexedConversionDeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.NestedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.NumberIntegerExpressionConverter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.PrimitiveTypeStringExpressionConverter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleTypeStringExpressionConverter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.StringExpressionConverter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.TypeStringExpressionConverter;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationElementAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedExpressionConverter;
-
-@SuppressWarnings("nls")
-public class MemberAnnotationElementAdapterTests extends AnnotationTestCase {
-
- public MemberAnnotationElementAdapterTests(String name) {
- super(name);
- }
-
- private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- this.javaProject.createCompilationUnit("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- private void createEnum(String enumName, String enumBody) throws Exception {
- this.createEnum("enums", enumName, enumBody);
- }
-
- private void createEnum(String packageName, String enumName, String enumBody) throws Exception {
- this.javaProject.createCompilationUnit(packageName, enumName + ".java", "public enum " + enumName + " { " + enumBody + " }");
- }
-
- public void testValue1() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"xxx\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("xxx", aea.getValue());
- }
-
- public void testValue2() throws Exception {
- this.createAnnotationAndMembers("Foo", "int bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=48)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Integer> daea = new ConversionDeclarationAnnotationElementAdapter<Integer>(daa, "bar", NumberIntegerExpressionConverter.instance());
- AnnotationElementAdapter<Integer> aea = new AnnotatedElementAnnotationElementAdapter<Integer>(this.idField(cu), daea);
- assertEquals(Integer.valueOf(48), aea.getValue());
- }
-
- public void testValue3() throws Exception {
- this.createAnnotationAndMembers("Foo", "char bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar='c')");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", CharacterStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("c", aea.getValue());
- }
-
- public void testValue4() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=false)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa, "bar", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValue5() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))");
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValue6() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(false)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa, BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValueNull1() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueNull2() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- ICompilationUnit cu = this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueNull3() throws Exception {
- this.createAnnotationAndMembers("Baz", "String fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(jimmy=@annot.Baz))");
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa3, "fred");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueStringConcatenation() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"xxx\" + \"yyy\" + \"zzz\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("xxxyyyzzz", aea.getValue());
- }
-
- public void testValueStringConstant() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- // just a bit hacky:
- ICompilationUnit cu = this.createTestType("private static final String FOO_BAR = \"xxx\"; @annot.Foo(bar=FOO_BAR + \"yyy\" + \"zzz\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("xxxyyyzzz", aea.getValue());
- }
-
- public void testValueNumberArithmetic() throws Exception {
- this.createAnnotationAndMembers("Foo", "int bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=47 - 7 + 2 * 1 / 1)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Integer> daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar");
- AnnotationElementAdapter<Integer> aea = new AnnotatedElementAnnotationElementAdapter<Integer>(this.idField(cu), daea);
- assertEquals(Integer.valueOf(42), aea.getValue());
- }
-
- public void testValueNumberShift() throws Exception {
- this.createAnnotationAndMembers("Foo", "int bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=2 << 2)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Integer> daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar");
- AnnotationElementAdapter<Integer> aea = new AnnotatedElementAnnotationElementAdapter<Integer>(this.idField(cu), daea);
- assertEquals(Integer.valueOf(8), aea.getValue());
- }
-
- public void testValueNumberConstant() throws Exception {
- this.createAnnotationAndMembers("Foo", "int bar();");
- // just a bit hacky:
- ICompilationUnit cu = this.createTestType("private static final int FOO_BAR = 77; @annot.Foo(bar=FOO_BAR)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Integer> daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar");
- AnnotationElementAdapter<Integer> aea = new AnnotatedElementAnnotationElementAdapter<Integer>(this.idField(cu), daea);
- assertEquals(Integer.valueOf(77), aea.getValue());
- }
-
- public void testValueCharacterConstant() throws Exception {
- this.createAnnotationAndMembers("Foo", "char bar();");
- // just a bit hacky:
- ICompilationUnit cu = this.createTestType("private static final char FOO_BAR = 'Q'; @annot.Foo(bar=FOO_BAR)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("Q", aea.getValue());
- }
-
- public void testValueCharacterCast() throws Exception {
- this.createAnnotationAndMembers("Foo", "char bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=(char) 0x41)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("A", aea.getValue());
- }
-
- public void testValueBooleanOperator1() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=7 > 2)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar");
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
- assertEquals(Boolean.TRUE, aea.getValue());
- }
-
- public void testValueBooleanOperator2() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=7 == 2)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar");
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValueBooleanOperator3() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=(7 != 2) && false)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar");
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValueBooleanOperator4() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=(7 != 2) ? false : true)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar");
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- }
-
- public void testValueInvalidValue1() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=77)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue2() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=bazzzz)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue3() throws Exception {
- this.createAnnotationAndMembers("Foo", "boolean bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=bazzzz)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<Boolean> daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar");
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue4() throws Exception {
- this.createAnnotationAndMembers("Foo", "char bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"bazzzz\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue5() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"java.lang.Object\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue6() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=enums.TestEnum.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue7() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String value = "\"false\"";
- String element = "fred=" + value;
- String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(" + element + ")))";
- ICompilationUnit cu = this.createTestType(annotation);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueInvalidValue8() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar={true, false})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[] {null, null}, aea.getValue()));
- }
-
- public void testValueInvalidValue9() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=77)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[0], aea.getValue()));
- }
-
- public void testASTNode1() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- String value = "\"xxx\"";
- String element = "bar=" + value;
- String annotation = "@annot.Foo(" + element + ")";
- ICompilationUnit cu = this.createTestType(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- TextRange textRange = ASTTools.buildTextRange(aea.getAstNode(this.buildASTRoot(cu)));
- assertEquals(this.getSource(cu).indexOf(value), textRange.getOffset());
- assertEquals(value.length(), textRange.getLength());
- assertEquals(7, textRange.getLineNumber());
- }
-
- public void testASTNode2() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String value = "false";
- String element = "fred=" + value;
- String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(" + element + ")))";
- ICompilationUnit cu = this.createTestType(annotation);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
- assertEquals(Boolean.FALSE, aea.getValue());
- TextRange textRange = ASTTools.buildTextRange(aea.getAstNode(this.buildASTRoot(cu)));
- assertEquals(value.length(), textRange.getLength());
- }
-
- public void testASTNode3() throws Exception {
- this.createAnnotationAndMembers("Foo", "String value();");
- String element = "\"xxx\"";
- String annotation = "@annot.Foo(" + element + ")";
- ICompilationUnit cu = this.createTestType(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa);
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- TextRange textRange = ASTTools.buildTextRange(aea.getAstNode(this.buildASTRoot(cu)));
- assertEquals(this.getSource(cu).indexOf(element), textRange.getOffset());
- assertEquals(element.length(), textRange.getLength());
- }
-
- public void testASTNode4() throws Exception {
- this.createAnnotationAndMembers("Foo", "String value();");
- String annotation = "@annot.Foo";
- ICompilationUnit cu = this.createTestType(annotation);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa);
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- TextRange textRange = ASTTools.buildTextRange(aea.getAstNode(this.buildASTRoot(cu)));
- assertEquals(this.getSource(cu).indexOf(annotation), textRange.getOffset());
- assertEquals(annotation.length(), textRange.getLength());
- }
-
- public void testSetValue1() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- String annotation = "@annot.Foo(bar=\"xxx\")";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- aea.setValue(null);
- this.assertSourceDoesNotContain("bar", cu);
- }
-
- public void testSetValue2() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- String annotation = "@annot.Foo(bar=\"xxx\")";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- aea.setValue(null);
- this.assertSourceDoesNotContain(annotation, cu);
- this.assertSourceContains("@Foo", cu);
- }
-
- public void testSetValue3() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
-
- aea.setValue(null);
- this.assertSourceDoesNotContain(annotation, cu);
- this.assertSourceDoesNotContain("fred", cu);
- }
-
- public void testSetValue3a() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
-
- aea.setValue(null);
- this.assertSourceDoesNotContain(annotation, cu);
- this.assertSourceDoesNotContain("fred", cu);
- this.assertSourceContains("@annot.Foo(@annot.Bar(jimmy=@Baz))", cu);
- }
-
- public void testSetValue4() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- ICompilationUnit cu = this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- aea.setValue("xxx");
- this.assertSourceContains("@Foo(bar = \"xxx\")", cu);
- }
-
- public void testSetValue5() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String annotation = "@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=false)))";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
-
- aea.setValue(Boolean.TRUE);
- this.assertSourceDoesNotContain(annotation, cu);
- this.assertSourceContains("@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=true)))", cu);
- }
-
- public void testSetValue6() throws Exception {
- this.createAnnotationAndMembers("Baz", "boolean fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- ICompilationUnit cu = this.createTestType();
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz");
- DeclarationAnnotationElementAdapter<Boolean> daea = new ConversionDeclarationAnnotationElementAdapter<Boolean>(daa3, "fred", BooleanExpressionConverter.instance());
- AnnotationElementAdapter<Boolean> aea = new AnnotatedElementAnnotationElementAdapter<Boolean>(this.idField(cu), daea);
-
- aea.setValue(Boolean.TRUE);
- this.assertSourceContains("@Foo(@Bar(jimmy = @Baz(fred = true)))", cu);
- }
-
- public void testSetValue7() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- String annotation = "@annot.Foo(bar=\"xxx\")";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- aea.setValue("yyy");
- this.assertSourceDoesNotContain(annotation, cu);
- this.assertSourceContains("@annot.Foo(bar=\"yyy\")", cu);
- }
-
- public void testSetValue8() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar();");
- String annotation = "@annot.Foo";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- aea.setValue("xxx");
- this.assertSourceContains("@Foo(bar = \"xxx\")", cu);
- }
-
- public void testSetValue9() throws Exception {
- this.createAnnotationAndMembers("Foo", "String value(); String bar();");
- String annotation = "@annot.Foo(\"zzz\")";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- aea.setValue("xxx");
- this.assertSourceDoesNotContain(annotation, cu);
- this.assertSourceContains("@Foo(value = \"zzz\", bar = \"xxx\")", cu);
- }
-
- public void testSetValue10() throws Exception {
- this.createAnnotationAndMembers("Foo", "String bar(); String baz();");
- String annotation = "@annot.Foo(bar=\"xxx\")";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "baz");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- aea.setValue("yyy");
- this.assertSourceDoesNotContain(annotation, cu);
- this.assertSourceContains("@annot.Foo(bar=\"xxx\", baz = \"yyy\")", cu);
- }
-
- public void testSetValue11() throws Exception {
- this.createAnnotationAndMembers("Baz", "int fred();");
- this.createAnnotationAndMembers("Bar", "annot.Baz[] jimmy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- String annotation = "@annot.Foo(@annot.Bar(jimmy={@annot.Baz(fred=0), @annot.Baz(fred=1), @annot.Baz(fred=2), @annot.Baz(fred=3)}))";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "jimmy", 2, "annot.Baz");
- DeclarationAnnotationElementAdapter<Integer> daea = new ConversionDeclarationAnnotationElementAdapter<Integer>(daa3, "fred", NumberIntegerExpressionConverter.instance());
- AnnotationElementAdapter<Integer> aea = new AnnotatedElementAnnotationElementAdapter<Integer>(this.idField(cu), daea);
-
- assertEquals(Integer.valueOf(2), aea.getValue());
- aea.setValue(Integer.valueOf(48));
- this.assertSourceContains("@annot.Foo(@annot.Bar(jimmy={@annot.Baz(fred=0), @annot.Baz(fred=1), @annot.Baz(fred=48), @annot.Baz(fred=3)}))", cu);
- }
-
- public void testSetValue12() throws Exception {
- this.createAnnotationAndMembers("Foo", "String value();");
- String annotation = "@annot.Foo";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "value");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- aea.setValue("xxx");
- this.assertSourceContains("@Foo(\"xxx\")", cu);
- }
-
- public void testSetValue13() throws Exception {
- this.createAnnotationAndMembers("Foo", "String value();");
- String annotation = "@annot.Foo(\"zzz\")";
- ICompilationUnit cu = this.createTestType(annotation);
- this.assertSourceContains(annotation, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "value");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
-
- aea.setValue("xxx");
- this.assertSourceDoesNotContain(annotation, cu);
- this.assertSourceContains("@annot.Foo(\"xxx\")", cu);
- }
-
- public void testSimpleTypeLiteral1() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=java.lang.Object.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("java.lang.Object", aea.getValue());
- }
-
- public void testSimpleTypeLiteral2() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- aea.setValue("java.lang.Object");
- this.assertSourceContains("@Foo(bar = java.lang.Object.class)", cu);
- }
-
- public void testSimpleTypeLiteral3() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=int.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testSimpleTypeLiteral4() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=java.util.Map.Entry.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", SimpleTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("java.util.Map.Entry", aea.getValue());
- }
-
- public void testPrimitiveTypeLiteral1() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=int.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("int", aea.getValue());
- }
-
- public void testPrimitiveTypeLiteral2() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- aea.setValue("int");
- this.assertSourceContains("@Foo(bar = int.class)", cu);
- }
-
- public void testPrimitiveTypeLiteral3() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=java.lang.Object.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testPrimitiveTypeLiteral4() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=void.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", PrimitiveTypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("void", aea.getValue());
- }
-
- public void testTypeLiteral1() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=java.lang.Object.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", TypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("java.lang.Object", aea.getValue());
- }
-
- public void testTypeLiteral2() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", TypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- aea.setValue("java.lang.Object");
- this.assertSourceContains("@Foo(bar = java.lang.Object.class)", cu);
- }
-
- public void testTypeLiteral3() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=java.util.Map.Entry.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", TypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("java.util.Map.Entry", aea.getValue());
- }
-
- public void testTypeLiteral14() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=int.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", TypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("int", aea.getValue());
- }
-
- public void testTypeLiteral5() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", TypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- aea.setValue("int");
- this.assertSourceContains("@Foo(bar = int.class)", cu);
- }
-
- public void testTypeLiteral6() throws Exception {
- this.createAnnotationAndMembers("Foo", "Class bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=void.class)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new ConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", TypeStringExpressionConverter.instance());
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("void", aea.getValue());
- }
-
- public void testValueEnum1() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=enums.TestEnum.XXX)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("enums.TestEnum.XXX", aea.getValue());
- }
-
- public void testValueEnum2() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- ICompilationUnit cu = this.createTestType("static enums.TestEnum.XXX", "@annot.Foo(bar=XXX)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("enums.TestEnum.XXX", aea.getValue());
- }
-
- public void testValueEnum3() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertNull(aea.getValue());
- }
-
- public void testValueEnum4() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- ICompilationUnit cu = this.createTestType("enums.TestEnum", "@annot.Foo(bar=TestEnum.XXX)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- assertEquals("enums.TestEnum.XXX", aea.getValue());
- }
-
- public void testSetValueEnum1() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- String expected = "@annot.Foo(bar=XXX)";
- ICompilationUnit cu = this.createTestType("static enums.TestEnum.XXX", expected);
- this.assertSourceContains(expected, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- aea.setValue(null);
- this.assertSourceDoesNotContain("bar", cu);
- }
-
- public void testSetValueEnum2() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();");
- String expected = "@Foo(bar = XXX)";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String> daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String> aea = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea);
- aea.setValue("enums.TestEnum.XXX");
- this.assertSourceContains("import static enums.TestEnum.XXX;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumImportCollision1() throws Exception {
- this.createEnum("enums1", "TestEnum", "XXX, YYY, ZZZ");
- this.createEnum("enums2", "TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums1.TestEnum bar1(); enums2.TestEnum bar2();");
- String expected = "@Foo(bar1 = XXX, bar2 = TestEnum.XXX)";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- DeclarationAnnotationElementAdapter<String> daea1 = new EnumDeclarationAnnotationElementAdapter(daa, "bar1");
- AnnotationElementAdapter<String> aea1 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea1);
- aea1.setValue("enums1.TestEnum.XXX");
-
- DeclarationAnnotationElementAdapter<String> daea2 = new EnumDeclarationAnnotationElementAdapter(daa, "bar2");
- AnnotationElementAdapter<String> aea2 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea2);
- aea2.setValue("enums2.TestEnum.XXX");
-
- this.assertSourceContains("import static enums1.TestEnum.XXX;", cu);
- this.assertSourceDoesNotContain("import static enums2.TestEnum.XXX;", cu);
- this.assertSourceContains("import enums2.TestEnum;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumImportCollision2() throws Exception {
- this.createEnum("enums1", "TestEnum", "XXX, YYY, ZZZ");
- this.createEnum("enums2", "TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums1.TestEnum bar1(); enums2.TestEnum bar2();");
- String expected = "@annot.Foo(bar1=XXX, bar2 = TestEnum.XXX)";
- ICompilationUnit cu = this.createTestType("static enums1.TestEnum.*", "@annot.Foo(bar1=XXX)");
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- DeclarationAnnotationElementAdapter<String> daea1 = new EnumDeclarationAnnotationElementAdapter(daa, "bar1");
- AnnotationElementAdapter<String> aea1 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea1);
- assertNotNull(aea1.getValue());
-
- DeclarationAnnotationElementAdapter<String> daea2 = new EnumDeclarationAnnotationElementAdapter(daa, "bar2");
- AnnotationElementAdapter<String> aea2 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea2);
- aea2.setValue("enums2.TestEnum.XXX");
-
- this.assertSourceContains("import static enums1.TestEnum.*;", cu);
- this.assertSourceDoesNotContain("import static enums2.TestEnum.XXX;", cu);
- this.assertSourceContains("import enums2.TestEnum;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumImportCollision3() throws Exception {
- this.createEnum("TestEnum1", "XXX, YYY, ZZZ");
- this.createEnum("TestEnum2", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum1 bar1(); enums.TestEnum2 bar2();");
- String expected = "@Foo(bar1 = XXX, bar2 = TestEnum2.XXX)";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- DeclarationAnnotationElementAdapter<String> daea1 = new EnumDeclarationAnnotationElementAdapter(daa, "bar1");
- AnnotationElementAdapter<String> aea1 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea1);
- aea1.setValue("enums.TestEnum1.XXX");
-
- DeclarationAnnotationElementAdapter<String> daea2 = new EnumDeclarationAnnotationElementAdapter(daa, "bar2");
- AnnotationElementAdapter<String> aea2 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea2);
- aea2.setValue("enums.TestEnum2.XXX");
-
- this.assertSourceContains("import static enums.TestEnum1.XXX;", cu);
- this.assertSourceContains("import enums.TestEnum2;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumImportCollision4() throws Exception {
- this.createEnum("TestEnum1", "XXX, YYY, ZZZ");
- this.createEnum("TestEnum2", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum1 bar1(); enums.TestEnum2 bar2();");
- String expected = "@annot.Foo(bar1=XXX, bar2 = TestEnum2.XXX)";
- ICompilationUnit cu = this.createTestType("static enums.TestEnum1.*", "@annot.Foo(bar1=XXX)");
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- DeclarationAnnotationElementAdapter<String> daea1 = new EnumDeclarationAnnotationElementAdapter(daa, "bar1");
- AnnotationElementAdapter<String> aea1 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea1);
- assertNotNull(aea1.getValue());
-
- DeclarationAnnotationElementAdapter<String> daea2 = new EnumDeclarationAnnotationElementAdapter(daa, "bar2");
- AnnotationElementAdapter<String> aea2 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea2);
- aea2.setValue("enums.TestEnum2.XXX");
-
- this.assertSourceContains("import static enums.TestEnum1.*;", cu);
- this.assertSourceContains("import enums.TestEnum2;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- /**
- * not sure this is exactly what we want...
- * it would be nice if we just skip the static import; but it's a matter of taste...
- */
- public void testSetValueEnumImportCollision5() throws Exception {
- this.createEnum("TestEnum1", "XXX, YYY, ZZZ");
- this.createEnum("TestEnum2", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum1 bar1(); enums.TestEnum2 bar2();");
- String expected = "@Foo(bar1 = XXX, bar2 = TestEnum2.XXX)";
- ICompilationUnit cu = this.createTestType("enums.*", "");
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- DeclarationAnnotationElementAdapter<String> daea1 = new EnumDeclarationAnnotationElementAdapter(daa, "bar1");
- AnnotationElementAdapter<String> aea1 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea1);
- aea1.setValue("enums.TestEnum1.XXX");
-
- DeclarationAnnotationElementAdapter<String> daea2 = new EnumDeclarationAnnotationElementAdapter(daa, "bar2");
- AnnotationElementAdapter<String> aea2 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea2);
- aea2.setValue("enums.TestEnum2.XXX");
-
- this.assertSourceContains("import enums.*;", cu);
- this.assertSourceContains("import static enums.TestEnum1.XXX;", cu);
- this.assertSourceDoesNotContain("import enums.TestEnum2;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumImportCollision6() throws Exception {
- this.createEnum("enums1", "TestEnum", "XXX, YYY, ZZZ");
- this.createEnum("enums2", "TestEnum", "XXX, YYY, ZZZ");
- this.createEnum("enums3", "TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums1.TestEnum bar1(); enums2.TestEnum bar2(); enums3.TestEnum bar3();");
- String expected = "@Foo(bar1 = XXX, bar2 = TestEnum.XXX, bar3 = enums3.TestEnum.XXX)";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- DeclarationAnnotationElementAdapter<String> daea1 = new EnumDeclarationAnnotationElementAdapter(daa, "bar1");
- AnnotationElementAdapter<String> aea1 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea1);
- aea1.setValue("enums1.TestEnum.XXX");
-
- DeclarationAnnotationElementAdapter<String> daea2 = new EnumDeclarationAnnotationElementAdapter(daa, "bar2");
- AnnotationElementAdapter<String> aea2 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea2);
- aea2.setValue("enums2.TestEnum.XXX");
-
- DeclarationAnnotationElementAdapter<String> daea3 = new EnumDeclarationAnnotationElementAdapter(daa, "bar3");
- AnnotationElementAdapter<String> aea3 = new AnnotatedElementAnnotationElementAdapter<String>(this.idField(cu), daea3);
- aea3.setValue("enums3.TestEnum.XXX");
-
- this.assertSourceContains("import static enums1.TestEnum.XXX;", cu);
- this.assertSourceDoesNotContain("import static enums2.TestEnum.XXX;", cu);
- this.assertSourceContains("import enums2.TestEnum;", cu);
- this.assertSourceDoesNotContain("import static enums3", cu);
- this.assertSourceDoesNotContain("import enums3", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testValueStringArray() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar={\"string0\", \"string1\"})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[] {"string0", "string1"}, aea.getValue()));
- }
-
- public void testValueStringArrayConcatenation() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar={\"stri\" + \"ng0\", \"s\" + \"tring1\"})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[] {"string0", "string1"}, aea.getValue()));
- }
-
- public void testValueStringArrayEmpty() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar={})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[0], aea.getValue()));
- }
-
- public void testValueStringArraySingleElement() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"string0\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new ConversionDeclarationAnnotationElementAdapter<String[]>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[] {"string0"}, aea.getValue()));
- }
-
- public void testValueNullStringArray() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo()");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new IndexedConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[0], aea.getValue()));
- }
-
- public void testSetValueStringArray() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- String expected = "@Foo(bar = { \"string0\", \"string1\" })";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new IndexedConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- aea.setValue(new String[] {"string0", "string1"});
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueStringArrayEmptyRemove() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- String expected = "@Foo";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new IndexedConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- aea.setValue(new String[0]);
- this.assertSourceDoesNotContain(expected, cu);
- }
-
- public void testSetValueStringArrayEmpty() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- String expected = "@Foo(bar = {})";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- IndexedExpressionConverter<String> expressionConverter = new AnnotationStringArrayExpressionConverter(StringExpressionConverter.instance(), false);
- DeclarationAnnotationElementAdapter<String[]> daea = new IndexedConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", expressionConverter);
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- aea.setValue(new String[0]);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueStringArraySingleElement() throws Exception {
- this.createAnnotationAndMembers("Foo", "String[] bar();");
- String annotation = "@Foo(bar = \"string0\")";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(annotation, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new IndexedConversionDeclarationAnnotationElementAdapter<String>(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings());
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- aea.setValue(new String[] {"string0"});
- this.assertSourceContains(annotation, cu);
- }
-
- public void testValueEnumArray() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar={enums.TestEnum.XXX, enums.TestEnum.YYY})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX", "enums.TestEnum.YYY"}, aea.getValue()));
- }
-
- public void testValueEnumArrayInvalidEntry() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar={enums.TestEnum.XXX, 88})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX", null}, aea.getValue()));
- }
-
- public void testValueEnumArrayEmpty() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar={})");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[0], aea.getValue()));
- }
-
- public void testValueEnumArraySingleElement() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=enums.TestEnum.XXX)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX"}, aea.getValue()));
- }
-
- public void testValueEnumArraySingleElementInvalid() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(bar=\"\")");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[] {null}, aea.getValue()));
- }
-
- public void testValueNullEnumArray() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- ICompilationUnit cu = this.createTestType("@annot.Foo()");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- assertTrue(Arrays.equals(new String[0], aea.getValue()));
- }
-
- public void testSetValueEnumArray() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- String expected = "@Foo(bar = { XXX, YYY })";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- aea.setValue(new String[] {"enums.TestEnum.XXX", "enums.TestEnum.YYY"});
- this.assertSourceContains("import static enums.TestEnum.XXX;", cu);
- this.assertSourceContains("import static enums.TestEnum.YYY;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumArrayEmptyRemove() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- String expected = "@Foo";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- aea.setValue(new String[0]);
- this.assertSourceDoesNotContain(expected, cu);
- }
-
- public void testSetValueEnumArrayEmpty() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- String expected = "@Foo(bar = {})";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar", false);
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- aea.setValue(new String[0]);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumArraySingleElement() throws Exception {
- this.createEnum("TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();");
- String expected = "@Foo(bar = XXX)";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationElementAdapter<String[]> daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar");
- AnnotationElementAdapter<String[]> aea = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea);
- aea.setValue(new String[] {"enums.TestEnum.XXX"});
- this.assertSourceContains("import static enums.TestEnum.XXX;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumArrayImportCollision1() throws Exception {
- this.createEnum("enums1", "TestEnum", "XXX, YYY, ZZZ");
- this.createEnum("enums2", "TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums1.TestEnum[] bar1(); enums2.TestEnum[] bar2();");
- String expected = "@Foo(bar1 = { XXX, YYY }, bar2 = { TestEnum.XXX, TestEnum.YYY })";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- DeclarationAnnotationElementAdapter<String[]> daea1 = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar1");
- AnnotationElementAdapter<String[]> aea1 = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea1);
- aea1.setValue(new String[] {"enums1.TestEnum.XXX", "enums1.TestEnum.YYY"});
-
- DeclarationAnnotationElementAdapter<String[]> daea2 = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar2");
- AnnotationElementAdapter<String[]> aea2 = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea2);
- aea2.setValue(new String[] {"enums2.TestEnum.XXX", "enums2.TestEnum.YYY"});
-
- this.assertSourceContains("import static enums1.TestEnum.XXX;", cu);
- this.assertSourceContains("import static enums1.TestEnum.YYY;", cu);
- this.assertSourceDoesNotContain("import static enums2.TestEnum.XXX;", cu);
- this.assertSourceDoesNotContain("import static enums2.TestEnum.YYY;", cu);
- this.assertSourceContains("import enums2.TestEnum;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumArrayImportCollision2() throws Exception {
- this.createEnum("enums1", "TestEnum", "XXX, YYY, ZZZ");
- this.createEnum("enums2", "TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums1.TestEnum[] bar1(); enums2.TestEnum[] bar2();");
- String expected = "@annot.Foo(bar1={XXX,YYY}, bar2 = { TestEnum.XXX, TestEnum.YYY })";
- ICompilationUnit cu = this.createTestType("static enums1.TestEnum.*", "@annot.Foo(bar1={XXX,YYY})");
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- DeclarationAnnotationElementAdapter<String[]> daea1 = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar1");
- AnnotationElementAdapter<String[]> aea1 = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea1);
- assertNotNull(aea1.getValue());
-
- DeclarationAnnotationElementAdapter<String[]> daea2 = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar2");
- AnnotationElementAdapter<String[]> aea2 = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea2);
- aea2.setValue(new String[] {"enums2.TestEnum.XXX", "enums2.TestEnum.YYY"});
-
- this.assertSourceContains("import static enums1.TestEnum.*;", cu);
- this.assertSourceDoesNotContain("import static enums2.TestEnum.XXX;", cu);
- this.assertSourceDoesNotContain("import static enums2.TestEnum.YYY;", cu);
- this.assertSourceContains("import enums2.TestEnum;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumArrayImportCollision3() throws Exception {
- this.createEnum("TestEnum1", "XXX, YYY, ZZZ");
- this.createEnum("TestEnum2", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum1[] bar1(); enums.TestEnum2[] bar2();");
- String expected = "@Foo(bar1 = { XXX, YYY }, bar2 = { TestEnum2.XXX, TestEnum2.YYY })";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- DeclarationAnnotationElementAdapter<String[]> daea1 = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar1");
- AnnotationElementAdapter<String[]> aea1 = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea1);
- aea1.setValue(new String[] {"enums.TestEnum1.XXX", "enums.TestEnum1.YYY"});
-
- DeclarationAnnotationElementAdapter<String[]> daea2 = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar2");
- AnnotationElementAdapter<String[]> aea2 = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea2);
- aea2.setValue(new String[] {"enums.TestEnum2.XXX", "enums.TestEnum2.YYY"});
-
- this.assertSourceContains("import static enums.TestEnum1.XXX;", cu);
- this.assertSourceContains("import static enums.TestEnum1.YYY;", cu);
- this.assertSourceDoesNotContain("import static enums.TestEnum2.XXX;", cu);
- this.assertSourceDoesNotContain("import static enums.TestEnum2.YYY;", cu);
- this.assertSourceContains("import enums.TestEnum2;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumArrayImportCollision4() throws Exception {
- this.createEnum("TestEnum1", "XXX, YYY, ZZZ");
- this.createEnum("TestEnum2", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums.TestEnum1[] bar1(); enums.TestEnum2[] bar2();");
- String expected = "@annot.Foo(bar1={XXX,YYY}, bar2 = { TestEnum2.XXX, TestEnum2.YYY })";
- ICompilationUnit cu = this.createTestType("static enums.TestEnum1.*", "@annot.Foo(bar1={XXX,YYY})");
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- DeclarationAnnotationElementAdapter<String[]> daea1 = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar1");
- AnnotationElementAdapter<String[]> aea1 = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea1);
- assertNotNull(aea1.getValue());
-
- DeclarationAnnotationElementAdapter<String[]> daea2 = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar2");
- AnnotationElementAdapter<String[]> aea2 = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea2);
- aea2.setValue(new String[] {"enums.TestEnum2.XXX", "enums.TestEnum2.YYY"});
-
- this.assertSourceContains("import static enums.TestEnum1.*;", cu);
- this.assertSourceDoesNotContain("import static enums.TestEnum2.XXX;", cu);
- this.assertSourceDoesNotContain("import static enums.TestEnum2.YYY;", cu);
- this.assertSourceContains("import enums.TestEnum2;", cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testSetValueEnumArrayImportCollision6() throws Exception {
- this.createEnum("enums1", "TestEnum", "XXX, YYY, ZZZ");
- this.createEnum("enums2", "TestEnum", "XXX, YYY, ZZZ");
- this.createEnum("enums3", "TestEnum", "XXX, YYY, ZZZ");
- this.createAnnotationAndMembers("Foo", "enums1.TestEnum[] bar1(); enums2.TestEnum[] bar2(); enums3.TestEnum[] bar3();");
- String expected = "@Foo(bar1 = { XXX, YYY }, bar2 = { TestEnum.XXX, TestEnum.YYY }, bar3 = { enums3.TestEnum.XXX, enums3.TestEnum.YYY })";
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- DeclarationAnnotationElementAdapter<String[]> daea1 = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar1");
- AnnotationElementAdapter<String[]> aea1 = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea1);
- aea1.setValue(new String[] {"enums1.TestEnum.XXX", "enums1.TestEnum.YYY"});
-
- DeclarationAnnotationElementAdapter<String[]> daea2 = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar2");
- AnnotationElementAdapter<String[]> aea2 = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea2);
- aea2.setValue(new String[] {"enums2.TestEnum.XXX", "enums2.TestEnum.YYY"});
-
- DeclarationAnnotationElementAdapter<String[]> daea3 = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar3");
- AnnotationElementAdapter<String[]> aea3 = new AnnotatedElementAnnotationElementAdapter<String[]>(this.idField(cu), daea3);
- aea3.setValue(new String[] {"enums3.TestEnum.XXX", "enums3.TestEnum.YYY"});
-
- this.assertSourceContains("import static enums1.TestEnum.XXX;", cu);
- this.assertSourceContains("import static enums1.TestEnum.YYY;", cu);
- this.assertSourceDoesNotContain("import static enums2", cu);
- this.assertSourceContains("import enums2.TestEnum;", cu);
- this.assertSourceDoesNotContain("import static enums3", cu);
- this.assertSourceDoesNotContain("import enums3", cu);
- this.assertSourceContains(expected, cu);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/MiscTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/MiscTests.java
deleted file mode 100644
index 77ef53aa9b..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/MiscTests.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.Signature;
-
-@SuppressWarnings("nls")
-public class MiscTests extends AnnotationTestCase {
-
- public MiscTests(String name) {
- super(name);
- }
-
- /*
- * Signature.toString(...) returns a dot-qualified name for member types
- */
- public void testSignature() throws Exception {
- IType hashTableType = this.getJavaProject().getJavaProject().findType("java.util.Hashtable");
- IField tableField = hashTableType.getField("table");
- String tableFieldTypeSignature = tableField.getTypeSignature();
- String tableFieldTypeName = Signature.toString(tableFieldTypeSignature);
- assertEquals(tableFieldTypeName, "java.util.Hashtable.Entry[]");
- }
-
- /*
- * IType.getFullyQualifiedName() returns a dollar-qualified name for member types
- * (but the lookup on IJavaProject takes a dot-qualified name!)
- */
- public void testITypeName() throws Exception {
- IType hashTableEntryType = this.getJavaProject().getJavaProject().findType("java.util.Hashtable.Entry");
- assertEquals(hashTableEntryType.getFullyQualifiedName(), "java.util.Hashtable$Entry");
- }
-
- public void testITypeParameterizedName() throws Exception {
- IType mapType = this.getJavaProject().getJavaProject().findType("java.util.Map");
- assertEquals(mapType.getFullyQualifiedParameterizedName(), "java.util.Map<K extends java.lang.Object, V extends java.lang.Object>");
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java
deleted file mode 100644
index f92e2d832f..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/NestedDeclarationAnnotationAdapterTests.java
+++ /dev/null
@@ -1,763 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ElementAnnotationAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.NestedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-
-@SuppressWarnings("nls")
-public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase {
-
- public NestedDeclarationAnnotationAdapterTests(String name) {
- super(name);
- }
-
- private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- this.javaProject.createCompilationUnit("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- public void testAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar)");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
- assertEquals("annot.Bar", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
- }
-
- public void testAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Baz", "String value();");
- this.createAnnotationAndMembers("Bar", "annot.Baz yana();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar(yana=@annot.Baz))");
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "nestedAnnotation", "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "yana", "annot.Baz");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa3);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
- assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
- }
-
- public void testAnnotationNull1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType("@annot.Foo()");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotationNull2() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType();
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotationNull3() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "String nestedAnnotation();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotation=\"annot.Bar\")");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotationNull4() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Bar2", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar2 nestedAnnotation();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar2)");
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testRemoveAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- String na = "@annot.Foo(nestedAnnotation=@annot.Bar)";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceDoesNotContain("nestedAnnotation", cu);
- }
-
- public void testRemoveAnnotation1a() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- String na = "@annot.Foo(nestedAnnotation=@annot.Bar)";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains("Foo", cu);
- }
-
- public void testRemoveAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("Foo", cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("Foo", cu);
- }
-
- public void testRemoveAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "String nestedAnnotation();");
- String na = "@annot.Foo(nestedAnnotation=\"annot.Bar\")";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na, cu);
- }
-
- public void testRemoveAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Bar2", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar2 nestedAnnotation();");
- String na = "@annot.Foo(nestedAnnotation=@annot.Bar2)";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na, cu);
- }
-
- public void testRemoveAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Baz", "String value();");
- this.createAnnotationAndMembers("Bar", "annot.Baz nestedAnnotation2();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation1();");
- String na = "@annot.Foo(nestedAnnotation1=@annot.Bar(nestedAnnotation2=@annot.Baz))";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daaFoo = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daaBar = new NestedDeclarationAnnotationAdapter(daaFoo, "nestedAnnotation1", "annot.Bar");
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(daaBar, "nestedAnnotation2", "annot.Baz");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceDoesNotContain("Baz", cu);
- }
-
- public void testRemoveAnnotation5a() throws Exception {
- this.createAnnotationAndMembers("Baz", "String value();");
- this.createAnnotationAndMembers("Bar", "annot.Baz nestedAnnotation2();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation1();");
- String na = "@annot.Foo(nestedAnnotation1=@annot.Bar(nestedAnnotation2=@annot.Baz))";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daaFoo = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daaBar = new NestedDeclarationAnnotationAdapter(daaFoo, "nestedAnnotation1", "annot.Bar");
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(daaBar, "nestedAnnotation2", "annot.Baz");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains("@annot.Foo(nestedAnnotation1=@Bar)", cu);
- }
-
- public void testNewMarkerAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("Foo", cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@Foo(nestedAnnotation = @Bar)", cu);
- }
-
- public void testNewMarkerAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("Foo", cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@Foo(@Bar)", cu);
- }
-
- public void testNewMarkerAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotation = @Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value = \"something\", nestedAnnotation = @Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "Object value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewSingleMemberAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("Foo", cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation1(declaration);
- }
- });
- this.assertSourceContains("@Foo(nestedAnnotation = @Bar(\"test string literal\"))", cu);
- }
-
- void editNewSingleMemberAnnotation1(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("Foo", cu);
-
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation2(declaration);
- }
- });
- this.assertSourceContains("@Foo(@Bar(\"test string literal\"))", cu);
- }
-
- void editNewSingleMemberAnnotation2(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotation = @Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation3(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation3(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation4(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation4(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value = \"something\", nestedAnnotation = @Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation5(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation5(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "Object value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation6(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation6(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String xxx();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation7(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation7(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewSingleMemberAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value(); String xxx();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar(\"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation8(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation8(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewNormalAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("Foo", cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation1(declaration);
- }
- });
- this.assertSourceContains("@Foo(nestedAnnotation = @Bar(yyy = \"test string literal\"))", cu);
- }
-
- void editNewNormalAnnotation1(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("Foo", cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation2(declaration);
- }
- });
- this.assertSourceContains("@Foo(@Bar(yyy = \"test string literal\"))", cu);
- }
-
- void editNewNormalAnnotation2(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotation = @Bar(yyy = \"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation3(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation3(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar(yyy = \"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation4(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation4(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value = \"something\", nestedAnnotation = @Bar(yyy = \"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation5(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation5(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "Object value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar(yyy = \"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation6(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation6(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar nestedAnnotation();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar(yyy = \"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation7(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation7(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
- public void testNewNormalAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "String yyy();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar(yyy = \"test string literal\"))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation8(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation8(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "yyy", "test string literal");
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java
deleted file mode 100644
index ae4f0f9788..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/NestedIndexedDeclarationAnnotationAdapterTests.java
+++ /dev/null
@@ -1,2229 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.NumberLiteral;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ElementAnnotationAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ElementIndexedAnnotationAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.IndexedDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-
-@SuppressWarnings("nls")
-public class NestedIndexedDeclarationAnnotationAdapterTests extends AnnotationTestCase {
-
- public NestedIndexedDeclarationAnnotationAdapterTests(String name) {
- super(name);
- }
-
- private void createAnnotation(String annotationName) throws Exception {
- this.createAnnotationAndMembers(annotationName, "");
- }
-
- private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception {
- this.javaProject.createCompilationUnit("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }");
- }
-
- public void testAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar, @annot.Bar(\"two\")})");
- // 0
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- CompilationUnit astRoot = this.buildASTRoot(cu);
- Annotation annotation = aa.getAnnotation(astRoot);
- assertNotNull(annotation);
- assertEquals("annot.Bar", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
-
- // 1
- daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 1, "annot.Bar");
- aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- annotation = aa.getAnnotation(astRoot);
- assertNotNull(annotation);
- assertEquals("annot.Bar", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isSingleMemberAnnotation());
- }
-
- public void testAnnotation2() throws Exception {
- this.createAnnotation("Baz");
- this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana=@annot.Baz))");
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Baz");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa3);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
- assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
- }
-
- public void testAnnotation3() throws Exception {
- this.createAnnotation("Baz");
- this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana={@annot.Baz}))");
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Baz");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa3);
- CompilationUnit astRoot = this.buildASTRoot(cu);
- Annotation annotation = aa.getAnnotation(astRoot);
- assertNotNull(annotation);
- assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
-
- // name mismatch
- daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Xyz");
- aa = new ElementAnnotationAdapter(this.idField(cu), daa3);
- annotation = aa.getAnnotation(astRoot);
- assertNull(annotation);
- }
-
- public void testAnnotationNull1() throws Exception {
- this.createAnnotation("Bar");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo()");
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotationNull2() throws Exception {
- this.createAnnotation("Bar");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType();
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotationNull3() throws Exception {
- this.createAnnotation("Bar");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=\"annot.Bar\")");
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotationNull4() throws Exception {
- this.createAnnotation("NotBar");
- this.createAnnotation("Bar");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotationNull5() throws Exception {
- this.createAnnotationAndMembers("Bar", "String value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar, @annot.Bar(\"two\")})");
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotationNull6() throws Exception {
- this.createAnnotation("Xyz");
- this.createAnnotation("Baz");
- this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(yana={@annot.Baz}))");
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar");
- DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Xyz");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa3);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testRemoveAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), @annot.Bar(1)})";
- String expected = "@annot.Foo(nestedAnnotations={null, @annot.Bar(1)})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceDoesNotContain(expected, cu);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("Foo", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("Foo", cu);
- }
-
- public void testRemoveAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={\"annot.Bar1\", \"annot.Bar2\", \"annot.Bar3\"})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na, cu);
- }
-
- public void testRemoveAnnotation4() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.NotBar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.NotBar(0), @annot.NotBar(1)})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na, cu);
- }
-
- public void testRemoveAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations=@annot.Bar)";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- assertNull(aa.getAnnotation(this.buildASTRoot(cu)));
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceDoesNotContain("nestedAnnotations", cu);
- }
-
- public void testRemoveAnnotation5a() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations=@annot.Bar)";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertTrue(aa1.getAnnotation(this.buildASTRoot(cu)).isMarkerAnnotation());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains("import annot.Foo;", cu);
- this.assertSourceContains("@Foo", cu);
- }
-
- public void testRemoveAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations=\"annot.Bar\")";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na, cu);
- }
-
- public void testRemoveAnnotation7() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.NotBar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations=@annot.NotBar)";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceContains(na, cu);
- }
-
- public void testRemoveAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), @annot.Bar(1), @annot.Bar(2), @annot.Bar(3)})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- CompilationUnit astRoot = this.buildASTRoot(cu);
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertTrue(aa1.getAnnotation(astRoot).isNormalAnnotation());
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "nestedAnnotations").getNodeType());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.Bar(0), @annot.Bar(1), null, @annot.Bar(3)})", cu);
- }
-
- public void testRemoveAnnotation9() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), @annot.Bar(1), @annot.Bar(2), @annot.Bar(3)})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- CompilationUnit astRoot = this.buildASTRoot(cu);
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertTrue(aa1.getAnnotation(astRoot).isSingleMemberAnnotation());
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "value").getNodeType());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains("@annot.Foo({@annot.Bar(0), @annot.Bar(1), null, @annot.Bar(3)})", cu);
- }
-
- public void testRemoveAnnotation10() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), @annot.Bar(1)})";
- String expected = "@annot.Foo({null, @annot.Bar(1)})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceDoesNotContain(expected, cu);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 0, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation11() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), @annot.Bar(1)})";
- String expected = "@annot.Foo(@annot.Bar(0))";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceDoesNotContain(expected, cu);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 1, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.buildASTRoot(cu)), "value").getNodeType());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation12() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2)})";
- String expected = "@annot.Foo(@annot.Bar(0))";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceDoesNotContain(expected, cu);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.buildASTRoot(cu)), "value").getNodeType());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation13() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({null, @annot.Bar(1)})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 1, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- this.assertSourceDoesNotContain("Bar", cu);
- }
-
- public void testRemoveAnnotation14() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2), null})";
- String expected = "@annot.Foo(@annot.Bar(0))";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceDoesNotContain(expected, cu);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.buildASTRoot(cu)), "value").getNodeType());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation15() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})";
- String expected = "@annot.Foo({@annot.Bar(0), null, null, @annot.Bar(3)})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceDoesNotContain(expected, cu);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- CompilationUnit astRoot = this.buildASTRoot(cu);
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "value").getNodeType());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation16() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String na = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})";
- String expected = "@annot.Foo({@annot.Bar(0), null, @annot.Bar(2)})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceDoesNotContain(expected, cu);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 3, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- CompilationUnit astRoot = this.buildASTRoot(cu);
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "value").getNodeType());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation17() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2)})";
- String expected = "@annot.Foo(nestedAnnotations=@annot.Bar(0))";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceDoesNotContain(expected, cu);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.buildASTRoot(cu)), "nestedAnnotations").getNodeType());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation18() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={null, @annot.Bar(1)})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 1, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- this.assertSourceDoesNotContain("nestedAnnotations", cu);
- }
-
- public void testRemoveAnnotation19() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2), null})";
- String expected = "@annot.Foo(nestedAnnotations=@annot.Bar(0))";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceDoesNotContain(expected, cu);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation = aa2.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(this.buildASTRoot(cu)), "nestedAnnotations").getNodeType());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation20() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})";
- String expected = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, null, @annot.Bar(3)})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceDoesNotContain(expected, cu);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- CompilationUnit astRoot = this.buildASTRoot(cu);
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "nestedAnnotations").getNodeType());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testRemoveAnnotation21() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- String na = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2), @annot.Bar(3)})";
- String expected = "@annot.Foo(nestedAnnotations={@annot.Bar(0), null, @annot.Bar(2)})";
- ICompilationUnit cu = this.createTestType(na);
- this.assertSourceDoesNotContain(expected, cu);
- this.assertSourceContains(na, cu);
-
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 3, "annot.Bar");
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- CompilationUnit astRoot = this.buildASTRoot(cu);
- Annotation annotation = aa2.getAnnotation(astRoot);
- assertNotNull(annotation);
-
- aa2.removeAnnotation();
- assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(astRoot), "nestedAnnotations").getNodeType());
- this.assertSourceDoesNotContain(na, cu);
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("Foo", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@Foo(nestedAnnotations = @Bar)", cu);
- }
-
- public void testNewMarkerAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("Foo", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@Foo(@Bar)", cu);
- }
-
- public void testNewMarkerAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotations = @Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value = \"something\", nestedAnnotations = @Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation9() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType();
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- assertNull(aa.getAnnotation(this.buildASTRoot(cu)));
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@Foo(nestedAnnotations = { null, null, null, null, null, @Bar })", cu);
- }
-
- public void testNewMarkerAnnotation10() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected1 = "@Foo(value = \"something\", nestedAnnotations = { null, null, null, null,";
- String expected2 = "null, @Bar })";
- this.assertSourceDoesNotContain("Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1, cu);
- this.assertSourceContains(expected2, cu);
- }
-
- public void testNewMarkerAnnotation11() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({\"one\", \"two\"})");
- String expected = "@annot.Foo({@Bar, \"two\"})";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation12() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({\"one\", \"two\"})");
- this.assertSourceDoesNotContain("Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("Bar})", cu); // split line
- }
-
- public void testNewMarkerAnnotation13() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(7)");
- String expected = "@annot.Foo(@Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation14() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(7)");
- this.assertSourceDoesNotContain("Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar})", cu);
- }
-
- public void testNewMarkerAnnotation15() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.NotBar)");
- String expected = "@annot.Foo(@Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation16() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(55))");
- String expected = "@annot.Foo({@annot.Bar(55),@Bar})";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation17() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})");
- String expected = "@annot.Foo(nestedAnnotations={@Bar})";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation18() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})");
- this.assertSourceDoesNotContain("Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("Bar})", cu); // split line
- }
-
- public void testNewMarkerAnnotation19() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=\"something\")");
- String expected = "@annot.Foo(nestedAnnotations=@Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation20() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- String expected = "@annot.Foo(nestedAnnotations=@Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation21() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar})", cu);
- }
-
- public void testNewMarkerAnnotation22() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(88))");
- String expected = "@annot.Foo(nestedAnnotations=@Bar)";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation23() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(88))");
- String expected = "@annot.Foo(nestedAnnotations={@annot.Bar(88),null,@Bar})";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 2, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation24() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(88))");
- String expected = "@annot.Foo({@annot.Bar(88),null,@Bar})";
- this.assertSourceDoesNotContain(expected, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected, cu);
- }
-
- public void testNewMarkerAnnotation25() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={@annot.Bar(88), @annot.Bar(77)})");
- String expected1 = "@annot.Foo(nestedAnnotations={@annot.Bar(88), @annot.Bar(77), null, null,"; // the line gets split
- String expected2 = "@Bar})";
- this.assertSourceDoesNotContain(expected1, cu);
- this.assertSourceDoesNotContain(expected2, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 4, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1, cu);
- this.assertSourceContains(expected2, cu);
- }
-
- public void testNewMarkerAnnotation26() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(88), @annot.Bar(77)})");
- String expected1 = "@annot.Foo({@annot.Bar(88), @annot.Bar(77), null, null,"; // the line gets split
- String expected2 = "@Bar})";
- this.assertSourceDoesNotContain(expected1, cu);
- this.assertSourceDoesNotContain(expected2, cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 4, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- aa.newMarkerAnnotation();
- this.assertSourceContains(expected1, cu);
- this.assertSourceContains(expected2, cu);
- }
-
- public void testNewSingleMemberAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("@Foo", cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation1(declaration);
- }
- });
- this.assertSourceContains("@Foo(nestedAnnotations = @Bar(88))", cu);
- }
-
- void editNewSingleMemberAnnotation1(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("@Foo", cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation2(declaration);
- }
- });
- this.assertSourceContains("@Foo(@Bar(88))", cu);
- }
-
- void editNewSingleMemberAnnotation2(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotations = @Bar(88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation3(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation3(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar(88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation4(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation4(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value = \"something\", nestedAnnotations = @Bar(88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation5(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation5(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar(88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation6(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation6(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar(88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation7(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation7(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar(88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation8(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation8(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation9() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains("@Foo(nestedAnnotations = { null, null, null, null, null, @Bar(MISSING) })", cu); // ???
- }
-
- public void testNewSingleMemberAnnotation10() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected1 = "@Foo(value = \"something\", nestedAnnotations = { null, null, null, null,";
- String expected2 = "null, @Bar(MISSING) })"; // ???
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains(expected1, cu);
- this.assertSourceContains(expected2, cu);
- }
-
- public void testNewSingleMemberAnnotation11() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({\"one\", \"two\"})");
- String expected = "@annot.Foo({@Bar(88), \"two\"})";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation11(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation11(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation12() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({\"one\", \"two\"})");
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains("@Bar(MISSING)})", cu); // split line
- }
-
- public void testNewSingleMemberAnnotation13() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(7)");
- String expected = "@annot.Foo(@Bar(88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation13(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation13(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation14() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(7)");
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar(MISSING)})", cu);
- }
-
- public void testNewSingleMemberAnnotation15() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.NotBar)");
- String expected = "@annot.Foo(@Bar(88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation15(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation15(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation16() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(55))");
- String expected = "@annot.Foo({@annot.Bar(55),@Bar(88)})";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation16(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation16(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation17() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})");
- String expected = "@annot.Foo(nestedAnnotations={@Bar(88)})";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation17(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation17(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation18() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})");
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains("@Bar(MISSING)})", cu); // ???
- }
-
- public void testNewSingleMemberAnnotation19() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=\"something\")");
- String expected = "@annot.Foo(nestedAnnotations=@Bar(88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation19(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation19(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation20() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- String expected = "@annot.Foo(nestedAnnotations=@Bar(88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation20(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation20(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewSingleMemberAnnotation21() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int value();");
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newSingleMemberAnnotation();
- this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar(MISSING)})", cu);
- }
-
- public void testNewSingleMemberAnnotation22() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(77))");
- String expected = "@annot.Foo(nestedAnnotations=@Bar(88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation22(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewSingleMemberAnnotation22(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- SingleMemberAnnotation annotation = daa.newSingleMemberAnnotation(declaration);
- NumberLiteral numberLiteral = annotation.getAST().newNumberLiteral();
- numberLiteral.setToken("88");
- annotation.setValue(numberLiteral);
- }
-
- public void testNewNormalAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("@Foo", cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation1(declaration);
- }
- });
- this.assertSourceContains("@Foo(nestedAnnotations = @Bar(xxx = 88))", cu);
- }
-
- void editNewNormalAnnotation1(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("@Foo", cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation2(declaration);
- }
- });
- this.assertSourceContains("@Foo(@Bar(xxx = 88))", cu);
- }
-
- void editNewNormalAnnotation2(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(nestedAnnotations = @Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation3(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation3(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- String expected = "@Foo(@Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation4(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation4(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@Foo(value = \"something\", nestedAnnotations = @Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation5(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation5(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected = "@annot.Foo(@Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation6(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation6(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String xxx();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation7(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation7(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value(); String xxx();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(xxx=\"something\")");
- String expected = "@annot.Foo(xxx=\"something\", value = @Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation8(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation8(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation9() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String xxx();");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains("@Foo(nestedAnnotations = { null, null, null, null, null, @Bar() })", cu);
- }
-
- public void testNewNormalAnnotation10() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(\"something\")");
- String expected1 = "@Foo(value = \"something\", nestedAnnotations = { null, null, null, null,";
- String expected2 = "null, @Bar() })";
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains(expected1, cu);
- this.assertSourceContains(expected2, cu);
- }
-
- public void testNewNormalAnnotation11() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({ \"one\", \"two\" })");
- String expected = "@annot.Foo({ @Bar(xxx = 88), \"two\" })";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation11(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation11(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation12() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({\"one\", \"two\"})");
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains("@Bar()})", cu); // split line
- }
-
- public void testNewNormalAnnotation13() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(7)");
- String expected = "@annot.Foo(@Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation13(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation13(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation14() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(7)");
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar()})", cu);
- }
-
- public void testNewNormalAnnotation15() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int xxx();");
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.NotBar)");
- String expected = "@annot.Foo(@Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation15(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation15(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation16() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(55))");
- String expected = "@annot.Foo({@annot.Bar(55),@Bar(xxx=88)})";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation16(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation16(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation17() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations = { \"something\" })");
- String expected = "@annot.Foo(nestedAnnotations = { @Bar(xxx = 88) })";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation17(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation17(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation18() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})");
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains("@Bar()})", cu); // split line
- }
-
- public void testNewNormalAnnotation19() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations = \"something\")");
- String expected = "@annot.Foo(nestedAnnotations = @Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation19(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation19(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation20() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int xxx();");
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations = @annot.NotBar)");
- String expected = "@annot.Foo(nestedAnnotations = @Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation20(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation20(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testNewNormalAnnotation21() throws Exception {
- this.createAnnotationAndMembers("NotBar", "int xxx();");
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)");
- this.assertSourceDoesNotContain("@Bar", cu);
-
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newNormalAnnotation();
- this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar()})", cu);
- }
-
- public void testNewNormalAnnotation22() throws Exception {
- this.createAnnotationAndMembers("Bar", "int xxx();");
- this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(nestedAnnotations = @annot.Bar(77))");
- String expected = "@annot.Foo(nestedAnnotations = @Bar(xxx = 88))";
- this.assertSourceDoesNotContain(expected, cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation22(declaration);
- }
- });
- this.assertSourceContains(expected, cu);
- }
-
- void editNewNormalAnnotation22(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar");
- NormalAnnotation annotation = daa.newNormalAnnotation(declaration);
- this.addMemberValuePair(annotation, "xxx", 88);
- }
-
- public void testMoveAnnotation1() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(00))");
- String expected = "@annot.Foo({null,@annot.Bar(00)})";
- this.assertSourceDoesNotContain(expected, cu);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(1);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation2() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({null, @annot.Bar(11)})");
- String expected = "@annot.Foo(@annot.Bar(11))";
- this.assertSourceDoesNotContain(expected, cu);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation3() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), @annot.Bar(33)})");
- String expected = "@annot.Foo({@annot.Bar(33), @annot.Bar(11), @annot.Bar(22)})";
- this.assertSourceDoesNotContain(expected, cu);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation4() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), @annot.Bar(33), @annot.Bar(44)})");
- String expected = "@annot.Foo({@annot.Bar(33), @annot.Bar(11), @annot.Bar(22), null, @annot.Bar(44)})";
- this.assertSourceDoesNotContain(expected, cu);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation5() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})");
- String expected = "@annot.Foo({@annot.Bar(00), @annot.Bar(11), null, @annot.Bar(22)})";
- this.assertSourceDoesNotContain(expected, cu);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation6() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})");
- String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22), @annot.Bar(00)})";
- this.assertSourceDoesNotContain(expected, cu);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation7() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22)})");
- String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22)})";
- this.assertSourceDoesNotContain(expected, cu);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation8() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), @annot.Bar(22), null, @annot.Bar(44)})");
- String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22), null, @annot.Bar(44)})";
- this.assertSourceDoesNotContain(expected, cu);
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation9() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- String expected = "@annot.Foo({null, @annot.Bar(11), @annot.Bar(22)})";
- ICompilationUnit cu = this.createTestType(expected); // the source should be unchanged
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- iaa.moveAnnotation(3);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation10() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11)})");
- String expected = "@annot.Foo(@annot.Bar(00))";
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- iaa.moveAnnotation(1);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation11() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo(@annot.Bar(00))");
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceDoesNotContain("Bar", cu);
- }
-
- public void testMoveAnnotation12() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), null, @annot.Bar(22)})");
- String expected = "@annot.Foo(@annot.Bar(22))";
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
- public void testMoveAnnotation13() throws Exception {
- this.createAnnotationAndMembers("Bar", "int value();");
- this.createAnnotationAndMembers("Foo", "annot.Bar[] value();");
- ICompilationUnit cu = this.createTestType("@annot.Foo({@annot.Bar(00), @annot.Bar(11), null, @annot.Bar(33)})");
- String expected = "@annot.Foo({@annot.Bar(33), @annot.Bar(11)})";
-
- IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter(
- new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar");
- IndexedAnnotationAdapter iaa = new ElementIndexedAnnotationAdapter(this.idField(cu), idaa);
- Annotation annotation = iaa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- iaa.moveAnnotation(0);
- this.assertSourceContains(expected, cu);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java
deleted file mode 100644
index 8c86b93406..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/SimpleDeclarationAnnotationAdapterTests.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.dom.ASTNode;
-import org.eclipse.jdt.core.dom.Annotation;
-import org.eclipse.jdt.core.dom.Expression;
-import org.eclipse.jdt.core.dom.MemberValuePair;
-import org.eclipse.jdt.core.dom.NormalAnnotation;
-import org.eclipse.jdt.core.dom.NumberLiteral;
-import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jdt.core.dom.StringLiteral;
-import org.eclipse.jpt.common.core.internal.utility.jdt.ElementAnnotationAdapter;
-import org.eclipse.jpt.common.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.AnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.DeclarationAnnotationAdapter;
-import org.eclipse.jpt.common.core.utility.jdt.Member;
-import org.eclipse.jpt.common.core.utility.jdt.ModifiedDeclaration;
-
-@SuppressWarnings("nls")
-public class SimpleDeclarationAnnotationAdapterTests extends AnnotationTestCase {
-
- public SimpleDeclarationAnnotationAdapterTests(String name) {
- super(name);
- }
-
- private void createAnnotation(String annotationName) throws Exception {
- this.createAnnotation("annot", annotationName);
- }
-
- private void createAnnotation(String packageName, String annotationName) throws Exception {
- this.javaProject.createCompilationUnit(packageName, annotationName + ".java", "public @interface " + annotationName + " {}");
- }
-
- public void testAnnotation1() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
- assertEquals("annot.Foo", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
- }
-
- public void testAnnotation2() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType("@annot.Foo(1) @annot.Foo(2)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
- assertEquals("annot.Foo", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isSingleMemberAnnotation());
- Expression value = ((SingleMemberAnnotation) annotation).getValue();
- assertEquals(ASTNode.NUMBER_LITERAL, value.getNodeType());
- assertEquals("1", ((NumberLiteral) value).getToken());
- }
-
- public void testAnnotation3() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType("annot.Foo", "@Foo");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
- assertEquals("Foo", annotation.getTypeName().getFullyQualifiedName());
- assertTrue(annotation.isMarkerAnnotation());
- }
-
- public void testAnnotationNull1() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType();
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- }
-
- public void testAnnotationNull2() throws Exception {
- this.createAnnotation("Foo");
- this.createAnnotation("Fop");
- ICompilationUnit cu = this.createTestType("@annot.Fop");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- this.assertSourceContains("@annot.Fop", cu);
- }
-
- public void testAnnotationNull3() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- // un-qualified name
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
- this.assertSourceContains("@annot.Foo", cu);
- }
-
- public void testRemoveAnnotation1() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType("@annot.Foo");
- this.assertSourceContains("@annot.Foo", cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("@annot.Foo", cu);
- }
-
- public void testRemoveAnnotation2() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType("@annot.Foo(1) @annot.Foo(2)");
- this.assertSourceContains("@annot.Foo(1) @annot.Foo(2)", cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.removeAnnotation();
- this.assertSourceDoesNotContain("@annot.Foo(1)", cu);
- this.assertSourceContains("@annot.Foo(2)", cu);
- }
-
- public void testNewMarkerAnnotation1() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("import annot.Foo;", cu);
- this.assertSourceDoesNotContain("@Foo", cu);
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("import annot.Foo;", cu);
- this.assertSourceContains("@Foo", cu);
- }
-
- public void testNewMarkerAnnotation2() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType("@annot.Foo(88)");
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- AnnotationAdapter aa = new ElementAnnotationAdapter(this.idField(cu), daa);
- Annotation annotation = aa.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation);
-
- aa.newMarkerAnnotation();
- this.assertSourceContains("import annot.Foo;", cu);
- this.assertSourceContains("@Foo", cu);
- this.assertSourceDoesNotContain("@annot.Foo(88)", cu);
- }
-
- public void testNewSingleMemberAnnotation() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("@Foo", cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- SimpleDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation(declaration);
- }
- });
- this.assertSourceContains("import annot.Foo;", cu);
- this.assertSourceContains("@Foo(\"test string literal\")", cu);
- }
-
- void editNewSingleMemberAnnotation(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- SingleMemberAnnotation annotation = (SingleMemberAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newSingleMemberAnnotation(declaration);
- StringLiteral stringLiteral = annotation.getAST().newStringLiteral();
- stringLiteral.setLiteralValue("test string literal");
- annotation.setValue(stringLiteral);
- }
-
- public void testNewNormalAnnotation() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("@Foo", cu);
- this.idField(cu).edit(new Member.Editor() {
- public void edit(ModifiedDeclaration declaration) {
- SimpleDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation(declaration);
- }
- });
- this.assertSourceContains("import annot.Foo;", cu);
- this.assertSourceContains("@Foo(bar = \"test string literal\")", cu);
- }
-
- void editNewNormalAnnotation(ModifiedDeclaration declaration) {
- DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo");
- NormalAnnotation annotation = (NormalAnnotation) daa.getAnnotation(declaration);
- assertNull(annotation);
- annotation = daa.newNormalAnnotation(declaration);
- MemberValuePair mvp = this.newMemberValuePair(annotation.getAST(), "bar", "test string literal");
- this.values(annotation).add(mvp);
- }
-
- public void testImportCollision1() throws Exception {
- this.createAnnotation("annot1", "Foo");
- this.createAnnotation("annot2", "Foo");
- ICompilationUnit cu = this.createTestType();
- this.assertSourceDoesNotContain("@Foo", cu);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot1.Foo");
- DeclarationAnnotationAdapter daa2 = new SimpleDeclarationAnnotationAdapter("annot2.Foo");
-
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- Annotation annotation1 = aa1.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation1);
-
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation2 = aa2.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation2);
-
- aa1.newMarkerAnnotation();
- this.assertSourceContains("import annot1.Foo;", cu);
- this.assertSourceContains("@Foo", cu);
-
- aa2.newMarkerAnnotation();
- this.assertSourceDoesNotContain("import annot2.Foo;", cu);
- this.assertSourceContains("@annot2.Foo", cu);
- }
-
- public void testImportCollision2() throws Exception {
- this.createAnnotation("annot1", "Foo");
- this.createAnnotation("annot2", "Foo");
- ICompilationUnit cu = this.createTestType("annot1.*", "@Foo");
- this.assertSourceContains("import annot1.*;", cu);
- this.assertSourceContains("@Foo", cu);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot1.Foo");
- DeclarationAnnotationAdapter daa2 = new SimpleDeclarationAnnotationAdapter("annot2.Foo");
-
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- Annotation annotation1 = aa1.getAnnotation(this.buildASTRoot(cu));
- assertNotNull(annotation1);
-
- AnnotationAdapter aa2 = new ElementAnnotationAdapter(this.idField(cu), daa2);
- Annotation annotation2 = aa2.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation2);
-
- aa2.newMarkerAnnotation();
- this.assertSourceDoesNotContain("import annot2.Foo;", cu);
- this.assertSourceContains("@annot2.Foo", cu);
- }
-
- public void testImportWildCard() throws Exception {
- this.createAnnotation("Foo");
- ICompilationUnit cu = this.createTestType("annot.*", "");
- this.assertSourceContains("import annot.*;", cu);
- this.assertSourceDoesNotContain("@Foo", cu);
- DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo");
-
- AnnotationAdapter aa1 = new ElementAnnotationAdapter(this.idField(cu), daa1);
- Annotation annotation1 = aa1.getAnnotation(this.buildASTRoot(cu));
- assertNull(annotation1);
-
- aa1.newMarkerAnnotation();
- this.assertSourceDoesNotContain("import annot.Foo;", cu);
- this.assertSourceContains("@Foo", cu);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/TypeTests.java b/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/TypeTests.java
deleted file mode 100644
index ebd80a401f..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/src/org/eclipse/jpt/common/core/tests/internal/utility/jdt/TypeTests.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.core.tests.internal.utility.jdt;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.ICompilationUnit;
-
-@SuppressWarnings("nls")
-public class TypeTests extends AnnotationTestCase {
-
- public TypeTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected ICompilationUnit createCompilationUnit(String source) throws CoreException {
- return this.javaProject.createCompilationUnit(PACKAGE_NAME, FILE_NAME, source);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void test1() throws Exception {
- ICompilationUnit jdtCompilationUnit = this.createCompilationUnit(this.buildTest1Source());
- assertNotNull(jdtCompilationUnit);
- }
-
- private String buildTest1Source() {
- StringBuilder sb = new StringBuilder();
- sb.append("public class ").append(TYPE_NAME).append(" {").append(CR);
- sb.append(" private int id;").append(CR);
- sb.append(" public int getId() {").append(CR);
- sb.append(" return this.id;").append(CR);
- sb.append(" }").append(CR);
- sb.append("}").append(CR);
- return sb.toString();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.core.tests/test.xml b/common/tests/org.eclipse.jpt.common.core.tests/test.xml
deleted file mode 100644
index 0034685b7a..0000000000
--- a/common/tests/org.eclipse.jpt.common.core.tests/test.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0"?> <!--
- Copyright (c) 2007, 2010 Oracle. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0, which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. Contributors: Oracle - initial API and implementation -->
-
-<project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <echo message="basedir ${basedir}" />
- <echo message="eclipse place ${eclipse-home}" />
- <!-- sets the properties plugin-name -->
- <property name="plugin-name" value="org.eclipse.jpt.common.core.tests"/> <echo level="debug" message="testRoot: ${testRoot}" />
- <fail message="testRoot must be set" unless="testRoot" />
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite1">
- <property file="${testRoot}/testServer.properties"/>
- <property name="jpt-folder" value="${eclipse-home}/jpt_folder"/>
- <delete dir="${jpt-folder}" quiet="true"/>
-
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="data-dir" value="${jpt-folder}"/>
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname" value="org.eclipse.jpt.common.core.tests.internal.JptCommonCoreTests" />
- <property name="plugin-path" value="${eclipse-home}/plugins/${plugin-name}"/>
- </ant> </target>
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init, suite1,cleanup">
- </target>
-</project> \ No newline at end of file
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/.classpath b/common/tests/org.eclipse.jpt.common.ui.tests/.classpath
deleted file mode 100644
index 62dd151822..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/.classpath
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/common/ui/**"/>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/common/utility/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/.cvsignore b/common/tests/org.eclipse.jpt.common.ui.tests/.cvsignore
deleted file mode 100644
index ba077a4031..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/.project b/common/tests/org.eclipse.jpt.common.ui.tests/.project
deleted file mode 100644
index 0e0633e91a..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.ui.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/.settings/org.eclipse.jdt.core.prefs b/common/tests/org.eclipse.jpt.common.ui.tests/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 1da1cd1a72..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Tue Mar 08 12:06:44 EST 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
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/META-INF/MANIFEST.MF b/common/tests/org.eclipse.jpt.common.ui.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index a8ccfe3992..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,21 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.common.ui.tests
-Bundle-Version: 1.1.0.qualifier
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle:
- org.eclipse.core.runtime;bundle-version="[3.6.100,4.0.0)",
- org.eclipse.jface;bundle-version="[3.7.0,4.0.0)",
- org.eclipse.jpt.common.utility;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.jpt.common.ui;bundle-version="[1.0.0,2.0.0)",
- org.eclipse.ui.forms;bundle-version="[3.5.100,4.0.0)",
- org.eclipse.ui.workbench;bundle-version="[3.7.0,4.0.0)",
- org.eclipse.ui.navigator;bundle-version="[3.5.0,4.0.0)",
- org.junit;bundle-version="[4.0.0,5.0.0)"
-Export-Package: org.eclipse.jpt.common.ui.tests;x-internal:=true,
- org.eclipse.jpt.common.ui.tests.internal.jface;x-internal:=true,
- org.eclipse.jpt.common.ui.tests.internal.swt;x-internal:=true,
- org.eclipse.jpt.common.ui.tests.internal.util;x-internal:=true,
- org.eclipse.jpt.common.ui.tests.internal.utility.swt;x-internal:=true
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/build.properties b/common/tests/org.eclipse.jpt.common.ui.tests/build.properties
deleted file mode 100644
index 4dce676b59..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/build.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-################################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/plugin.properties b/common/tests/org.eclipse.jpt.common.ui.tests/plugin.properties
deleted file mode 100644
index 7b81997383..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/plugin.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-################################################################################
-# Copyright (c) 2011 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName=Dali Java Persistence Tools - Common UI Tests
-providerName=Eclipse Web Tools Platform
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/JptCommonUiTests.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/JptCommonUiTests.java
deleted file mode 100644
index bb3b72fe07..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/JptCommonUiTests.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.common.ui.tests.internal.swt.JptUiSWTTests;
-import org.eclipse.jpt.common.ui.tests.internal.util.JptUiUtilTests;
-
-/**
- * Runs all JPT UI Tests
- */
-public class JptCommonUiTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptCommonUiTests.class.getPackage().getName());
- suite.addTest(JptUiSWTTests.suite());
- suite.addTest(JptUiUtilTests.suite());
- return suite;
- }
-
- private JptCommonUiTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/jface/DelegatingLabelProviderUiTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/jface/DelegatingLabelProviderUiTest.java
deleted file mode 100644
index 74891f3a08..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/jface/DelegatingLabelProviderUiTest.java
+++ /dev/null
@@ -1,565 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.jface;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.BaseLabelProvider;
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.common.ui.internal.jface.AbstractItemExtendedLabelProvider;
-import org.eclipse.jpt.common.ui.internal.jface.ItemTreeStateProviderManager;
-import org.eclipse.jpt.common.ui.internal.jface.StaticItemTreeContentProvider;
-import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProvider;
-import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProviderFactory;
-import org.eclipse.jpt.common.ui.jface.ItemLabelProvider;
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider;
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProviderFactory;
-import org.eclipse.jpt.common.ui.jface.TreeStateProvider;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-public class DelegatingLabelProviderUiTest extends ApplicationWindow
-{
- private TreeViewer tree;
-
- private ModifiablePropertyValueModel<Vehicle> selectedVehicle;
-
-
- public static void main(String[] args) {
- Window window = new DelegatingLabelProviderUiTest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
-
- private DelegatingLabelProviderUiTest(String[] args) {
- super(null);
- this.selectedVehicle = new SimplePropertyValueModel<Vehicle>();
- }
-
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(this.getClass().getSimpleName());
- parent.setSize(400, 400);
- parent.setLayout(new GridLayout());
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
- mainPanel.setLayout(new GridLayout());
- buildTreePanel(mainPanel);
- buildControlPanel(mainPanel);
- return mainPanel;
- }
-
- private void buildTreePanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL_BOTH));
- panel.setLayout(new GridLayout());
-
- Label label = new Label(panel, SWT.NONE);
- label.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
- label.setText("My Vehicles");
-
- tree = new TreeViewer(panel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- tree.getTree().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
- TreeStateProvider contentAndLabelProvider =
- new ItemTreeStateProviderManager(
- new VehicleContentProviderFactory(),
- new VehicleLabelProviderFactory());
- tree.setContentProvider(contentAndLabelProvider);
- tree.setLabelProvider(contentAndLabelProvider);
- tree.setInput(new Root());
- tree.addSelectionChangedListener(buildTreeSelectionChangedListener());
- }
-
- private ISelectionChangedListener buildTreeSelectionChangedListener() {
- return new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- selectedVehicle.setValue((Vehicle) ((IStructuredSelection) event.getSelection()).getFirstElement());
- }
- };
- }
-
- private void buildControlPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- panel.setLayout(new GridLayout());
- buildUpperControlPanel(panel);
- buildLowerControlPanel(panel);
- }
-
- private void buildUpperControlPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- panel.setLayout(new GridLayout(2, true));
- buildVehicleCombo(panel);
- buildColorCombo(panel);
- }
-
- private void buildVehicleCombo(Composite parent) {
- final ComboViewer combo = new ComboViewer(parent, SWT.READ_ONLY);
- combo.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- combo.setContentProvider(new ArrayContentProvider());
- combo.setLabelProvider(new VehicleTypeLabelProvider());
- combo.setInput(
- new VehicleType[] {
- VehicleType.BICYCLE, VehicleType.CAR,
- VehicleType.TRUCK, VehicleType.BOAT
- });
- combo.getCombo().setEnabled(false);
- combo.addSelectionChangedListener(
- new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- selectedVehicle().setVehicleType((VehicleType) ((StructuredSelection) event.getSelection()).getFirstElement());
- }
- });
- selectedVehicle.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- Vehicle vehicle = selectedVehicle();
- combo.getCombo().setEnabled(vehicle != null);
- combo.setSelection(new StructuredSelection((vehicle == null) ? null : vehicle.vehicleType()));
- }
- });
- }
-
- private void buildColorCombo(Composite parent) {
- final ComboViewer combo = new ComboViewer(parent, SWT.READ_ONLY);
- combo.getCombo().setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- combo.setContentProvider(new ArrayContentProvider());
- combo.setLabelProvider(new ColorLabelProvider());
- combo.setInput(new Color[] {Color.RED, Color.BLUE, Color.YELLOW, Color.GREEN});
- combo.addSelectionChangedListener(
- new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- selectedVehicle().setColor((Color) ((StructuredSelection) event.getSelection()).getFirstElement());
- }
- });
- selectedVehicle.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- Vehicle vehicle = selectedVehicle();
- combo.getCombo().setEnabled(vehicle != null);
- combo.setSelection(new StructuredSelection((vehicle == null) ? null : vehicle.color()));
- }
- });
- }
-
- private void buildLowerControlPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- panel.setLayout(new GridLayout(3, false));
- buildEffectsLabel(panel);
- buildGreyedCheckBox(panel);
- buildTranslucentCheckBox(panel);
- buildActionPanel(panel);
- }
-
- private void buildEffectsLabel(Composite parent) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText("Color effects: ");
- label.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false, 3, 1));
- }
-
- private void buildGreyedCheckBox(Composite parent) {
- final Button button = new Button(parent, SWT.CHECK);
- button.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
- button.setText("greyed");
- button.setEnabled(false);
- button.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedVehicle().setGreyed(button.getSelection());
- }
- });
- selectedVehicle.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- Vehicle vehicle = selectedVehicle();
- button.setEnabled(vehicle != null);
- button.setSelection(vehicle != null && vehicle.isGreyed());
- }
- });
- }
-
- private void buildTranslucentCheckBox(Composite parent) {
- final Button button = new Button(parent, SWT.CHECK);
- button.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false));
- button.setText("translucent");
- button.setEnabled(false);
- button.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- selectedVehicle().setTranslucent(button.getSelection());
- }
- });
- selectedVehicle.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- Vehicle vehicle = selectedVehicle();
- button.setEnabled(vehicle != null);
- button.setSelection(vehicle != null && vehicle.isTranslucent());
- }
- });
- }
-
- private void buildActionPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.END, GridData.FILL, false, false));
- panel.setLayout(new GridLayout());
- buildRefreshTreeACI().fill(panel);
- }
-
- private ActionContributionItem buildRefreshTreeACI() {
- Action action = new Action("Refresh tree", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- refreshTree();
- }
- };
- action.setToolTipText("Refresh the tree's labels");
- return new ActionContributionItem(action);
- }
-
- void refreshTree() {
- tree.refresh();
- }
-
- private Vehicle selectedVehicle() {
- return selectedVehicle.getValue();
- }
-
-
- private static class VehicleTypeLabelProvider extends BaseLabelProvider
- implements ILabelProvider
- {
- public Image getImage(Object element) {
- return null;
- }
-
- public String getText(Object element) {
- return ((VehicleType) element).description();
- }
- }
-
-
- private static class ColorLabelProvider extends BaseLabelProvider
- implements ILabelProvider
- {
- public Image getImage(Object element) {
- return null;
- }
-
- public String getText(Object element) {
- return ((Color) element).description();
- }
- }
-
-
- private static class VehicleContentProviderFactory
- implements ItemTreeContentProviderFactory
- {
- public ItemTreeContentProvider buildProvider(Object item, ItemTreeContentProvider.Manager manager) {
- if (item instanceof Root) {
- return this.buildRootProvider((Root) item);
- }
- return this.buildVehicleProvider((Vehicle) item);
- }
- protected ItemTreeContentProvider buildRootProvider(Root item) {
- return new StaticItemTreeContentProvider(null, item.vehicles());
- }
- protected ItemTreeContentProvider buildVehicleProvider(Vehicle item) {
- return new StaticItemTreeContentProvider(item.parent());
- }
- }
-
-
- private static class VehicleLabelProviderFactory
- implements ItemExtendedLabelProviderFactory
- {
- public ItemExtendedLabelProvider buildProvider(Object item, ItemExtendedLabelProvider.Manager manager) {
- return new VehicleLabelProvider((Vehicle) item, manager);
- }
- }
-
-
- private static class VehicleLabelProvider
- extends AbstractItemExtendedLabelProvider<Vehicle>
- {
- public VehicleLabelProvider(Vehicle vehicle, ItemLabelProvider.Manager manager) {
- super(vehicle, manager);
- }
-
- @Override
- protected PropertyValueModel<Image> buildImageModel() {
- return new PropertyAspectAdapter<Vehicle, Image>(IMAGE_ASPECT_NAMES, this.item) {
- @Override
- protected Image buildValue_() {
- return subject.image();
- }
- };
- }
- private static final String[] IMAGE_ASPECT_NAMES =
- new String[] {
- Vehicle.COLOR_PROPERTY,
- Vehicle.GREYED_PROPERTY,
- Vehicle.TRANSLUCENT_PROPERTY
- };
-
- @Override
- protected PropertyValueModel<String> buildTextModel() {
- return new PropertyAspectAdapter<Vehicle, String>(TEXT_ASPECT_NAMES, this.item) {
- @Override
- protected String buildValue_() {
- return subject.color().description() + ' ' + subject.vehicleType().description();
- }
- };
- }
- private static final String[] TEXT_ASPECT_NAMES =
- new String[] {
- Vehicle.VEHICLE_TYPE_PROPERTY,
- Vehicle.COLOR_PROPERTY
- };
-
- @Override
- protected PropertyValueModel<String> buildDescriptionModel() {
- return buildTextModel();
- }
- }
-
-
- private static abstract class TreeNode extends AbstractModel
- {
- private TreeNode parent;
-
-
- public TreeNode(TreeNode parent) {
- this.parent = parent;
- }
-
-
- public TreeNode parent() {
- return parent;
- }
- }
-
-
- private static class Root extends TreeNode
- {
- protected final Vehicle[] vehicles;
-
-
- public Root() {
- super(null);
- vehicles = new Vehicle[] {
- new Vehicle(this, VehicleType.BICYCLE, Color.BLUE),
- new Vehicle(this, VehicleType.CAR, Color.YELLOW),
- new Vehicle(this, VehicleType.TRUCK, Color.RED),
- new Vehicle(this, VehicleType.BOAT, Color.GREEN)};
- }
-
- public Vehicle[] vehicles() {
- return vehicles;
- }
- }
-
-
- private static class Vehicle extends TreeNode
- {
- private VehicleType vehicleType;
- public final static String VEHICLE_TYPE_PROPERTY = "vehicleType";
-
- private Color color;
- public final static String COLOR_PROPERTY = "color";
-
- private boolean greyed = false;
- public final static String GREYED_PROPERTY = "greyed";
-
- private boolean translucent = false;
- public final static String TRANSLUCENT_PROPERTY = "translucent";
-
- private Image image;
-
-
- public Vehicle(TreeNode parent, VehicleType vehicleType, Color color) {
- super(parent);
- this.vehicleType = vehicleType;
- this.color = color;
- }
-
- public VehicleType vehicleType() {
- return vehicleType;
- }
-
- public void setVehicleType(VehicleType newVehicleType) {
- VehicleType oldVehicleType = vehicleType;
- vehicleType = newVehicleType;
- firePropertyChanged(VEHICLE_TYPE_PROPERTY, oldVehicleType, newVehicleType);
- }
-
- public Color color() {
- return color;
- }
-
- public void setColor(Color newColor) {
- Color oldColor = color;
- color = newColor;
- firePropertyChanged(COLOR_PROPERTY, oldColor, newColor);
- }
-
- public boolean isGreyed() {
- return greyed;
- }
-
- public void setGreyed(boolean newGreyed) {
- boolean oldGreyed = greyed;
- greyed = newGreyed;
- firePropertyChanged(GREYED_PROPERTY, oldGreyed, newGreyed);
- }
-
- public boolean isTranslucent() {
- return translucent;
- }
-
- public void setTranslucent(boolean newTranslucent) {
- boolean oldTranslucent = translucent;
- translucent = newTranslucent;
- firePropertyChanged(TRANSLUCENT_PROPERTY, oldTranslucent, newTranslucent);
- }
-
- public Image image() {
- if (image != null) {
- image.dispose();
- }
-
- return ImageFactory.image(color(), greyed, translucent);
- }
- }
-
-
- private static enum VehicleType
- {
- BICYCLE("bicycle"),
- CAR("car"),
- TRUCK("truck"),
- BOAT("boat");
-
- private final String description;
-
- private VehicleType(String description) {
- this.description = description;
- }
-
- public String description() {
- return description;
- }
-
- @Override
- public String toString() {
- return description();
- }
- }
-
-
- private static enum Color
- {
- RED("red", new RGB(255, 0, 0)),
- BLUE("blue", new RGB(0, 0, 255)),
- YELLOW("yellow", new RGB(255, 255, 0)),
- GREEN("green", new RGB(0, 255, 0));
-
- private final String description;
-
- private final RGB rgb;
-
- private Color(String description, RGB rgb) {
- this.description = description;
- this.rgb = rgb;
- }
-
- public String description() {
- return description;
- }
-
- public RGB rgb() {
- return rgb;
- }
-
- @Override
- public String toString() {
- return description();
- }
- }
-
-
- private static class ImageFactory
- {
- private static RGB rgb(Color color, boolean greyed, boolean translucent) {
- RGB rgb = (greyed) ? new RGB(127, 127, 127) : color.rgb();
- if (translucent) {
- rgb = new RGB(translucify(rgb.red), translucify(rgb.green), translucify(rgb.blue));
- }
- return rgb;
- }
-
- private static int translucify(int color) {
- return 255 - (int) ((255 - color) * 0.3);
- }
-
- public static Image image(Color color, boolean greyed, boolean translucent) {
- PaletteData pd = new PaletteData(new RGB[] {rgb(color, greyed, translucent)});
- ImageData id = new ImageData(20, 20, 1, pd);
- for (int x = 0; x < 20; x ++) {
- for (int y = 0; y < 20; y ++) {
- id.setPixel(x, y, 0);
- }
- }
- return new Image(Display.getCurrent(), id);
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/jface/DelegatingTreeContentProviderUiTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/jface/DelegatingTreeContentProviderUiTest.java
deleted file mode 100644
index fb8abd7edb..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/jface/DelegatingTreeContentProviderUiTest.java
+++ /dev/null
@@ -1,554 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.jface;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.BaseLabelProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.common.ui.internal.jface.AbstractItemTreeContentProvider;
-import org.eclipse.jpt.common.ui.internal.jface.ItemTreeStateProviderManager;
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProvider;
-import org.eclipse.jpt.common.ui.jface.ItemTreeContentProviderFactory;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.NotNullFilter;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.CompositeCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.ListCollectionValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-@SuppressWarnings("nls")
-public class DelegatingTreeContentProviderUiTest extends ApplicationWindow
-{
- private final Root root;
-
- private ModifiablePropertyValueModel<TreeNode> selectedNode;
-
- private TreeViewer controlTree;
-
- private TreeViewer viewTree;
-
- private Text nodeNameText;
-
-
- public static void main(String[] args) {
- Window window = new DelegatingTreeContentProviderUiTest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private DelegatingTreeContentProviderUiTest(String[] args) {
- super(null);
- this.root = new Root();
- this.root.addChild("Parent_1");
- this.selectedNode = new SimplePropertyValueModel<TreeNode>(this.root);
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(this.getClass().getSimpleName());
- parent.setSize(800, 400);
- parent.setLayout(new GridLayout());
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
- mainPanel.setLayout(new GridLayout());
- buildTreePanel(mainPanel);
- buildControlPanel(mainPanel);
- return mainPanel;
- }
-
- private void buildTreePanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL_BOTH));
- panel.setLayout(new GridLayout(2, true));
- buildControlTreePanel(panel);
- buildViewTreePanel(panel);
- }
-
- private void buildControlTreePanel(Composite parent) {
- controlTree = buildTreePanel(
- parent, "Control tree",
- new ItemTreeStateProviderManager(new ControlTreeItemContentProviderFactory()),
- new LabelProvider());
- controlTree.addSelectionChangedListener(buildTreeSelectionChangedListener());
- selectedNode.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- controlTree.setSelection(new StructuredSelection(event.getNewValue()));
- }
- }
- );
- }
-
- private void buildViewTreePanel(Composite parent) {
- viewTree = buildTreePanel(
- parent, "View tree",
- new ItemTreeStateProviderManager(new ViewItemTreeContentProviderFactory()),
- new LabelProvider());
- }
-
- private TreeViewer buildTreePanel(Composite parent, String labelText, ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL_BOTH));
- panel.setLayout(new GridLayout());
-
- Label label = new Label(panel, SWT.LEFT);
- label.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, false));
- label.setText(labelText);
-
- final TreeViewer tree = new TreeViewer(panel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
- tree.getTree().setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
- tree.setContentProvider(contentProvider);
- tree.setLabelProvider(labelProvider);
- tree.setInput(root);
-
- return tree;
- }
-
- private ISelectionChangedListener buildTreeSelectionChangedListener() {
- return new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- TreeNode selection = (TreeNode) ((IStructuredSelection) event.getSelection()).getFirstElement();
- selectedNode.setValue((selection == null) ? root : selection);
- }
- };
- }
-
- private void buildControlPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
- panel.setLayout(new GridLayout(6, false));
- buildNodeNameText(panel);
- buildAddChildACI().fill(panel);
- buildAddNestedChildACI().fill(panel);
- buildRemoveACI().fill(panel);
- buildClearModelACI().fill(panel);
- buildRestoreModelACI().fill(panel);
- }
-
- private void buildNodeNameText(Composite parent) {
- nodeNameText = new Text(parent, SWT.SINGLE | SWT.BORDER);
- nodeNameText.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- }
-
- private ActionContributionItem buildAddChildACI() {
- final Action action = new Action("Add child", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- addChild();
- }
- };
- action.setToolTipText("Add a child with the given name");
- selectedNode.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- action.setEnabled(((TreeNode) event.getNewValue()).canHaveChildren());
- }
- }
- );
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildAddNestedChildACI() {
- final Action action = new Action("Add nested child", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- addNestedChild();
- }
- };
- action.setToolTipText("Add a nested child with the given name");
- action.setEnabled(false);
- selectedNode.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- action.setEnabled(((TreeNode) event.getNewValue()).canHaveNestedChildren());
- }
- }
- );
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildRemoveACI() {
- final Action action = new Action("Remove", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- remove();
- }
- };
- action.setToolTipText("Remove the selected node");
- action.setEnabled(false);
- selectedNode.addPropertyChangeListener(
- PropertyValueModel.VALUE,
- new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent event) {
- action.setEnabled(event.getNewValue() != root);
- }
- }
- );
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildClearModelACI() {
- Action action = new Action("Clear model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- clearModel();
- }
- };
- action.setToolTipText("Clear the model");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildRestoreModelACI() {
- Action action = new Action("Restore model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- restoreModel();
- }
- };
- action.setToolTipText("Restore the model");
- return new ActionContributionItem(action);
- }
-
- void addChild() {
- String nodeName = nodeNameText.getText();
- if (nodeName.length() != 0) {
- selectedNode.getValue().addChild(nodeName);
- }
- }
-
- void addNestedChild() {
- String nodeName = nodeNameText.getText();
- if (nodeName.length() != 0) {
- selectedNode.getValue().addNestedChild(nodeName);
- }
- }
-
- void remove() {
- TreeNode node = selectedNode.getValue();
- node.parent().removeChild(node);
- }
-
- void clearModel() {
- controlTree.setInput(null);
- viewTree.setInput(null);
- }
-
- void restoreModel() {
- controlTree.setInput(root);
- viewTree.setInput(root);
- }
-
-
- static abstract class AbstractTreeItemContentProviderFactory
- implements ItemTreeContentProviderFactory
- {
- public ItemTreeContentProvider buildProvider(Object item, ItemTreeContentProvider.Manager manager) {
- return new GenericItemTreeContentProvider((TreeNode) item, manager);
- }
- }
-
-
- static class ControlTreeItemContentProviderFactory
- extends AbstractTreeItemContentProviderFactory
- {
- // nothing
- }
-
-
- static class ViewItemTreeContentProviderFactory
- extends AbstractTreeItemContentProviderFactory
- {
- @Override
- public ItemTreeContentProvider buildProvider(Object item, ItemTreeContentProvider.Manager manager) {
- if (item instanceof Parent) {
- return new ViewParentItemTreeContentProvider((Parent) item, manager);
- }
- return super.buildProvider(item, manager);
- }
- }
-
-
- static class GenericItemTreeContentProvider
- extends AbstractItemTreeContentProvider<TreeNode, TreeNode>
- {
- public GenericItemTreeContentProvider(TreeNode treeNode, ItemTreeContentProvider.Manager manager) {
- super(treeNode, manager);
- }
-
- public TreeNode getParent() {
- return this.item.parent();
- }
-
- @Override
- protected CollectionValueModel<TreeNode> buildChildrenModel() {
- return new ListCollectionValueModelAdapter<TreeNode>(
- new ListAspectAdapter<TreeNode, TreeNode>(TreeNode.CHILDREN_LIST, this.item) {
- @Override
- protected ListIterator<TreeNode> listIterator_() {
- return this.subject.children();
- }
- });
- }
- }
-
- static class ViewParentItemTreeContentProvider
- extends GenericItemTreeContentProvider
- {
- public ViewParentItemTreeContentProvider(TreeNode treeNode, ItemTreeContentProvider.Manager manager) {
- super(treeNode, manager);
- }
-
- @Override
- public TreeNode getParent() {
- TreeNode parent = super.getParent();
- if (parent instanceof Nest) {
- parent = parent.parent();
- }
- return parent;
- }
-
- @Override
- protected CollectionValueModel<TreeNode> buildChildrenModel() {
- return new CompositeCollectionValueModel<TreeNode, TreeNode>(super.buildChildrenModel()) {
- @Override
- protected CollectionValueModel<TreeNode> transform(TreeNode value) {
- if (value instanceof Nest) {
- final Nest nest = (Nest) value;
- return new ListCollectionValueModelAdapter<TreeNode>(
- new ListAspectAdapter<TreeNode, TreeNode>(TreeNode.CHILDREN_LIST, nest) {
- @Override
- protected ListIterator<TreeNode> listIterator_() {
- return nest.children();
- }
- }
- );
- }
- return new StaticCollectionValueModel<TreeNode>(CollectionTools.collection(value));
- }
- };
- }
- }
-
-
- static class LabelProvider extends BaseLabelProvider
- implements ILabelProvider
- {
- public Image getImage(Object element) {
- return null;
- }
-
- public String getText(Object element) {
- return ((TreeNode) element).getName();
- }
- }
-
-
- static abstract class TreeNode extends AbstractModel
- {
- private TreeNode parent;
-
- protected final List<TreeNode> children;
- public final static String CHILDREN_LIST = "children";
-
- protected String name;
- public final static String NAME_PROPERTY = "name";
-
-
- public TreeNode(TreeNode parent, String name) {
- this.parent = parent;
- this.children = new ArrayList<TreeNode>();
- this.name = name;
- }
-
- public TreeNode parent() {
- return parent;
- }
-
- public ListIterator<TreeNode> children() {
- return new ReadOnlyListIterator<TreeNode>(children);
- }
-
- protected void addChild(TreeNode child) {
- addItemToList(child, children, CHILDREN_LIST);
- }
-
- public void removeChild(TreeNode child) {
- removeItemFromList(child, children, CHILDREN_LIST);
- }
-
- public void removeChild(int index) {
- removeItemFromList(index, children, CHILDREN_LIST);
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String newName) {
- String oldName = name;
- name = newName;
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- public boolean canHaveChildren() {
- return false;
- }
-
- public void addChild(String name) {
- throw new UnsupportedOperationException();
- }
-
- public boolean canHaveNestedChildren() {
- return false;
- }
-
- public void addNestedChild(String name) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(getName());
- }
- }
-
-
- static class Root extends TreeNode
- {
- public Root() {
- super(null, null);
- }
-
- @Override
- public boolean canHaveChildren() {
- return true;
- }
-
- @Override
- public void addChild(String name) {
- addChild(new Parent(this, name));
- }
- }
-
-
- static class Parent extends TreeNode
- {
- public Parent(TreeNode parent, String name) {
- super(parent, name);
- }
-
- @Override
- public boolean canHaveChildren() {
- return true;
- }
-
- @Override
- public void addChild(String name) {
- addChild(new Child(this, name));
- }
-
- @Override
- public boolean canHaveNestedChildren() {
- return true;
- }
-
- @Override
- public void addNestedChild(String name) {
- TreeNode nest = new Nest(this);
- addChild(nest);
- nest.addChild(name);
- }
-
- public Iterator<Child> nestlessChildren() {
- return new FilteringIterator<Child>(
- new TransformationIterator<TreeNode, Child>(children()) {
- @Override
- protected Child transform(TreeNode next) {
- if (next instanceof Nest) {
- return ((Nest) next).child();
- }
- return (Child) next;
- }
- },
- NotNullFilter.<Child>instance()
- );
- }
- }
-
-
- static class Nest extends TreeNode
- {
- public Nest(TreeNode parent) {
- super(parent, "nest");
- }
-
- @Override
- public boolean canHaveChildren() {
- return children.size() == 0;
- }
-
- @Override
- public void addChild(String name) {
- addChild(new Child(this, name));
- }
-
- /* can only have one child */
- public Child child() {
- return (children.isEmpty()) ? null : (Child) children.get(0);
- }
- }
-
-
- static class Child extends TreeNode
- {
- public Child(TreeNode parent, String name) {
- super(parent, name);
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/AbstractComboModelAdapterTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/AbstractComboModelAdapterTest.java
deleted file mode 100644
index 56940203ea..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/AbstractComboModelAdapterTest.java
+++ /dev/null
@@ -1,777 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.swt;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.ui.internal.swt.AbstractComboModelAdapter;
-import org.eclipse.jpt.common.ui.internal.swt.AbstractComboModelAdapter.SelectionChangeEvent;
-import org.eclipse.jpt.common.ui.internal.swt.AbstractComboModelAdapter.SelectionChangeListener;
-import org.eclipse.jpt.common.utility.internal.StringConverter;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.swing.SimpleDisplayable;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public abstract class AbstractComboModelAdapterTest {
-
- private Model model;
- private ModifiablePropertyValueModel<SimpleDisplayable> selectedItemHolder;
- private Shell shell;
- private ModifiablePropertyValueModel<Model> subjectHolder;
-
- protected abstract AbstractComboModelAdapter<SimpleDisplayable> buildEditableComboModelAdapter();
-
- protected final ListValueModel<SimpleDisplayable> buildEmptyListHolder() {
- return new SimpleListValueModel<SimpleDisplayable>();
- }
-
- private List<SimpleDisplayable> buildList() {
- List<SimpleDisplayable> list = new ArrayList<SimpleDisplayable>();
- populateCollection(list);
- return list;
- }
-
- protected final ListValueModel<SimpleDisplayable> buildListHolder() {
- return new ListAspectAdapter<Model, SimpleDisplayable>(subjectHolder, Model.ITEMS_LIST) {
- @Override
- protected ListIterator<SimpleDisplayable> listIterator_() {
- return subject.items();
- }
-
- @Override
- protected int size_() {
- return subject.itemsSize();
- }
- };
- }
-
- protected abstract AbstractComboModelAdapter<SimpleDisplayable> buildReadOnlyComboModelAdapter();
-
- private SimpleDisplayable buildSelectedItem() {
- return new SimpleDisplayable("baz");
- }
-
- private ModifiablePropertyValueModel<SimpleDisplayable> buildSelectedItemHolder() {
- return new PropertyAspectAdapter<Model, SimpleDisplayable>(subjectHolder, Model.ITEM_PROPERTY) {
- @Override
- protected SimpleDisplayable buildValue_() {
- return subject.getItem();
- }
-
- @Override
- protected void setValue_(SimpleDisplayable value) {
- subject.setItem(value);
- }
- };
- }
-
- protected final StringConverter<SimpleDisplayable> buildStringConverter() {
- return new StringConverter<SimpleDisplayable>() {
- public String convertToString(SimpleDisplayable value) {
- return (value == null) ? "" : value.displayString();
- }
- };
- }
-
- private ModifiablePropertyValueModel<Model> buildSubjectHolder() {
- return new SimplePropertyValueModel<Model>();
- }
-
- public abstract String comboSelectedItem();
-
- protected abstract boolean emptyComboCanHaveSelectedValue();
-
- protected abstract String itemAt(int index);
-
- protected abstract int itemCounts();
-
- private void populateCollection(Collection<SimpleDisplayable> c) {
- c.add(new SimpleDisplayable("foo"));
- c.add(new SimpleDisplayable("bar"));
- c.add(new SimpleDisplayable("baz"));
- c.add(new SimpleDisplayable("joo"));
- c.add(new SimpleDisplayable("jar"));
- c.add(new SimpleDisplayable("jaz"));
- }
-
- protected final ModifiablePropertyValueModel<SimpleDisplayable> selectedItemHolder() {
- return selectedItemHolder;
- }
-
- @Before
- public void setUp() throws Exception {
-
- shell = new Shell(Display.getCurrent());
- model = new Model();
- subjectHolder = buildSubjectHolder();
- selectedItemHolder = buildSelectedItemHolder();
- }
-
- protected final Shell shell() {
- return shell;
- }
-
- protected final ModifiablePropertyValueModel<Model> subjectHolder() {
- return subjectHolder;
- }
-
- @After
- public void tearDown() throws Exception {
-
- if (!shell.isDisposed()) {
- shell.dispose();
- }
-
- shell = null;
- subjectHolder = null;
- selectedItemHolder = null;
- }
-
- private void testItems() {
-
- assertEquals(
- "The count of items is not in sync with the model",
- model.itemsSize(),
- itemCounts()
- );
-
- for (int index = 0; index < model.itemsSize(); index++) {
- assertEquals(
- "The item at index " + index + " is not the same between the model and the combo",
- model.itemAt(index).displayString(),
- itemAt(index)
- );
- }
- }
-
- @Test
- public void testNonNullSubjectAfter_AddedAfter_ReadOnly() throws Exception {
-
- buildReadOnlyComboModelAdapter();
- testRemoveItems_AddedAfter();
- }
-
- @Test
- public void testNonNullSubjectAfter_AddedAfter_RemoveItems_Editable() throws Exception {
-
- buildEditableComboModelAdapter();
- testRemoveItems_AddedAfter();
- }
-
- @Test
- public void testNonNullSubjectAfter_AddedBefore_RemoveItems_Editable() throws Exception {
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- buildEditableComboModelAdapter();
- testSelectedItem(null);
- testItems();
-
- ArrayList<SimpleDisplayable> items = new ArrayList<SimpleDisplayable>();
- items.add(model.itemAt(0));
- items.add(model.itemAt(3));
- model.removeItems(items.iterator());
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_AddedBefore_RemoveItems_ReadOnly() throws Exception {
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- buildReadOnlyComboModelAdapter();
- testSelectedItem(null);
- testItems();
-
- ArrayList<SimpleDisplayable> items = new ArrayList<SimpleDisplayable>();
- items.add(model.itemAt(0));
- items.add(model.itemAt(3));
- model.removeItems(items.iterator());
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsAfterAfter_Editable() throws Exception {
-
- buildEditableComboModelAdapter();
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsAfterAfter_ReadOnly() throws Exception {
-
- buildReadOnlyComboModelAdapter();
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsAfterBefore_Editable() throws Exception {
-
- buildEditableComboModelAdapter();
-
- model.addItems(buildList());
- subjectHolder.setValue(model);
-
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsAfterBefore_ReadOnly() throws Exception {
-
- buildReadOnlyComboModelAdapter();
-
- model.addItems(buildList());
- subjectHolder.setValue(model);
-
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsBefore_Editable() throws Exception {
-
- model.addItems(buildList());
- buildEditableComboModelAdapter();
-
- subjectHolder.setValue(model);
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_ItemsBefore_ReadOnly() throws Exception {
-
- model.addItems(buildList());
- buildReadOnlyComboModelAdapter();
-
- subjectHolder.setValue(model);
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_NoItems_Editable() throws Exception {
-
- buildEditableComboModelAdapter();
-
- subjectHolder.setValue(model);
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_NullSelectedItem_NoItems_ReadOnly() throws Exception {
-
- buildReadOnlyComboModelAdapter();
-
- subjectHolder.setValue(model);
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectAfter_SelectedItemChanged_ReadOnly() throws Exception {
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- SimpleDisplayable selectedItem = model.itemAt(0);
-
- AbstractComboModelAdapter<SimpleDisplayable> adapter = buildEditableComboModelAdapter();
- SelectionListener selectionListener = new SelectionListener();
- adapter.addSelectionChangeListener(selectionListener);
-
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
- testSelectedItem(null);
-
- testSelectedItemChanged(selectedItem, selectionListener);
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemAfter_Editable() throws Exception {
-
- SimpleDisplayable selectedItem = buildSelectedItem();
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemAfter_Items_Editable() throws Exception {
-
- SimpleDisplayable selectedItem = buildSelectedItem();
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemAfter_Items_ReadOnly() throws Exception {
-
- List<SimpleDisplayable> list = buildList();
- SimpleDisplayable selectedItem = list.get(0);
- subjectHolder.setValue(model);
-
- buildReadOnlyComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemAfter_ReadOnly() throws Exception {
-
- List<SimpleDisplayable> list = buildList();
- SimpleDisplayable selectedItem = list.get(0);
- subjectHolder.setValue(model);
-
- buildReadOnlyComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemBefore_Editable() throws Exception {
-
- model.addItems(buildList());
- SimpleDisplayable selectedItem = model.itemAt(0);
- subjectHolder.setValue(model);
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- model.clearItemCalledFlag();
- buildEditableComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemBefore_Items_Editable() throws Exception {
-
- model.addItems(buildList());
- SimpleDisplayable selectedItem = model.itemAt(0);
- subjectHolder.setValue(model);
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- model.clearItemCalledFlag();
- buildEditableComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemBefore_Items_ReadOnly() throws Exception {
-
- List<SimpleDisplayable> list = buildList();
- SimpleDisplayable selectedItem = list.get(0);
- subjectHolder.setValue(model);
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- model.clearItemCalledFlag();
- buildReadOnlyComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NonNullSelectedItemBefore_ReadOnly() throws Exception {
-
- List<SimpleDisplayable> list = buildList();
- SimpleDisplayable selectedItem = list.get(0);
- subjectHolder.setValue(model);
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
-
- model.clearItemCalledFlag();
- buildReadOnlyComboModelAdapter();
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
-
- testSelectedItem(selectedItem);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NullSelectedItem_Items_Editable() throws Exception {
-
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
-
- assertFalse("The item wasn't supposed to be modified", model.isSetItemCalled());
- assertNull("The selected item is supposed to remain null", model.getItem());
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NullSelectedItem_Items_ReadOnly() throws Exception {
-
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
-
- assertFalse("The item wasn't supposed to be modified", model.isSetItemCalled());
- assertNull("The selected item is supposed to remain null", model.getItem());
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NullSelectedItem_NoItems_Editable() throws Exception {
-
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
-
- assertFalse("The item wasn't supposed to be modified", model.isSetItemCalled());
- assertNull("The selected item is supposed to remain null", model.getItem());
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_NullSelectedItem_NoItems_ReadOnly() throws Exception {
-
- subjectHolder.setValue(model);
-
- buildEditableComboModelAdapter();
-
- assertFalse("The item wasn't supposed to be modified", model.isSetItemCalled());
- assertNull("The selected item is supposed to remain null", model.getItem());
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNonNullSubjectBefore_SelectedItemChanged_Editable() throws Exception {
-
- model.addItems(buildList());
-
- SimpleDisplayable selectedItem = model.itemAt(3);
- subjectHolder.setValue(model);
-
- AbstractComboModelAdapter<SimpleDisplayable> adapter = buildEditableComboModelAdapter();
- SelectionListener selectionListener = new SelectionListener();
- adapter.addSelectionChangeListener(selectionListener);
-
- assertFalse("The selected item wasn't supposed to be modified", model.isSetItemCalled());
- testSelectedItem(null);
-
- testSelectedItemChanged(selectedItem, selectionListener);
- }
-
- private void testNullSubject() throws Exception {
-
- assertNull("The selected item should be null", selectedItemHolder.getValue());
-
- selectedItemHolder.setValue(buildSelectedItem());
- assertFalse("The item wasn't supposed to be modified", model.isSetItemCalled());
-
- // Null because the subject holder doesn't have the subject set
- testSelectedItem(null);
- testItems();
- }
-
- @Test
- public void testNullSubject_NullSelectedItem_Items_Editable() throws Exception {
- buildEditableComboModelAdapter();
- testNullSubject();
- testItems();
- testSelectedItem(null);
- }
-
- @Test
- public void testNullSubject_NullSelectedItem_Items_ReadOnly() throws Exception {
- buildReadOnlyComboModelAdapter();
- testNullSubject();
- testItems();
- testSelectedItem(null);
- }
-
- @Test
- public void testNullSubject_NullSelectedItem_NoItems_Editable() throws Exception {
- buildEditableComboModelAdapter();
- testNullSubject();
- testItems();
- testSelectedItem(null);
- }
-
- @Test
- public void testNullSubject_NullSelectedItem_NoItems_ReadOnly() throws Exception {
- buildReadOnlyComboModelAdapter();
- testNullSubject();
- testItems();
- testSelectedItem(null);
- }
-
- private void testRemoveItems_AddedAfter() {
-
- subjectHolder.setValue(model);
- model.addItems(buildList());
-
- testSelectedItem(null);
- testItems();
- testSelectedItem(null);
-
- ArrayList<SimpleDisplayable> items = new ArrayList<SimpleDisplayable>();
- items.add(model.itemAt(0));
- items.add(model.itemAt(3));
- model.removeItems(items.iterator());
-
- testItems();
- testSelectedItem(null);
- }
-
- private void testSelectedItem(SimpleDisplayable selectedItem) {
-
- if (selectedItem == null) {
-
- assertNull(
- "The selected item is supposed to be null",
- model.getItem()
- );
-
- assertEquals(
- "The combo's selected item should be null",
- "",
- comboSelectedItem()
- );
- }
- else if (!emptyComboCanHaveSelectedValue()) {
-
- assertEquals(
- "The selected item wasn't set correctly",
- selectedItem,
- model.getItem()
- );
-
- assertEquals(
- "The combo's selected item should be null",
- "",
- comboSelectedItem()
- );
- }
- else {
-
- assertEquals(
- "The selected item wasn't set correctly",
- selectedItem,
- model.getItem()
- );
-
- assertEquals(
- "The selected item wasn't set correctly",
- selectedItem.displayString(),
- comboSelectedItem()
- );
- }
- }
-
- private void testSelectedItemChanged(SimpleDisplayable selectedItem,
- SelectionListener selectionListener) {
-
- // Test 1
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
- assertTrue("The SelectionListener was supposed to be notified", selectionListener.isListenerNotified());
- assertSame("The SelectionListener was supposed to be notified", selectedItem, selectionListener.getItem());
- testSelectedItem(selectedItem);
-
- // Test 2
- selectedItem = model.itemAt(1);
- model.clearItemCalledFlag();
- selectionListener.clearInfo();
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
- assertTrue("The SelectionListener was supposed to be notified", selectionListener.isListenerNotified());
- assertSame("The SelectionListener was supposed to be notified", selectedItem, selectionListener.getItem());
- testSelectedItem(selectedItem);
-
- // Test 3
- selectedItem = null;
- model.clearItemCalledFlag();
- selectionListener.clearInfo();
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertNull("The selected item wasn't set properly", model.getItem());
- assertTrue("The SelectionListener was supposed to be notified", selectionListener.isListenerNotified());
- assertSame("The SelectionListener was supposed to be notified", selectedItem, selectionListener.getItem());
- testSelectedItem(selectedItem);
-
- // Test 3
- selectedItem = model.itemAt(2);
- model.clearItemCalledFlag();
- selectionListener.clearInfo();
-
- model.setItem(selectedItem);
- assertTrue("The selected item was supposed to be modified", model.isSetItemCalled());
- assertSame("The selected item wasn't set properly", selectedItem, model.getItem());
- assertTrue("The SelectionListener was supposed to be notified", selectionListener.isListenerNotified());
- assertSame("The SelectionListener was supposed to be notified", selectedItem, selectionListener.getItem());
- testSelectedItem(selectedItem);
- }
-
- private static class Model extends AbstractModel {
-
- private SimpleDisplayable item;
- private List<SimpleDisplayable> items = new ArrayList<SimpleDisplayable>();
- private boolean setItemCalled;
-
- static final String ITEM_PROPERTY = "item";
- static final String ITEMS_LIST = "items";
-
- void addItems(Iterator<SimpleDisplayable> items) {
- addItemsToList(items, this.items, ITEMS_LIST);
- }
-
- void addItems(List<SimpleDisplayable> items) {
- addItemsToList(items, this.items, ITEMS_LIST);
- }
-
- void clearItemCalledFlag() {
- setItemCalled = false;
- }
-
- SimpleDisplayable getItem() {
- return item;
- }
-
- boolean isSetItemCalled() {
- return setItemCalled;
- }
-
- SimpleDisplayable itemAt(int index) {
- return this.items.get(index);
- }
-
- ListIterator<SimpleDisplayable> items() {
- return items.listIterator();
- }
-
- int itemsSize() {
- return items.size();
- }
-
- void removeItems(Iterator<SimpleDisplayable> items) {
- removeItemsFromList(items, this.items, ITEMS_LIST);
- }
-
- void setItem(SimpleDisplayable item) {
- setItemCalled = true;
-
- SimpleDisplayable oldItem = this.item;
- this.item = item;
- firePropertyChanged(ITEM_PROPERTY, oldItem, item);
- }
- }
-
- private class SelectionListener implements SelectionChangeListener<SimpleDisplayable> {
-
- private SimpleDisplayable item;
- private boolean listenerNotified;
-
- void clearInfo() {
- this.listenerNotified = false;
- this.item = null;
- }
-
- SimpleDisplayable getItem() {
- return item;
- }
-
- public boolean isListenerNotified() {
- return listenerNotified;
- }
-
- public void selectionChanged(SelectionChangeEvent<SimpleDisplayable> e) {
- listenerNotified = true;
- item = e.selectedItem();
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/ComboModelAdapterTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/ComboModelAdapterTest.java
deleted file mode 100644
index f2379318d9..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/ComboModelAdapterTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.swt;
-
-import org.eclipse.jpt.common.ui.internal.swt.AbstractComboModelAdapter;
-import org.eclipse.jpt.common.ui.internal.swt.ComboModelAdapter;
-import org.eclipse.jpt.common.utility.internal.swing.SimpleDisplayable;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Combo;
-import org.junit.After;
-
-public class ComboModelAdapterTest extends AbstractComboModelAdapterTest {
-
- private Combo combo;
- private boolean editable;
-
- @Override
- protected AbstractComboModelAdapter<SimpleDisplayable> buildEditableComboModelAdapter() {
-
- combo = new Combo(shell(), SWT.NULL);
- editable = true;
-
- return ComboModelAdapter.adapt(
- buildListHolder(),
- selectedItemHolder(),
- combo,
- buildStringConverter()
- );
- }
-
- @Override
- protected AbstractComboModelAdapter<SimpleDisplayable> buildReadOnlyComboModelAdapter() {
-
- combo = new Combo(shell(), SWT.READ_ONLY);
- editable = false;
-
- return ComboModelAdapter.adapt(
- buildListHolder(),
- selectedItemHolder(),
- combo,
- buildStringConverter()
- );
- }
-
- @Override
- public String comboSelectedItem() {
- return combo.getText();
- }
-
- @Override
- protected boolean emptyComboCanHaveSelectedValue() {
- return editable;
- }
-
- @Override
- protected String itemAt(int index) {
- return this.combo.getItem(index);
- }
-
- @Override
- protected int itemCounts() {
- return combo.getItemCount();
- }
-
- @After
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- combo = null;
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/JptUiSWTTests.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/JptUiSWTTests.java
deleted file mode 100644
index fb7f5d3d61..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/JptUiSWTTests.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.swt;
-
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@SuiteClasses
-({
- ComboModelAdapterTest.class,
- SpinnerModelAdapterTest.class,
- TableModelAdapterTest.class
-})
-@RunWith(Suite.class)
-public final class JptUiSWTTests {
-
- private JptUiSWTTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(JptUiSWTTests.class));
- return suite;
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/SpinnerModelAdapterTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/SpinnerModelAdapterTest.java
deleted file mode 100644
index 205d5bb425..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/SpinnerModelAdapterTest.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.swt;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import org.eclipse.jpt.common.ui.internal.swt.SpinnerModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Spinner;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public class SpinnerModelAdapterTest {
-
- private Model model;
- private Shell shell;
- private ModifiablePropertyValueModel<Model> subjectHolder;
-
- private ModifiablePropertyValueModel<Model> buildSubjectHolder() {
- return new SimplePropertyValueModel<Model>();
- }
-
- private ModifiablePropertyValueModel<Integer> buildValueHolder() {
- return new PropertyAspectAdapter<Model, Integer>(subjectHolder, Model.VALUE_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return subject.getValue();
- }
-
- @Override
- protected void setValue_(Integer value) {
- subject.setValue(value);
- }
- };
- }
-
- @Before
- public void setUp() throws Exception {
-
- shell = new Shell(Display.getCurrent());
- model = new Model();
- subjectHolder = buildSubjectHolder();
- }
-
- @After
- public void tearDown() throws Exception {
-
- if (!shell.isDisposed()) {
- shell.dispose();
- }
-
- shell = null;
- subjectHolder = null;
- }
-
- @Test
- public void testDisposed() {
-
- int value = 2;
- model.setValue(value);
- model.clearSetValueCalledFlag();
- subjectHolder.setValue(model);
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- ModifiablePropertyValueModel<Integer> numberHolder = buildValueHolder();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be coming from the model",
- value,
- spinner.getSelection()
- );
-
- assertEquals(
- "The number holder's value should be the model's value",
- model.getValue(),
- numberHolder.getValue()
- );
-
- assertFalse(
- "The model should not have received the value during initialization",
- model.isSetValueCalled()
- );
-
- // Change the value in the model
- spinner.dispose();
-
- value = 4;
- model.setValue(value);
-
- assertEquals(
- "The model's value was somehow changed",
- Integer.valueOf(value),
- model.getValue()
- );
- }
-
- @Test
- public void testInitialization_1() {
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- ModifiablePropertyValueModel<Integer> numberHolder = new SimplePropertyValueModel<Integer>();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be the default value",
- defaultValue,
- spinner.getSelection()
- );
-
- assertNull(
- "The number holder's value should be null",
- numberHolder.getValue()
- );
- }
-
- @Test
- public void testInitialization_2() {
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- ModifiablePropertyValueModel<Integer> numberHolder = buildValueHolder();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be the default value",
- defaultValue,
- spinner.getSelection()
- );
-
- assertNull(
- "The number holder's value should be null",
- numberHolder.getValue()
- );
- }
-
- @Test
- public void testInitialization_3() {
-
- subjectHolder.setValue(model);
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- ModifiablePropertyValueModel<Integer> numberHolder = buildValueHolder();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be the default value",
- defaultValue,
- spinner.getSelection()
- );
-
- assertNull(
- "The number holder's value should be null",
- numberHolder.getValue()
- );
-
- assertFalse(
- "The model should not have received the value during initialization",
- model.isSetValueCalled()
- );
- }
-
- @Test
- public void testInitialization_4() {
-
- int value = 2;
- model.setValue(value);
- model.clearSetValueCalledFlag();
- subjectHolder.setValue(model);
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- ModifiablePropertyValueModel<Integer> numberHolder = buildValueHolder();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be the value coming from the model",
- value,
- spinner.getSelection()
- );
-
- assertEquals(
- "The number holder's value should be " + value,
- Integer.valueOf(value),
- numberHolder.getValue()
- );
-
- assertFalse(
- "The model should not have received the value during initialization",
- model.isSetValueCalled()
- );
- }
-
- @Test
- public void testValueChanged() {
-
- int value = 2;
- model.setValue(value);
- model.clearSetValueCalledFlag();
- subjectHolder.setValue(model);
-
- Spinner spinner = new Spinner(shell, SWT.NULL);
- ModifiablePropertyValueModel<Integer> numberHolder = buildValueHolder();
- int defaultValue = 1;
-
- SpinnerModelAdapter.adapt(
- numberHolder,
- spinner,
- defaultValue
- );
-
- assertEquals(
- "The spinner's value should be coming from the model",
- value,
- spinner.getSelection()
- );
-
- assertEquals(
- "The number holder's value should be the model's value",
- model.getValue(),
- numberHolder.getValue()
- );
-
- assertFalse(
- "The model should not have received the value during initialization",
- model.isSetValueCalled()
- );
-
- // Change the value in the model
- value = 4;
- model.setValue(value);
-
- assertEquals(
- "The spinner's value should be coming from the model",
- value,
- spinner.getSelection()
- );
-
- assertEquals(
- "The model's value was somehow changed",
- Integer.valueOf(value),
- model.getValue()
- );
-
- // Change the value from the spinner
- value = 6;
- spinner.setSelection(value);
-
- assertEquals(
- "The spinner's value should be the new value set",
- value,
- spinner.getSelection()
- );
-
- assertEquals(
- "The model's value was supposed to be updated",
- Integer.valueOf(value),
- model.getValue()
- );
-
- // Disconnect from model
- subjectHolder.setValue(null);
-
- assertEquals(
- "The spinner's value should be the default value",
- defaultValue,
- spinner.getSelection()
- );
- }
-
- private static class Model extends AbstractModel {
-
- private boolean setValueCalled;
- private Integer value;
-
- static final String VALUE_PROPERTY = "value";
-
- void clearSetValueCalledFlag() {
- setValueCalled = false;
- }
-
- Integer getValue() {
- return value;
- }
-
- boolean isSetValueCalled() {
- return setValueCalled;
- }
-
- void setValue(Integer value) {
- setValueCalled = true;
-
- Integer oldValue = this.value;
- this.value = value;
- firePropertyChanged(VALUE_PROPERTY, oldValue, value);
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/TableModelAdapterTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/TableModelAdapterTest.java
deleted file mode 100644
index 6e102a9948..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/TableModelAdapterTest.java
+++ /dev/null
@@ -1,1201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.swt;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jpt.common.ui.internal.swt.ColumnAdapter;
-import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter;
-import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter.SelectionChangeEvent;
-import org.eclipse.jpt.common.ui.internal.swt.TableModelAdapter.SelectionChangeListener;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyCollectionValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public class TableModelAdapterTest {
-
- private Shell shell;
- private ModifiablePropertyValueModel<Manager> subjectHolder;
-
- private ColumnAdapter<Employee> buildColumnAdapter() {
- return new TableColumnAdapter();
- }
-
- private ModifiablePropertyValueModel<Employee> buildEmployeeHolder() {
- return new SimplePropertyValueModel<Employee>();
- }
-
- private SimpleCollectionValueModel<Employee> buildEmployeeHolders() {
- return new SimpleCollectionValueModel<Employee>();
- }
-
- private ListValueModel<Employee> buildEmployeeListHolder() {
- return new ListAspectAdapter<Manager, Employee>(subjectHolder, Manager.EMPLOYEES_LIST) {
- @Override
- protected ListIterator<Employee> listIterator_() {
- return subject.employees();
- }
-
- @Override
- protected int size_() {
- return subject.employeesSize();
- }
- };
- }
-
- private ITableLabelProvider buildLabelProvider() {
- return new TableLabelProvider();
- }
-
- private SelectionChangeListener<Employee> buildSelectionChangeListener(final Collection<Employee> employees) {
- return new SelectionChangeListener<Employee>() {
- public void selectionChanged(SelectionChangeEvent<Employee> e) {
- employees.clear();
- CollectionTools.addAll(employees, e.selection());
- }
- };
- }
-
- private ModifiablePropertyValueModel<Manager> buildSubjectHolder() {
- return new SimplePropertyValueModel<Manager>();
- }
-
- @Before
- public void setUp() throws Exception {
-
- shell = new Shell(Display.getCurrent());
- subjectHolder = buildSubjectHolder();
- }
-
- @After
- public void tearDown() throws Exception {
-
- if (!shell.isDisposed()) {
- shell.dispose();
- }
-
- shell = null;
- subjectHolder = null;
- }
-
- @Test
- public void testChanged() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- ModifiablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Make sure the Table was populated
- Assert.assertEquals("The number of TableItems should be 3", 3, table.getItemCount());
-
- // Change the list of Employees
- ArrayList<Employee> employees = new ArrayList<Employee>(3);
- employees.add(employee3);
- employees.add(employee2);
- employees.add(employee1);
- manager.changeEmployees(employees);
-
- Assert.assertEquals("The number of TableItems should be 3", 3, table.getItemCount());
-
- testTableItemProperties(table, 0, expectedName3, expectedManager3, expectedTitle3);
- testTableItemProperties(table, 1, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, 2, expectedName1, expectedManager1, expectedTitle1);
- }
-
- @Test
- public void testCleared() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- ModifiablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Make sure the Table was populated
- Assert.assertEquals("The number of TableItems should be 3", 3, table.getItemCount());
-
- // Test removing them all
- manager.removeAllEmployees();
-
- Assert.assertEquals("The list holder should have been cleared", 0, listHolder.size());
- Assert.assertEquals("The Table should have been cleared", 0, table.getItemCount());
- }
-
- @Test
- public void testItemAdded() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- ModifiablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create a new Employee
- String expectedName = "Dali";
- String expectedManager = "WTP";
- String expectedTitle = "plug-in";
-
- Employee employee = manager.addEmployee(expectedName, expectedTitle, expectedManager);
- Assert.assertNotNull("The new Employee was not created", employee);
-
- // Retrieve the TableItem representing the new Employee
- int index = tableModel.indexOf(employee);
- Assert.assertEquals("The new Employee was not added to the table model", 0, index);
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
-
- testTableItemProperties(table, index, expectedName, expectedManager, expectedTitle);
- }
-
- @Test
- public void testItemMoved() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- ModifiablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Make sure the Employees were added to the Table
- Assert.assertEquals("The number of TableItem should be 3", 3, table.getItemCount());
-
- // Move an Employee up the list
- manager.moveEmployeeUp(employee2);
-
- int index1 = tableModel.indexOf(employee1);
- Assert.assertEquals("The Employee 1 was not moved in the table model", 1, index1);
-
- int index2 = tableModel.indexOf(employee2);
- Assert.assertEquals("The Employee 2 was not moved in the table model", 0, index2);
-
- int index3 = tableModel.indexOf(employee3);
- Assert.assertEquals("The Employee 3 should not have been moved in the table model", 2, index3);
-
- testTableItemProperties(table, index1, expectedName1, expectedManager1, expectedTitle1);
- testTableItemProperties(table, index2, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, index3, expectedName3, expectedManager3, expectedTitle3);
-
- // Move an Employee down the list
- manager.moveEmployeeDown(employee1);
-
- index1 = tableModel.indexOf(employee1);
- Assert.assertEquals("The Employee 1 should not have been moved in the table model", 2, index1);
-
- index2 = tableModel.indexOf(employee2);
- Assert.assertEquals("The Employee 2 was not moved in the table model", 0, index2);
-
- index3 = tableModel.indexOf(employee3);
- Assert.assertEquals("The Employee 3 was not moved in the table model", 1, index3);
-
- testTableItemProperties(table, index1, expectedName1, expectedManager1, expectedTitle1);
- testTableItemProperties(table, index2, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, index3, expectedName3, expectedManager3, expectedTitle3);
- }
-
- @Test
- public void testItemRemoved() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- ModifiablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create a new Employee
- String expectedName = "Dali";
- String expectedManager = "WTP";
- String expectedTitle = "plug-in";
-
- Employee employee = manager.addEmployee(expectedName, expectedTitle, expectedManager);
- Assert.assertNotNull("The new Employee was not created", employee);
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
-
- // Make sure it was added to the model
- int index = tableModel.indexOf(employee);
- Assert.assertEquals("The new Employee was not added to the table model", 0, index);
- testTableItemProperties(table, index, expectedName, expectedManager, expectedTitle);
-
- // Retrieve the TableItem representing the new Employee
- TableItem tableItem = table.getItem(index);
- Assert.assertNotNull("No TableItem was found for the new Employee", tableItem);
-
- // Now test the item being removed
- manager.removeEmployee(employee);
- index = tableModel.indexOf(employee);
- Assert.assertEquals("The Employee was not removed from the table model", -1, index);
- Assert.assertEquals("The number of TableItem should be 0", 0, table.getItemCount());
- }
-
- @Test
- public void testItemReplaced() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- ModifiablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create a new Employee
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- Employee employee1 = manager.addEmployee(expectedName1, expectedTitle1, expectedManager1);
- Assert.assertNotNull("The new Employee was not created", employee1);
-
- // Make sure it was added to the model
- int index1 = tableModel.indexOf(employee1);
- Assert.assertEquals("The new Employee was not added to the table model", 0, index1);
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
-
- // Retrieve the TableItem representing the new Employee
- TableItem tableItem = table.getItem(index1);
- Assert.assertNotNull("No TableItem was found for the new Employee", tableItem);
-
- testTableItemProperties(table, index1, expectedName1, expectedManager1, expectedTitle1);
-
- // Replace the Employee
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- manager.replace(employee1, employee2);
-
- int index2 = tableModel.indexOf(employee2);
- Assert.assertSame("The Employee that got replaced should be at index " + index1, index1, index2);
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
-
- testTableItemProperties(table, index2, expectedName2, expectedManager2, expectedTitle2);
- }
-
- @Test
- public void testItemsAdded() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- ModifiablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Retrieve the TableItems representing the employees
- Assert.assertEquals("The number of TableItem should be 3", 3, table.getItemCount());
-
- int index = tableModel.indexOf(employee1);
- Assert.assertEquals("The Employee 1 was not added to the table model", 0, index);
-
- index = tableModel.indexOf(employee2);
- Assert.assertEquals("The Employee 2 was not added to the table model", 1, index);
-
- index = tableModel.indexOf(employee3);
- Assert.assertEquals("The Employee 3 was not added to the table model", 2, index);
-
- // Make sure the TableItem was correctly populated
- testTableItemProperties(table, 0, expectedName1, expectedManager1, expectedTitle1);
- testTableItemProperties(table, 1, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, 2, expectedName3, expectedManager3, expectedTitle3);
- }
-
- @Test
- public void testItemsMoved() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- ModifiablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- String expectedName4 = "Dali_4";
- String expectedManager4 = "WTP_4";
- String expectedTitle4 = "plug-in_4";
-
- String expectedName5 = "Dali_5";
- String expectedManager5 = "WTP_5";
- String expectedTitle5 = "plug-in_5";
-
- String expectedName6 = "Dali_6";
- String expectedManager6 = "WTP_6";
- String expectedTitle6 = "plug-in_6";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
- Employee employee4 = new Employee(expectedName4, expectedTitle4, expectedManager4);
- Employee employee5 = new Employee(expectedName5, expectedTitle5, expectedManager5);
- Employee employee6 = new Employee(expectedName6, expectedTitle6, expectedManager6);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
- manager.addEmployee(employee4);
- manager.addEmployee(employee5);
- manager.addEmployee(employee6);
-
- // Make sure the Employees were added to the Table
- Assert.assertEquals("The number of TableItem should be 6", 6, table.getItemCount());
-
- // Move an Employee up the list
- ArrayList<Employee> employees = new ArrayList<Employee>(3);
- employees.add(employee3);
- employees.add(employee4);
- employees.add(employee5);
- manager.moveEmployees(employees, 0);
-
- int index1 = tableModel.indexOf(employee1);
- int index2 = tableModel.indexOf(employee2);
- int index3 = tableModel.indexOf(employee3);
- int index4 = tableModel.indexOf(employee4);
- int index5 = tableModel.indexOf(employee5);
- int index6 = tableModel.indexOf(employee6);
-
- Assert.assertEquals("The Employee 1 is not at the right index", 3, index1);
- Assert.assertEquals("The Employee 2 is not at the right index", 4, index2);
- Assert.assertEquals("The Employee 3 is not at the right index", 0, index3);
- Assert.assertEquals("The Employee 4 is not at the right index", 1, index4);
- Assert.assertEquals("The Employee 5 is not at the right index", 2, index5);
- Assert.assertEquals("The Employee 6 is not at the right index", 5, index6);
-
- testTableItemProperties(table, index1, expectedName1, expectedManager1, expectedTitle1);
- testTableItemProperties(table, index2, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, index3, expectedName3, expectedManager3, expectedTitle3);
- testTableItemProperties(table, index4, expectedName4, expectedManager4, expectedTitle4);
- testTableItemProperties(table, index5, expectedName5, expectedManager5, expectedTitle5);
- testTableItemProperties(table, index6, expectedName6, expectedManager6, expectedTitle6);
-
- // Move an Employee down the list
- employees = new ArrayList<Employee>(2);
- employees.add(employee1);
- employees.add(employee2);
- manager.moveEmployees(employees, 4);
-
- index1 = tableModel.indexOf(employee1);
- index2 = tableModel.indexOf(employee2);
- index3 = tableModel.indexOf(employee3);
- index4 = tableModel.indexOf(employee4);
- index5 = tableModel.indexOf(employee5);
- index6 = tableModel.indexOf(employee6);
-
- Assert.assertEquals("The Employee 1 is not at the right index", 4, index1);
- Assert.assertEquals("The Employee 2 is not at the right index", 5, index2);
- Assert.assertEquals("The Employee 3 is not at the right index", 0, index3);
- Assert.assertEquals("The Employee 4 is not at the right index", 1, index4);
- Assert.assertEquals("The Employee 5 is not at the right index", 2, index5);
- Assert.assertEquals("The Employee 6 is not at the right index", 3, index6);
-
- testTableItemProperties(table, index1, expectedName1, expectedManager1, expectedTitle1);
- testTableItemProperties(table, index2, expectedName2, expectedManager2, expectedTitle2);
- testTableItemProperties(table, index3, expectedName3, expectedManager3, expectedTitle3);
- testTableItemProperties(table, index4, expectedName4, expectedManager4, expectedTitle4);
- testTableItemProperties(table, index5, expectedName5, expectedManager5, expectedTitle5);
- testTableItemProperties(table, index6, expectedName6, expectedManager6, expectedTitle6);
- }
-
- @Test
- public void testItemsRemoved() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- ModifiablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Retrieve the TableItems representing the employees
- Assert.assertEquals("The number of TableItem should be 3", 3, table.getItemCount());
-
- int index = tableModel.indexOf(employee1);
- Assert.assertEquals("The Employee 1 was not added to the table model", 0, index);
-
- index = tableModel.indexOf(employee2);
- Assert.assertEquals("The Employee 2 was not added to the table model", 1, index);
-
- index = tableModel.indexOf(employee3);
- Assert.assertEquals("The Employee 3 was not added to the table model", 2, index);
-
- // Remove 2 items
- ArrayList<Employee> employees = new ArrayList<Employee>(2);
- employees.add(employee1);
- employees.add(employee3);
- manager.removeEmployees(employees);
-
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
- }
-
- @Test
- public void testPropertyChanged() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- ModifiablePropertyValueModel<Employee> selectedItemHolder = buildEmployeeHolder();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create a new Employee
- String expectedName = "Dali";
- String expectedManager = "WTP";
- String expectedTitle = "plug-in";
-
- Employee employee = manager.addEmployee(expectedName, expectedTitle, expectedManager);
- Assert.assertNotNull("The new Employee was not created", employee);
-
- // Make sure it was added to the model
- int index = tableModel.indexOf(employee);
- Assert.assertEquals("The new Employee was not added to the table model", 0, index);
- Assert.assertEquals("The number of TableItem should be 1", 1, table.getItemCount());
-
- // Retrieve the TableItem representing the new Employee
- TableItem tableItem = table.getItem(index);
- Assert.assertNotNull("No TableItem was found for the new Employee", tableItem);
-
- // Name property
- String actualName = tableItem.getText(TableColumnAdapter.NAME_COLUMN);
- Assert.assertEquals("TableItem[NAME_COLUMN] was not set correctly", expectedName, actualName);
-
- expectedName = "Jpt";
- employee.setName(expectedName);
-
- actualName = tableItem.getText(TableColumnAdapter.NAME_COLUMN);
- Assert.assertEquals("TableItem[NAME_COLUMN] was not set correctly", expectedName, actualName);
-
- // Manager property
- String actualManager = tableItem.getText(TableColumnAdapter.MANAGER_COLUMN);
- Assert.assertEquals("TableItem[MANAGER_COLUMN] was not set correctly", expectedManager, actualManager);
-
- expectedManager = "boss";
- employee.setManager(expectedManager);
-
- actualManager = tableItem.getText(TableColumnAdapter.MANAGER_COLUMN);
- Assert.assertEquals("TableItem[MANAGER_COLUMN] was not set correctly", expectedManager, actualManager);
-
- // Title property
- String actualTitle = tableItem.getText(TableColumnAdapter.TITLE_COLUMN);
- Assert.assertEquals("TableItem[TITLE_COLUMN] was not set correctly", expectedTitle, actualTitle);
-
- expectedTitle = "EclipseLink";
- employee.setTitle(expectedTitle);
-
- actualTitle = tableItem.getText(TableColumnAdapter.TITLE_COLUMN);
- Assert.assertEquals("TableItem[TITLE_COLUMN] was not set correctly", expectedTitle, actualTitle);
- }
-
- @Test
- public void testSelectedItemsAddedRemoved() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- SimpleCollectionValueModel<Employee> selectedItemsHolder = buildEmployeeHolders();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemsHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Test adding selected items
- ArrayList<Employee> employees = new ArrayList<Employee>(2);
- employees.add(employee1);
- employees.add(employee3);
- selectedItemsHolder.addAll(employees);
-
- Collection<Employee> actualEmployees = tableModel.selectedItems();
- Assert.assertNotNull("The collection of selected items can't be null", actualEmployees);
- Assert.assertEquals("The count of selected items should be 2", 2, actualEmployees.size());
-
- actualEmployees.remove(employee1);
- actualEmployees.remove(employee3);
-
- Assert.assertTrue("The selected items was not retrieved correctly", actualEmployees.isEmpty());
-
- // Test removing selected items
- selectedItemsHolder.remove(employee1);
-
- actualEmployees = tableModel.selectedItems();
- Assert.assertNotNull("The collection of selected items can't be null", actualEmployees);
- Assert.assertEquals("The count of selected items should be 1", 1, actualEmployees.size());
-
- actualEmployees.remove(employee3);
-
- Assert.assertTrue("The selected items was not retrieved correctly", actualEmployees.isEmpty());
- }
-
- @Test
- public void testSelectedItemsCleared() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- ListValueModel<Employee> listHolder = buildEmployeeListHolder();
- SimpleCollectionValueModel<Employee> selectedItemsHolder = buildEmployeeHolders();
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- listHolder,
- selectedItemsHolder,
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Test adding selected items
- ArrayList<Employee> employees = new ArrayList<Employee>(2);
- employees.add(employee1);
- employees.add(employee3);
- selectedItemsHolder.addAll(employees);
-
- Collection<Employee> actualEmployees = tableModel.selectedItems();
- Assert.assertNotNull("The collection of selected items can't be null", actualEmployees);
- Assert.assertEquals("The count of selected items should be 2", 2, actualEmployees.size());
-
- actualEmployees.remove(employee1);
- actualEmployees.remove(employee3);
- Assert.assertTrue("The selected items was not retrieved correctly", actualEmployees.isEmpty());
-
- // Test removing selected items
- selectedItemsHolder.clear();
-
- actualEmployees = tableModel.selectedItems();
- Assert.assertNotNull("The collection of selected items can't be null", actualEmployees);
- Assert.assertEquals("The count of selected items should be ", 0, actualEmployees.size());
- }
-
- @Test
- public void testSelectionChangeListener() {
-
- Table table = new Table(shell, SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.MULTI);
-
- Manager manager = new Manager();
- subjectHolder.setValue(manager);
-
- TableModel tableModel = new TableModel(
- buildEmployeeListHolder(),
- buildEmployeeHolder(),
- table,
- buildColumnAdapter(),
- buildLabelProvider()
- );
-
- Collection<Employee> employees = new ArrayList<Employee>();
- tableModel.addSelectionChangeListener(buildSelectionChangeListener(employees));
-
- // Create Employees
- String expectedName1 = "Dali_1";
- String expectedManager1 = "WTP_1";
- String expectedTitle1 = "plug-in_1";
-
- String expectedName2 = "Dali_2";
- String expectedManager2 = "WTP_2";
- String expectedTitle2 = "plug-in_2";
-
- String expectedName3 = "Dali_3";
- String expectedManager3 = "WTP_3";
- String expectedTitle3 = "plug-in_3";
-
- Employee employee1 = new Employee(expectedName1, expectedTitle1, expectedManager1);
- Employee employee2 = new Employee(expectedName2, expectedTitle2, expectedManager2);
- Employee employee3 = new Employee(expectedName3, expectedTitle3, expectedManager3);
-
- manager.addEmployee(employee1);
- manager.addEmployee(employee2);
- manager.addEmployee(employee3);
-
- // Test adding selected items
- table.setSelection(new int[] { 0, 2 });
-
- // It seems a manual selection doesn't send any selection event
- tableModel.tableSelectionChanged(null);
-
- Assert.assertNotNull("The collection of selected items can't be null", employees);
- Assert.assertEquals("The count of selected items should be 2", 2, employees.size());
-
- employees.remove(employee1);
- employees.remove(employee3);
- Assert.assertTrue("The selected items was not retrieved correctly", employees.isEmpty());
-
- // Test adding selected items
- employees.add(employee1);
- employees.add(employee3);
- table.deselectAll();
-
- // It seems a manual selection doesn't send any selection event
- tableModel.tableSelectionChanged(null);
-
- Assert.assertNotNull("The collection of selected items can't be null", employees);
- Assert.assertEquals("The count of selected items should be 0", 0, employees.size());
- }
-
- private void testTableItemProperties(Table table,
- int index,
- String expectedName,
- String expectedManager,
- String expectedTitle)
- {
- TableItem tableItem = table.getItem(index);
- Assert.assertNotNull("No TableItem was found for the Employee", tableItem);
-
- String actualName = tableItem.getText(TableColumnAdapter.NAME_COLUMN);
- Assert.assertEquals("TableItem[NAME_COLUMN] was not set correctly", expectedName, actualName);
-
- String actualTitle = tableItem.getText(TableColumnAdapter.TITLE_COLUMN);
- Assert.assertEquals("TableItem[TITLE_COLUMN] was not set correctly", expectedTitle, actualTitle);
-
- String actualManager = tableItem.getText(TableColumnAdapter.MANAGER_COLUMN);
- Assert.assertEquals("TableItem[MANAGER_COLUMN] was not set correctly", expectedManager, actualManager);
- }
-
- private class Employee extends AbstractModel {
-
- private String manager;
- private String name;
- private String title;
-
- static final String MANAGER_PROPERTY = "manager";
- static final String NAME_PROPERTY = "name";
- static final String TITLE_PROPERTY = "title";
-
- Employee(String name, String title, String manager) {
- super();
-
- this.name = name;
- this.title = title;
- this.manager = manager;
- }
-
- String getManager() {
- return manager;
- }
-
- String getName() {
- return name;
- }
-
- String getTitle() {
- return title;
- }
-
- void setManager(String manager) {
- String oldManager = this.manager;
- this.manager = manager;
- firePropertyChanged(MANAGER_PROPERTY, oldManager, manager);
- }
-
- void setName(String name) {
- String oldName = this.name;
- this.name = name;
- firePropertyChanged(NAME_PROPERTY, oldName, name);
- }
-
- void setTitle(String title) {
- String oldTitle = this.title;
- this.title = title;
- firePropertyChanged(TITLE_PROPERTY, oldTitle, title);
- }
- }
-
- private class Manager extends AbstractModel {
-
- private List<Employee> employees;
-
- static final String EMPLOYEES_LIST = "employees";
-
- Manager() {
- super();
- employees = new ArrayList<Employee>();
- }
-
- Employee addEmployee(Employee employee) {
- addItemToList(employee, employees, EMPLOYEES_LIST);
- return employee;
- }
-
- Employee addEmployee(String name, String title, String manager) {
- Employee employee = new Employee(name, title, manager);
- return addEmployee(employee);
- }
-
- void changeEmployees(List<Employee> newEmployees) {
- this.synchronizeList(newEmployees, this.employees, EMPLOYEES_LIST);
- }
-
- ListIterator<Employee> employees() {
- return new CloneListIterator<Employee>(employees);
- }
-
- int employeesSize() {
- return employees.size();
- }
-
- void moveEmployeeDown(Employee employee) {
- int index = employees.indexOf(employee);
- moveItemInList(index + 1, index, employees, EMPLOYEES_LIST);
- }
-
- void moveEmployees(Collection<Employee> employees, int targetIndex) {
-
- int sourceIndex = Integer.MAX_VALUE;
-
- for (Employee employee : employees) {
- sourceIndex = Math.min(sourceIndex, this.employees.indexOf(employee));
- }
-
- moveItemsInList(
- targetIndex,
- sourceIndex,
- employees.size(),
- this.employees,
- EMPLOYEES_LIST
- );
- }
-
- void moveEmployeeUp(Employee employee) {
- int index = employees.indexOf(employee);
- moveItemInList(index - 1, index, employees, EMPLOYEES_LIST);
- }
-
- void removeAllEmployees() {
- clearList(employees, EMPLOYEES_LIST);
- }
-
- void removeEmployee(Employee employee) {
- removeItemFromList(employee, employees, EMPLOYEES_LIST);
- }
-
- void removeEmployees(Collection<Employee> employees) {
- removeItemsFromList(employees.iterator(), this.employees, EMPLOYEES_LIST);
- }
-
- void replace(Employee oldEmployee, Employee newEmployee) {
- replaceItemInList(oldEmployee, newEmployee, employees, EMPLOYEES_LIST);
- }
- }
-
- private class TableColumnAdapter implements ColumnAdapter<Employee> {
-
- static final int COLUMN_COUNT = 3;
- static final int MANAGER_COLUMN = 2;
- static final int NAME_COLUMN = 0;
- static final int TITLE_COLUMN = 1;
-
- private ModifiablePropertyValueModel<String> buildManagerHolder(Employee subject) {
- return new PropertyAspectAdapter<Employee, String>(Employee.MANAGER_PROPERTY, subject) {
- @Override
- protected String buildValue_() {
- return subject.getManager();
- }
-
- @Override
- protected void setValue_(String value) {
- subject.setManager(value);
- }
- };
- }
-
- private ModifiablePropertyValueModel<String> buildNameHolder(Employee subject) {
- return new PropertyAspectAdapter<Employee, String>(Employee.NAME_PROPERTY, subject) {
- @Override
- protected String buildValue_() {
- return subject.getName();
- }
-
- @Override
- protected void setValue_(String value) {
- subject.setName(value);
- }
- };
- }
-
- private ModifiablePropertyValueModel<String> buildTitleHolder(Employee subject) {
- return new PropertyAspectAdapter<Employee, String>(Employee.TITLE_PROPERTY, subject) {
- @Override
- protected String buildValue_() {
- return subject.getTitle();
- }
-
- @Override
- protected void setValue_(String value) {
- subject.setTitle(value);
- }
- };
- }
-
- public ModifiablePropertyValueModel<?>[] cellModels(Employee subject) {
- ModifiablePropertyValueModel<?>[] holders = new ModifiablePropertyValueModel<?>[3];
- holders[NAME_COLUMN] = buildNameHolder(subject);
- holders[TITLE_COLUMN] = buildTitleHolder(subject);
- holders[MANAGER_COLUMN] = buildManagerHolder(subject);
- return holders;
- }
-
- public int columnCount() {
- return COLUMN_COUNT;
- }
-
- public String columnName(int columnIndex) {
- return String.valueOf(columnIndex);
- }
- }
-
- private class TableLabelProvider extends LabelProvider
- implements ITableLabelProvider {
-
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- Employee employee = (Employee) element;
-
- if (columnIndex == TableColumnAdapter.NAME_COLUMN) {
- return employee.getName();
- }
-
- if (columnIndex == TableColumnAdapter.TITLE_COLUMN) {
- return employee.getTitle();
- }
-
- return employee.getManager();
- }
- }
-
- private class TableModel extends TableModelAdapter<Employee> {
-
- TableModel(ListValueModel<Employee> listHolder,
- CollectionValueModel<Employee> selectedItemsHolder,
- Table table,
- ColumnAdapter<Employee> columnAdapter,
- ITableLabelProvider labelProvider) {
-
- super(listHolder,
- selectedItemsHolder,
- table,
- columnAdapter,
- labelProvider);
- }
-
- TableModel(ListValueModel<Employee> listHolder,
- ModifiablePropertyValueModel<Employee> selectedItemHolder,
- Table table,
- ColumnAdapter<Employee> columnAdapter,
- ITableLabelProvider labelProvider) {
-
- super(listHolder,
- new PropertyCollectionValueModelAdapter<Employee>(selectedItemHolder),
- table,
- columnAdapter,
- labelProvider);
- }
-
- @Override
- protected int indexOf(Employee item) {
- return super.indexOf(item);
- }
-
- @Override
- protected Collection<Employee> selectedItems() {
- return super.selectedItems();
- }
-
- @Override
- protected void tableSelectionChanged(SelectionEvent event) {
- super.tableSelectionChanged(event);
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/TriStateCheckBoxModelAdapterUITest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/TriStateCheckBoxModelAdapterUITest.java
deleted file mode 100644
index afb8078b1c..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/swt/TriStateCheckBoxModelAdapterUITest.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.swt;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.common.ui.internal.swt.TriStateCheckBoxModelAdapter;
-import org.eclipse.jpt.common.ui.internal.widgets.DefaultWidgetFactory;
-import org.eclipse.jpt.common.ui.internal.widgets.TriStateCheckBox;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Play around with a set of tri-state check boxes.
- */
-public class TriStateCheckBoxModelAdapterUITest
- extends ApplicationWindow
-{
- private final TestModel testModel;
- private final ModifiablePropertyValueModel<TestModel> testModelHolder;
- private final ModifiablePropertyValueModel<Boolean> flag1Holder;
- private final ModifiablePropertyValueModel<Boolean> flag2Holder;
- private final ModifiablePropertyValueModel<Boolean> notFlag2Holder;
-
- public static void main(String[] args) throws Exception {
- Window window = new TriStateCheckBoxModelAdapterUITest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private TriStateCheckBoxModelAdapterUITest(String[] args) {
- super(null);
- this.testModel = new TestModel(Boolean.TRUE, Boolean.FALSE);
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.flag1Holder = this.buildFlag1Holder(this.testModelHolder);
- this.flag2Holder = this.buildFlag2Holder(this.testModelHolder);
- this.notFlag2Holder = this.buildNotFlag2Holder(this.testModelHolder);
- }
-
- private ModifiablePropertyValueModel<Boolean> buildFlag1Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.FLAG1_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.isFlag1();
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag1(value);
- }
- };
- }
-
- private ModifiablePropertyValueModel<Boolean> buildFlag2Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.isFlag2();
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag2(value);
- }
- };
- }
-
- private ModifiablePropertyValueModel<Boolean> buildNotFlag2Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.NOT_FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return this.subject.isNotFlag2();
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setNotFlag2(value);
- }
- };
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(this.getClass().getSimpleName());
- parent.setSize(400, 100);
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayout(new FormLayout());
- Control checkBoxPanel = this.buildCheckBoxPanel(mainPanel);
- this.buildControlPanel(mainPanel, checkBoxPanel);
- return mainPanel;
- }
-
- private Control buildCheckBoxPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100, -35);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildFlag1CheckBox(panel);
- this.buildFlag2CheckBox(panel);
- this.buildNotFlag2CheckBox(panel);
- this.buildUnattachedCheckBox(panel);
-
- return panel;
- }
-
- private void buildFlag1CheckBox(Composite parent) {
- TriStateCheckBox checkBox = new TriStateCheckBox(parent, "flag 1", DefaultWidgetFactory.instance());
- TriStateCheckBoxModelAdapter.adapt(this.flag1Holder, checkBox);
- }
-
- private void buildFlag2CheckBox(Composite parent) {
- TriStateCheckBox checkBox = new TriStateCheckBox(parent, "flag 2", DefaultWidgetFactory.instance());
- TriStateCheckBoxModelAdapter.adapt(this.flag2Holder, checkBox);
- }
-
- private void buildNotFlag2CheckBox(Composite parent) {
- TriStateCheckBox checkBox = new TriStateCheckBox(parent, "next flag 2", DefaultWidgetFactory.instance());
- TriStateCheckBoxModelAdapter.adapt(this.notFlag2Holder, checkBox);
- }
-
- private void buildUnattachedCheckBox(Composite parent) {
- TriStateCheckBox checkBox = new TriStateCheckBox(parent, "unattached", DefaultWidgetFactory.instance());
- checkBox.addSelectionListener(this.buildUnattachedSelectionListener());
- }
-
- private SelectionListener buildUnattachedSelectionListener() {
- return new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- System.out.println("unattached default selected: " + e);
- }
- public void widgetSelected(SelectionEvent e) {
- System.out.println("unattached selected: " + e);
- }
- };
- }
-
- private void buildControlPanel(Composite parent, Control checkBoxPanel) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(checkBoxPanel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildFlipFlag1Button(panel);
- this.buildClearModelButton(panel);
- this.buildRestoreModelButton(panel);
- this.buildPrintModelButton(panel);
- }
-
- private void buildFlipFlag1Button(Composite parent) {
- this.buildFlipFlag1ACI().fill(parent);
- }
-
- private ActionContributionItem buildFlipFlag1ACI() {
- Action action = new Action("next flag 1", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TriStateCheckBoxModelAdapterUITest.this.nextFlag1();
- }
- };
- action.setToolTipText("next flag 1");
- return new ActionContributionItem(action);
- }
-
- void nextFlag1() {
- this.testModel.nextFlag1();
- }
-
- private void buildClearModelButton(Composite parent) {
- this.buildClearModelACI().fill(parent);
- }
-
- private ActionContributionItem buildClearModelACI() {
- Action action = new Action("clear model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TriStateCheckBoxModelAdapterUITest.this.clearModel();
- }
- };
- action.setToolTipText("clear model");
- return new ActionContributionItem(action);
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private void buildRestoreModelButton(Composite parent) {
- this.buildRestoreModelACI().fill(parent);
- }
-
- private ActionContributionItem buildRestoreModelACI() {
- Action action = new Action("restore model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TriStateCheckBoxModelAdapterUITest.this.restoreModel();
- }
- };
- action.setToolTipText("restore model");
- return new ActionContributionItem(action);
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private void buildPrintModelButton(Composite parent) {
- this.buildPrintModelACI().fill(parent);
- }
-
- private ActionContributionItem buildPrintModelACI() {
- Action action = new Action("print model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TriStateCheckBoxModelAdapterUITest.this.printModel();
- }
- };
- action.setToolTipText("print model");
- return new ActionContributionItem(action);
- }
-
- void printModel() {
- System.out.println("flag 1: " + this.testModel.isFlag1());
- System.out.println("flag 2: " + this.testModel.isFlag2());
- System.out.println("not flag 2: " + this.testModel.isNotFlag2());
- System.out.println("***");
- }
-
-
- private class TestModel extends AbstractModel {
- private Boolean flag1;
- public static final String FLAG1_PROPERTY = "flag1";
- private Boolean flag2;
- public static final String FLAG2_PROPERTY = "flag2";
- private Boolean notFlag2;
- public static final String NOT_FLAG2_PROPERTY = "notFlag2";
-
- public TestModel(Boolean flag1, Boolean flag2) {
- this.flag1 = flag1;
- this.flag2 = flag2;
- this.notFlag2 = this.next(flag2);
- }
- private Boolean next(Boolean b) {
- return (b == null) ? Boolean.TRUE : b.booleanValue() ? Boolean.FALSE : null;
- }
- public Boolean isFlag1() {
- return this.flag1;
- }
- public void setFlag1(Boolean flag1) {
- Boolean old = this.flag1;
- this.flag1 = flag1;
- this.firePropertyChanged(FLAG1_PROPERTY, old, flag1);
- }
- public void nextFlag1() {
- this.setFlag1(this.next(this.flag1));
- }
- public Boolean isFlag2() {
- return this.flag2;
- }
- public void setFlag2(Boolean flag2) {
- Boolean old = this.flag2;
- this.flag2 = flag2;
- this.firePropertyChanged(FLAG2_PROPERTY, old, flag2);
-
- old = this.notFlag2;
- this.notFlag2 = this.next(flag2);
- this.firePropertyChanged(NOT_FLAG2_PROPERTY, old, this.notFlag2);
- }
- public void nextFlag2() {
- this.setFlag2(this.next(this.flag2));
- }
- public Boolean isNotFlag2() {
- return this.notFlag2;
- }
- public void setNotFlag2(Boolean notFlag2) {
- this.setFlag2(this.next(flag2));
- }
- public void nextNotFlag2() {
- this.setNotFlag2(this.next(this.notFlag2));
- }
- @Override
- public String toString() {
- return "TestModel(" + this.isFlag1() + " - " + this.isFlag2() + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlAlignerTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlAlignerTest.java
deleted file mode 100644
index 1c2904e0e7..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlAlignerTest.java
+++ /dev/null
@@ -1,803 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.fail;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.jpt.common.ui.internal.util.ControlAligner;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Shell;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public final class ControlAlignerTest {
-
- private ControlAligner controlAligner;
- private Composite parent;
- private Shell shell;
-
- private Layout buildSpacerLayout() {
- return new Layout() {
- @Override
- protected Point computeSize(Composite composite,
- int widthHint,
- int heightHint,
- boolean flushCache) {
-
- return new Point(widthHint, heightHint);
- }
-
- @Override
- protected void layout(Composite composite, boolean flushCache) {
- GridData data = (GridData) composite.getLayoutData();
- composite.setBounds(0, 0, data.widthHint, data.heightHint);
- }
- };
- }
-
- @Before
- public void setUp() {
-
- controlAligner = new ControlAligner();
-
- shell = new Shell(Display.getCurrent());
- shell.setLayout(new GridLayout(1, false));
-
- parent = new Composite(shell, SWT.NONE);
- parent.setLayout(new GridLayout(1, false));
- parent.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- }
-
- @After
- public void tearDown() {
-
- if (controlAligner != null) {
- controlAligner.dispose();
- controlAligner = null;
- }
-
- if (shell != null) {
- shell.dispose();
- shell = null;
- }
- }
-
- @Test
- public void testAddControl1() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label label = new Label(pane, SWT.NULL);
- updateGridData(label);
-
- controlAligner.add(label);
-
- assertEquals(
- "The maximum width should be 0,",
- 0,
- controlAligner.getMaximumWidth()
- );
-
- label.setText("This is a ControlAligner");
-// parent.layout(true, true);
-
- Point size = label.getSize();
-
- assertEquals(
- "The width should be " + size.x + ",",
- size.x,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testAddControl2() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Button button = new Button(pane, SWT.NULL);
- button.setText("This is a ControlAligner");
- updateGridData(button);
-
- controlAligner.add(button);
- parent.layout(true, true);
-
- Point size = button.getSize();
-
- assertEquals(
- "The width should be " + size.x + ",",
- size.x,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testAddControl3() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label label = new Label(pane, SWT.NULL);
- label.setText("This is very long text");
- updateGridData(label);
-
- Button button = new Button(pane, SWT.NULL);
- button.setText("Short text");
- updateGridData(button);
-
-// parent.layout(true, true);
-
- controlAligner.add(label);
- controlAligner.add(button);
-
- Point labelSize = label.getSize();
- Point buttonSize = button.getSize();
- int max = Math.max(labelSize.x, buttonSize.x);
-
- assertEquals(
- "The width should be " + max + ",",
- max,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testAddControlAligner1() throws Exception {
-
- Label label1 = new Label(parent, SWT.NULL);
- Label label2 = new Label(parent, SWT.NULL);
-
- updateGridData(label1);
- updateGridData(label2);
-
- controlAligner.add(label1);
-
- ControlAligner controlAligner2 = new ControlAligner();
- controlAligner.add(controlAligner2);
- controlAligner2.add(label2);
-
- label1.setText("This is a ControlAligner");
- label2.setText("This is a very long ControlAligner");
-// parent.layout(true, true);
-
- Point size1 = label1.getSize();
- Point size2 = label2.getSize();
- int width = Math.max(size1.x, size2.x);
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
- }
-
- @Test
- public void testAddControlAligner2() throws Exception {
-
- Label label1 = new Label(parent, SWT.NULL);
- Label label2 = new Label(parent, SWT.NULL);
-
- updateGridData(label1);
- updateGridData(label2);
-
- controlAligner.add(label1);
-
- ControlAligner controlAligner2 = new ControlAligner();
- controlAligner2.add(label2);
-
- label1.setText("This is a ControlAligner");
- label2.setText("This is a very long ControlAligner");
-
- controlAligner.add(controlAligner2);
-// parent.layout(true, true);
-
- Point size1 = label1.getSize();
- Point size2 = label2.getSize();
- int width = Math.max(size1.x, size2.x);
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
- }
-
- @Test(expected=IllegalArgumentException.class)
- public void testAddControlAlignerToItself() throws Exception {
- controlAligner.add(controlAligner);
- fail("A ControlAligner can't be added to itself");
- }
-
- @Test
- public void testDialog_AddControl1() throws Exception {
-
- final int[] maximumWidth = new int[1];
- final int[] size = new int[1];
-
- TitleAreaDialog dialog = new TitleAreaDialog(SWTUtil.getShell()) {
-
- private Label label;
-
- @Override
- protected Control createDialogArea(Composite parent) {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- label = new Label(pane, SWT.LEFT);
- label.setText("This is a ControlAligner");
- updateGridData(label);
-
- controlAligner.add(label);
-
- return parent;
- }
-
- @Override
- protected void initializeBounds() {
- super.initializeBounds();
- size[0] = label.getSize().x;
- maximumWidth[0] = controlAligner.getMaximumWidth();
- }
- };
-
- dialog.create();
- dialog.close();
-
- assertEquals(
- "The width should be " + size[0] + ",",
- size[0],
- maximumWidth[0]
- );
- }
-
- @Test
- public void testDialog_AddControl2() throws Exception {
-
- final int[] maximumWidth = new int[1];
- final int[] sizes = new int[2];
-
- TitleAreaDialog dialog = new TitleAreaDialog(SWTUtil.getShell()) {
-
- private Button button;
- private Label label;
-
- @Override
- protected Control createDialogArea(Composite parent) {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- label = new Label(pane, SWT.NULL);
- label.setText("This is a ControlAligner");
- updateGridData(label);
-
- controlAligner.add(label);
-
- button = new Button(pane, SWT.NULL);
- button.setText("Short text");
- updateGridData(button);
-
- controlAligner.add(button);
-
- return parent;
- }
-
- @Override
- protected void initializeBounds() {
- super.initializeBounds();
- sizes[0] = label.getSize().x;
- sizes[1] = button.getSize().x;
- maximumWidth[0] = controlAligner.getMaximumWidth();
- }
- };
-
- dialog.create();
- dialog.close();
-
- int labelSize = sizes[0];
- int buttonSize = sizes[1];
- int max = Math.max(labelSize, buttonSize);
-
- assertEquals(
- "The width should be " + max + ",",
- max,
- maximumWidth[0]
- );
- }
-
- @Test
- public void testDispose() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label label = new Label(pane, SWT.NULL);
- label.setText("This is very long text");
- updateGridData(label);
-
- Button button = new Button(pane, SWT.NULL);
- button.setText("Short text");
- updateGridData(button);
-
- controlAligner.add(label);
- controlAligner.add(button);
-
- Point labelSize = label.getSize();
- Point buttonSize = button.getSize();
- int max = Math.max(labelSize.x, buttonSize.x);
-
- assertEquals(
- "The width should be " + max + ",",
- max,
- controlAligner.getMaximumWidth()
- );
-
- label.dispose();
-
- Point newButtonSize = button.getSize();
-
- assertNotSame(
- "The old max and new max should not be the same",
- max,
- newButtonSize.x
- );
-
- assertEquals(
- "The ControlAligner doesn't have the right maximum width",
- newButtonSize.x,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testHierarchyOfControlAligners() throws Exception {
-
- // Aligner1
- // ^
- // |-Aligner2
- // ^
- // |-Aligner3
- ControlAligner controlAligner2 = new ControlAligner();
- controlAligner.add(controlAligner2);
-
- ControlAligner controlAligner3 = new ControlAligner();
- controlAligner2.add(controlAligner3);
-
- // Test 1
- Label label1 = new Label(parent, SWT.NULL);
- label1.setText("This is a label widget");
- parent.layout(true, true);
-
- int labelWidth1 = label1.getSize().x;
- controlAligner3.add(label1);
-
- assertEquals(controlAligner3.getMaximumWidth(), labelWidth1);
- assertEquals(controlAligner2.getMaximumWidth(), labelWidth1);
- assertEquals(controlAligner.getMaximumWidth(), labelWidth1);
-
- // Test 2
- Label label2 = new Label(parent, SWT.NULL);
- label2.setText("ShortLabel");
- controlAligner2.add(label2);
- parent.layout(true);
-
- int newLabelWidth1 = label1.getSize().x;
- int newLabelWidth2 = label2.getSize().x;
-
- assertEquals(controlAligner3.getMaximumWidth(), controlAligner2.getMaximumWidth());
- assertEquals(controlAligner2.getMaximumWidth(), controlAligner.getMaximumWidth());
- assertEquals(newLabelWidth1, newLabelWidth2);
- assertEquals(newLabelWidth1, controlAligner.getMaximumWidth());
-
- // Test 3
- Label label3 = new Label(parent, SWT.NULL);
- label3.setText("A very long label that takes a lot of horizontal space");
-// parent.layout(true);
- controlAligner.add(label3);
-
- newLabelWidth1 = label1.getSize().x;
- newLabelWidth2 = label2.getSize().x;
- int newLabelWidth3 = label3.getSize().x;
-
- assertEquals(controlAligner3.getMaximumWidth(), controlAligner2.getMaximumWidth());
- assertEquals(controlAligner2.getMaximumWidth(), controlAligner.getMaximumWidth());
- assertEquals(newLabelWidth1, newLabelWidth2);
- assertEquals(newLabelWidth2, newLabelWidth3);
- assertEquals(newLabelWidth1, controlAligner.getMaximumWidth());
-
- // Make sure all the locked are removed
- assertEquals(ReflectionTools.getFieldValue_(controlAligner, "locked"), Boolean.FALSE);
- assertEquals(ReflectionTools.getFieldValue_(controlAligner2, "locked"), Boolean.FALSE);
- assertEquals(ReflectionTools.getFieldValue_(controlAligner3, "locked"), Boolean.FALSE);
-
- // Change the text of label2
- label2.setText("mm");
-// parent.layout(true);
-
- newLabelWidth1 = label1.getSize().x;
- newLabelWidth2 = label2.getSize().x;
- newLabelWidth3 = label3.getSize().x;
-
- assertEquals(controlAligner3.getMaximumWidth(), controlAligner2.getMaximumWidth());
- assertEquals(controlAligner2.getMaximumWidth(), controlAligner.getMaximumWidth());
- assertEquals(newLabelWidth1, newLabelWidth2);
- assertEquals(newLabelWidth2, newLabelWidth3);
- assertEquals(newLabelWidth1, controlAligner.getMaximumWidth());
-
- assertEquals(ReflectionTools.getFieldValue_(controlAligner, "locked"), Boolean.FALSE);
- assertEquals(ReflectionTools.getFieldValue_(controlAligner2, "locked"), Boolean.FALSE);
- assertEquals(ReflectionTools.getFieldValue_(controlAligner3, "locked"), Boolean.FALSE);
-
- // Change the text of label1
- label1.setText("a");
-// parent.layout(true);
-
- Composite parent1 = new Composite(SWTUtil.getShell(), SWT.NULL);
- parent1.setLayout(new GridLayout());
-
- Label tempLabel = new Label(parent1, SWT.NULL);
- tempLabel.setText("a");
-// parent1.layout(true);
-
- int realWidth = tempLabel.getSize().x;
-
- newLabelWidth1 = label1.getSize().x;
- newLabelWidth2 = label2.getSize().x;
- newLabelWidth3 = label3.getSize().x;
-
- assertEquals(controlAligner3.getMaximumWidth(), controlAligner2.getMaximumWidth());
- assertEquals(controlAligner2.getMaximumWidth(), controlAligner.getMaximumWidth());
- assertEquals(newLabelWidth1, newLabelWidth2);
- assertEquals(newLabelWidth2, newLabelWidth3);
- assertEquals(newLabelWidth1, controlAligner.getMaximumWidth());
- assertFalse(newLabelWidth1 == realWidth);
-
- assertEquals(ReflectionTools.getFieldValue_(controlAligner, "locked"), Boolean.FALSE);
- assertEquals(ReflectionTools.getFieldValue_(controlAligner2, "locked"), Boolean.FALSE);
- assertEquals(ReflectionTools.getFieldValue_(controlAligner3, "locked"), Boolean.FALSE);
-
- // Change the text of label1
- label1.setText("Yes another big long long text so that all the labels will have to take the size of this label to make sure ControlAligner works correctly");
-// parent.layout(true);
-
- // Weird: It seems no notification is sent, fire one manually
- Event event = new Event();
- event.widget = label1;
- event.type = SWT.Resize;
- label1.notifyListeners(SWT.Resize, event);
-
- Composite parent2 = new Composite(SWTUtil.getShell(), SWT.NULL);
- parent2.setLayout(new GridLayout());
-
- tempLabel = new Label(parent2, SWT.NULL);
- tempLabel.setText(label1.getText());
- parent2.layout(true);
-
- realWidth = tempLabel.getSize().x;
-
- newLabelWidth1 = label1.getSize().x;
- newLabelWidth2 = label2.getSize().x;
- newLabelWidth3 = label3.getSize().x;
-
- assertEquals(controlAligner3.getMaximumWidth(), controlAligner2.getMaximumWidth());
- assertEquals(controlAligner2.getMaximumWidth(), controlAligner.getMaximumWidth());
- assertEquals(newLabelWidth1, newLabelWidth2);
- assertEquals(newLabelWidth2, newLabelWidth3);
- assertEquals(controlAligner.getMaximumWidth(), newLabelWidth1);
- assertEquals(realWidth, newLabelWidth1);
-
- assertEquals(ReflectionTools.getFieldValue_(controlAligner, "locked"), Boolean.FALSE);
- assertEquals(ReflectionTools.getFieldValue_(controlAligner2, "locked"), Boolean.FALSE);
- assertEquals(ReflectionTools.getFieldValue_(controlAligner3, "locked"), Boolean.FALSE);
- }
-
- @Test
- public void testRemoveControl1() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Button button = new Button(pane, SWT.NULL);
- button.setText("This is a ControlAligner");
- updateGridData(button);
-
- controlAligner.add(button);
- parent.layout(true, true);
-
- Point size = button.getSize();
-
- assertEquals(
- "The width should be " + size.x + ",",
- size.x,
- controlAligner.getMaximumWidth()
- );
-
- controlAligner.remove(button);
-
- assertEquals(
- "The width should be 0, ",
- 0,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testRemoveControl2() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label label = new Label(pane, SWT.NULL);
- label.setText("This is very long text");
- updateGridData(label);
-
- Button button = new Button(pane, SWT.NULL);
- button.setText("Short text");
- updateGridData(button);
-// parent.layout(true, true);
-
- controlAligner.add(label);
- controlAligner.add(button);
-
- Point labelSize = label.getSize();
- Point buttonSize = button.getSize();
- int max = Math.max(labelSize.x, buttonSize.x);
-
- assertEquals(
- "The width should be " + max + ",",
- max,
- controlAligner.getMaximumWidth()
- );
-
- controlAligner.remove(label);
-
- Point newButtonSize = button.getSize();
-
- assertNotSame(
- "The old max and new max should not be the same",
- max,
- newButtonSize.x
- );
-
- assertEquals(
- "The ControlAligner doesn't have the right maximum width",
- newButtonSize.x,
- controlAligner.getMaximumWidth()
- );
- }
-
- @Test
- public void testRemoveControl4() throws Exception {
-
- Composite pane = new Composite(parent, SWT.NULL);
- pane.setLayout(new GridLayout(3, false));
- pane.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Widget 1
- Label label = new Label(pane, SWT.NULL);
- label.setText("This is very long text");
- updateGridData(label);
- controlAligner.add(label);
-
- // Widget 2
- Composite spacer = new Composite(pane, SWT.NULL);
- spacer.setLayout(buildSpacerLayout());
- updateGridData(spacer);
- controlAligner.add(spacer);
-
- // Widget 3
- Button button = new Button(pane, SWT.NULL);
- button.setText("Short text");
- updateGridData(button);
- controlAligner.add(button);
-
-// parent.layout(true, true);
-
- // Make sure the 3 widgets have the same width
- Point labelSize = label.getSize();
- Point spacerSize = spacer.getSize();
- Point buttonSize = button.getSize();
- int max = Math.max(labelSize.x, buttonSize.x);
- max = Math.max(max, spacerSize.x);
-
- assertEquals(
- "The width should be " + max + ",",
- max,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The spacer's width should be " + max + ",",
- max,
- spacerSize.x
- );
-
- // Remove the label (the widest widget) and make sure the width was
- // correctly calculated
- controlAligner.remove(label);
-
- spacerSize = spacer.getSize();
- buttonSize = button.getSize();
- int max2 = Math.max(spacerSize.x, buttonSize.x);
-
- assertNotSame(
- "The old max and new max should not be the same",
- max,
- max2
- );
-
- assertEquals(
- "The ControlAligner doesn't have the right maximum width",
- max2,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The spacer's width should have been adjusted",
- max2,
- spacerSize.x
- );
- }
-
- @Test
- public void testRemoveControlAligner1() throws Exception {
-
- Label label1 = new Label(parent, SWT.NULL);
- Label label2 = new Label(parent, SWT.NULL);
-
- updateGridData(label1);
- updateGridData(label2);
-
- controlAligner.add(label1);
-
- ControlAligner controlAligner2 = new ControlAligner();
- controlAligner.add(controlAligner2);
- controlAligner2.add(label2);
-
- label1.setText("This is a ControlAligner");
- label2.setText("This is a very long ControlAligner");
-// parent.layout(true, true);
-
- Point size1 = label1.getSize();
- Point size2 = label2.getSize();
- int width = Math.max(size1.x, size2.x);
-
- // Test 1
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
-
- // Test 2
- controlAligner.remove(label1);
-
- width = label2.getSize().x;
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
- }
-
- @Test
- public void testRemoveControlAligner2() throws Exception {
-
- Label label1 = new Label(parent, SWT.NULL);
- Label label2 = new Label(parent, SWT.NULL);
-
- updateGridData(label1);
- updateGridData(label2);
-
- controlAligner.add(label1);
-
- ControlAligner controlAligner2 = new ControlAligner();
- controlAligner.add(controlAligner2);
- controlAligner2.add(label2);
-
- label1.setText("This is a ControlAligner");
- label2.setText("This is a very long ControlAligner");
-// parent.layout(true, true);
-
- Point size1 = label1.getSize();
- Point size2 = label2.getSize();
- int width = Math.max(size1.x, size2.x);
-
- // Test 1
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
-
- // Test 2
- controlAligner2.remove(label2);
-
- width = label1.getSize().x;
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner.getMaximumWidth()
- );
-
- assertEquals(
- "The width should be " + width + ",",
- width,
- controlAligner2.getMaximumWidth()
- );
- }
-
- private void updateGridData(Control control) {
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = false;
- control.setLayoutData(data);
- }
-} \ No newline at end of file
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlEnablerTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlEnablerTest.java
deleted file mode 100644
index d6406a1bb9..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlEnablerTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.util;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public final class ControlEnablerTest {
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- }
- }
-
- @Test
- public void testSwitchState() {
-
- SimplePropertyValueModel<Boolean> booleanHolder =
- new SimplePropertyValueModel<Boolean>(true);
-
- Combo combo = new Combo(parent, SWT.BORDER);
-
- SWTTools.controlEnabledState(booleanHolder, combo);
-
- assertTrue(
- "The Combo should be enabled",
- combo.isEnabled()
- );
-
- // Change state (null)
- booleanHolder.setValue(null);
-
- assertFalse(
- "The Combo should not be enabled",
- combo.isEnabled()
- );
-
- // Change state (true)
- booleanHolder.setValue(true);
-
- assertTrue(
- "The Combo should be enabled",
- combo.isEnabled()
- );
-
- // Change state (false)
- booleanHolder.setValue(false);
-
- assertFalse(
- "The Combo should not be enabled",
- combo.isEnabled()
- );
-
- // Dispose
- combo.dispose();
- booleanHolder.setValue(true);
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlSwitcherTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlSwitcherTest.java
deleted file mode 100644
index 49111bdef5..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlSwitcherTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import org.eclipse.jpt.common.ui.internal.util.ControlSwitcher;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.part.PageBook;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public final class ControlSwitcherTest {
-
- private PageBook pageBook;
- private Composite pane1;
- private Composite pane2;
- private Composite parent;
-
- private Composite buildPane1() {
-
- if (pane1 == null) {
-
- pane1 = new Composite(pageBook, SWT.NULL);
- pane1.setLayout(new GridLayout(2, false));
-
- Label label = new Label(pane1, SWT.NULL);
- label.setText("&Test2:");
-
- Text text = new Text(pane1, SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Combo combo = new Combo(pane1, SWT.BORDER);
-
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalSpan = 2;
- combo.setLayoutData(data);
- }
-
- return pane1;
- }
-
- private Composite buildPane2() {
-
- if (pane2 == null) {
-
- pane2 = new Composite(pageBook, SWT.NULL);
- pane2.setLayout(new GridLayout(2, false));
-
- Label label = new Label(pane2, SWT.NULL);
- label.setText("&Test1:");
-
- Text text = new Text(pane2, SWT.BORDER);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
-
- return pane2;
- }
-
- private Transformer<Boolean, Control> buildTransformer() {
- return new Transformer<Boolean, Control>() {
- public Control transform(Boolean value) {
- return (value == null) ? null : (value ? pane1 : pane2);
- }
- };
- }
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
-
- pageBook = new PageBook(parent, SWT.NULL);
- pageBook.setLayoutData(new GridData());
- }
-
- @After
- public void tearDown() {
-
- if (parent != null) {
-
- parent.dispose();
-
- parent = null;
- pageBook = null;
- }
- }
-
- @Test
- public void testSwitch() {
-
- SimplePropertyValueModel<Boolean> switchHolder = new SimplePropertyValueModel<Boolean>();
- Transformer<Boolean, Control> transformer = buildTransformer();
-
- pane1 = buildPane1();
- pane1.setVisible(false);
-
- pane2 = buildPane2();
- pane2.setVisible(false);
-
- new ControlSwitcher(
- switchHolder,
- transformer,
- pageBook
- );
-
- // Test 1
- switchHolder.setValue(true);
- Control control = (Control) ReflectionTools.getFieldValue(pageBook, "currentPage");
-
- assertNotNull(
- "The page book's page shouldn't be null",
- control
- );
-
- assertSame(
- "The current pane should be pane1",
- pane1,
- control
- );
-
- Point pane1Size = pane1.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- Point pageBookSize = pageBook.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- assertEquals(
- "The width of the PageBook should be the same as the width of pane1",
- pane1Size.x,
- pageBookSize.x
- );
-
- assertEquals(
- "The height of the PageBook should be the same as the height of pane1",
- pane1Size.y,
- pageBookSize.y
- );
-
- // Test 2
- switchHolder.setValue(false);
- control = (Control) ReflectionTools.getFieldValue(pageBook, "currentPage");
-
- assertNotNull(
- "The page book's page shouldn't be null",
- control
- );
-
- assertSame(
- "The current pane should be pane2",
- pane2,
- control
- );
-
- Point pane2Size = pane2.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- pageBookSize = pageBook.computeSize(SWT.DEFAULT, SWT.DEFAULT);
-
- assertEquals(
- "The width of the PageBook should be the same as the width of pane2",
- pane2Size.x,
- pageBookSize.x
- );
-
- assertEquals(
- "The height of the PageBook should be the same as the height of pane2",
- pane2Size.y,
- pageBookSize.y
- );
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlVisibilityEnablerTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlVisibilityEnablerTest.java
deleted file mode 100644
index f978ed1618..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/ControlVisibilityEnablerTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.util;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public final class ControlVisibilityEnablerTest {
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- }
- }
-
- @Test
- public void testSwitchState() {
-
- SimplePropertyValueModel<Boolean> booleanHolder =
- new SimplePropertyValueModel<Boolean>(true);
-
- Combo combo = new Combo(parent, SWT.BORDER);
-
- SWTTools.controlVisibleState(booleanHolder, combo);
-
- assertTrue(
- "The Combo should be visible",
- combo.isVisible()
- );
-
- // Change state (null)
- booleanHolder.setValue(null);
-
- assertFalse(
- "The Combo should not be visible",
- combo.isVisible()
- );
-
- // Change state (true)
- booleanHolder.setValue(true);
-
- assertTrue(
- "The Combo should be visible",
- combo.isVisible()
- );
-
- // Change state (false)
- booleanHolder.setValue(false);
-
- assertFalse(
- "The Combo should not be visible",
- combo.isVisible()
- );
-
- // Dispose
- combo.dispose();
- booleanHolder.setValue(true);
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/JptUiUtilTests.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/JptUiUtilTests.java
deleted file mode 100644
index 38f00d21d0..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/JptUiUtilTests.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.util;
-
-import junit.framework.JUnit4TestAdapter;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.junit.runners.Suite.SuiteClasses;
-
-@SuiteClasses
-({
- ControlAlignerTest.class,
- ControlSwitcherTest.class,
- ControlEnablerTest.class,
- ControlVisibilityEnablerTest.class,
- LabeledButtonTest.class,
- LabeledLabelTest.class,
- LabeledControlUpdaterTest.class,
- PaneEnablerTest.class,
- PaneVisibilityEnablerTest.class,
-})
-@RunWith(Suite.class)
-public final class JptUiUtilTests {
-
- private JptUiUtilTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
- public static Test suite() {
- TestSuite suite = new TestSuite();
- suite.addTest(new JUnit4TestAdapter(JptUiUtilTests.class));
- return suite;
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledButtonTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledButtonTest.java
deleted file mode 100644
index 52515acb41..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledButtonTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.util;
-
-import static org.junit.Assert.assertEquals;
-import org.eclipse.core.runtime.AssertionFailedException;
-import org.eclipse.jpt.common.ui.internal.util.LabeledButton;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public final class LabeledButtonTest {
-
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- parent = null;
- }
- }
-
- @Test
- public void testLabeledButton1() {
- Button button = new Button(parent, SWT.NULL);
- new LabeledButton(button);
- }
-
- @Test(expected=AssertionFailedException.class)
- public void testLabeledButton2() {
- new LabeledButton(null);
- }
-
- @Test
- public void testSetImage() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Button button = new Button(parent, SWT.NULL);
- LabeledButton labeledButton = new LabeledButton(button);
-
- labeledButton.setImage(expected);
-
- assertEquals(
- "The Button didn't receive the Image",
- expected,
- button.getImage()
- );
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetImageDispose() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Button button = new Button(parent, SWT.NULL);
- LabeledButton labeledButton = new LabeledButton(button);
-
- button.dispose();
-
- // This should not fail but simply do nothing
- labeledButton.setImage(expected);
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetText() {
- Button button = new Button(parent, SWT.NULL);
- LabeledButton labeledButton = new LabeledButton(button);
-
- String expected = "This is a test";
- labeledButton.setText(expected);
-
- assertEquals(
- "The Button didn't receive the text",
- expected,
- button.getText()
- );
- }
-
- @Test
- public void testSetTextDispose() {
- Button button = new Button(parent, SWT.NULL);
- LabeledButton labeledButton = new LabeledButton(button);
-
- button.dispose();
-
- // This should not fail but simply do nothing
- String expected = "This is a test";
- labeledButton.setText(expected);
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledControlUpdaterTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledControlUpdaterTest.java
deleted file mode 100644
index cc8d6ee13f..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledControlUpdaterTest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.util;
-
-import static org.junit.Assert.assertEquals;
-import org.eclipse.jpt.common.ui.internal.util.LabeledControlUpdater;
-import org.eclipse.jpt.common.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public final class LabeledControlUpdaterTest {
-
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- parent = null;
- }
- }
-
- @Test
- public void testSetImage() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- ModifiablePropertyValueModel<Image> imageHolder = new SimplePropertyValueModel<Image>();
- new LabeledControlUpdater(labeledLabel, null, imageHolder);
-
- labeledLabel.setImage(expected);
-
- assertEquals(
- "The Label didn't receive the Image",
- expected,
- label.getImage()
- );
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetImageDispose() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- ModifiablePropertyValueModel<Image> imageHolder = new SimplePropertyValueModel<Image>();
- new LabeledControlUpdater(labeledLabel, null, imageHolder);
-
- label.dispose();
- labeledLabel.setImage(expected);
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetText() {
-
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- ModifiablePropertyValueModel<String> textHolder = new SimplePropertyValueModel<String>();
- new LabeledControlUpdater(labeledLabel, textHolder);
-
- String expected = "This is a test";
- textHolder.setValue(expected);
-
- assertEquals(
- "The Label didn't receive the text",
- expected,
- label.getText()
- );
- }
-
- @Test
- public void testSetTextDispose() {
-
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- ModifiablePropertyValueModel<String> textHolder = new SimplePropertyValueModel<String>();
- new LabeledControlUpdater(labeledLabel, textHolder);
-
- label.dispose();
-
- String expected = "This is a test";
- textHolder.setValue(expected);
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledLabelTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledLabelTest.java
deleted file mode 100644
index d43bcee4fb..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/LabeledLabelTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.util;
-
-import static org.junit.Assert.assertEquals;
-import org.eclipse.core.runtime.AssertionFailedException;
-import org.eclipse.jpt.common.ui.internal.util.LabeledLabel;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public final class LabeledLabelTest {
-
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- parent = null;
- }
- }
-
- @Test
- public void testLabeledButton1() {
- Label label = new Label(parent, SWT.NULL);
- new LabeledLabel(label);
- }
-
- @Test(expected=AssertionFailedException.class)
- public void testLabeledButton2() {
- new LabeledLabel(null);
- }
-
- @Test
- public void testSetImage() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- labeledLabel.setImage(expected);
-
- assertEquals(
- "The Label didn't receive the Image",
- expected,
- label.getImage()
- );
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetImageDispose() {
-
- Image expected = new Image(parent.getDisplay(), 16, 16);
-
- try {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- label.dispose();
-
- // This should not fail but simply do nothing
- labeledLabel.setImage(expected);
- }
- finally {
- expected.dispose();
- }
- }
-
- @Test
- public void testSetText() {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- String expected = "This is a test";
- labeledLabel.setText(expected);
-
- assertEquals(
- "The Label didn't receive the text",
- expected,
- label.getText()
- );
- }
-
- @Test
- public void testSetTextDispose() {
- Label label = new Label(parent, SWT.NULL);
- LabeledLabel labeledLabel = new LabeledLabel(label);
-
- label.dispose();
-
- // This should not fail but simply do nothing
- String expected = "This is a test";
- labeledLabel.setText(expected);
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/PaneEnablerTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/PaneEnablerTest.java
deleted file mode 100644
index b68fd99686..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/PaneEnablerTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.util;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.eclipse.jpt.common.ui.internal.util.PaneEnabler;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.ui.internal.widgets.DialogPane;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.node.Node;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public final class PaneEnablerTest {
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- }
- }
-
- @Test
- public void testSwitchState() {
-
- SimplePropertyValueModel<Boolean> booleanHolder =
- new SimplePropertyValueModel<Boolean>(true);
-
- DialogPane<Node> pane = new DialogPane<Node>(
- new SimplePropertyValueModel<Node>(),
- parent)
- {
- @Override
- protected void initializeLayout(Composite container) {
- }
- };
-
- new PaneEnabler(booleanHolder, pane);
-
- assertTrue(
- "The pane should be enabled",
- pane.getControl().isEnabled()
- );
-
- // Change state (null)
- booleanHolder.setValue(null);
-
- assertFalse(
- "The pane should not be enabled",
- pane.getControl().isEnabled()
- );
-
- // Change state (true)
- booleanHolder.setValue(true);
-
- assertTrue(
- "The pane should be enabled",
- pane.getControl().isEnabled()
- );
-
- // Change state (false)
- booleanHolder.setValue(false);
-
- assertFalse(
- "The pane should not be enabled",
- pane.getControl().isEnabled()
- );
-
- // Dispose
- pane.dispose();
- booleanHolder.setValue(true);
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/PaneVisibilityEnablerTest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/PaneVisibilityEnablerTest.java
deleted file mode 100644
index e0ac3ce2ad..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/util/PaneVisibilityEnablerTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.util;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import org.eclipse.jpt.common.ui.internal.util.PaneVisibilityEnabler;
-import org.eclipse.jpt.common.ui.internal.util.SWTUtil;
-import org.eclipse.jpt.common.ui.internal.widgets.DialogPane;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.node.Node;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-@SuppressWarnings("nls")
-public final class PaneVisibilityEnablerTest {
- private Composite parent;
-
- @Before
- public void setUp() {
- parent = new Composite(SWTUtil.getShell(), SWT.NONE);
- parent.setLayout(new GridLayout());
- }
-
- @After
- public void tearDown() {
- if (parent != null) {
- parent.dispose();
- }
- }
-
- @Test
- public void testSwitchState() {
-
- SimplePropertyValueModel<Boolean> booleanHolder =
- new SimplePropertyValueModel<Boolean>(true);
-
- DialogPane<Node> pane = new DialogPane<Node>(
- new SimplePropertyValueModel<Node>(),
- parent)
- {
- @Override
- protected void initializeLayout(Composite container) {
- }
- };
-
- new PaneVisibilityEnabler(booleanHolder, pane);
-
- assertTrue(
- "The pane should be visible",
- pane.getControl().isVisible()
- );
-
- // Change state (null)
- booleanHolder.setValue(null);
-
- assertFalse(
- "The pane should not be visible",
- pane.getControl().isVisible()
- );
-
- // Change state (true)
- booleanHolder.setValue(true);
-
- assertTrue(
- "The pane should be visible",
- pane.getControl().isVisible()
- );
-
- // Change state (false)
- booleanHolder.setValue(false);
-
- assertFalse(
- "The pane should not be visible",
- pane.getControl().isVisible()
- );
-
- // Dispose
- pane.dispose();
- booleanHolder.setValue(true);
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/BooleanStateControllerUITest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/BooleanStateControllerUITest.java
deleted file mode 100644
index 5430977a5c..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/BooleanStateControllerUITest.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.utility.swt;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Play around with boolean state controllers ('enabled' and 'visible').
- * <p>
- * Note the behavior of composites:<ul>
- * <li>When a composite is disabled, its children are disabled but <em>not</em>
- * grayed out.
- * <li>When a composite is made invisible, its children are also made
- * invisible.
- * </ul>
- */
-@SuppressWarnings("nls")
-public class BooleanStateControllerUITest
- extends ApplicationWindow
-{
- private final ModifiablePropertyValueModel<Boolean> enabledHolder;
- private final ModifiablePropertyValueModel<Boolean> visibleHolder;
- private final SimpleListValueModel<String> listHolder;
- private final ModifiablePropertyValueModel<String> listSelectionHolder;
-
- public static void main(String[] args) throws Exception {
- Window window = new BooleanStateControllerUITest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private BooleanStateControllerUITest(@SuppressWarnings("unused") String[] args) {
- super(null);
- this.enabledHolder = new SimplePropertyValueModel<Boolean>(Boolean.TRUE);
- this.visibleHolder = new SimplePropertyValueModel<Boolean>(Boolean.TRUE);
- this.listHolder = this.buildListHolder();
- this.listSelectionHolder = new SimplePropertyValueModel<String>(null);
- }
-
- private SimpleListValueModel<String> buildListHolder() {
- SimpleListValueModel<String> result = new SimpleListValueModel<String>();
- result.add("zero");
- result.add("one");
- result.add("two");
- result.add("three");
- result.add("four");
- result.add("five");
- result.add("six");
- result.add("seven");
- return result;
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(this.getClass().getSimpleName());
- parent.setSize(500, 150);
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayout(new FormLayout());
- Control widgetPanel = this.buildWidgetPanels(mainPanel);
- this.buildControlPanel(mainPanel, widgetPanel);
- return mainPanel;
- }
-
- private Control buildWidgetPanels(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100, -35);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout(SWT.VERTICAL));
-
- this.buildWidgetPanel1(panel);
- this.buildWidgetPanel2(panel);
-
- return panel;
- }
-
- private void buildWidgetPanel1(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayout(new FillLayout(SWT.HORIZONTAL));
-
- Button enabledComboBoxCheckBox = this.buildEnabledComboBoxCheckBox(panel);
- SWTTools.bind(this.enabledHolder, enabledComboBoxCheckBox);
-
- Button visibleComboBoxCheckBox = this.buildVisibleComboBoxCheckBox(panel);
- SWTTools.bind(this.visibleHolder, visibleComboBoxCheckBox);
-
- Label comboBoxLabel = this.buildComboBoxLabel(panel);
- Combo comboBox = this.buildComboBox(panel);
- SWTTools.bind(this.listHolder, this.listSelectionHolder, comboBox);
- SWTTools.controlEnabledState(this.enabledHolder, comboBoxLabel, comboBox);
- SWTTools.controlVisibleState(this.visibleHolder, comboBoxLabel, comboBox);
- }
-
- private Button buildEnabledComboBoxCheckBox(Composite parent) {
- return this.buildCheckBox(parent, "enabled");
- }
-
- private Button buildVisibleComboBoxCheckBox(Composite parent) {
- return this.buildCheckBox(parent, "visible");
- }
-
- private Button buildCheckBox(Composite parent, String text) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText(text);
- return checkBox;
- }
-
- private Label buildComboBoxLabel(Composite parent) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText("list:");
- return label;
- }
-
- private Combo buildComboBox(Composite parent) {
- return new Combo(parent, SWT.READ_ONLY);
- }
-
- private void buildWidgetPanel2(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayout(new FillLayout(SWT.HORIZONTAL));
-
- Button checkBox1 = this.buildCheckBox(panel, "one");
- this.buildCheckBox(panel, "two");
- this.buildCheckBox(panel, "three");
- this.buildCheckBox(panel, "four");
-
- SWTTools.controlEnabledState(this.enabledHolder, panel, checkBox1);
- SWTTools.controlVisibleState(this.visibleHolder, panel);
- }
-
- private void buildControlPanel(Composite parent, Control widgetPanel) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(widgetPanel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildClearEnabledModelButton(panel);
- this.buildClearVisibleModelButton(panel);
- this.buildNullSelectionModelButton(panel);
- this.buildNextButton(panel);
- }
-
- private void buildClearEnabledModelButton(Composite parent) {
- this.buildClearEnabledModelACI().fill(parent);
- }
-
- private ActionContributionItem buildClearEnabledModelACI() {
- Action action = new Action("clear enabled model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- BooleanStateControllerUITest.this.clearEnabledModel();
- }
- };
- action.setToolTipText("clear enabled model");
- return new ActionContributionItem(action);
- }
-
- void clearEnabledModel() {
- this.enabledHolder.setValue(null);
- }
-
- private void buildClearVisibleModelButton(Composite parent) {
- this.buildClearVisibleModelACI().fill(parent);
- }
-
- private ActionContributionItem buildClearVisibleModelACI() {
- Action action = new Action("clear visible model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- BooleanStateControllerUITest.this.clearVisibleModel();
- }
- };
- action.setToolTipText("clear visible model");
- return new ActionContributionItem(action);
- }
-
- void clearVisibleModel() {
- this.visibleHolder.setValue(null);
- }
-
- private void buildNullSelectionModelButton(Composite parent) {
- this.buildNullSelectionModelACI().fill(parent);
- }
-
- private ActionContributionItem buildNullSelectionModelACI() {
- Action action = new Action("null selection model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- BooleanStateControllerUITest.this.setSelectionModelNull();
- }
- };
- action.setToolTipText("null selection model");
- return new ActionContributionItem(action);
- }
-
- void setSelectionModelNull() {
- this.listSelectionHolder.setValue(null);
- }
-
- private void buildNextButton(Composite parent) {
- this.buildNextACI().fill(parent);
- }
-
- private ActionContributionItem buildNextACI() {
- Action action = new Action("next", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- BooleanStateControllerUITest.this.next();
- }
- };
- action.setToolTipText("next");
- return new ActionContributionItem(action);
- }
-
- void next() {
- this.listSelectionHolder.setValue(this.getNextListSelection());
- }
-
- private String getNextListSelection() {
- return this.listHolder.get(this.getNextListSelectionIndex());
- }
-
- private int getNextListSelectionIndex() {
- int index = this.getListSelectionIndex();
- if (index == -1) {
- return 0;
- }
- index++;
- return (index == this.listHolder.size()) ? 0 : index;
- }
-
- private int getListSelectionIndex() {
- return this.listHolder.indexOf(this.getListSelection());
- }
-
- private String getListSelection() {
- return this.listSelectionHolder.getValue();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/CheckBoxModelBindingUITest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/CheckBoxModelBindingUITest.java
deleted file mode 100644
index 2f65e39f1b..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/CheckBoxModelBindingUITest.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.utility.swt;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Play around with a set of check boxes.
- */
-@SuppressWarnings("nls")
-public class CheckBoxModelBindingUITest
- extends ApplicationWindow
-{
- private final TestModel testModel;
- private final ModifiablePropertyValueModel<TestModel> testModelHolder;
- private final ModifiablePropertyValueModel<Boolean> flag1Holder;
- private final ModifiablePropertyValueModel<Boolean> flag2Holder;
- private final ModifiablePropertyValueModel<Boolean> notFlag2Holder;
-
- public static void main(String[] args) throws Exception {
- Window window = new CheckBoxModelBindingUITest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private CheckBoxModelBindingUITest(@SuppressWarnings("unused") String[] args) {
- super(null);
- this.testModel = new TestModel(true, true);
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.flag1Holder = this.buildFlag1Holder(this.testModelHolder);
- this.flag2Holder = this.buildFlag2Holder(this.testModelHolder);
- this.notFlag2Holder = this.buildNotFlag2Holder(this.testModelHolder);
- }
-
- private ModifiablePropertyValueModel<Boolean> buildFlag1Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.FLAG1_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isFlag1());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag1(value.booleanValue());
- }
- };
- }
-
- private ModifiablePropertyValueModel<Boolean> buildFlag2Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isFlag2());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag2(value.booleanValue());
- }
- };
- }
-
- private ModifiablePropertyValueModel<Boolean> buildNotFlag2Holder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Boolean>(subjectHolder, TestModel.NOT_FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isNotFlag2());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setNotFlag2(value.booleanValue());
- }
- };
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(this.getClass().getSimpleName());
- parent.setSize(400, 100);
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayout(new FormLayout());
- Control checkBoxPanel = this.buildCheckBoxPanel(mainPanel);
- this.buildControlPanel(mainPanel, checkBoxPanel);
- return mainPanel;
- }
-
- private Control buildCheckBoxPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100, -35);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildFlag1CheckBox(panel);
- this.buildFlag2CheckBox(panel);
- this.buildNotFlag2CheckBox(panel);
- this.buildUnattachedCheckBox(panel);
-
- return panel;
- }
-
- private void buildFlag1CheckBox(Composite parent) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText("flag 1");
- SWTTools.bind(this.flag1Holder, checkBox);
- }
-
- private void buildFlag2CheckBox(Composite parent) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText("flag 2");
- SWTTools.bind(this.flag2Holder, checkBox);
- }
-
- private void buildNotFlag2CheckBox(Composite parent) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText("not flag 2");
- SWTTools.bind(this.notFlag2Holder, checkBox);
- }
-
- private void buildUnattachedCheckBox(Composite parent) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText("unattached");
- checkBox.addSelectionListener(this.buildUnattachedSelectionListener());
- }
-
- private SelectionListener buildUnattachedSelectionListener() {
- return new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- System.out.println("unattached default selected: " + e);
- }
- public void widgetSelected(SelectionEvent e) {
- System.out.println("unattached selected: " + e);
- }
- };
- }
-
- private void buildControlPanel(Composite parent, Control checkBoxPanel) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(checkBoxPanel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildFlipFlag1Button(panel);
- this.buildNotFlag2ToggleButton(panel);
- this.buildClearModelButton(panel);
- this.buildRestoreModelButton(panel);
- this.buildPrintModelButton(panel);
- }
-
- private void buildFlipFlag1Button(Composite parent) {
- this.buildFlipFlag1ACI().fill(parent);
- }
-
- private ActionContributionItem buildFlipFlag1ACI() {
- Action action = new Action("flip flag 1", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- CheckBoxModelBindingUITest.this.flipFlag1();
- }
- };
- action.setToolTipText("flip flag 1");
- return new ActionContributionItem(action);
- }
-
- void flipFlag1() {
- this.testModel.setFlag1( ! this.testModel.isFlag1());
- }
-
- private void buildNotFlag2ToggleButton(Composite parent) {
- Button checkBox = new Button(parent, SWT.TOGGLE);
- checkBox.setText("not flag 2");
- SWTTools.bind(this.notFlag2Holder, checkBox);
- }
-
- private void buildClearModelButton(Composite parent) {
- this.buildClearModelACI().fill(parent);
- }
-
- private ActionContributionItem buildClearModelACI() {
- Action action = new Action("clear model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- CheckBoxModelBindingUITest.this.clearModel();
- }
- };
- action.setToolTipText("clear model");
- return new ActionContributionItem(action);
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private void buildRestoreModelButton(Composite parent) {
- this.buildRestoreModelACI().fill(parent);
- }
-
- private ActionContributionItem buildRestoreModelACI() {
- Action action = new Action("restore model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- CheckBoxModelBindingUITest.this.restoreModel();
- }
- };
- action.setToolTipText("restore model");
- return new ActionContributionItem(action);
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private void buildPrintModelButton(Composite parent) {
- this.buildPrintModelACI().fill(parent);
- }
-
- private ActionContributionItem buildPrintModelACI() {
- Action action = new Action("print model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- CheckBoxModelBindingUITest.this.printModel();
- }
- };
- action.setToolTipText("print model");
- return new ActionContributionItem(action);
- }
-
- void printModel() {
- System.out.println("flag 1: " + this.testModel.isFlag1());
- System.out.println("flag 2: " + this.testModel.isFlag2());
- System.out.println("not flag 2: " + this.testModel.isNotFlag2());
- System.out.println("***");
- }
-
-
- public static class TestModel extends AbstractModel {
- private boolean flag1;
- public static final String FLAG1_PROPERTY = "flag1";
- private boolean flag2;
- public static final String FLAG2_PROPERTY = "flag2";
- private boolean notFlag2;
- public static final String NOT_FLAG2_PROPERTY = "notFlag2";
-
- public TestModel(boolean flag1, boolean flag2) {
- this.flag1 = flag1;
- this.flag2 = flag2;
- this.notFlag2 = ! flag2;
- }
- public boolean isFlag1() {
- return this.flag1;
- }
- public void setFlag1(boolean flag1) {
- boolean old = this.flag1;
- this.flag1 = flag1;
- this.firePropertyChanged(FLAG1_PROPERTY, old, flag1);
- }
- public boolean isFlag2() {
- return this.flag2;
- }
- public void setFlag2(boolean flag2) {
- boolean old = this.flag2;
- this.flag2 = flag2;
- this.firePropertyChanged(FLAG2_PROPERTY, old, flag2);
-
- old = this.notFlag2;
- this.notFlag2 = ! flag2;
- this.firePropertyChanged(NOT_FLAG2_PROPERTY, old, this.notFlag2);
- }
- public boolean isNotFlag2() {
- return this.notFlag2;
- }
- public void setNotFlag2(boolean notFlag2) {
- this.setFlag2( ! notFlag2);
- }
- @Override
- public String toString() {
- return "TestModel(" + this.isFlag1() + " - " + this.isFlag2() + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/DropDownListBoxModelBindingUITest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/DropDownListBoxModelBindingUITest.java
deleted file mode 100644
index 041b48d31a..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/DropDownListBoxModelBindingUITest.java
+++ /dev/null
@@ -1,664 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.utility.swt;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Play around with a set of read-only combo-boxes.
- */
-@SuppressWarnings("nls")
-public class DropDownListBoxModelBindingUITest
- extends ApplicationWindow
-{
- final TaskList taskList;
- private final ModifiablePropertyValueModel<TaskList> taskListHolder;
- private Text taskTextField;
-
- public static void main(String[] args) throws Exception {
- Window window = new DropDownListBoxModelBindingUITest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private DropDownListBoxModelBindingUITest(@SuppressWarnings("unused") String[] args) {
- super(null);
- this.taskList = new TaskList();
- this.taskListHolder = new SimplePropertyValueModel<TaskList>(this.taskList);
- this.taskList.addTask("swim");
- this.taskList.addTask("bike");
- this.taskList.addTask("run");
- Task rest = this.taskList.addTask("rest");
- this.taskList.addTask("repeat");
- this.taskList.setPriorityTask(rest);
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(this.getClass().getSimpleName());
- parent.setSize(800, 300);
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayout(new FormLayout());
- Control taskListPanel = this.buildTaskListPanel(mainPanel);
- this.buildControlPanel(mainPanel, taskListPanel);
- return mainPanel;
- }
-
- private Control buildTaskListPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100, -30);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FormLayout());
- this.buildTaskListPanel_(panel); // false = native (Combo)
-
- return panel;
- }
-
- private Control buildTaskListPanel_(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(50);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FormLayout());
- this.buildPrimitiveTaskListPanel(panel);
- this.buildObjectTaskListPanel(panel);
-
- return panel;
- }
-
- private void buildPrimitiveTaskListPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(50);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildUnsortedPrimitiveListPanel(panel);
- this.buildStandardSortedPrimitiveListPanel(panel);
- this.buildCustomSortedPrimitiveListPanel(panel);
- }
-
- private void buildObjectTaskListPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(50);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildUnsortedObjectListPanel(panel);
- this.buildStandardSortedObjectListPanel(panel);
- this.buildCustomSortedObjectListPanel(panel);
- }
-
- private void buildUnsortedPrimitiveListPanel(Composite parent) {
- String label = "primitive unsorted";
- this.buildComboBoxPanel(parent, label, this.buildUnsortedPrimitiveListModel(), this.buildPriorityTaskNameAdapter());
- }
-
- private void buildStandardSortedPrimitiveListPanel(Composite parent) {
- String label = "primitive sorted";
- this.buildComboBoxPanel(parent, label, this.buildStandardSortedPrimitiveListModel(), this.buildPriorityTaskNameAdapter());
- }
-
- private void buildCustomSortedPrimitiveListPanel(Composite parent) {
- String label = "primitive reverse sorted";
- this.buildComboBoxPanel(parent, label, this.buildCustomSortedPrimitiveListModel(), this.buildPriorityTaskNameAdapter());
- }
-
- private void buildUnsortedObjectListPanel(Composite parent) {
- String label = "object unsorted";
- this.buildComboBoxPanel(parent, label, this.buildUnsortedObjectListModel(), this.buildPriorityTaskAdapter());
- }
-
- private void buildStandardSortedObjectListPanel(Composite parent) {
- String label = "object sorted";
- this.buildComboBoxPanel(parent, label, this.buildStandardSortedObjectListModel(), this.buildPriorityTaskAdapter());
- }
-
- private void buildCustomSortedObjectListPanel(Composite parent) {
- String label = "object reverse sorted";
- this.buildComboBoxPanel(parent, label, this.buildCustomSortedObjectListModel(), this.buildPriorityTaskAdapter());
- }
-
- private ListValueModel<String> buildUnsortedPrimitiveListModel() {
- return this.buildPrimitiveTaskListAdapter();
- }
-
- private ListValueModel<String> buildStandardSortedPrimitiveListModel() {
- return new SortedListValueModelWrapper<String>(this.buildPrimitiveTaskListAdapter());
- }
-
- private ListValueModel<String> buildCustomSortedPrimitiveListModel() {
- return new SortedListValueModelWrapper<String>(this.buildPrimitiveTaskListAdapter(), this.buildCustomStringComparator());
- }
-
- private ListValueModel<Task> buildUnsortedObjectListModel() {
- return this.buildObjectTaskListAdapter();
- }
-
- private ListValueModel<Task> buildStandardSortedObjectListModel() {
- return new SortedListValueModelWrapper<Task>(this.buildObjectTaskListAdapter());
- }
-
- private ListValueModel<Task> buildCustomSortedObjectListModel() {
- return new SortedListValueModelWrapper<Task>(this.buildObjectTaskListAdapter(), this.buildCustomTaskComparator());
- }
-
- private <E> void buildComboBoxPanel(Composite parent, String label, ListValueModel<E> model, ModifiablePropertyValueModel<E> selectedItemModel) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayout(new FormLayout());
-
- Label comboBoxLabel = new Label(panel, SWT.LEFT | SWT.VERTICAL);
- comboBoxLabel.setText(label);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0, 3);
- fd.bottom = new FormAttachment(0, 20);
- fd.left = new FormAttachment(0, 5);
- fd.right = new FormAttachment(100);
- comboBoxLabel.setLayoutData(fd);
-
- Combo comboBox = this.buildComboBox(panel);
- fd = new FormData();
- fd.top = new FormAttachment(comboBoxLabel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- comboBox.setLayoutData(fd);
- SWTTools.bind(model, selectedItemModel, comboBox); // use #toString()
- }
-
- private Combo buildComboBox(Composite parent) {
- return new Combo(parent, SWT.READ_ONLY);
- }
-
- private Comparator<String> buildCustomStringComparator() {
- return new Comparator<String>() {
- public int compare(String s1, String s2) {
- return s2.compareTo(s1);
- }
- };
- }
-
- private Comparator<Task> buildCustomTaskComparator() {
- return new Comparator<Task>() {
- public int compare(Task to1, Task to2) {
- return to2.compareTo(to1);
- }
- };
- }
-
- private ListValueModel<String> buildPrimitiveTaskListAdapter() {
- return new ListAspectAdapter<TaskList, String>(this.taskListHolder, TaskList.TASK_NAMES_LIST) {
- @Override
- protected ListIterator<String> listIterator_() {
- return this.subject.taskNames();
- }
- };
- }
-
- private ListValueModel<Task> buildObjectTaskListAdapter() {
- return new ListAspectAdapter<TaskList, Task>(this.taskListHolder, TaskList.TASKS_LIST) {
- @Override
- protected ListIterator<Task> listIterator_() {
- return this.subject.tasks();
- }
- };
- }
-
- private ModifiablePropertyValueModel<Task> buildPriorityTaskAdapter() {
- return new PriorityTaskAdapter(this.taskListHolder);
- }
-
- static class PriorityTaskAdapter
- extends PropertyAspectAdapter<TaskList, Task>
- {
- PriorityTaskAdapter(ModifiablePropertyValueModel<TaskList> taskListHolder) {
- super(taskListHolder, TaskList.PRIORITY_TASK_PROPERTY);
- }
- @Override
- protected Task buildValue_() {
- return this.subject.getPriorityTask();
- }
- @Override
- protected void setValue_(Task value) {
- this.subject.setPriorityTask(value);
- }
- }
-
- private ModifiablePropertyValueModel<String> buildPriorityTaskNameAdapter() {
- return new PriorityTaskNameAdapter(this.taskListHolder);
- }
-
- static class PriorityTaskNameAdapter
- extends PropertyAspectAdapter<TaskList, String>
- {
- PriorityTaskNameAdapter(ModifiablePropertyValueModel<TaskList> taskListHolder) {
- super(taskListHolder, TaskList.PRIORITY_TASK_NAME_PROPERTY);
- }
- @Override
- protected String buildValue_() {
- return this.subject.getPriorityTaskName();
- }
- @Override
- protected void setValue_(String value) {
- // ignore
- }
- }
-
- private void buildControlPanel(Composite parent, Control taskListPanel) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(taskListPanel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FormLayout());
- Control misc = this.buildMiscTaskPanel(panel);
- this.buildAddRemoveTaskPanel(panel, misc);
- }
-
- // is there a better way to associate an ACI with form data?
- private Control buildMiscTaskPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(100, -400);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildClearListACI().fill(panel);
- this.buildClearModelACI().fill(panel);
- this.buildRestoreModelACI().fill(panel);
- this.buildChangePriorityTaskACI().fill(panel);
- this.buildClearPriorityTaskACI().fill(panel);
- return panel;
- }
-
- private ActionContributionItem buildClearListACI() {
- Action action = new Action("clear list", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- DropDownListBoxModelBindingUITest.this.clearTasks();
- }
- };
- action.setToolTipText("clear all the tasks");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildClearModelACI() {
- Action action = new Action("clear model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- DropDownListBoxModelBindingUITest.this.clearModel();
- }
- };
- action.setToolTipText("clear the task list model");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildRestoreModelACI() {
- Action action = new Action("restore model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- DropDownListBoxModelBindingUITest.this.restoreModel();
- }
- };
- action.setToolTipText("restore the task list model");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildChangePriorityTaskACI() {
- Action action = new Action("change priority", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- DropDownListBoxModelBindingUITest.this.changePriorityTask();
- }
- };
- action.setToolTipText("change the priority task");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildClearPriorityTaskACI() {
- Action action = new Action("clear priority", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- DropDownListBoxModelBindingUITest.this.clearPriorityTask();
- }
- };
- action.setToolTipText("clear the priority task");
- return new ActionContributionItem(action);
- }
-
- private void buildAddRemoveTaskPanel(Composite parent, Control clearButton) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(clearButton);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FormLayout());
- Control addButton = this.buildAddButton(panel);
- Control removeButton = this.buildRemoveButton(panel);
- this.buildTaskTextField(panel, addButton, removeButton);
- }
-
- // is there a better way to associate an ACI with form data?
- private Control buildAddButton(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(0, 50);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildAddACI().fill(panel);
- return panel;
- }
-
- private ActionContributionItem buildAddACI() {
- Action action = new Action("add", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- DropDownListBoxModelBindingUITest.this.addTask();
- }
- };
- action.setToolTipText("add a task with the name in the entry field");
- return new ActionContributionItem(action);
- }
-
- // is there a better way to associate an ACI with form data?
- private Control buildRemoveButton(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(100, -50);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildRemoveACI().fill(panel);
- return panel;
- }
-
- private ActionContributionItem buildRemoveACI() {
- Action action = new Action("remove", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- DropDownListBoxModelBindingUITest.this.removeTask();
- }
- };
- action.setToolTipText("remove the task with the name in the entry field");
- return new ActionContributionItem(action);
- }
-
- private void buildTaskTextField(Composite parent, Control addButton, Control removeButton) {
- this.taskTextField = new Text(parent, SWT.SINGLE | SWT.BORDER);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(addButton);
- fd.right = new FormAttachment(removeButton);
- this.taskTextField.setLayoutData(fd);
- }
-
- private String taskTextFieldText() {
- return this.taskTextField.getText();
- }
-
- void addTask() {
- String taskText = this.taskTextFieldText();
- if (taskText.length() != 0) {
- this.taskList.addTask(taskText);
- }
- }
-
- void removeTask() {
- String task = this.taskTextFieldText();
- if (task.length() != 0) {
- this.taskList.removeTask(task);
- }
- }
-
- void clearTasks() {
- this.taskList.clearTasks();
- }
-
- void clearModel() {
- this.taskListHolder.setValue(null);
- }
-
- void restoreModel() {
- this.taskListHolder.setValue(this.taskList);
- }
-
- void changePriorityTask() {
- boolean found = false;
- for (Task task : this.taskList.getTasks()) {
- if (this.taskList.getPriorityTask() == task) {
- found = true;
- } else {
- if (found) {
- this.taskList.setPriorityTask(task);
- return;
- }
- }
- }
- Iterator<Task> tasks = this.taskList.tasks();
- if (tasks.hasNext()) {
- this.taskList.setPriorityTask(tasks.next());
- }
- }
-
- void clearPriorityTask() {
- this.taskList.setPriorityTask(null);
- }
-
-
- // ********** TaskList **********
-
- // note absence of validation...
- public static class TaskList extends AbstractModel {
- private final List<String> taskNames = new ArrayList<String>();
- public static final String TASK_NAMES_LIST = "taskNames";
- private final List<Task> tasks = new ArrayList<Task>();
- public static final String TASKS_LIST = "tasks";
- private String priorityTaskName = null;
- public static final String PRIORITY_TASK_NAME_PROPERTY = "priorityTaskName";
- private Task priorityTask = null;
- public static final String PRIORITY_TASK_PROPERTY = "priorityTask";
- public TaskList() {
- super();
- }
- public ListIterator<String> taskNames() {
- return this.taskNames.listIterator();
- }
- public Iterable<Task> getTasks() {
- return this.tasks;
- }
- public ListIterator<Task> tasks() {
- return this.tasks.listIterator();
- }
- public String getPriorityTaskName() {
- return this.priorityTaskName;
- }
- public Task getPriorityTask() {
- return this.priorityTask;
- }
- public Task addTask(String taskName) {
- this.addItemToList(taskName, this.taskNames, TASK_NAMES_LIST);
- Task task = new Task(taskName);
- this.addItemToList(task, this.tasks, TASKS_LIST);
- return task;
- }
- public void removeTask(String taskName) {
- int index = this.taskNames.indexOf(taskName);
- if (index != -1) {
- Task task = this.tasks.get(index);
- if (task == this.priorityTask) {
- this.setPriorityTask(null);
- }
- // assume the indexes match...
- this.removeItemFromList(index, this.taskNames, TASK_NAMES_LIST);
- this.removeItemFromList(index, this.tasks, TASKS_LIST);
- }
- }
- public void clearTasks() {
- this.setPriorityTask(null);
- this.clearList(this.taskNames, TASK_NAMES_LIST);
- this.clearList(this.tasks, TASKS_LIST);
- }
- private void setPriorityTaskName(String priorityTaskName) {
- String old = this.priorityTaskName;
- this.priorityTaskName = priorityTaskName;
- this.firePropertyChanged(PRIORITY_TASK_NAME_PROPERTY, old, priorityTaskName);
- }
- public void setPriorityTask(Task priorityTask) {
- Task old = this.priorityTask;
- this.priorityTask = priorityTask;
- this.firePropertyChanged(PRIORITY_TASK_PROPERTY, old, priorityTask);
- this.setPriorityTaskName((priorityTask == null) ? null : priorityTask.getName());
- }
- }
-
-
- // ********** Task **********
-
- public static class Task extends AbstractModel implements Displayable {
- private String name;
- private int instanceCount;
- private static int INSTANCE_COUNT = 1;
- public Task(String name) {
- this.name = name;
- this.instanceCount = INSTANCE_COUNT++;
- }
- public String displayString() {
- return this.name + ": " + this.instanceCount;
- }
- public int compareTo(Displayable o) {
- return DEFAULT_COMPARATOR.compare(this, o);
- }
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(DISPLAY_STRING_PROPERTY, old, name);
- }
- @Override
- public String toString() {
- return this.displayString();
- }
- }
-
- public interface Displayable extends Model, Comparable<Displayable> {
-
- String displayString();
- String DISPLAY_STRING_PROPERTY = "displayString";
-
-
- // ********** helper implementations **********
-
- Collator DEFAULT_COLLATOR = Collator.getInstance();
-
- Comparator<Displayable> DEFAULT_COMPARATOR =
- new Comparator<Displayable>() {
- public int compare(Displayable d1, Displayable d2) {
- // disallow duplicates based on object identity
- if (d1 == d2) {
- return 0;
- }
-
- // first compare display strings using the default collator
- int result = DEFAULT_COLLATOR.compare(d1.displayString(), d2.displayString());
- if (result != 0) {
- return result;
- }
-
- // then compare using object-id
- result = System.identityHashCode(d1) - System.identityHashCode(d2);
- if (result != 0) {
- return result;
- }
-
- // It's unlikely that we get to this point; but, just in case, we will return -1.
- // Unfortunately, this introduces some mild unpredictability to the sort order
- // (unless the objects are always passed into this method in the same order).
- return -1; // if all else fails, indicate that o1 < o2
- }
- @Override
- public String toString() {
- return "Displayable.DEFAULT_COMPARATOR";
- }
- };
-
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/ListBoxModelBindingUITest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/ListBoxModelBindingUITest.java
deleted file mode 100644
index 6ae7c792f6..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/ListBoxModelBindingUITest.java
+++ /dev/null
@@ -1,626 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.utility.swt;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Play around with a set of list boxes.
- */
-@SuppressWarnings("nls")
-public class ListBoxModelBindingUITest
- extends ApplicationWindow
-{
- final TaskList taskList;
- private final ModifiablePropertyValueModel<TaskList> taskListHolder;
- private Text taskTextField;
-
- public static void main(String[] args) throws Exception {
- Window window = new ListBoxModelBindingUITest(args);
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private ListBoxModelBindingUITest(@SuppressWarnings("unused") String[] args) {
- super(null);
- this.taskList = new TaskList();
- this.taskListHolder = new SimplePropertyValueModel<TaskList>(this.taskList);
- this.taskList.addTask("swim");
- this.taskList.addTask("bike");
- this.taskList.addTask("run");
- Task rest = this.taskList.addTask("rest");
- this.taskList.addPriorityTask(rest);
- Task repeat = this.taskList.addTask("repeat");
- this.taskList.addPriorityTask(repeat);
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(this.getClass().getSimpleName());
- parent.setSize(800, 400);
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayout(new FormLayout());
- Control taskListPanel = this.buildTaskListPanel(mainPanel);
- this.buildControlPanel(mainPanel, taskListPanel);
- return mainPanel;
- }
-
- private Control buildTaskListPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100, -30);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FormLayout());
- this.buildPrimitiveTaskListPanel(panel);
- this.buildObjectTaskListPanel(panel);
-
- return panel;
- }
-
- private void buildPrimitiveTaskListPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(50);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildUnsortedPrimitiveListPanel(panel);
- this.buildStandardSortedPrimitiveListPanel(panel);
- this.buildCustomSortedPrimitiveListPanel(panel);
- }
-
- private void buildObjectTaskListPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(50);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildUnsortedObjectListPanel(panel);
- this.buildStandardSortedObjectListPanel(panel);
- this.buildCustomSortedObjectListPanel(panel);
- }
-
- private void buildUnsortedPrimitiveListPanel(Composite parent) {
- this.buildListPanel(parent, "primitive unsorted", this.buildUnsortedPrimitiveListModel(), new SimpleCollectionValueModel<String>());
- }
-
- private void buildStandardSortedPrimitiveListPanel(Composite parent) {
- this.buildListPanel(parent, "primitive sorted", this.buildStandardSortedPrimitiveListModel(), new SimpleCollectionValueModel<String>());
- }
-
- private void buildCustomSortedPrimitiveListPanel(Composite parent) {
- this.buildListPanel(parent, "primitive reverse sorted", this.buildCustomSortedPrimitiveListModel(), new SimpleCollectionValueModel<String>());
- }
-
- private void buildUnsortedObjectListPanel(Composite parent) {
- this.buildListPanel(parent, "object unsorted", this.buildUnsortedObjectListModel(), this.buildPriorityTaskListAdapter());
- }
-
- private void buildStandardSortedObjectListPanel(Composite parent) {
- this.buildListPanel(parent, "object sorted", this.buildStandardSortedObjectListModel(), this.buildPriorityTaskListAdapter());
- }
-
- private void buildCustomSortedObjectListPanel(Composite parent) {
- this.buildListPanel(parent, "object reverse sorted", this.buildCustomSortedObjectListModel(), this.buildPriorityTaskListAdapter());
- }
-
- private ListValueModel<String> buildUnsortedPrimitiveListModel() {
- return this.buildPrimitiveTaskListAdapter();
- }
-
- private ListValueModel<String> buildStandardSortedPrimitiveListModel() {
- return new SortedListValueModelWrapper<String>(this.buildPrimitiveTaskListAdapter());
- }
-
- private ListValueModel<String> buildCustomSortedPrimitiveListModel() {
- return new SortedListValueModelWrapper<String>(this.buildPrimitiveTaskListAdapter(), this.buildCustomStringComparator());
- }
-
- private ListValueModel<Task> buildUnsortedObjectListModel() {
- return this.buildObjectTaskListAdapter();
- }
-
- private ListValueModel<Task> buildStandardSortedObjectListModel() {
- return new SortedListValueModelWrapper<Task>(this.buildObjectTaskListAdapter());
- }
-
- private ListValueModel<Task> buildCustomSortedObjectListModel() {
- return new SortedListValueModelWrapper<Task>(this.buildObjectTaskListAdapter(), this.buildCustomTaskComparator());
- }
-
- private <E> org.eclipse.swt.widgets.List buildListPanel(Composite parent, String label, ListValueModel<E> model, ModifiableCollectionValueModel<E> selectedItemsModel) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayout(new FormLayout());
-
- Label listLabel = new Label(panel, SWT.LEFT | SWT.VERTICAL);
- listLabel.setText(label);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0, 3);
- fd.bottom = new FormAttachment(0, 20);
- fd.left = new FormAttachment(0, 5);
- fd.right = new FormAttachment(100);
- listLabel.setLayoutData(fd);
-
- org.eclipse.swt.widgets.List listBox = new org.eclipse.swt.widgets.List(panel, SWT.MULTI | SWT.BORDER);
- fd = new FormData();
- fd.top = new FormAttachment(listLabel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- listBox.setLayoutData(fd);
- SWTTools.bind(model, selectedItemsModel, listBox); // use #toString()
- return listBox;
- }
-
- private Comparator<String> buildCustomStringComparator() {
- return new Comparator<String>() {
- public int compare(String s1, String s2) {
- return s2.compareTo(s1);
- }
- };
- }
-
- private Comparator<Task> buildCustomTaskComparator() {
- return new Comparator<Task>() {
- public int compare(Task to1, Task to2) {
- return to2.compareTo(to1);
- }
- };
- }
-
- private ListValueModel<String> buildPrimitiveTaskListAdapter() {
- return new ListAspectAdapter<TaskList, String>(this.taskListHolder, TaskList.TASK_NAMES_LIST) {
- @Override
- protected ListIterator<String> listIterator_() {
- return this.subject.taskNames();
- }
- };
- }
-
- private ListValueModel<Task> buildObjectTaskListAdapter() {
- return new ListAspectAdapter<TaskList, Task>(this.taskListHolder, TaskList.TASKS_LIST) {
- @Override
- protected ListIterator<Task> listIterator_() {
- return this.subject.tasks();
- }
- };
- }
-
- private ModifiableCollectionValueModel<Task> buildPriorityTaskListAdapter() {
- return new PriorityTaskListAdapter(this.taskListHolder);
- }
-
- static class PriorityTaskListAdapter
- extends CollectionAspectAdapter<TaskList, Task>
- implements ModifiableCollectionValueModel<Task>
- {
- PriorityTaskListAdapter(ModifiablePropertyValueModel<TaskList> taskListHolder) {
- super(taskListHolder, TaskList.PRIORITY_TASKS_COLLECTION);
- }
- @Override
- protected Iterator<Task> iterator_() {
- return this.subject.priorityTasks();
- }
- public void setValues(Iterable<Task> values) {
- this.subject.setPriorityTasks(values);
- }
- }
-
- private void buildControlPanel(Composite parent, Control taskListPanel) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(taskListPanel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FormLayout());
- Control misc = this.buildMiscTaskPanel(panel);
- this.buildAddRemoveTaskPanel(panel, misc);
- }
-
- // is there a better way to associate an ACI with form data?
- private Control buildMiscTaskPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(100, -400);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildClearListACI().fill(panel);
- this.buildClearModelACI().fill(panel);
- this.buildRestoreModelACI().fill(panel);
- this.buildAddPriorityTaskACI().fill(panel);
- this.buildRemovePriorityTaskACI().fill(panel);
- this.buildClearPriorityTasksACI().fill(panel);
- return panel;
- }
-
- private ActionContributionItem buildClearListACI() {
- Action action = new Action("clear list", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelBindingUITest.this.clearTasks();
- }
- };
- action.setToolTipText("clear all the tasks");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildClearModelACI() {
- Action action = new Action("clear model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelBindingUITest.this.clearModel();
- }
- };
- action.setToolTipText("clear the task list model");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildRestoreModelACI() {
- Action action = new Action("restore model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelBindingUITest.this.restoreModel();
- }
- };
- action.setToolTipText("restore the task list model");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildAddPriorityTaskACI() {
- Action action = new Action("add priority", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelBindingUITest.this.addPriorityTask();
- }
- };
- action.setToolTipText("add a task to the priority tasks");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildRemovePriorityTaskACI() {
- Action action = new Action("remove priority", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelBindingUITest.this.removePriorityTask();
- }
- };
- action.setToolTipText("remove a task from the priority tasks");
- return new ActionContributionItem(action);
- }
-
- private ActionContributionItem buildClearPriorityTasksACI() {
- Action action = new Action("clear priority", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelBindingUITest.this.clearPriorityTasks();
- }
- };
- action.setToolTipText("clear the priority tasks");
- return new ActionContributionItem(action);
- }
-
- private void buildAddRemoveTaskPanel(Composite parent, Control clearButton) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(clearButton);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FormLayout());
- Control addButton = this.buildAddButton(panel);
- Control removeButton = this.buildRemoveButton(panel);
- this.buildTaskTextField(panel, addButton, removeButton);
- }
-
- // is there a better way to associate an ACI with form data?
- private Control buildAddButton(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(0, 50);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildAddACI().fill(panel);
- return panel;
- }
-
- private ActionContributionItem buildAddACI() {
- Action action = new Action("add", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelBindingUITest.this.addTask();
- }
- };
- action.setToolTipText("add a task with the name in the entry field");
- return new ActionContributionItem(action);
- }
-
- // is there a better way to associate an ACI with form data?
- private Control buildRemoveButton(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(100, -50);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildRemoveACI().fill(panel);
- return panel;
- }
-
- private ActionContributionItem buildRemoveACI() {
- Action action = new Action("remove", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- ListBoxModelBindingUITest.this.removeTask();
- }
- };
- action.setToolTipText("remove the task with the name in the entry field");
- return new ActionContributionItem(action);
- }
-
- private void buildTaskTextField(Composite parent, Control addButton, Control removeButton) {
- this.taskTextField = new Text(parent, SWT.SINGLE | SWT.BORDER);
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(addButton);
- fd.right = new FormAttachment(removeButton);
- this.taskTextField.setLayoutData(fd);
- }
-
- private String taskTextFieldText() {
- return this.taskTextField.getText();
- }
-
- void addTask() {
- String taskText = this.taskTextFieldText();
- if (taskText.length() != 0) {
- this.taskList.addTask(taskText);
- }
- }
-
- void removeTask() {
- String task = this.taskTextFieldText();
- if (task.length() != 0) {
- this.taskList.removeTask(task);
- }
- }
-
- void clearTasks() {
- this.taskList.clearTasks();
- }
-
- void clearModel() {
- this.taskListHolder.setValue(null);
- }
-
- void restoreModel() {
- this.taskListHolder.setValue(this.taskList);
- }
-
- void addPriorityTask() {
- Iterator<Task> tasks = this.taskList.tasks();
- while (tasks.hasNext()) {
- if (this.taskList.addPriorityTask(tasks.next())) {
- return;
- }
- }
- }
-
- void removePriorityTask() {
- Iterator<Task> pTasks = this.taskList.priorityTasks();
- if (pTasks.hasNext()) {
- this.taskList.removePriorityTask(pTasks.next());
- }
- }
-
- void clearPriorityTasks() {
- this.taskList.clearPriorityTasks();
- }
-
-
- // ********** TaskList **********
-
- // note absence of validation...
- public static class TaskList extends AbstractModel {
- private final List<String> taskNames = new ArrayList<String>();
- public static final String TASK_NAMES_LIST = "taskNames";
- private final List<Task> tasks = new ArrayList<Task>();
- public static final String TASKS_LIST = "tasks";
- private final Collection<Task> priorityTasks = new HashSet<Task>();
- public static final String PRIORITY_TASKS_COLLECTION = "priorityTasks";
- public TaskList() {
- super();
- }
- public ListIterator<String> taskNames() {
- return this.taskNames.listIterator();
- }
- public ListIterator<Task> tasks() {
- return this.tasks.listIterator();
- }
- public Iterator<Task> priorityTasks() {
- return this.priorityTasks.iterator();
- }
- public Task addTask(String taskName) {
- this.addItemToList(taskName, this.taskNames, TASK_NAMES_LIST);
- Task task = new Task(taskName);
- this.addItemToList(task, this.tasks, TASKS_LIST);
- return task;
- }
- public void removeTask(String taskName) {
- int index = this.taskNames.indexOf(taskName);
- if (index != -1) {
- this.removeItemFromList(index, this.taskNames, TASK_NAMES_LIST);
- // assume the indexes match...
- Task removedTask = this.removeItemFromList(index, this.tasks, TASKS_LIST);
- this.removeItemFromCollection(removedTask, this.priorityTasks, PRIORITY_TASKS_COLLECTION);
- }
- }
- public void clearTasks() {
- this.clearCollection(this.priorityTasks, PRIORITY_TASKS_COLLECTION);
- this.clearList(this.taskNames, TASK_NAMES_LIST);
- this.clearList(this.tasks, TASKS_LIST);
- }
- public boolean addPriorityTask(Task task) {
- return this.addItemToCollection(task, this.priorityTasks, PRIORITY_TASKS_COLLECTION);
- }
- public void removePriorityTask(Task task) {
- this.removeItemFromCollection(task, this.priorityTasks, PRIORITY_TASKS_COLLECTION);
- }
- public void clearPriorityTasks() {
- this.clearCollection(this.priorityTasks, PRIORITY_TASKS_COLLECTION);
- }
- public void setPriorityTasks(Iterable<Task> tasks) {
- this.priorityTasks.clear();
- CollectionTools.addAll(this.priorityTasks, tasks);
- this.fireCollectionChanged(PRIORITY_TASKS_COLLECTION, this.priorityTasks);
- }
- }
-
-
- // ********** Task **********
-
- public static class Task extends AbstractModel implements Displayable {
- private String name;
- private int instanceCount;
- private static int INSTANCE_COUNT = 1;
- public Task(String name) {
- this.name = name;
- this.instanceCount = INSTANCE_COUNT++;
- }
- public String displayString() {
- return this.name + ": " + this.instanceCount;
- }
- public int compareTo(Displayable o) {
- return DEFAULT_COMPARATOR.compare(this, o);
- }
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(DISPLAY_STRING_PROPERTY, old, name);
- }
- @Override
- public String toString() {
- return this.displayString();
- }
- }
-
- public interface Displayable extends Model, Comparable<Displayable> {
-
- String displayString();
- String DISPLAY_STRING_PROPERTY = "displayString";
-
-
- // ********** helper implementations **********
-
- Collator DEFAULT_COLLATOR = Collator.getInstance();
-
- Comparator<Displayable> DEFAULT_COMPARATOR =
- new Comparator<Displayable>() {
- public int compare(Displayable d1, Displayable d2) {
- // disallow duplicates based on object identity
- if (d1 == d2) {
- return 0;
- }
-
- // first compare display strings using the default collator
- int result = DEFAULT_COLLATOR.compare(d1.displayString(), d2.displayString());
- if (result != 0) {
- return result;
- }
-
- // then compare using object-id
- result = System.identityHashCode(d1) - System.identityHashCode(d2);
- if (result != 0) {
- return result;
- }
-
- // It's unlikely that we get to this point; but, just in case, we will return -1.
- // Unfortunately, this introduces some mild unpredictability to the sort order
- // (unless the objects are always passed into this method in the same order).
- return -1; // if all else fails, indicate that o1 < o2
- }
- @Override
- public String toString() {
- return "Displayable.DEFAULT_COMPARATOR";
- }
- };
-
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/TextFieldModelBindingUITest.java b/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/TextFieldModelBindingUITest.java
deleted file mode 100644
index efc476ad4a..0000000000
--- a/common/tests/org.eclipse.jpt.common.ui.tests/src/org/eclipse/jpt/common/ui/tests/internal/utility/swt/TextFieldModelBindingUITest.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.ui.tests.internal.utility.swt;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jpt.common.ui.internal.utility.swt.SWTTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Play around with a set of entry fields.
- */
-@SuppressWarnings("nls")
-public class TextFieldModelBindingUITest
- extends ApplicationWindow
-{
- private final TestModel testModel;
- private static final String DEFAULT_NAME = "Scooby Doo";
- private final ModifiablePropertyValueModel<TestModel> testModelHolder;
- private final ModifiablePropertyValueModel<String> nameHolder;
- private final ModifiablePropertyValueModel<String> allCapsNameHolder;
-
-
- public static void main(String[] args) throws Exception {
- Window window = new TextFieldModelBindingUITest();
- window.setBlockOnOpen(true);
- window.open();
- Display.getCurrent().dispose();
- System.exit(0);
- }
-
- private TextFieldModelBindingUITest() {
- super(null);
- this.testModel = new TestModel(DEFAULT_NAME);
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.nameHolder = this.buildNameHolder(this.testModelHolder);
- this.allCapsNameHolder = this.buildAllCapsNameHolder(this.testModelHolder);
- }
-
- private ModifiablePropertyValueModel<String> buildNameHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, String>(vm, TestModel.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.name();
- }
- @Override
- protected void setValue_(String value) {
- this.subject.setName(value);
- }
- };
- }
-
- private ModifiablePropertyValueModel<String> buildAllCapsNameHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, String>(vm, TestModel.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.name().toUpperCase();
- }
- @Override
- protected void setValue_(String value) {
- // do nothing
- }
- };
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ((Shell) parent).setText(this.getClass().getSimpleName());
- parent.setSize(400, 100);
- Composite mainPanel = new Composite(parent, SWT.NONE);
- mainPanel.setLayout(new FormLayout());
- Control textFieldPanel = this.buildTextFieldPanel(mainPanel);
- this.buildControlPanel(mainPanel, textFieldPanel);
- return mainPanel;
- }
-
- private Control buildTextFieldPanel(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
-
- FormData fd = new FormData();
- fd.top = new FormAttachment(0);
- fd.bottom = new FormAttachment(100, -35);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildNameTextField(panel);
- this.buildReadOnlyNameTextField(panel);
- this.buildAllCapsNameTextField(panel);
-
- return panel;
- }
-
- private void buildNameTextField(Composite parent) {
- Text textField = new Text(parent, SWT.SINGLE);
- SWTTools.bind(this.nameHolder, textField);
- }
-
- private void buildReadOnlyNameTextField(Composite parent) {
- Text textField = new Text(parent, SWT.SINGLE);
- textField.setEnabled(false);
- SWTTools.bind(this.nameHolder, textField);
- }
-
- private void buildAllCapsNameTextField(Composite parent) {
- Text textField = new Text(parent, SWT.SINGLE);
- textField.setEnabled(false);
- SWTTools.bind(this.allCapsNameHolder, textField);
- }
-
- private void buildControlPanel(Composite parent, Control checkBoxPanel) {
- Composite panel = new Composite(parent, SWT.NONE);
- FormData fd = new FormData();
- fd.top = new FormAttachment(checkBoxPanel);
- fd.bottom = new FormAttachment(100);
- fd.left = new FormAttachment(0);
- fd.right = new FormAttachment(100);
- panel.setLayoutData(fd);
-
- panel.setLayout(new FillLayout());
- this.buildResetNameButton(panel);
- this.buildClearModelButton(panel);
- this.buildRestoreModelButton(panel);
- this.buildPrintModelButton(panel);
- }
-
- private void buildResetNameButton(Composite parent) {
- this.buildResetNameACI().fill(parent);
- }
-
- private ActionContributionItem buildResetNameACI() {
- Action action = new Action("reset name", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TextFieldModelBindingUITest.this.resetName();
- }
- };
- action.setToolTipText("reset name");
- return new ActionContributionItem(action);
- }
-
- void resetName() {
- this.testModel.setName(DEFAULT_NAME);
- }
-
- private void buildClearModelButton(Composite parent) {
- this.buildClearModelACI().fill(parent);
- }
-
- private ActionContributionItem buildClearModelACI() {
- Action action = new Action("clear model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TextFieldModelBindingUITest.this.clearModel();
- }
- };
- action.setToolTipText("clear model");
- return new ActionContributionItem(action);
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private void buildRestoreModelButton(Composite parent) {
- this.buildRestoreModelACI().fill(parent);
- }
-
- private ActionContributionItem buildRestoreModelACI() {
- Action action = new Action("restore model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TextFieldModelBindingUITest.this.restoreModel();
- }
- };
- action.setToolTipText("restore model");
- return new ActionContributionItem(action);
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private void buildPrintModelButton(Composite parent) {
- this.buildPrintModelACI().fill(parent);
- }
-
- private ActionContributionItem buildPrintModelACI() {
- Action action = new Action("print model", IAction.AS_PUSH_BUTTON) {
- @Override
- public void run() {
- TextFieldModelBindingUITest.this.printModel();
- }
- };
- action.setToolTipText("print model");
- return new ActionContributionItem(action);
- }
-
- void printModel() {
- System.out.println("name: " + this.testModel.name());
- }
-
-
- // ********** model class **********
-
- class TestModel extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- public TestModel(String name) {
- this.name = name;
- }
- public String name() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
- @Override
- public String toString() {
- return "TestModel(" + this.name + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/.classpath b/common/tests/org.eclipse.jpt.common.utility.tests/.classpath
deleted file mode 100644
index 5c128f330d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
- <accessrules>
- <accessrule kind="accessible" pattern="org/eclipse/jpt/common/utility/**"/>
- </accessrules>
- </classpathentry>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/.cvsignore b/common/tests/org.eclipse.jpt.common.utility.tests/.cvsignore
deleted file mode 100644
index ba077a4031..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/.project b/common/tests/org.eclipse.jpt.common.utility.tests/.project
deleted file mode 100644
index 898e230aaf..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.jpt.common.utility.tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/.settings/org.eclipse.jdt.core.prefs b/common/tests/org.eclipse.jpt.common.utility.tests/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 03215865ea..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Tue Mar 08 12:06:57 EST 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
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/META-INF/MANIFEST.MF b/common/tests/org.eclipse.jpt.common.utility.tests/META-INF/MANIFEST.MF
deleted file mode 100644
index cf9398b9f3..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,22 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-Vendor: %providerName
-Bundle-SymbolicName: org.eclipse.jpt.common.utility.tests
-Bundle-Version: 2.1.0.qualifier
-Bundle-Localization: plugin
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Require-Bundle: org.eclipse.jpt.common.utility;bundle-version="[2.0.0,3.0.0)",
- org.junit;bundle-version="[4.0.0,5.0.0)"
-Export-Package: org.eclipse.jpt.common.utility.tests.internal;x-internal:=true,
- org.eclipse.jpt.common.utility.tests.internal.command;x-internal:=true,
- org.eclipse.jpt.common.utility.tests.internal.enumerations;x-internal:=true,
- org.eclipse.jpt.common.utility.tests.internal.iterables;x-internal:=true,
- org.eclipse.jpt.common.utility.tests.internal.iterators;x-internal:=true,
- org.eclipse.jpt.common.utility.tests.internal.model;x-internal:=true,
- org.eclipse.jpt.common.utility.tests.internal.model.listener;x-internal:=true,
- org.eclipse.jpt.common.utility.tests.internal.model.value;x-internal:=true,
- org.eclipse.jpt.common.utility.tests.internal.model.value.prefs;x-internal:=true,
- org.eclipse.jpt.common.utility.tests.internal.model.value.swing;x-internal:=true,
- org.eclipse.jpt.common.utility.tests.internal.node;x-internal:=true,
- org.eclipse.jpt.common.utility.tests.internal.synchronizers;x-internal:=true
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/about.html b/common/tests/org.eclipse.jpt.common.utility.tests/about.html
deleted file mode 100644
index be534ba44f..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/about.html
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<HTML>
-
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-
-<BODY lang="EN-US">
-
-<H3>About This Content</H3>
-
-<P>May 02, 2008</P>
-
-<H3>License</H3>
-
-<P>The Eclipse Foundation makes available all content in this plug-in
-("Content"). Unless otherwise indicated below, the Content is provided to you
-under the terms and conditions of the Eclipse Public License Version 1.0
-("EPL"). A copy of the EPL is available at
-<A href="http://www.eclipse.org/org/documents/epl-v10.php">http://www.eclipse.org/org/documents/epl-v10.php</A>.
-For purposes of the EPL, "Program" will mean the Content.</P>
-
-<P>If you did not receive this Content directly from the Eclipse Foundation, the
-Content is being redistributed by another party ("Redistributor") and different
-terms and conditions may apply to your use of any object code in the Content.
-Check the Redistributor's license that was provided with the Content. If no such
-license exists, contact the Redistributor. Unless otherwise indicated below, the
-terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at
-<A href="http://www.eclipse.org/">http://www.eclipse.org/</A>.</P>
-
-</BODY>
-</HTML>
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/build.properties b/common/tests/org.eclipse.jpt.common.utility.tests/build.properties
deleted file mode 100644
index ebe9c08ef9..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/build.properties
+++ /dev/null
@@ -1,16 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2007 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-source.. = src/
-output.. = bin/
-bin.includes = .,\
- META-INF/,\
- about.html,\
- test.xml,\
- plugin.properties
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/plugin.properties b/common/tests/org.eclipse.jpt.common.utility.tests/plugin.properties
deleted file mode 100644
index 8ea447bc75..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/plugin.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-################################################################################
-# Copyright (c) 2006, 2009 Oracle. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0, which accompanies this distribution
-# and is available at http://www.eclipse.org/legal/epl-v10.html.
-#
-# Contributors:
-# Oracle - initial API and implementation
-################################################################################
-# ====================================================================
-# To code developer:
-# Do NOT change the properties between this line and the
-# "%%% END OF TRANSLATED PROPERTIES %%%" line.
-# Make a new property name, append to the end of the file and change
-# the code to use the new property.
-# ====================================================================
-
-# ====================================================================
-# %%% END OF TRANSLATED PROPERTIES %%%
-# ====================================================================
-
-pluginName = Dali Java Persistence Tools - Common Utility Tests
-providerName = Eclipse Web Tools Platform
-
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/resource/ClassTools.java b/common/tests/org.eclipse.jpt.common.utility.tests/resource/ClassTools.java
deleted file mode 100644
index aac17b6044..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/resource/ClassTools.java
+++ /dev/null
@@ -1,1680 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package test;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collections;
-import java.util.Stack;
-
-/**
- * Convenience methods related to the java.lang.reflect package.
- * These methods provide shortcuts for manipulating objects via
- * reflection; particularly when dealing with fields and/or methods that
- * are not publicly accessible or are inherited.
- *
- * In most cases, all the exceptions are handled and
- * wrapped in java.lang.RuntimeExceptions; so these methods should
- * be used when you are confident that you will not having any problems
- * using reflection.
- *
- * There are also a number of methods whose names
- * begin with "attempt". These methods will throw a NoSuchMethodException
- * or NoSuchFieldException when appropriate, allowing you to probe
- * for methods that should be present but might not.
- */
-public final class ClassTools {
-
- public static final Class<?>[] ZERO_PARAMETER_TYPES = new Class[0];
- public static final Object[] ZERO_PARAMETERS = new Object[0];
- private static final String CR = StringTools.CR;
-
- public static final char NESTED_CLASS_NAME_SEPARATOR = '$';
-
- public static final char ARRAY_INDICATOR = '[';
- public static final char TYPE_DECLARATION_ARRAY_OPEN = '[';
- public static final char TYPE_DECLARATION_ARRAY_CLOSE = ']';
-
- public static final char REFERENCE_CLASS_CODE = 'L';
- public static final char REFERENCE_CLASS_NAME_DELIMITER = ';';
-
- private static Primitive[] PRIMITIVES; // pseudo-'final' - lazy-initialized
- public static final char BYTE_CODE = 'B';
- public static final char CHAR_CODE = 'C';
- public static final char DOUBLE_CODE = 'D';
- public static final char FLOAT_CODE = 'F';
- public static final char INT_CODE = 'I';
- public static final char LONG_CODE = 'J';
- public static final char SHORT_CODE = 'S';
- public static final char BOOLEAN_CODE = 'Z';
- public static final char VOID_CODE = 'V';
- private static int MAX_PRIMITIVE_CLASS_NAME_LENGTH = -1; // pseudo-'final' - lazy-initialized
- private static int MAX_PRIMITIVE_WRAPPER_CLASS_NAME_LENGTH = -1; // pseudo-'final' - lazy-initialized
-
- public static final String VOID_CLASS_NAME = void.class.getName();
- public static final String VOID_WRAPPER_CLASS_NAME = java.lang.Void.class.getName();
-
-
- /**
- * Return all the fields for the
- * specified class, including inherited fields.
- * Class#allFields()
- */
- @Deprecated
- public static Field[] allFields(Class<?> javaClass) {
- Stack<Field> stack = new Stack<Field>();
- for (Class<?> tempClass = javaClass; tempClass != null; tempClass = tempClass.getSuperclass()) {
- pushDeclaredFields(tempClass, stack);
- }
- Collections.reverse(stack);
- return stack.toArray(new Field[stack.size()]);
- }
-
- /**
- * Return all the methods for the
- * specified class, including inherited methods.
- * Class#allMethods()
- */
- public static Method[] allMethods(Class<?> javaClass) {
- Stack<Method> stack = new Stack<Method>();
- for (Class<?> tempClass = javaClass; tempClass != null; tempClass = tempClass.getSuperclass()) {
- pushDeclaredMethods(tempClass, stack);
- }
- Collections.reverse(stack);
- return stack.toArray(new Method[stack.size()]);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * Throw an exception if the default constructor is not defined.
- * Class#newInstance() throws NoSuchMethodException
- */
- @Deprecated
- public static <T> T attemptNewInstance(Class<T> javaClass) throws NoSuchMethodException {
- return attemptNewInstance(javaClass, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and parameters.
- * Throw an exception if the constructor is not defined.
- * Class#newInstance(Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException
- */
- public static <T> T attemptNewInstance(Class<T> javaClass, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException {
- try {
- return constructor(javaClass, parameterTypes).newInstance(parameters);
- } catch (InstantiationException ie) {
- throw new RuntimeException(ie + CR + fullyQualifiedConstructorSignature(javaClass, parameterTypes), ie);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + fullyQualifiedConstructorSignature(javaClass, parameterTypes), iae);
- } catch (InvocationTargetException ite) {
- throw new RuntimeException(fullyQualifiedConstructorSignature(javaClass, parameterTypes) + CR + ite.getTargetException(), ite);
- }
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * given the constructor parameter type and parameter.
- * Throw an exception if the constructor is not defined.
- * Class#newInstance(Class<?> parameterType, Object parameter) throws NoSuchMethodException
- */
- public static <T> T attemptNewInstance(Class<T> javaClass, Class<?> parameterType, Object parameter) throws NoSuchMethodException {
- return attemptNewInstance(javaClass, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Attempt to get a field value, given the containing object and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * Throw an exception if the field is not defined.
- * Object#getFieldValue(String fieldName) throws NoSuchFieldException
- */
- public static Object attemptToGetFieldValue(Object object, String fieldName) throws NoSuchFieldException {
- try {
- return field(object, fieldName).get(object);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + fullyQualifiedFieldName(object, fieldName), iae);
- }
- }
-
- /**
- * Attempt to get a static field value, given the containing object and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * Throw an exception if the field is not defined.
- * Class#getStaticFieldValue(String fieldName) throws NoSuchFieldException
- */
- public static Object attemptToGetStaticFieldValue(Class<?> javaClass, String fieldName) throws NoSuchFieldException {
- try {
- return field(javaClass, fieldName).get(null);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + fullyQualifiedFieldName(javaClass, fieldName), iae);
- }
- }
-
- /**
- * Convenience method.
- * Attempt to execute a zero-argument method,
- * given the receiver and method name.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName) throws NoSuchMethodException
- */
- public static Object attemptToExecuteMethod(Object receiver, String methodName) throws NoSuchMethodException {
- return attemptToExecuteMethod(receiver, methodName, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Convenience method.
- * Attempt to execute a method, given the receiver,
- * method name, parameter type, and parameter.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?> parameterType, Object parameter) throws NoSuchMethodException
- */
- public static Object attemptToExecuteMethod(Object receiver, String methodName, Class<?> parameterType, Object parameter) throws NoSuchMethodException {
- return attemptToExecuteMethod(receiver, methodName, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Attempt to execute a method, given the receiver,
- * method name, parameter types, and parameters.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException
- */
- public static Object attemptToExecuteMethod(Object receiver, String methodName, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException {
- return executeMethod(method(receiver, methodName, parameterTypes), receiver, parameters);
- }
-
- /**
- * Attempt to execute a method, given the receiver,
- * method name, parameter types, and parameters.
- * Return its result.
- * Throw an exception if the method is not found.
- * If the executed method throws an exception, rethrow that exception.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException
- */
- public static Object attemptToExecuteMethodWithException(Object receiver, String methodName, Class<?>[] parameterTypes, Object[] parameters)
- throws Throwable, NoSuchMethodException
- {
- return executeMethodWithException(method(receiver, methodName, parameterTypes), receiver, parameters);
- }
-
- /**
- * Convenience method.
- * Attempt to execute a zero-argument static method,
- * given the class and method name.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName) throws NoSuchMethodException
- */
- public static Object attemptToExecuteStaticMethod(Class<?> javaClass, String methodName) throws NoSuchMethodException {
- return attemptToExecuteStaticMethod(javaClass, methodName, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Attempt to execute a static method, given the class,
- * method name, parameter types, and parameters.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException
- */
- public static Object attemptToExecuteStaticMethod(Class<?> javaClass, String methodName, Class<?>[] parameterTypes, Object[] parameters) throws NoSuchMethodException {
- return executeStaticMethod(staticMethod(javaClass, methodName, parameterTypes), parameters);
- }
-
- /**
- * Convenience method.
- * Attempt to execute a static method, given the class,
- * method name, parameter type, and parameter.
- * Return its result.
- * Throw an exception if the method is not found.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName, Class<?> parameterType, Object parameter) throws NoSuchMethodException
- */
- public static Object attemptToExecuteStaticMethod(Class<?> javaClass, String methodName, Class<?> parameterType, Object parameter) throws NoSuchMethodException {
- return attemptToExecuteStaticMethod(javaClass, methodName, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Attempt to set a field value, given the
- * containing object, field name, and new field value.
- * Useful for accessing private, package, or protected fields.
- * Throw an exception if the field is not defined.
- * Object#setFieldValue(String fieldName, Object fieldValue) throws NoSuchFieldException
- */
- public static void attemptToSetFieldValue(Object object, String fieldName, Object fieldValue) throws NoSuchFieldException {
- try {
- field(object, fieldName).set(object, fieldValue);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + fullyQualifiedFieldName(object, fieldName), iae);
- }
- }
-
- /**
- * Attempt to set a static field value, given the
- * containing class, field name, and new field value.
- * Useful for accessing private, package, or protected fields.
- * Throw an exception if the field is not defined.
- * Class#setStaticFieldValue(String fieldName, Object fieldValue) throws NoSuchFieldException
- */
- public static void attemptToSetStaticFieldValue(Class<?> javaClass, String fieldName, Object fieldValue) throws NoSuchFieldException {
- try {
- field(javaClass, fieldName).set(null, fieldValue);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + fullyQualifiedFieldName(javaClass, fieldName), iae);
- }
- }
-
- /**
- * Convenience method.
- * Return the default (zero-argument) constructor
- * for the specified class.
- * Set accessible to true, so we can access
- * private/package/protected constructors.
- * Class#constructor() throws NoSuchMethodException
- */
- public static <T> Constructor<T> constructor(Class<T> javaClass) throws NoSuchMethodException {
- return constructor(javaClass, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Return the constructor for the specified class
- * and formal parameter types.
- * Set accessible to true, so we can access
- * private/package/protected constructors.
- * Class#constructor(Class<?>[] parameterTypes) throws NoSuchMethodException
- */
- public static <T> Constructor<T> constructor(Class<T> javaClass, Class<?>[] parameterTypes) throws NoSuchMethodException {
- Constructor<T> constructor = javaClass.getDeclaredConstructor(parameterTypes);
- constructor.setAccessible(true);
- return constructor;
- }
-
- /**
- * Convenience method.
- * Return the constructor for the specified class
- * and formal parameter type.
- * Set accessible to true, so we can access
- * private/package/protected constructors.
- * Class#constructor(Class<?> parameterType) throws NoSuchMethodException
- */
- public static <T> Constructor<T> constructor(Class<T> javaClass, Class<?> parameterType) throws NoSuchMethodException {
- return constructor(javaClass, new Class[] {parameterType});
- }
-
- /**
- * Return the declared fields for the specified class.
- * Set accessible to true, so we can access
- * private/package/protected fields.
- * Class#accessibleDeclaredFields()
- */
- public static Field[] declaredFields(Class<?> javaClass) {
- Field[] fields = javaClass.getDeclaredFields();
- for (Field field : fields) {
- field.setAccessible(true);
- }
- return fields;
- }
-
- /**
- * Return the declared methods for the
- * specified class.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- * Class#accessibleDeclaredMethods()
- */
- public static Method[] declaredMethods(Class<?> javaClass) {
- Method[] methods = javaClass.getDeclaredMethods();
- for (Method method : methods) {
- method.setAccessible(true);
- }
- return methods;
- }
-
- /**
- * Return the default (zero-argument) constructor
- * for the specified class.
- * Set accessible to true, so we can access
- * private/package/protected constructors.
- * Class#defaultConstructor()
- */
- public static <T> Constructor<T> defaultConstructor(Class<T> javaClass) throws NoSuchMethodException {
- return constructor(javaClass);
- }
-
- /**
- * Return a field for the specified class and field name.
- * If the class does not directly
- * define the field, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected fields.
- */
- public static Field field(Class<?> javaClass, String fieldName) throws NoSuchFieldException {
- Field field = null;
- try {
- field = javaClass.getDeclaredField(fieldName);
- } catch (NoSuchFieldException ex) {
- Class<?> superclass = javaClass.getSuperclass();
- if (superclass == null) {
- throw ex;
- }
- // recurse
- return field(superclass, fieldName);
- }
- field.setAccessible(true);
- return field;
- }
-
- /**
- * Convenience method.
- * Return a field for the specified object and field name.
- * If the object's class does not directly
- * define the field, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected fields.
- */
- public static Field field(Object object, String fieldName) throws NoSuchFieldException {
- return field(object.getClass(), fieldName);
- }
-
- /*
- * Return a string representation of the specified constructor.
- */
- private static String fullyQualifiedConstructorSignature(Class<?> javaClass, Class<?>[] parameterTypes) {
- return fullyQualifiedMethodSignature(javaClass, null, parameterTypes);
- }
-
- /*
- * Return a string representation of the specified field.
- */
- private static String fullyQualifiedFieldName(Class<?> javaClass, String fieldName) {
- StringBuilder sb = new StringBuilder(200);
- sb.append(javaClass.getName());
- sb.append('.');
- sb.append(fieldName);
- return sb.toString();
- }
-
- /*
- * Return a string representation of the specified field.
- */
- private static String fullyQualifiedFieldName(Object object, String fieldName) {
- return fullyQualifiedFieldName(object.getClass(), fieldName);
- }
-
- /*
- * Return a string representation of the specified method.
- */
- private static String fullyQualifiedMethodSignature(Class<?> javaClass, String methodName, Class<?>[] parameterTypes) {
- StringBuilder sb = new StringBuilder(200);
- sb.append(javaClass.getName());
- // this check allows us to use this code for constructors, where the methodName is null
- if (methodName != null) {
- sb.append('.');
- sb.append(methodName);
- }
- sb.append('(');
- int max = parameterTypes.length - 1;
- if (max != -1) {
- // stop one short of the end of the array
- for (int i = 0; i < max; i++) {
- sb.append(parameterTypes[i].getName());
- sb.append(", ");
- }
- sb.append(parameterTypes[max].getName());
- }
- sb.append(')');
- return sb.toString();
- }
-
- /*
- * Return a string representation of the specified method.
- */
- private static String fullyQualifiedMethodSignature(Object receiver, String methodName, Class<?>[] parameterTypes) {
- return fullyQualifiedMethodSignature(receiver.getClass(), methodName, parameterTypes);
- }
-
- /**
- * Get a field value, given the containing object and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * Object#getFieldValue(String fieldName)
- */
- public static Object fieldValue(Object object, String fieldName) {
- try {
- return attemptToGetFieldValue(object, fieldName);
- } catch (NoSuchFieldException nsfe) {
- throw new RuntimeException(nsfe + CR + fullyQualifiedFieldName(object, fieldName), nsfe);
- }
- }
-
- /**
- * Get a static field value, given the containing class and field name.
- * Return its result.
- * Useful for accessing private, package, or protected fields.
- * Class#getStaticFieldValue(String fieldName)
- */
- public static Object staticFieldValue(Class<?> javaClass, String fieldName) {
- try {
- return attemptToGetStaticFieldValue(javaClass, fieldName);
- } catch (NoSuchFieldException nsfe) {
- throw new RuntimeException(nsfe + CR + fullyQualifiedFieldName(javaClass, fieldName), nsfe);
- }
- }
-
- /**
- * Convenience method.
- * Execute a zero-argument method, given the receiver and method name.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName)
- */
- public static Object executeMethod(Object receiver, String methodName) {
- return executeMethod(receiver, methodName, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Execute a method, given the receiver,
- * method name, parameter types, and parameters.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?>[] parameterTypes, Object[] parameters)
- */
- public static Object executeMethod(Object receiver, String methodName, Class<?>[] parameterTypes, Object[] parameters) {
- try {
- return attemptToExecuteMethod(receiver, methodName, parameterTypes, parameters);
- } catch (NoSuchMethodException nsme) {
- throw new RuntimeException(nsme + CR + fullyQualifiedMethodSignature(receiver, methodName, parameterTypes), nsme);
- }
- }
-
- /**
- * Convenience method.
- * Execute a one-argument method, given the receiver,
- * method name, parameter type, and parameter.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?> parameterType, Object parameter)
- */
- public static Object executeMethod(Object receiver, String methodName, Class<?> parameterType, Object parameter) {
- return executeMethod(receiver, methodName, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Convenience method.
- * Execute a zero-argument method, given the receiver and method name.
- * Return its result.
- * If the method throws an exception, rethrow that exception.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName)
- */
- public static Object executeMethodWithException(Object receiver, String methodName)
- throws Throwable
- {
- return executeMethodWithException(receiver, methodName, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Convenience method.
- * Execute a one-argument method, given the receiver,
- * method name, parameter type, and parameter.
- * Return its result.
- * If the method throws an exception, rethrow that exception.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?> parameterType, Object parameter)
- */
- public static Object executeMethodWithException(Object receiver, String methodName, Class<?> parameterType, Object parameter)
- throws Throwable
- {
- return executeMethodWithException(receiver, methodName, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Execute a method, given the receiver,
- * method name, parameter types, and parameters.
- * Return its result.
- * If the method throws an exception, rethrow that exception.
- * Useful for invoking private, package, or protected methods.
- * Object#execute(String methodName, Class<?>[] parameterTypes, Object[] parameters)
- */
- public static Object executeMethodWithException(Object receiver, String methodName, Class<?>[] parameterTypes, Object[] parameters)
- throws Throwable
- {
- try {
- return attemptToExecuteMethodWithException(receiver, methodName, parameterTypes, parameters);
- } catch (NoSuchMethodException nsme) {
- throw new RuntimeException(nsme + CR + fullyQualifiedMethodSignature(receiver, methodName, parameterTypes), nsme);
- }
- }
-
- /**
- * Execute the specified method with the specified parameters.
- * Return its result.
- * Convert exceptions to RuntimeExceptions.
- */
- public static Object executeMethod(Method method, Object receiver, Object[] parameters) {
- try {
- return method.invoke(receiver, parameters);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + method, iae);
- } catch (InvocationTargetException ite) {
- throw new RuntimeException(method + CR + ite.getTargetException(), ite);
- }
- }
-
- /**
- * Execute the specified method with the specified parameters.
- * Return its result.
- * If the method throws an exception, rethrow that exception.
- * Convert all other exceptions to RuntimeExceptions.
- */
- public static Object executeMethodWithException(Method method, Object receiver, Object[] parameters)
- throws Throwable
- {
- try {
- return method.invoke(receiver, parameters);
- } catch (IllegalAccessException iae) {
- throw new RuntimeException(iae + CR + method, iae);
- } catch (InvocationTargetException ite) {
- Throwable cause = ite.getCause();
- if (cause == null) {
- throw new RuntimeException(method.toString(), ite);
- }
- throw cause;
- }
- }
-
- /**
- * Convenience method.
- * Execute a zero-argument static method,
- * given the class and method name.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName)
- */
- public static Object executeStaticMethod(Class<?> javaClass, String methodName) {
- return executeStaticMethod(javaClass, methodName, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Execute a static method, given the class,
- * method name, parameter types, and parameters.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName, Class<?>[] parameterTypes, Object[] parameters)
- */
- public static Object executeStaticMethod(Class<?> javaClass, String methodName, Class<?>[] parameterTypes, Object[] parameters) {
- try {
- return attemptToExecuteStaticMethod(javaClass, methodName, parameterTypes, parameters);
- } catch (NoSuchMethodException nsme) {
- throw new RuntimeException(nsme + CR + fullyQualifiedMethodSignature(javaClass, methodName, parameterTypes), nsme);
- }
- }
-
- /**
- * Convenience method.
- * Execute a static method, given the class,
- * method name, parameter type, and parameter.
- * Return its result.
- * Useful for invoking private, package, or protected methods.
- * Class#executeStaticMethod(String methodName, Class<?> parameterType, Object parameter)
- */
- public static Object executeStaticMethod(Class<?> javaClass, String methodName, Class<?> parameterType, Object parameter) {
- return executeStaticMethod(javaClass, methodName, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Execute the specified static method with the specified parameters.
- * Return its result.
- * Convert exceptions to RuntimeExceptions.
- */
- public static Object executeStaticMethod(Method method, Object[] parameters) {
- return executeMethod(method, null, parameters);
- }
-
- /**
- * Convenience method.
- * Return a zero-argument method for the specified class
- * and method name. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Class<?> javaClass, String methodName) throws NoSuchMethodException {
- return method(javaClass, methodName, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Return a method for the specified class, method name,
- * and formal parameter types. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Class<?> javaClass, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException {
- Method method = null;
- try {
- method = javaClass.getDeclaredMethod(methodName, parameterTypes);
- } catch (NoSuchMethodException ex) {
- Class<?> superclass = javaClass.getSuperclass();
- if (superclass == null) {
- throw ex;
- }
- // recurse
- return method(superclass, methodName, parameterTypes);
- }
- method.setAccessible(true);
- return method;
- }
-
- /**
- * Convenience method.
- * Return a method for the specified class, method name,
- * and formal parameter type. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Class<?> javaClass, String methodName, Class<?> parameterType) throws NoSuchMethodException {
- return method(javaClass, methodName, new Class[] {parameterType});
- }
-
- /**
- * Convenience method.
- * Return a zero-argument method for the specified object
- * and method name. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Object object, String methodName) throws NoSuchMethodException {
- return method(object.getClass(), methodName);
- }
-
- /**
- * Convenience method.
- * Return a method for the specified object, method name,
- * and formal parameter types. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Object object, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException {
- return method(object.getClass(), methodName, parameterTypes);
- }
-
- /**
- * Convenience method.
- * Return a method for the specified object, method name,
- * and formal parameter type. If the object's class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method method(Object object, String methodName, Class<?> parameterType) throws NoSuchMethodException {
- return method(object.getClass(), methodName, parameterType);
- }
-
- /**
- * Convenience method.
- * Return the specified class (without the checked exception).
- */
- public static Class<?> classForName(String className) {
- try {
- return Class.forName(className);
- } catch (ClassNotFoundException ex) {
- throw new RuntimeException(className, ex);
- }
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * Class#newInstance()
- */
- public static <T> T newInstance(Class<T> javaClass) {
- return newInstance(javaClass, ZERO_PARAMETER_TYPES, ZERO_PARAMETERS);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * Class#newInstance()
- */
- public static Object newInstance(String className) throws ClassNotFoundException {
- return newInstance(className, null);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * using the class's default (zero-argument) constructor.
- * Class#newInstance()
- */
- public static Object newInstance(String className, ClassLoader classLoader) throws ClassNotFoundException {
- return newInstance(Class.forName(className, true, classLoader));
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and parameters.
- * Class#newInstance(Class<?>[] parameterTypes, Object[] parameters)
- */
- public static <T> T newInstance(Class<T> javaClass, Class<?>[] parameterTypes, Object[] parameters) {
- try {
- return attemptNewInstance(javaClass, parameterTypes, parameters);
- } catch (NoSuchMethodException nsme) {
- throw new RuntimeException(nsme + CR + fullyQualifiedConstructorSignature(javaClass, parameterTypes), nsme);
- }
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and parameters.
- * Class#newInstance(Class<?>[] parameterTypes, Object[] parameters)
- */
- public static Object newInstance(String className, Class<?>[] parameterTypes, Object[] parameters) throws ClassNotFoundException {
- return newInstance(className, parameterTypes, parameters, null);
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter types and parameters.
- * Class#newInstance(Class<?>[] parameterTypes, Object[] parameters)
- */
- public static Object newInstance(String className, Class<?>[] parameterTypes, Object[] parameters, ClassLoader classLoader) throws ClassNotFoundException {
- return newInstance(Class.forName(className, true, classLoader), parameterTypes, parameters);
- }
-
- /**
- * Convenience method.
- * Return a new instance of the specified class,
- * given the constructor parameter type and parameter.
- * Class#newInstance(Class<?> parameterType, Object parameter)
- */
- public static <T> T newInstance(Class<T> javaClass, Class<?> parameterType, Object parameter) {
- return newInstance(javaClass, new Class[] {parameterType}, new Object[] {parameter});
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter type and parameter.
- * Class#newInstance(Class<?> parameterType, Object parameter)
- */
- public static Object newInstance(String className, Class<?> parameterType, Object parameter) throws ClassNotFoundException {
- return newInstance(className, parameterType, parameter, null);
- }
-
- /**
- * Return a new instance of the specified class,
- * given the constructor parameter type and parameter.
- * Class#newInstance(Class<?> parameterType, Object parameter)
- */
- public static Object newInstance(String className, Class<?> parameterType, Object parameter, ClassLoader classLoader) throws ClassNotFoundException {
- return newInstance(Class.forName(className, false, classLoader), parameterType, parameter);
- }
-
- /*
- * Push the declared fields for the specified class
- * onto the top of the stack.
- */
- private static void pushDeclaredFields(Class<?> javaClass, Stack<Field> stack) {
- Field[] fields = declaredFields(javaClass);
- for (int i = fields.length; i-- > 0; ) {
- stack.push(fields[i]);
- }
- }
-
- /*
- * Push the declared methods for the specified class
- * onto the top of the stack.
- */
- private static void pushDeclaredMethods(Class<?> javaClass, Stack<Method> stack) {
- Method[] methods = declaredMethods(javaClass);
- for (int i = methods.length; i-- > 0; ) {
- stack.push(methods[i]);
- }
- }
-
- /**
- * Set a field value, given the containing object, field name, and new field value.
- * Useful for accessing private, package, or protected fields.
- * Object#setFieldValue(String fieldName, Object fieldValue)
- */
- public static void setFieldValue(Object object, String fieldName, Object fieldValue) {
- try {
- attemptToSetFieldValue(object, fieldName, fieldValue);
- } catch (NoSuchFieldException nsfe) {
- throw new RuntimeException(nsfe + CR + fullyQualifiedFieldName(object, fieldName), nsfe);
- }
- }
-
- /**
- * Set a static field value, given the containing class, field name, and new field value.
- * Useful for accessing private, package, or protected fields.
- * Class#setStaticFieldValue(String fieldName, Object fieldValue)
- */
- public static void setStaticFieldValue(Class<?> javaClass, String fieldName, Object fieldValue) {
- try {
- attemptToSetStaticFieldValue(javaClass, fieldName, fieldValue);
- } catch (NoSuchFieldException nsfe) {
- throw new RuntimeException(nsfe + CR + fullyQualifiedFieldName(javaClass, fieldName), nsfe);
- }
- }
-
- /**
- * Return the short name of the object's class.
- * Class#getShortName()
- */
- public static String shortClassNameForObject(Object object) {
- return shortNameFor(object.getClass());
- }
-
- /**
- * Return the short name of the class (e.g. "Object").
- * Class#getShortName()
- */
- public static String shortNameForClassNamed(String className) {
- return className.substring(className.lastIndexOf('.') + 1);
- }
-
- /**
- * Return the short name of the class (e.g. "Object").
- * Class#getShortName()
- */
- public static String shortNameFor(Class<?> javaClass) {
- return shortNameForClassNamed(javaClass.getName());
- }
-
- /**
- * Return the nested name of the object's class.
- * Class#getNestedName()
- */
- public static String nestedClassNameForObject(Object object) {
- return nestedNameFor(object.getClass());
- }
-
- /**
- * Return the nested name of the class (e.g. "Entry").
- * Class#getNestedName()
- */
- public static String nestedNameForClassNamed(String className) {
- return className.substring(className.lastIndexOf(NESTED_CLASS_NAME_SEPARATOR) + 1);
- }
-
- /**
- * Return the nested name of the class (e.g. "Entry").
- * Class#getNestedName()
- */
- public static String nestedNameFor(Class<?> javaClass) {
- return nestedNameForClassNamed(javaClass.getName());
- }
-
- /**
- * Return the "toString()" name of the object's class.
- */
- public static String toStringClassNameForObject(Object object) {
- return toStringNameFor(object.getClass());
- }
-
- /**
- * Return the "toString()" name of the class.
- * "Member" classes will return only the final name:
- * "com.foo.bar.TopLevelClass$MemberClass$NestedMemberClass"
- * => "NestedMemberClass"
- * "Local" and "anonymous" classes will still return the embedded '$'s:
- * "com.foo.bar.TopLevelClass$1LocalClass"
- * => "TopLevelClass$1LocalClass"
- * "com.foo.bar.TopLevelClass$1"
- * => "TopLevelClass$1"
- */
- public static String toStringNameForClassNamed(String className) {
- return classNamedIsMember(className) ?
- className.substring(className.lastIndexOf(NESTED_CLASS_NAME_SEPARATOR) + 1)
- :
- className.substring(className.lastIndexOf('.') + 1);
- }
-
- /**
- * Return the "toString()" name of the class.
- */
- public static String toStringNameFor(Class<?> javaClass) {
- return toStringNameForClassNamed(javaClass.getName());
- }
-
- /**
- * Return the package name of the class (e.g. "java.lang").
- * Class#getPackageName()
- */
- public static String packageNameFor(Class<?> javaClass) {
- return packageNameForClassNamed(javaClass.getName());
- }
-
- /**
- * Return the package name of the class (e.g. "java.lang").
- * Class#getPackageName()
- */
- public static String packageNameForClassNamed(String className) {
- int lastPeriod = className.lastIndexOf('.');
- if (lastPeriod == -1) {
- return "";
- }
- return className.substring(0, lastPeriod);
- }
-
- /**
- * Return the short name of the class,
- * followed by its package name (e.g. "Object (java.lang)").
- * Class#getShortNameWithPackage()
- */
- public static String shortNameWithPackage(Class<?> javaClass) {
- StringBuilder sb = new StringBuilder(200);
- sb.append(shortNameFor(javaClass));
- if ( ! javaClass.isPrimitive()) {
- sb.append(" (");
- sb.append(packageNameFor(javaClass));
- sb.append(')');
- }
- return sb.toString();
- }
-
- /**
- * Convenience method.
- * Return a zero-argument, static method for the specified class
- * and method name. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method staticMethod(Class<?> javaClass, String methodName) throws NoSuchMethodException {
- return staticMethod(javaClass, methodName, ZERO_PARAMETER_TYPES);
- }
-
- /**
- * Return a static method for the specified class, method name,
- * and formal parameter types. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method staticMethod(Class<?> javaClass, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException {
- Method method = method(javaClass, methodName, parameterTypes);
- if (Modifier.isStatic(method.getModifiers())) {
- return method;
- }
- throw new NoSuchMethodException(fullyQualifiedMethodSignature(javaClass, methodName, parameterTypes));
- }
-
- /**
- * Convenience method.
- * Return a static method for the specified class, method name,
- * and formal parameter type. If the class does not directly
- * implement the method, look for it in the class's superclasses.
- * Set accessible to true, so we can access
- * private/package/protected methods.
- */
- public static Method staticMethod(Class<?> javaClass, String methodName, Class<?> parameterTypes) throws NoSuchMethodException {
- return staticMethod(javaClass, methodName, new Class[] {parameterTypes});
- }
-
- /**
- * Return whether the specified class can be "declared" in code;
- * i.e. it is either a "top-level" class or a "member" class, but it
- * is not an "array" class. This method rolls together all the checks
- * from the other methods for a bit of a performance tweak.
- * Class#isDeclarable()
- */
- public static boolean classNamedIsDeclarable(String className) {
- if (className.charAt(0) == ARRAY_INDICATOR) {
- return false; // it is an "array" class
- }
- int index = className.indexOf(NESTED_CLASS_NAME_SEPARATOR);
- if (index == -1) {
- return true; // it is a "top-level" class
- }
- do {
- // the character immediately after each dollar sign cannot be a digit
- index++;
- if (Character.isDigit(className.charAt(index))) {
- return false;
- }
- index = className.indexOf(NESTED_CLASS_NAME_SEPARATOR, index);
- } while (index != -1);
- return true;
- }
-
- /**
- * Return whether the specified class is a "top-level" class,
- * as opposed to a "member", "local", or "anonymous" class,
- * using the standard jdk naming conventions (i.e. the class
- * name does NOT contain a '$': "TopLevelClass").
- * Class#isTopLevel()
- */
- public static boolean classNamedIsTopLevel(String className) {
- if (classNamedIsArray(className)) {
- return false;
- }
- return className.indexOf(NESTED_CLASS_NAME_SEPARATOR) == -1;
- }
-
- /**
- * Return whether the specified class is a "member" class,
- * as opposed to a "top-level", "local", or "anonymous" class,
- * using the standard jdk naming conventions (i.e. the class
- * name contains at least one '$' and all the names between
- * each '$' are legal class names:
- * "TopLevelClass$MemberClass$NestedMemberClass").
- * Class#isMember()
- */
- public static boolean classNamedIsMember(String className) {
- if (classNamedIsArray(className)) {
- return false;
- }
- int index = className.indexOf(NESTED_CLASS_NAME_SEPARATOR);
- if (index == -1) {
- return false; // it is a "top-level" class
- }
- do {
- // the character immediately after each dollar sign cannot be a digit
- index++;
- if (Character.isDigit(className.charAt(index))) {
- return false;
- }
- index = className.indexOf(NESTED_CLASS_NAME_SEPARATOR, index);
- } while (index != -1);
- return true;
- }
-
- /**
- * Return whether the specified class is a "local" class,
- * as opposed to a "top-level", "member", or "anonymous" class,
- * using the standard jdk (or Eclipse) naming conventions.
- * In the jdk, the class name ends with '$nnnXXX' where the '$' is
- * followed by a series of numeric digits which are followed by the
- * local class name: "TopLevelClass$1LocalClass".
- * In Eclipse, the class name ends with '$nnn$XXX' where the '$' is
- * followed by a series of numeric digits which are separated from
- * the local class name by another '$': "TopLevelClass$1$LocalClass".
- * Class#isLocal()
- */
- public static boolean classNamedIsLocal(String className) {
- if (classNamedIsArray(className)) {
- return false;
- }
- int dollar = className.indexOf(NESTED_CLASS_NAME_SEPARATOR);
- if (dollar == -1) {
- return false;
- }
- if ( ! Character.isDigit(className.charAt(dollar + 1))) {
- return false;
- }
- int len = className.length();
- for (int i = dollar + 2; i < len; i++) {
- if (Character.isJavaIdentifierStart(className.charAt(i))) {
- return true;
- }
- }
- // all the characters past the $ are digits (anonymous)
- return false;
- }
-
- /**
- * Return whether the specified class is an "anonymous" class,
- * as opposed to a "top-level", "member", or "local" class,
- * using the standard jdk naming conventions (i.e. the class
- * name ends with '$nnn' where all the characters past the
- * last '$' are numeric digits: "TopLevelClass$1").
- * Class#isAnonymous()
- */
- public static boolean classNamedIsAnonymous(String className) {
- if (classNamedIsArray(className)) {
- return false;
- }
- int dollar = className.indexOf(NESTED_CLASS_NAME_SEPARATOR);
- if (dollar == -1) {
- return false;
- }
- int start = dollar + 1;
- for (int i = className.length(); i-- > start; ) {
- if ( ! Character.isDigit(className.charAt(i))) {
- return false;
- }
- }
- // all the characters past the $ are digits
- return true;
- }
-
- /**
- * Return the "array depth" of the specified class.
- * The depth is the number of dimensions for an array type.
- * Non-array types have a depth of zero.
- * Class#getArrayDepth()
- */
- public static int arrayDepthFor(Class<?> javaClass) {
- int depth = 0;
- while (javaClass.isArray()) {
- depth++;
- javaClass = javaClass.getComponentType();
- }
- return depth;
- }
-
- /**
- * Return the "array depth" of the specified object.
- * The depth is the number of dimensions for an array.
- * Non-arrays have a depth of zero.
- */
- public static int arrayDepthForObject(Object object) {
- return arrayDepthFor(object.getClass());
- }
-
- /**
- * Return the "array depth" of the specified class.
- * The depth is the number of dimensions for an array type.
- * Non-array types have a depth of zero.
- * @see java.lang.Class#getName()
- * Class#getArrayDepth()
- */
- public static int arrayDepthForClassNamed(String className) {
- int depth = 0;
- while (className.charAt(depth) == ARRAY_INDICATOR) {
- depth++;
- }
- return depth;
- }
-
- /**
- * Return whether the specified class is an array type.
- * @see java.lang.Class#getName()
- */
- public static boolean classNamedIsArray(String className) {
- return className.charAt(0) == ARRAY_INDICATOR;
- }
-
- /**
- * Return the "element type" of the specified class.
- * The element type is the base type held by an array type.
- * A non-array type simply returns itself.
- * Class#getElementType()
- */
- public static Class<?> elementTypeFor(Class<?> javaClass) {
- while (javaClass.isArray()) {
- javaClass = javaClass.getComponentType();
- }
- return javaClass;
- }
-
- /**
- * Return the "element type" of the specified object.
- * The element type is the base type held by an array.
- * A non-array simply returns its class.
- */
- public static Class<?> elementTypeForObject(Object object) {
- return elementTypeFor(object.getClass());
- }
-
- /**
- * Return the "element type" of the specified class.
- * The element type is the base type held by an array type.
- * Non-array types simply return themselves.
- * Class#getElementType()
- */
- public static String elementTypeNameFor(Class<?> javaClass) {
- return elementTypeFor(javaClass).getName();
- }
-
- /**
- * Return the "element type" of the specified class.
- * The element type is the base type held by an array type.
- * Non-array types simply return themselves.
- * @see java.lang.Class#getName()
- * Class#getElementType()
- */
- public static String elementTypeNameForClassNamed(String className) {
- int depth = arrayDepthForClassNamed(className);
- if (depth == 0) {
- // the name is in the form: "java.lang.Object" or "int"
- return className;
- }
- int last = className.length() - 1;
- if (className.charAt(depth) == REFERENCE_CLASS_CODE) {
- // the name is in the form: "[[[Ljava.lang.Object;"
- return className.substring(depth + 1, last); // drop the trailing ';'
- }
- // the name is in the form: "[[[I"
- return classNameForCode(className.charAt(last));
- }
-
- /**
- * Return whether the specified class is a "reference"
- * class (i.e. neither 'void' nor one of the primitive variable classes,
- * ['boolean', 'int', 'float', etc.]).
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classNamedIsReference(String className) {
- return ! classNamedIsPrimitive(className);
- }
-
- /**
- * Return whether the specified class is a primitive
- * class (i.e. 'void' or one of the primitive variable classes,
- * ['boolean', 'int', 'float', etc.]).
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classNamedIsPrimitive(String className) {
- if (classNamedIsArray(className) || (className.length() > maxPrimitiveClassNameLength())) {
- return false; // performance tweak
- }
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].javaClass.getName().equals(className)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified class is a "variable" primitive
- * class (i.e. 'boolean', 'int', 'float', etc., but not 'void').
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classNamedIsVariablePrimitive(String className) {
- return classNamedIsPrimitive(className)
- && ( ! className.equals(VOID_CLASS_NAME));
- }
-
- /**
- * Return whether the specified class is a primitive wrapper
- * class (i.e. 'java.lang.Void' or one of the primitive variable wrapper classes,
- * ['java.lang.Boolean', 'java.lang.Integer', 'java.lang.Float', etc.]).
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classNamedIsPrimitiveWrapperClass(String className) {
- if (classNamedIsArray(className) || (className.length() > maxPrimitiveWrapperClassNameLength())) {
- return false; // performance tweak
- }
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].wrapperClass.getName().equals(className)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified class is a "variable" primitive
- * class (i.e. 'boolean', 'int', 'float', etc., but not 'void').
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classNamedIsVariablePrimitiveWrapperClass(String className) {
- return classNamedIsPrimitiveWrapperClass(className)
- && ( ! className.equals(VOID_WRAPPER_CLASS_NAME));
- }
-
- /**
- * Return whether the specified class is a primitive wrapper
- * class (i.e. 'java.lang.Void' or one of the primitive variable wrapper classes,
- * ['java.lang.Boolean', 'java.lang.Integer', 'java.lang.Float', etc.]).
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classIsPrimitiveWrapperClass(Class<?> javaClass) {
- if (javaClass.isArray() || (javaClass.getName().length() > maxPrimitiveWrapperClassNameLength())) {
- return false; // performance tweak
- }
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].wrapperClass == javaClass) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return whether the specified class is a "variable" primitive
- * class (i.e. 'boolean', 'int', 'float', etc., but not 'void').
- * NB: void.class.isPrimitive() == true
- */
- public static boolean classIsVariablePrimitiveWrapperClass(Class<?> javaClass) {
- return classIsPrimitiveWrapperClass(javaClass)
- && (javaClass != java.lang.Void.class);
- }
-
- /**
- * Return the class name for the specified class code.
- * @see java.lang.Class#getName()
- */
- public static String classNameForCode(char classCode) {
- return classForCode(classCode).getName();
- }
-
- /**
- * Return the class name for the specified class code.
- * @see java.lang.Class#getName()
- */
- public static String classNameForCode(int classCode) {
- return classNameForCode((char) classCode);
- }
-
- /**
- * Return the class for the specified class code.
- * @see java.lang.Class#getName()
- */
- public static Class<?> classForCode(char classCode) {
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].code == classCode) {
- return codes[i].javaClass;
- }
- }
- throw new IllegalArgumentException(String.valueOf(classCode));
- }
-
- /**
- * Return the class for the specified class code.
- * @see java.lang.Class#getName()
- */
- public static Class<?> classForCode(int classCode) {
- return classForCode((char) classCode);
- }
-
- /**
- * Return the class code for the specified class.
- * @see java.lang.Class#getName()
- */
- public static char codeForClass(Class<?> javaClass) {
- if (( ! javaClass.isArray()) && (javaClass.getName().length() <= maxPrimitiveClassNameLength())) {
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].javaClass == javaClass) {
- return codes[i].code;
- }
- }
- }
- throw new IllegalArgumentException(javaClass.getName());
- }
-
- /**
- * Return the class code for the specified class.
- * @see java.lang.Class#getName()
- */
- public static char codeForClassNamed(String className) {
- if (( ! classNamedIsArray(className)) && (className.length() <= maxPrimitiveClassNameLength())) {
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].javaClass.getName().equals(className)) {
- return codes[i].code;
- }
- }
- }
- throw new IllegalArgumentException(className);
- }
-
- /**
- * Return the class for the specified "type declaration".
- */
- public static Class<?> classForTypeDeclaration(String typeDeclaration) throws ClassNotFoundException {
- return classForTypeDeclaration(typeDeclaration, ClassTools.class.getClassLoader());
- }
-
- /**
- * Return the class for the specified "type declaration",
- * using the specified class loader.
- */
- public static Class<?> classForTypeDeclaration(String typeDeclaration, ClassLoader classLoader) throws ClassNotFoundException {
- TypeDeclaration td = typeDeclaration(typeDeclaration);
- return classForTypeDeclaration(td.elementTypeName, td.arrayDepth);
- }
-
- private static TypeDeclaration typeDeclaration(String typeDeclaration) {
- typeDeclaration = StringTools.removeAllWhitespace(typeDeclaration);
- int arrayDepth = arrayDepthForTypeDeclaration_(typeDeclaration);
- String elementTypeName = typeDeclaration.substring(0, typeDeclaration.length() - (arrayDepth * 2));
- return new TypeDeclaration(elementTypeName, arrayDepth);
- }
-
- /**
- * Return the class for the specified "type declaration".
- */
- public static Class<?> classForTypeDeclaration(String elementTypeName, int arrayDepth) throws ClassNotFoundException {
- return classForTypeDeclaration(elementTypeName, arrayDepth, null);
- }
-
- /**
- * Return the class for the specified "type declaration",
- * using the specified class loader.
- */
- // see the "Evaluation" of jdk bug 6446627 for a discussion of loading classes
- public static Class<?> classForTypeDeclaration(String elementTypeName, int arrayDepth, ClassLoader classLoader) throws ClassNotFoundException {
- // primitives cannot be loaded via Class#forName(),
- // so check for a primitive class name first
- Primitive pcc = null;
- if (elementTypeName.length() <= maxPrimitiveClassNameLength()) { // performance tweak
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].javaClass.getName().equals(elementTypeName)) {
- pcc = codes[i];
- break;
- }
- }
- }
-
- // non-array
- if (arrayDepth == 0) {
- return (pcc == null) ? Class.forName(elementTypeName, false, classLoader) : pcc.javaClass;
- }
-
- // array
- StringBuilder sb = new StringBuilder(100);
- for (int i = arrayDepth; i-- > 0; ) {
- sb.append(ARRAY_INDICATOR);
- }
- if (pcc == null) {
- sb.append(REFERENCE_CLASS_CODE);
- sb.append(elementTypeName);
- sb.append(REFERENCE_CLASS_NAME_DELIMITER);
- } else {
- sb.append(pcc.code);
- }
- return Class.forName(sb.toString(), false, classLoader);
- }
-
- /**
- * Return the class name for the specified "type declaration"; e.g.
- * "int[]" -> "[I"
- * @see java.lang.Class#getName()
- */
- public static String classNameForTypeDeclaration(String typeDeclaration) {
- TypeDeclaration td = typeDeclaration(typeDeclaration);
- return classNameForTypeDeclaration(td.elementTypeName, td.arrayDepth);
- }
-
- /**
- * Return the array depth for the specified "type declaration"; e.g.
- * "int[]" -> 1
- */
- public static int arrayDepthForTypeDeclaration(String typeDeclaration) {
- return arrayDepthForTypeDeclaration_(StringTools.removeAllWhitespace(typeDeclaration));
- }
-
- /*
- * Assume no whitespace in the type declaration.
- */
- private static int arrayDepthForTypeDeclaration_(String typeDeclaration) {
- int last = typeDeclaration.length() - 1;
- int depth = 0;
- int close = last;
- while (typeDeclaration.charAt(close) == TYPE_DECLARATION_ARRAY_CLOSE) {
- if (typeDeclaration.charAt(close - 1) == TYPE_DECLARATION_ARRAY_OPEN) {
- depth++;
- } else {
- throw new IllegalArgumentException("invalid type declaration: " + typeDeclaration);
- }
- close = last - (depth * 2);
- }
- return depth;
- }
-
- /**
- * Return the class name for the specified "type declaration".
- * @see java.lang.Class#getName()
- */
- public static String classNameForTypeDeclaration(String elementTypeName, int arrayDepth) {
- // non-array
- if (arrayDepth == 0) {
- return elementTypeName;
- }
-
- if (elementTypeName.equals(VOID_CLASS_NAME)) {
- throw new IllegalArgumentException("'" + VOID_CLASS_NAME + "' must have an array depth of zero: " + arrayDepth + '.');
- }
- // array
- StringBuilder sb = new StringBuilder(100);
- for (int i = arrayDepth; i-- > 0; ) {
- sb.append(ARRAY_INDICATOR);
- }
-
- // look for a primitive first
- Primitive pcc = null;
- if (elementTypeName.length() <= maxPrimitiveClassNameLength()) { // performance tweak
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- if (codes[i].javaClass.getName().equals(elementTypeName)) {
- pcc = codes[i];
- break;
- }
- }
- }
-
- if (pcc == null) {
- sb.append(REFERENCE_CLASS_CODE);
- sb.append(elementTypeName);
- sb.append(REFERENCE_CLASS_NAME_DELIMITER);
- } else {
- sb.append(pcc.code);
- }
-
- return sb.toString();
- }
-
- private static int maxPrimitiveClassNameLength() {
- if (MAX_PRIMITIVE_CLASS_NAME_LENGTH == -1) {
- MAX_PRIMITIVE_CLASS_NAME_LENGTH = calculateMaxPrimitiveClassNameLength();
- }
- return MAX_PRIMITIVE_CLASS_NAME_LENGTH;
- }
-
- private static int calculateMaxPrimitiveClassNameLength() {
- int max = -1;
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- int len = codes[i].javaClass.getName().length();
- if (len > max) {
- max = len;
- }
- }
- return max;
- }
-
- private static int maxPrimitiveWrapperClassNameLength() {
- if (MAX_PRIMITIVE_WRAPPER_CLASS_NAME_LENGTH == -1) {
- MAX_PRIMITIVE_WRAPPER_CLASS_NAME_LENGTH = calculateMaxPrimitiveWrapperClassNameLength();
- }
- return MAX_PRIMITIVE_WRAPPER_CLASS_NAME_LENGTH;
- }
-
- private static int calculateMaxPrimitiveWrapperClassNameLength() {
- int max = -1;
- Primitive[] codes = primitives();
- for (int i = codes.length; i-- > 0; ) {
- int len = codes[i].wrapperClass.getName().length();
- if (len > max) {
- max = len;
- }
- }
- return max;
- }
-
- private static Primitive[] primitives() {
- if (PRIMITIVES == null) {
- PRIMITIVES = buildPrimitives();
- }
- return PRIMITIVES;
- }
-
- /**
- * NB: void.class.isPrimitive() == true
- */
- private static Primitive[] buildPrimitives() {
- Primitive[] result = new Primitive[9];
- result[0] = new Primitive(BYTE_CODE, java.lang.Byte.class);
- result[1] = new Primitive(CHAR_CODE, java.lang.Character.class);
- result[2] = new Primitive(DOUBLE_CODE, java.lang.Double.class);
- result[3] = new Primitive(FLOAT_CODE, java.lang.Float.class);
- result[4] = new Primitive(INT_CODE, java.lang.Integer.class);
- result[5] = new Primitive(LONG_CODE, java.lang.Long.class);
- result[6] = new Primitive(SHORT_CODE, java.lang.Short.class);
- result[7] = new Primitive(BOOLEAN_CODE, java.lang.Boolean.class);
- result[8] = new Primitive(VOID_CODE, java.lang.Void.class);
- return result;
- }
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private ClassTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-
- // ********** member classes **********
-
- private static class Primitive {
- final char code;
- final Class<?> javaClass;
- final Class<?> wrapperClass;
- private static final String WRAPPER_CLASS_TYPE_FIELD_NAME = "TYPE";
- // e.g. java.lang.Boolean.TYPE => boolean.class
- Primitive(char code, Class<?> wrapperClass) {
- this.code = code;
- this.wrapperClass = wrapperClass;
- this.javaClass = (Class<?>) staticFieldValue(wrapperClass, WRAPPER_CLASS_TYPE_FIELD_NAME);
- }
- }
-
- private static class TypeDeclaration {
- final String elementTypeName;
- final int arrayDepth;
- TypeDeclaration(String elementTypeName, int arrayDepth) {
- this.elementTypeName = elementTypeName;
- this.arrayDepth = arrayDepth;
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ArrayToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ArrayToolsTests.java
deleted file mode 100644
index b5f840729f..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ArrayToolsTests.java
+++ /dev/null
@@ -1,3523 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.Range;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.ReverseComparator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-
-@SuppressWarnings("nls")
-public class ArrayToolsTests extends TestCase {
-
- public ArrayToolsTests(String name) {
- super(name);
- }
-
-
- // ********** instantiation **********
-
- public void testNewArrayObjectArray() {
- String[] array1 = new String[2];
- String[] array2 = ArrayTools.newArray(array1);
- array2[0] = "foo";
- array2[1] = "bar";
- assertEquals(String.class, array2.getClass().getComponentType());
- assertEquals(2, array2.length);
- }
-
- public void testNewArrayObjectArrayInt() {
- String[] array1 = new String[2];
- String[] array2 = ArrayTools.newArray(array1, 5);
- array2[0] = "foo";
- array2[4] = "bar";
- assertEquals(String.class, array2.getClass().getComponentType());
- assertEquals(5, array2.length);
- }
-
- public void testNewArrayObjectArrayInt_Exception() {
- String[] array1 = new String[2];
- Object[] array2 = ArrayTools.newArray(array1, 5);
- boolean exCaught = false;
- try {
- array2[1] = Integer.valueOf(7);
- fail("bogus array: " + Arrays.toString(array2));
- } catch (ArrayStoreException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testComponentType() {
- String[] array = new String[2];
- Class<? extends String> javaClass = ArrayTools.componentType(array);
- assertEquals(String.class, javaClass);
- }
-
- public void testNewArrayClassInt() {
- String[] array = ArrayTools.newArray(String.class, 5);
- array[0] = "foo";
- array[4] = "bar";
- assertEquals(String.class, array.getClass().getComponentType());
- assertEquals(5, array.length);
- }
-
- public void testNewArrayClassInt_Exception() {
- Object[] array = ArrayTools.newArray(String.class, 5);
- boolean exCaught = false;
- try {
- array[1] = Integer.valueOf(7);
- fail("bogus array: " + Arrays.toString(array));
- } catch (ArrayStoreException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testNewArrayClassInt_Primitive() {
- boolean exCaught = false;
- try {
- Object[] array = ArrayTools.newArray(int.class, 5);
- fail("bogus array: " + Arrays.toString(array));
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- // ********** conversion **********
-
- public void testArrayIterable() {
- Iterable<String> iterable = this.buildStringList1();
- Object[] a = ArrayTools.array(iterable);
- assertEquals(3, a.length);
- assertTrue(ArrayTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- Object[] a = ArrayTools.array(iterable, 3);
- assertEquals(3, a.length);
- assertTrue(ArrayTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterableObjectArray_String() {
- Iterable<String> iterable = this.buildStringList1();
- String[] a = ArrayTools.array(iterable, new String[0]);
- assertEquals(3, a.length);
- assertTrue(ArrayTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterableObjectArray_Object() {
- Iterable<String> iterable = this.buildStringList1();
- Object[] a = ArrayTools.array(iterable, new Object[0]);
- assertEquals(3, a.length);
- assertTrue(ArrayTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterableIntObjectArray() {
- Iterable<String> iterable = this.buildStringList1();
- String[] a = ArrayTools.array(iterable, 3, new String[0]);
- assertEquals(3, a.length);
- assertTrue(ArrayTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterator() {
- Object[] a = ArrayTools.array(this.buildStringList1().iterator());
- assertEquals(3, a.length);
- assertTrue(ArrayTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIterator_Empty() {
- Object[] a = ArrayTools.array(EmptyIterator.instance());
- assertEquals(0, a.length);
- }
-
- public void testArrayIteratorInt() {
- Object[] a = ArrayTools.array(this.buildStringList1().iterator(), 3);
- assertEquals(3, a.length);
- assertTrue(ArrayTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIteratorInt_Empty() {
- Object[] a = ArrayTools.array(EmptyIterator.instance(), 3);
- assertEquals(0, a.length);
- }
-
- public void testArrayIteratorObjectArray_String() {
- String[] a = ArrayTools.array(this.buildStringList1().iterator(), new String[0]);
- assertEquals(3, a.length);
- assertTrue(ArrayTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIteratorObjectArray_Empty() {
- String[] a = ArrayTools.array(EmptyIterator.<String>instance(), new String[0]);
- assertEquals(0, a.length);
- }
-
- public void testArrayIteratorObjectArray_Empty_ClearArray() {
- String[] a = ArrayTools.array(EmptyIterator.<String>instance(), new String[5]);
- assertEquals(5, a.length);
- assertNull(a[0]);
- }
-
- public void testArrayIteratorObjectArray_Object() {
- Object[] a = ArrayTools.array(this.buildStringList1().iterator(), new Object[0]);
- assertEquals(3, a.length);
- assertTrue(ArrayTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIteratorIntObjectArray() {
- String[] a = ArrayTools.array(this.buildStringList1().iterator(), 3, new String[0]);
- assertEquals(3, a.length);
- assertTrue(ArrayTools.containsAll(a, this.buildStringList1().iterator()));
- }
-
- public void testArrayIteratorIntObjectArray_Empty() {
- String[] a = ArrayTools.array(EmptyIterator.<String>instance(), 3, new String[0]);
- assertEquals(0, a.length);
- }
-
-
- // ********** add **********
-
- public void testAddObjectArrayObject_Object() {
- Object[] a = ArrayTools.add(this.buildObjectArray1(), "twenty");
- assertEquals(4, a.length);
- assertTrue(ArrayTools.contains(a, "twenty"));
- assertEquals("twenty", a[a.length-1]);
- }
-
- public void testAddObjectArrayObject_String() {
- String[] a = ArrayTools.add(this.buildStringArray1(), "twenty");
- assertEquals(4, a.length);
- assertTrue(ArrayTools.contains(a, "twenty"));
- assertEquals("twenty", a[a.length-1]);
- }
-
- public void testAddObjectArrayObject_EmptyArray() {
- String[] a = new String[0];
- a = ArrayTools.add(a, "twenty");
- assertEquals(1, a.length);
- assertTrue(ArrayTools.contains(a, "twenty"));
- assertEquals("twenty", a[0]);
- }
-
- public void testAddObjectArrayIntObject_Object() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- a = ArrayTools.add(a, 2, "X");
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, "X"));
- assertTrue(Arrays.equals(new Object[] { "a", "b", "X", "c", "d" }, a));
- }
-
- public void testAddObjectArrayIntObject_String() {
- String[] a = new String[] { "a", "b", "c", "d" };
- a = ArrayTools.add(a, 2, "X");
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, "X"));
- assertTrue(Arrays.equals(new String[] { "a", "b", "X", "c", "d" }, a));
- }
-
- public void testAddObjectArrayIntObject_End() {
- String[] a = new String[] { "a", "b", "c", "d" };
- a = ArrayTools.add(a, 4, "X");
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, "X"));
- assertTrue(Arrays.equals(new String[] { "a", "b", "c", "d", "X" }, a));
- }
-
- public void testAddObjectArrayIntObject_Zero() {
- String[] a = new String[] { "a", "b", "c", "d" };
- a = ArrayTools.add(a, 0, "X");
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, "X"));
- assertTrue(Arrays.equals(new String[] { "X", "a", "b", "c", "d" }, a));
- }
-
- public void testAddObjectArrayIntObject_Exception() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- boolean exCaught = false;
- try {
- a = ArrayTools.add(a, 33, "X");
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddCharArrayChar() {
- char[] a = ArrayTools.add(this.buildCharArray(), 'd');
- assertEquals(4, a.length);
- assertTrue(ArrayTools.contains(a, 'd'));
- }
-
- public void testAddCharArrayChar_Empty() {
- char[] a = new char[0];
- a = ArrayTools.add(a, 'd');
- assertEquals(1, a.length);
- assertTrue(ArrayTools.contains(a, 'd'));
- assertTrue(Arrays.equals(new char[] { 'd' }, a));
- }
-
- public void testAddCharArrayIntChar() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = ArrayTools.add(a, 2, 'X');
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'X', 'c', 'd' }, a));
- }
-
- public void testAddCharArrayIntChar_Zero() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = ArrayTools.add(a, 0, 'X');
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'X', 'a', 'b', 'c', 'd' }, a));
- }
-
- public void testAddCharArrayIntChar_End() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = ArrayTools.add(a, 4, 'X');
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'c', 'd', 'X' }, a));
- }
-
- public void testAddIntArrayInt() {
- int[] a = ArrayTools.add(this.buildIntArray(), 30);
- assertEquals(4, a.length);
- assertTrue(ArrayTools.contains(a, 30));
- }
-
- public void testAddIntArrayInt_Empty() {
- int[] a = new int[0];
- a = ArrayTools.add(a, 30);
- assertEquals(1, a.length);
- assertTrue(ArrayTools.contains(a, 30));
- assertTrue(Arrays.equals(new int[] { 30 }, a));
- }
-
- public void testAddIntArrayIntInt() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = ArrayTools.add(a, 2, 99);
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 1, 2, 99, 3, 4 }, a));
- }
-
- public void testAddIntArrayIntInt_Zero() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = ArrayTools.add(a, 0, 99);
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 99, 1, 2, 3, 4 }, a));
- }
-
- public void testAddIntArrayIntInt_End() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = ArrayTools.add(a, 4, 99);
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 1, 2, 3, 4, 99 }, a));
- }
-
-
- // ********** add all **********
-
- public void testAddAllObjectArrayCollection_String() {
- String[] a = this.buildStringArray1();
- Collection<String> c = this.buildStringList2();
- String[] newArray = ArrayTools.addAll(a, c);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, c));
- }
-
- public void testAddAllObjectArrayCollection_Object() {
- Object[] a = this.buildObjectArray1();
- Collection<String> c = this.buildStringList2();
- Object[] newArray = ArrayTools.addAll(a, c);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, c));
- }
-
- public void testAddAllObjectArrayCollection_EmptyArray() {
- String[] a = new String[0];
- Collection<String> c = this.buildStringList2();
- String[] newArray = ArrayTools.addAll(a, c);
-
- assertEquals(3, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, c));
- }
-
- public void testAddAllObjectArrayCollection_EmptyCollection() {
- String[] a = this.buildStringArray1();
- Collection<String> c = new ArrayList<String>();
- String[] newArray = ArrayTools.addAll(a, c);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIntCollection_String() {
- String[] a = this.buildStringArray1();
- Collection<String> c = this.buildStringList2();
- String[] newArray = ArrayTools.addAll(a, 1, c);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, c));
- }
-
- public void testAddAllObjectArrayIntCollection_String_End() {
- String[] a = this.buildStringArray1();
- Collection<String> c = this.buildStringList2();
- String[] newArray = ArrayTools.addAll(a, 3, c);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, c));
- }
-
- public void testAddAllObjectArrayIntCollection_EmptyArray() {
- String[] a = new String[0];
- Collection<String> c = this.buildStringList2();
- String[] newArray = ArrayTools.addAll(a, 0, c);
-
- assertEquals(3, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, c));
- }
-
- public void testAddAllObjectArrayIntCollection_EmptyArray_Exception() {
- String[] a = new String[0];
- Collection<String> c = this.buildStringList2();
- boolean exCaught = false;
- try {
- String[] newArray = ArrayTools.addAll(a, 3, c);
- fail("bogus array: " + Arrays.toString(newArray));
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddAllObjectArrayIntCollection_EmptyCollection() {
- String[] a = this.buildStringArray1();
- Collection<String> c = new ArrayList<String>();
- String[] newArray = ArrayTools.addAll(a, 1, c);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIntIterable_String() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = this.buildStringList2();
- String[] newArray = ArrayTools.addAll(a, 1, iterable);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, iterable));
- }
-
- public void testAddAllObjectArrayIntIterable_EmptyArray() {
- String[] a = new String[0];
- Iterable<String> iterable = this.buildStringList2();
- String[] newArray = ArrayTools.addAll(a, 0, iterable);
-
- assertEquals(3, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, iterable));
- }
-
- public void testAddAllObjectArrayIntIterable_EmptyIterable() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = new ArrayList<String>();
- String[] newArray = ArrayTools.addAll(a, 1, iterable);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIntIterableInt_String() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = this.buildStringList2();
- String[] newArray = ArrayTools.addAll(a, 1, iterable, 3);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, iterable));
- }
-
- public void testAddAllObjectArrayIntIterableInt_EmptyArray() {
- String[] a = new String[0];
- Iterable<String> iterable = this.buildStringList2();
- String[] newArray = ArrayTools.addAll(a, 0, iterable, 3);
-
- assertEquals(3, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, iterable));
- }
-
- public void testAddAllObjectArrayIntIterableInt_EmptyIterable() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = new ArrayList<String>();
- String[] newArray = ArrayTools.addAll(a, 1, iterable, 0);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIntIterator_String() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = this.buildStringList2().iterator();
- String[] newArray = ArrayTools.addAll(a, 1, iterator);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, this.buildStringList2()));
- }
-
- public void testAddAllObjectArrayIntIterator_EmptyArray() {
- String[] a = new String[0];
- Iterator<String> iterator = this.buildStringList2().iterator();
- String[] newArray = ArrayTools.addAll(a, 0, iterator);
-
- assertEquals(3, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, this.buildStringList2()));
- }
-
- public void testAddAllObjectArrayIntIterator_EmptyIterable() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = EmptyIterator.instance();
- String[] newArray = ArrayTools.addAll(a, 1, iterator);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIntIteratorInt_String() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = this.buildStringList2().iterator();
- String[] newArray = ArrayTools.addAll(a, 1, iterator, 3);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, this.buildStringList2()));
- }
-
- public void testAddAllObjectArrayIntIteratorInt_EmptyArray() {
- String[] a = new String[0];
- Iterator<String> iterator = this.buildStringList2().iterator();
- String[] newArray = ArrayTools.addAll(a, 0, iterator, 3);
-
- assertEquals(3, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, this.buildStringList2()));
- }
-
- public void testAddAllObjectArrayIntIteratorInt_EmptyIterator() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = EmptyIterator.instance();
- String[] newArray = ArrayTools.addAll(a, 1, iterator, 0);
-
- assertEquals(3, newArray.length);
- }
-
- public void testAddAllObjectArrayIterable() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = this.buildStringList1();
- String[] newArray = ArrayTools.addAll(a, iterable);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, this.buildStringList1()));
- }
-
- public void testAddAllObjectArrayIterableInt() {
- String[] a = this.buildStringArray1();
- Iterable<String> iterable = this.buildStringList1();
- String[] newArray = ArrayTools.addAll(a, iterable, 33);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, this.buildStringList1()));
- }
-
- public void testAddAllObjectArrayIterator_String() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = this.buildStringList1().iterator();
- String[] newArray = ArrayTools.addAll(a, iterator);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, this.buildStringList1()));
- }
-
- public void testAddAllObjectArrayIterator_Object() {
- String[] a = this.buildStringArray1();
- Iterator<Object> iterator = this.buildObjectList1().iterator();
- Object[] newArray = ArrayTools.addAll(a, iterator);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, this.buildObjectList1()));
- }
-
- public void testAddAllObjectArrayIterator_EmptyIterator() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = EmptyIterator.instance();
- String[] newArray = ArrayTools.addAll(a, iterator);
-
- assertEquals(3, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, this.buildStringList1()));
- }
-
- public void testAddAllObjectArrayIteratorInt() {
- String[] a = this.buildStringArray1();
- Iterator<Object> iterator = this.buildObjectList1().iterator();
- Object[] newArray = ArrayTools.addAll(a, iterator, 3);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, this.buildObjectList1()));
- }
-
- public void testAddAllObjectArrayIteratorInt_EmptyIterator() {
- String[] a = this.buildStringArray1();
- Iterator<String> iterator = EmptyIterator.instance();
- String[] newArray = ArrayTools.addAll(a, iterator, 0);
-
- assertEquals(3, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, this.buildStringList1()));
- }
-
- public void testAddAllObjectArrayObjectArray_Object() {
- Object[] a1 = this.buildObjectArray1();
- Object[] a2 = this.buildObjectArray2();
- Object[] newArray = ArrayTools.addAll(a1, a2);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, a1));
- assertTrue(ArrayTools.containsAll(newArray, a2));
- }
-
- public void testAddAllObjectArrayObjectArray_String() {
- String[] a1 = this.buildStringArray1();
- String[] a2 = this.buildStringArray2();
- String[] newArray = ArrayTools.addAll(a1, a2);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, (Object[]) a1));
- assertTrue(ArrayTools.containsAll(newArray, (Object[]) a2));
- }
-
- public void testAddAllObjectArrayObjectArray_ObjectString() {
- Object[] a1 = this.buildObjectArray1();
- String[] a2 = this.buildStringArray2();
- Object[] newArray = ArrayTools.addAll(a1, (Object[]) a2);
-
- assertEquals(6, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, a1));
- assertTrue(ArrayTools.containsAll(newArray, (Object[]) a2));
- }
-
- public void testAddAllObjectArrayObjectArray_EmptyArray1() {
- Object[] a1 = new Object[0];
- Object[] a2 = this.buildObjectArray2();
- Object[] newArray = ArrayTools.addAll(a1, a2);
-
- assertEquals(3, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, a2));
- }
-
- public void testAddAllObjectArrayObjectArray_EmptyArray2() {
- Object[] a1 = this.buildObjectArray1();
- Object[] a2 = new Object[0];
- Object[] newArray = ArrayTools.addAll(a1, a2);
-
- assertEquals(3, newArray.length);
- assertTrue(ArrayTools.containsAll(newArray, a1));
- }
-
- public void testAddAllObjectArrayIntObjectArray_Object() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- a = ArrayTools.addAll(a, 2, new Object[] { "X", "X", "X" });
- assertEquals(7, a.length);
- assertTrue(ArrayTools.contains(a, "X"));
- assertTrue(Arrays.equals(new Object[] { "a", "b", "X", "X", "X", "c", "d" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_String() {
- String[] a = new String[] { "a", "b", "c", "d" };
- a = ArrayTools.addAll(a, 2, new String[] { "X", "X", "X" });
- assertEquals(7, a.length);
- assertTrue(ArrayTools.contains(a, "X"));
- assertTrue(Arrays.equals(new String[] { "a", "b", "X", "X", "X", "c", "d" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_ObjectString() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- a = ArrayTools.addAll(a, 2, (Object[]) new String[] { "X", "X", "X" });
- assertEquals(7, a.length);
- assertTrue(ArrayTools.contains(a, "X"));
- assertTrue(Arrays.equals(new Object[] { "a", "b", "X", "X", "X", "c", "d" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_End() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- a = ArrayTools.addAll(a, 4, (Object[]) new String[] { "X", "X", "X" });
- assertEquals(7, a.length);
- assertTrue(ArrayTools.contains(a, "X"));
- assertTrue(Arrays.equals(new Object[] { "a", "b", "c", "d", "X", "X", "X" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_Zero() {
- Object[] a = new Object[0];
- a = ArrayTools.addAll(a, 0, (Object[]) new String[] { "X", "X", "X" });
- assertEquals(3, a.length);
- assertTrue(ArrayTools.contains(a, "X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_EmptyArray2() {
- Object[] a = new Object[] { "a", "b", "c", "d" };
- a = ArrayTools.addAll(a, 4, (Object[]) new String[0]);
- assertEquals(4, a.length);
- assertTrue(Arrays.equals(new Object[] { "a", "b", "c", "d" }, a));
- }
-
- public void testAddAllObjectArrayIntObjectArray_EmptyArray1() {
- Object[] a = new String[0];
- a = ArrayTools.addAll(a, 0, new Object[] { "a", "b", "c", "d" });
- assertEquals(4, a.length);
- assertTrue(Arrays.equals(new Object[] { "a", "b", "c", "d" }, a));
- }
-
- public void testAddAllCharArrayCharArray() {
- char[] a = ArrayTools.addAll(this.buildCharArray(), new char[] { 'd', 'e' });
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, 'd'));
- assertTrue(ArrayTools.contains(a, 'e'));
- }
-
- public void testAddAllCharArrayCharArray_EmptyArray2() {
- char[] a = ArrayTools.addAll(this.buildCharArray(), new char[0]);
- assertEquals(3, a.length);
- }
-
- public void testAddAllCharArrayCharArrayEmptyArray1() {
- char[] a = ArrayTools.addAll(new char[0], new char[] { 'd', 'e' });
- assertEquals(2, a.length);
- assertTrue(ArrayTools.contains(a, 'd'));
- assertTrue(ArrayTools.contains(a, 'e'));
- }
-
- public void testAddAllCharArrayIntCharArray() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = ArrayTools.addAll(a, 2, new char[] { 'X', 'X', 'X' });
- assertEquals(7, a.length);
- assertTrue(ArrayTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'X', 'X', 'X', 'c', 'd' }, a));
- }
-
- public void testAddAllCharArrayIntCharArray_End() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = ArrayTools.addAll(a, 4, new char[] { 'X', 'X', 'X' });
- assertEquals(7, a.length);
- assertTrue(ArrayTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'c', 'd', 'X', 'X', 'X' }, a));
- }
-
- public void testAddAllCharArrayIntCharArray_EmptyArray1() {
- char[] a = new char[0];
- a = ArrayTools.addAll(a, 0, new char[] { 'X', 'X', 'X' });
- assertEquals(3, a.length);
- assertTrue(ArrayTools.contains(a, 'X'));
- assertTrue(Arrays.equals(new char[] { 'X', 'X', 'X' }, a));
- }
-
- public void testAddAllCharArrayIntCharArray_EmptyArray2() {
- char[] a = new char[] { 'a', 'b', 'c', 'd' };
- a = ArrayTools.addAll(a, 2, new char[0]);
- assertEquals(4, a.length);
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'c', 'd' }, a));
- }
-
- public void testAddAllIntArrayIntArray() {
- int[] a = ArrayTools.addAll(this.buildIntArray(), new int[] { 30, 40 });
- assertEquals(5, a.length);
- assertTrue(ArrayTools.contains(a, 30));
- assertTrue(ArrayTools.contains(a, 40));
- }
-
- public void testAddAllIntArrayIntArray_EmptyArray2() {
- int[] a = ArrayTools.addAll(this.buildIntArray(), new int[0]);
- assertEquals(3, a.length);
- }
-
- public void testAddAllIntArrayIntArray_EmptyArray1() {
- int[] a = ArrayTools.addAll(new int[0], new int[] { 30, 40 });
- assertEquals(2, a.length);
- assertTrue(ArrayTools.contains(a, 30));
- assertTrue(ArrayTools.contains(a, 40));
- }
-
- public void testAddAllIntArrayIntIntArray() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = ArrayTools.addAll(a, 2, new int[] { 99, 99, 99 });
- assertEquals(7, a.length);
- assertTrue(ArrayTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 1, 2, 99, 99, 99, 3, 4 }, a));
- }
-
- public void testAddAllIntArrayIntIntArray_End() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = ArrayTools.addAll(a, 4, new int[] { 99, 99, 99 });
- assertEquals(7, a.length);
- assertTrue(ArrayTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 1, 2, 3, 4, 99, 99, 99 }, a));
- }
-
- public void testAddAllIntArrayIntIntArray_EmptyArray2() {
- int[] a = new int[] { 1, 2, 3, 4 };
- a = ArrayTools.addAll(a, 2, new int[0]);
- assertEquals(4, a.length);
- assertTrue(Arrays.equals(new int[] { 1, 2, 3, 4 }, a));
- }
-
- public void testAddAllIntArrayIntIntArray_EmptyArray1() {
- int[] a = new int[0];
- a = ArrayTools.addAll(a, 0, new int[] { 99, 99, 99 });
- assertEquals(3, a.length);
- assertTrue(ArrayTools.contains(a, 99));
- assertTrue(Arrays.equals(new int[] { 99, 99, 99 }, a));
- }
-
-
- // ********** clear **********
-
- public void testClearObjectArray() {
- String[] a = this.buildStringArray1();
- assertEquals(3, a.length);
- a = ArrayTools.clear(a);
- assertEquals(0, a.length);
- }
-
- public void testClearObjectArray_Empty() {
- String[] a = new String[0];
- assertEquals(0, a.length);
- a = ArrayTools.clear(a);
- assertEquals(0, a.length);
- }
-
-
- // ********** concatenate **********
-
- public void testConcatenateObjectArrayArray() {
- String[] aArray = new String[] { "a", "b", "c", "d" };
- String[] eArray = new String[] { "e", "f", "g", "h" };
- String[] iArray = new String[] { "i", "j", "k", "l" };
-
- String[] expected = new String[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l" };
- String[] actual = ArrayTools.concatenate(aArray, eArray, iArray);
- assertTrue(Arrays.equals(expected, actual));
- }
-
- public void testConcatenateObjectArrayArray_Empty() {
- String[] aArray = new String[] { };
- String[] eArray = new String[0];
- String[] iArray = new String[0];
-
- String[] expected = new String[0];
- String[] actual = ArrayTools.concatenate(aArray, eArray, iArray);
- assertEquals(0, actual.length);
- assertTrue(Arrays.equals(expected, actual));
- }
-
- public void testConcatenateCharArrayArray() {
- char[] aArray = new char[] { 'a', 'b', 'c', 'd' };
- char[] eArray = new char[] { 'e', 'f', 'g', 'h' };
- char[] iArray = new char[] { 'i', 'j', 'k', 'l' };
-
- char[] expected = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l' };
- char[] actual = ArrayTools.concatenate(aArray, eArray, iArray);
- assertTrue(Arrays.equals(expected, actual));
- }
-
- public void testConcatenateCharArrayArray_Empty() {
- char[] aArray = new char[] { };
- char[] eArray = new char[0];
- char[] iArray = new char[0];
-
- char[] expected = new char[0];
- char[] actual = ArrayTools.concatenate(aArray, eArray, iArray);
- assertEquals(0, actual.length);
- assertTrue(Arrays.equals(expected, actual));
- }
-
- public void testConcatenateIntArrayArray() {
- int[] aArray = new int[] { 'a', 'b', 'c', 'd' };
- int[] eArray = new int[] { 'e', 'f', 'g', 'h' };
- int[] iArray = new int[] { 'i', 'j', 'k', 'l' };
-
- int[] expected = new int[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l' };
- int[] actual = ArrayTools.concatenate(aArray, eArray, iArray);
- assertTrue(Arrays.equals(expected, actual));
- }
-
- public void testConcatenateIntArrayArray_Empty() {
- int[] aArray = new int[] { };
- int[] eArray = new int[0];
- int[] iArray = new int[0];
-
- int[] expected = new int[0];
- int[] actual = ArrayTools.concatenate(aArray, eArray, iArray);
- assertEquals(0, actual.length);
- assertTrue(Arrays.equals(expected, actual));
- }
-
-
- // ********** contains **********
-
- public void testContainsObjectArrayObject() {
- Object[] a = this.buildObjectArray1();
- assertTrue(ArrayTools.contains(a, "one"));
- assertFalse(ArrayTools.contains(a, null));
- Object[] a2 = ArrayTools.add(a, null);
- assertTrue(ArrayTools.contains(a2, null));
- }
-
- public void testContainsObjectArrayObject_EmptyArray() {
- Object[] a = new Object[0];
- assertFalse(ArrayTools.contains(a, "one"));
- assertFalse(ArrayTools.contains(a, null));
- }
-
- public void testContainsCharArrayChar() {
- char[] a = this.buildCharArray();
- assertTrue(ArrayTools.contains(a, 'a'));
- assertFalse(ArrayTools.contains(a, 'z'));
- char[] a2 = ArrayTools.add(a, 'z');
- assertTrue(ArrayTools.contains(a2, 'z'));
- }
-
- public void testContainsCharArrayObject_EmptyArray() {
- char[] a = new char[0];
- assertFalse(ArrayTools.contains(a, 'a'));
- }
-
- public void testContainsIntArrayInt() {
- int[] a = this.buildIntArray();
- assertTrue(ArrayTools.contains(a, 10));
- assertFalse(ArrayTools.contains(a, 55));
- int[] a2 = ArrayTools.add(a, 55);
- assertTrue(ArrayTools.contains(a2, 55));
- }
-
- public void testContainsIntArrayObject_EmptyArray() {
- int[] a = new int[0];
- assertFalse(ArrayTools.contains(a, 'a'));
- }
-
-
- // ********** contains all **********
-
- public void testContainsAllObjectArrayCollection() {
- assertTrue(ArrayTools.containsAll(this.buildObjectArray1(), this.buildStringList1()));
- assertFalse(ArrayTools.containsAll(this.buildObjectArray1(), this.buildStringList2()));
- }
-
- public void testContainsAllObjectArrayIterable() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(ArrayTools.containsAll(this.buildObjectArray1(), iterable));
- iterable = this.buildStringList2();
- assertFalse(ArrayTools.containsAll(this.buildObjectArray1(), iterable));
- }
-
- public void testContainsAllObjectArrayIterator() {
- assertTrue(ArrayTools.containsAll(this.buildObjectArray1(), this.buildStringList1().iterator()));
- assertFalse(ArrayTools.containsAll(this.buildObjectArray1(), this.buildStringList2().iterator()));
- }
-
- public void testContainsAllObjectArrayIterator_Empty() {
- assertTrue(ArrayTools.containsAll(this.buildObjectArray1(), EmptyIterator.instance()));
- }
-
- public void testContainsAllObjectArrayObjectArray() {
- assertTrue(ArrayTools.containsAll(this.buildObjectArray1(), this.buildObjectArray1()));
- assertFalse(ArrayTools.containsAll(this.buildObjectArray1(), this.buildObjectArray2()));
- }
-
- public void testContainsAllCharArrayCharArray() {
- assertTrue(ArrayTools.containsAll(this.buildCharArray(), this.buildCharArray()));
- assertFalse(ArrayTools.containsAll(this.buildCharArray(), new char[] { 'x', 'y' }));
- }
-
- public void testContainsAllIntArrayIntArray() {
- assertTrue(ArrayTools.containsAll(this.buildIntArray(), this.buildIntArray()));
- assertFalse(ArrayTools.containsAll(this.buildIntArray(), new int[] { 444, 888 }));
- }
-
-
- // ********** diff **********
-
- public void testDiffEnd() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = new String("a");
- String b_ = new String("b");
- String c_ = new String("c");
- String d_ = new String("d");
- String e_ = new String("e");
- assertTrue((a != a_) && a.equals(a_));
- assertTrue((b != b_) && b.equals(b_));
- assertTrue((c != c_) && c.equals(c_));
- assertTrue((d != d_) && d.equals(d_));
- assertTrue((e != e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(-1, ArrayTools.diffEnd(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(-1, ArrayTools.diffEnd(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, ArrayTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, d_, e_ };
- assertEquals(4, ArrayTools.diffEnd(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, ArrayTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(4, ArrayTools.diffEnd(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(-1, ArrayTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, a_, d_, e_ };
- assertEquals(2, ArrayTools.diffEnd(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(0, ArrayTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(3, ArrayTools.diffEnd(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c_));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(-1, ArrayTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(2, ArrayTools.diffEnd(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(-1, ArrayTools.diffEnd(array1, array2));
- }
-
- public void testDiffRange() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = a;
- String b_ = b;
- String c_ = c;
- String d_ = d;
- String e_ = e;
- assertTrue((a == a_) && a.equals(a_));
- assertTrue((b == b_) && b.equals(b_));
- assertTrue((c == c_) && c.equals(c_));
- assertTrue((d == d_) && d.equals(d_));
- assertTrue((e == e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(5, -1), ArrayTools.diffRange(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(new Range(1, -1), ArrayTools.diffRange(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), ArrayTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), ArrayTools.diffRange(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), ArrayTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(new Range(0, 4), ArrayTools.diffRange(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(new Range(0, -1), ArrayTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, a_, d_, e_ };
- assertEquals(new Range(0, 2), ArrayTools.diffRange(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(new Range(0, 0), ArrayTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(new Range(3, 3), ArrayTools.diffRange(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c_));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(new Range(5, -1), ArrayTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(2, 2), ArrayTools.diffRange(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(new Range(5, -1), ArrayTools.diffRange(array1, array2));
- }
-
- public void testDiffStart() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = new String("a");
- String b_ = new String("b");
- String c_ = new String("c");
- String d_ = new String("d");
- String e_ = new String("e");
- assertTrue((a != a_) && a.equals(a_));
- assertTrue((b != b_) && b.equals(b_));
- assertTrue((c != c_) && c.equals(c_));
- assertTrue((d != d_) && d.equals(d_));
- assertTrue((e != e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(5, ArrayTools.diffStart(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(1, ArrayTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, ArrayTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(4, ArrayTools.diffStart(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(0, ArrayTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(0, ArrayTools.diffStart(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(0, ArrayTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, e_, c_, d_ };
- assertEquals(2, ArrayTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(3, ArrayTools.diffStart(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(0, ArrayTools.diffStart(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c__));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(5, ArrayTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(2, ArrayTools.diffStart(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(5, ArrayTools.diffStart(array1, array2));
- }
-
-
- // ********** identity diff **********
-
- public void testIdentityDiffEnd() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = a;
- String b_ = b;
- String c_ = c;
- String d_ = d;
- String e_ = e;
- assertTrue((a == a_) && a.equals(a_));
- assertTrue((b == b_) && b.equals(b_));
- assertTrue((c == c_) && c.equals(c_));
- assertTrue((d == d_) && d.equals(d_));
- assertTrue((e == e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(-1, ArrayTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(-1, ArrayTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, ArrayTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, d_, e_ };
- assertEquals(4, ArrayTools.identityDiffEnd(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, ArrayTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(4, ArrayTools.identityDiffEnd(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(-1, ArrayTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, a_, d_, e_ };
- assertEquals(2, ArrayTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(0, ArrayTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(3, ArrayTools.identityDiffEnd(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c_));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(2, ArrayTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(2, ArrayTools.identityDiffEnd(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(-1, ArrayTools.identityDiffEnd(array1, array2));
- }
-
- public void testIdentityDiffRange() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = a;
- String b_ = b;
- String c_ = c;
- String d_ = d;
- String e_ = e;
- assertTrue((a == a_) && a.equals(a_));
- assertTrue((b == b_) && b.equals(b_));
- assertTrue((c == c_) && c.equals(c_));
- assertTrue((d == d_) && d.equals(d_));
- assertTrue((e == e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(5, -1), ArrayTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(new Range(1, -1), ArrayTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), ArrayTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), ArrayTools.identityDiffRange(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(0, 4), ArrayTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(new Range(0, 4), ArrayTools.identityDiffRange(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(new Range(0, -1), ArrayTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { b_, c_, a_, d_, e_ };
- assertEquals(new Range(0, 2), ArrayTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(new Range(0, 0), ArrayTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(new Range(3, 3), ArrayTools.identityDiffRange(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c_));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(new Range(2, 2), ArrayTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(new Range(2, 2), ArrayTools.identityDiffRange(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(new Range(5, -1), ArrayTools.identityDiffRange(array1, array2));
- }
-
- public void testIdentityDiffStart() {
- String a = "a";
- String b = "b";
- String c = "c";
- String d = "d";
- String e = "e";
- String a_ = a;
- String b_ = b;
- String c_ = c;
- String d_ = d;
- String e_ = e;
- assertTrue((a == a_) && a.equals(a_));
- assertTrue((b == b_) && b.equals(b_));
- assertTrue((c == c_) && c.equals(c_));
- assertTrue((d == d_) && d.equals(d_));
- assertTrue((e == e_) && e.equals(e_));
- String[] array1;
- String[] array2;
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(5, ArrayTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a };
- array2 = new String[] { a_ };
- assertEquals(1, ArrayTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(4, ArrayTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(4, ArrayTools.identityDiffStart(array1, array2));
-
- array1 = new String[0];
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(0, ArrayTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[0];
- assertEquals(0, ArrayTools.identityDiffStart(array1, array2));
-
- array1 = new String[0];
- array2 = new String[0];
- assertEquals(0, ArrayTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, e_, c_, d_ };
- assertEquals(2, ArrayTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, c, e };
- array2 = new String[] { a_, b_, c_, d_ };
- assertEquals(3, ArrayTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { b, c, d, e };
- array2 = new String[] { a_, c_, d_, e_ };
- assertEquals(0, ArrayTools.identityDiffStart(array1, array2));
-
- String c__ = new String(c);
- assertTrue((c != c__) && c.equals(c_));
- array1 = new String[] { a, b, c, d, e };
- array2 = new String[] { a_, b_, c__, d_, e_ };
- assertEquals(2, ArrayTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, c_, d_, e_ };
- assertEquals(2, ArrayTools.identityDiffStart(array1, array2));
-
- array1 = new String[] { a, b, null, d, e };
- array2 = new String[] { a_, b_, null, d_, e_ };
- assertEquals(5, ArrayTools.identityDiffStart(array1, array2));
- }
-
-
- // ********** elements are identical **********
-
- public void testElementsAreIdenticalObjectArrayObjectArray() {
- Object[] a1 = new Object[4];
- for (int i = 0; i < a1.length; i++) {
- a1[i] = String.valueOf(i * 1000);
- }
-
- Object[] a2 = new Object[a1.length];
- for (int i = 0; i < a2.length; i++) {
- a2[i] = a1[i];
- }
-
- assertTrue(ArrayTools.elementsAreIdentical(a1, a2));
- a2[2] = "2000";
- assertFalse(ArrayTools.elementsAreIdentical(a1, a2));
- assertTrue(Arrays.equals(a1, a2));
- }
-
- public void testElementsAreIdenticalObjectArrayObjectArray_BothNull() {
- Object[] a1 = null;
- Object[] a2 = null;
- assertTrue(ArrayTools.elementsAreIdentical(a1, a2));
- }
-
- public void testElementsAreIdenticalObjectArrayObjectArray_OneNull() {
- Object[] a1 = null;
- Object[] a2 = new Object[0];
- assertFalse(ArrayTools.elementsAreIdentical(a1, a2));
- }
-
- public void testElementsAreIdenticalObjectArrayObjectArray_DifferentLengths() {
- Object[] a1 = new String[] {"foo", "bar"};
- Object[] a2 = new String[] {"foo", "bar", "baz"};
- assertFalse(ArrayTools.elementsAreIdentical(a1, a2));
- }
-
-
- // ********** index of **********
-
- public void testIndexOfObjectArrayObject() {
- Object[] a = this.buildObjectArray1();
- assertEquals(1, ArrayTools.indexOf(a, "one"));
- }
-
- public void testIndexOfObjectArrayObject_NotFound() {
- Object[] a = this.buildObjectArray1();
- assertEquals(-1, ArrayTools.indexOf(a, "twenty"));
- }
-
- public void testIndexOfObjectArrayObject_Null() {
- Object[] a = this.buildObjectArray1();
- a = ArrayTools.add(a, null);
- assertEquals(a.length - 1, ArrayTools.indexOf(a, null));
- }
-
- public void testIndexOfObjectArrayObject_Null_NotFound() {
- Object[] a = this.buildObjectArray1();
- assertEquals(-1, ArrayTools.indexOf(a, null));
- }
-
- public void testIdentityIndexOfObjectArrayObject() {
- String foo = "foo";
- String bar = "bar";
- String baz = "baz";
- Object[] a = new Object[3];
- a[0] = foo;
- a[1] = bar;
- a[2] = baz;
- assertEquals(1, ArrayTools.identityIndexOf(a, bar));
- }
-
- public void testIdentityIndexOfObjectArrayObject_NotFound() {
- String foo = "foo";
- String bar = "bar";
- String baz = "baz";
- Object[] a = new Object[3];
- a[0] = foo;
- a[1] = bar;
- a[2] = baz;
- assertEquals(-1, ArrayTools.identityIndexOf(a, new String("bar")));
- }
-
- public void testIndexOfCharArrayChar() {
- char[] a = this.buildCharArray();
- assertEquals(1, ArrayTools.indexOf(a, 'b'));
- a = ArrayTools.add(a, 'd');
- assertEquals(a.length - 1, ArrayTools.indexOf(a, 'd'));
- }
-
- public void testIndexOfCharArrayChar_NotFound() {
- char[] a = this.buildCharArray();
- assertEquals(-1, ArrayTools.indexOf(a, 'z'));
- }
-
- public void testIndexOfIntArrayInt() {
- int[] a = this.buildIntArray();
- assertEquals(1, ArrayTools.indexOf(a, 10));
- a = ArrayTools.add(a, 30);
- assertEquals(a.length - 1, ArrayTools.indexOf(a, 30));
- }
-
- public void testIndexOfIntArrayInt_NotFound() {
- int[] a = this.buildIntArray();
- assertEquals(-1, ArrayTools.indexOf(a, 1000));
- }
-
-
- // ********** insertion index of **********
-
- public void testInsertionIndexOfObjectArrayComparable() {
- String[] a = new String[] { "A", "C", "D" };
- assertEquals(1, ArrayTools.insertionIndexOf(a, "B"));
-
- a = new String[] { "A", "B", "C", "D" };
- assertEquals(2, ArrayTools.insertionIndexOf(a, "B"));
-
- a = new String[] { "A", "B", "B", "B", "C", "D" };
- assertEquals(4, ArrayTools.insertionIndexOf(a, "B"));
-
- a = new String[] { "A", "B", "B", "B", "C", "D" };
- assertEquals(6, ArrayTools.insertionIndexOf(a, "E"));
-
- a = new String[] { "B", "B", "B", "C", "D" };
- assertEquals(0, ArrayTools.insertionIndexOf(a, "A"));
-
- a = new String[] { "A", "A", "B", "B", "C", "D" };
- assertEquals(2, ArrayTools.insertionIndexOf(a, "A"));
- }
-
- public void testInsertionIndexOfObjectArrayObjectComparator() {
- Comparator<String> c = new ReverseComparator<String>();
- String[] a = new String[] { "D", "C", "A" };
- assertEquals(2, ArrayTools.insertionIndexOf(a, "B", c));
-
- a = new String[] { "D", "C", "B", "A" };
- assertEquals(3, ArrayTools.insertionIndexOf(a, "B", c));
-
- a = new String[] { "D", "C", "B", "B", "B", "A" };
- assertEquals(5, ArrayTools.insertionIndexOf(a, "B", c));
-
- a = new String[] { "D", "C", "B", "B", "B", "A" };
- assertEquals(0, ArrayTools.insertionIndexOf(a, "E", c));
-
- a = new String[] { "D", "C", "B", "B", "B" };
- assertEquals(5, ArrayTools.insertionIndexOf(a, "A", c));
-
- a = new String[] { "D", "C", "B", "B", "A", "A" };
- assertEquals(6, ArrayTools.insertionIndexOf(a, "A", c));
- }
-
-
- // ********** last index of **********
-
- public void testLastIndexOfObjectArrayObject() {
- Object[] a = this.buildObjectArray1();
- assertEquals(1, ArrayTools.lastIndexOf(a, "one"));
- }
-
- public void testLastIndexOfObjectArrayObject_NotFound() {
- Object[] a = this.buildObjectArray1();
- assertEquals(-1, ArrayTools.lastIndexOf(a, "twenty"));
- }
-
- public void testLastIndexOfObjectArrayObject_Null() {
- Object[] a = this.buildObjectArray1();
- a = ArrayTools.add(a, null);
- assertEquals(a.length - 1, ArrayTools.lastIndexOf(a, null));
- }
-
- public void testLastIndexOfObjectArrayObject_Null_NotFound() {
- Object[] a = this.buildObjectArray1();
- assertEquals(-1, ArrayTools.lastIndexOf(a, null));
- }
-
- public void testLastIndexOfCharArrayChar() {
- char[] a = this.buildCharArray();
- assertEquals(1, ArrayTools.lastIndexOf(a, 'b'));
- a = ArrayTools.add(a, 'd');
- assertEquals(a.length - 1, ArrayTools.lastIndexOf(a, 'd'));
- }
-
- public void testLastIndexOfCharArrayChar_NotFound() {
- char[] a = this.buildCharArray();
- assertEquals(-1, ArrayTools.lastIndexOf(a, 'z'));
- }
-
- public void testLastIndexOfIntArrayInt() {
- int[] a = this.buildIntArray();
- assertEquals(1, ArrayTools.lastIndexOf(a, 10));
- a = ArrayTools.add(a, 30);
- assertEquals(a.length - 1, ArrayTools.lastIndexOf(a, 30));
- }
-
- public void testLastIndexOfIntArrayInt_NotFound() {
- int[] a = this.buildIntArray();
- assertEquals(-1, ArrayTools.lastIndexOf(a, 1000));
- }
-
-
- // ********** min/max **********
-
- public void testMinCharArray() {
- assertEquals('a', ArrayTools.min(this.buildCharArray()));
- }
-
- public void testMinCharArray_Exception() {
- char[] array = new char[0];
- boolean exCaught = false;
- try {
- char c = ArrayTools.min(array);
- fail("bogus char: " + c);
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testMinIntArray() {
- assertEquals(0, ArrayTools.min(this.buildIntArray()));
- }
-
- public void testMinIntArray_Exception() {
- int[] array = new int[0];
- boolean exCaught = false;
- try {
- int i = ArrayTools.min(array);
- fail("bogus int: " + i);
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testMaxCharArray1() {
- assertEquals('c', ArrayTools.max(this.buildCharArray()));
- }
-
- public void testMaxCharArray2() {
- char[] array = new char[] { 'x', 'a', 'b', 'c' };
- assertEquals('x', ArrayTools.max(array));
- }
-
- public void testMaxCharArray_Exception() {
- char[] array = new char[0];
- boolean exCaught = false;
- try {
- char c = ArrayTools.max(array);
- fail("bogus char: " + c);
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testMaxIntArray1() {
- assertEquals(20, ArrayTools.max(this.buildIntArray()));
- }
-
- public void testMaxIntArray2() {
- int[] array = new int[] { 77, 3, 1, -3 };
- assertEquals(77, ArrayTools.max(array));
- }
-
- public void testMaxIntArray_Exception() {
- int[] array = new int[0];
- boolean exCaught = false;
- try {
- int i = ArrayTools.max(array);
- fail("bogus int: " + i);
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- // ********** move **********
-
- public void testMoveObjectArrayIntInt() {
- String[] array = new String[] { "0", "1", "2", "3", "4", "5" };
-
- String[] result = ArrayTools.move(array, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result));
-
- result = ArrayTools.move(array, 0, 5);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result));
-
- result = ArrayTools.move(array, 2, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result));
-
- result = ArrayTools.move(array, 4, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result));
- }
-
- public void testMoveObjectArrayIntIntInt() {
- String[] array = new String[] { "0", "1", "2", "3", "4", "5" };
-
- String[] result = ArrayTools.move(array, 4, 2, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result));
-
- result = ArrayTools.move(array, 0, 5, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result));
-
- result = ArrayTools.move(array, 2, 4, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result));
-
- result = ArrayTools.move(array, 2, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result));
-
- result = ArrayTools.move(array, 0, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "3", "2", "4", "5", "1" }, result));
-
- result = ArrayTools.move(array, 1, 0, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result));
-
- result = ArrayTools.move(array, 1, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result));
-
- result = ArrayTools.move(array, 1, 0, 0);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result));
- }
-
- public void testMoveIntArrayIntInt() {
- int[] array = new int[] { 0, 1, 2, 3, 4, 5 };
-
- int[] result = ArrayTools.move(array, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 0, 1, 3, 4, 2, 5 }, result));
-
- result = ArrayTools.move(array, 0, 5);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 1, 3, 4, 2 }, result));
-
- result = ArrayTools.move(array, 2, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 4, 1, 3, 2 }, result));
-
- result = ArrayTools.move(array, 2, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 4, 1, 3, 2 }, result));
- }
-
- public void testMoveIntArrayIntIntInt() {
- int[] array = new int[] { 0, 1, 2, 3, 4, 5 };
-
- int[] result = ArrayTools.move(array, 4, 2, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 0, 1, 3, 4, 2, 5 }, result));
-
- result = ArrayTools.move(array, 0, 5, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 1, 3, 4, 2 }, result));
-
- result = ArrayTools.move(array, 2, 4, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 4, 1, 3, 2 }, result));
-
- result = ArrayTools.move(array, 2, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 3, 2, 4, 1 }, result));
-
- result = ArrayTools.move(array, 0, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 0, 3, 2, 4, 5, 1 }, result));
-
- result = ArrayTools.move(array, 1, 0, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 3, 2, 4, 1 }, result));
-
- result = ArrayTools.move(array, 1, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 3, 2, 4, 1 }, result));
-
- result = ArrayTools.move(array, 1, 0, 0);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new int[] { 5, 0, 3, 2, 4, 1 }, result));
- }
-
- public void testMoveCharArrayIntInt() {
- char[] array = new char[] { 'a', 'b', 'c', 'd', 'e', 'f' };
-
- char[] result = ArrayTools.move(array, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'd', 'e', 'c', 'f' }, result));
-
- result = ArrayTools.move(array, 0, 5);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'f', 'a', 'b', 'd', 'e', 'c' }, result));
-
- result = ArrayTools.move(array, 2, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'f', 'a', 'e', 'b', 'd', 'c' }, result));
-
- result = ArrayTools.move(array, 2, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'f', 'a', 'e', 'b', 'd', 'c' }, result));
- }
-
- public void testMoveCharArrayIntIntInt() {
- char[] array = new char[] { 'a', 'b', 'b', 'c', 'd', 'e' };
-
- char[] result = ArrayTools.move(array, 4, 2, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'a', 'b', 'c', 'd', 'b', 'e' }, result));
-
- result = ArrayTools.move(array, 0, 5, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'b', 'c', 'd', 'b' }, result));
-
- result = ArrayTools.move(array, 2, 4, 1);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'd', 'b', 'c', 'b' }, result));
-
- result = ArrayTools.move(array, 2, 4, 2);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'c', 'b', 'd', 'b' }, result));
-
- result = ArrayTools.move(array, 0, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'a', 'c', 'b', 'd', 'e', 'b' }, result));
-
- result = ArrayTools.move(array, 1, 0, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'c', 'b', 'd', 'b' }, result));
-
- result = ArrayTools.move(array, 1, 1, 4);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'c', 'b', 'd', 'b' }, result));
-
- result = ArrayTools.move(array, 1, 0, 0);
- assertSame(array, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new char[] { 'e', 'a', 'c', 'b', 'd', 'b' }, result));
- }
-
-
- // ********** remove **********
-
- public void testRemoveObjectArrayObject_Object() {
- Object[] a = this.buildObjectArray1();
- a = ArrayTools.add(a, "three");
- a = ArrayTools.add(a, "four");
- a = ArrayTools.add(a, "five");
-
- assertEquals(6, a.length);
- assertTrue(ArrayTools.contains(a, "three"));
- a = ArrayTools.remove(a, "three");
- assertEquals(5, a.length);
- assertFalse(ArrayTools.contains(a, "three"));
- assertTrue(ArrayTools.contains(a, "four"));
- assertTrue(ArrayTools.contains(a, "five"));
- }
-
- public void testRemoveObjectArrayObject_String() {
- String[] a = this.buildStringArray1();
- a = ArrayTools.add(a, "three");
- a = ArrayTools.add(a, "four");
- a = ArrayTools.add(a, "five");
-
- assertEquals(6, a.length);
- assertTrue(ArrayTools.contains(a, "three"));
- a = ArrayTools.remove(a, "three");
- assertEquals(5, a.length);
- assertFalse(ArrayTools.contains(a, "three"));
- assertTrue(ArrayTools.contains(a, "four"));
- assertTrue(ArrayTools.contains(a, "five"));
- }
-
- public void testRemoveCharArrayChar() {
- char[] a = this.buildCharArray();
- a = ArrayTools.add(a, 'd');
- a = ArrayTools.add(a, 'e');
- a = ArrayTools.add(a, 'f');
-
- assertEquals(6, a.length);
- assertTrue(ArrayTools.contains(a, 'd'));
- a = ArrayTools.remove(a, 'd');
- assertEquals(5, a.length);
- assertFalse(ArrayTools.contains(a, 'd'));
- assertTrue(ArrayTools.contains(a, 'e'));
- assertTrue(ArrayTools.contains(a, 'f'));
- }
-
- public void testRemoveIntArrayInt() {
- int[] a = this.buildIntArray();
- a = ArrayTools.add(a, 30);
- a = ArrayTools.add(a, 40);
- a = ArrayTools.add(a, 50);
-
- assertEquals(6, a.length);
- assertTrue(ArrayTools.contains(a, 30));
- a = ArrayTools.remove(a, 30);
- assertEquals(5, a.length);
- assertFalse(ArrayTools.contains(a, 30));
- assertTrue(ArrayTools.contains(a, 40));
- assertTrue(ArrayTools.contains(a, 50));
- }
-
-
- // ********** remove all **********
-
- public void testRemoveAllObjectArrayObjectArray() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- String[] a2 = new String[] { "E", "B" };
- String[] a3 = ArrayTools.removeAll(a1, (Object[]) a2);
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayObjectArray_Empty() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- String[] a2 = new String[0];
- String[] a3 = ArrayTools.removeAll(a1, (Object[]) a2);
- assertTrue(Arrays.equals(a1, a3));
- }
-
- public void testRemoveAllObjectArrayObjectArray_NoMatches() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- String[] a2 = new String[] { "X", "Y", "Z" };
- String[] a3 = ArrayTools.removeAll(a1, (Object[]) a2);
- assertTrue(Arrays.equals(a1, a3));
- }
-
- public void testRemoveAllObjectArrayIterable() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<?> iterable = Arrays.asList(new String[] { "E", "B" });
- String[] a3 = ArrayTools.removeAll(a1, iterable);
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayIterableInt() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<?> iterable = Arrays.asList(new String[] { "E", "B" });
- String[] a3 = ArrayTools.removeAll(a1, iterable, 7);
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayIterator() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<?> iterable = Arrays.asList(new String[] { "E", "B" });
- String[] a3 = ArrayTools.removeAll(a1, iterable.iterator());
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayIterator_Empty() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- String[] a3 = ArrayTools.removeAll(a1, EmptyIterator.instance());
- assertTrue(Arrays.equals(a1, a3));
- }
-
- public void testRemoveAllObjectArrayIteratorInt() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<?> iterable = Arrays.asList(new String[] { "E", "B" });
- String[] a3 = ArrayTools.removeAll(a1, iterable.iterator(), 7);
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayIteratorInt_Empty() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- String[] a3 = ArrayTools.removeAll(a1, EmptyIterator.instance(), 7);
- assertTrue(Arrays.equals(a1, a3));
- }
-
- public void testRemoveAllObjectArrayCollection() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = Arrays.asList(new String[] { "E", "B" });
- String[] a3 = ArrayTools.removeAll(a1, collection);
- assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, a3));
- }
-
- public void testRemoveAllObjectArrayCollection_Empty() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = new ArrayList<String>();
- String[] a3 = ArrayTools.removeAll(a1, collection);
- assertTrue(Arrays.equals(a1, a3));
- }
-
- public void testRemoveAllObjectArrayCollection_EmptyArray() {
- String[] a1 = new String[0];
- Collection<String> collection = Arrays.asList(new String[] { "E", "B" });
- String[] a3 = ArrayTools.removeAll(a1, collection);
- assertTrue(Arrays.equals(a1, a3));
- assertEquals(0, a3.length);
- }
-
- public void testRemoveAllObjectArrayCollection_NoMatches() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = Arrays.asList(new String[] { "X", "Y", "Z" });
- String[] a3 = ArrayTools.removeAll(a1, collection);
- assertTrue(Arrays.equals(a1, a3));
- }
-
- public void testRemoveAllCharArrayCharArray() {
- char[] a1 = new char[] { 'A', 'A', 'B', 'B', 'C', 'C', 'D', 'D', 'E', 'E', 'F', 'F' };
- char[] a2 = new char[] { 'E', 'B' };
- assertTrue(Arrays.equals(new char[] { 'A', 'A', 'C', 'C', 'D', 'D', 'F', 'F' }, ArrayTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllCharArrayCharArray_Empty1() {
- char[] a1 = new char[0];
- char[] a2 = new char[] { 'E', 'B' };
- assertTrue(Arrays.equals(a1, ArrayTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllCharArrayCharArray_Empty2() {
- char[] a1 = new char[] { 'A', 'A', 'B', 'B', 'C', 'C', 'D', 'D', 'E', 'E', 'F', 'F' };
- char[] a2 = new char[0];
- assertTrue(Arrays.equals(a1, ArrayTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllCharArrayCharArray_NoMatches() {
- char[] a1 = new char[] { 'A', 'A', 'B', 'B', 'C', 'C', 'D', 'D', 'E', 'E', 'F', 'F' };
- char[] a2 = new char[] { 'X', 'Z' };
- assertTrue(Arrays.equals(a1, ArrayTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllIntArrayIntArray() {
- int[] a1 = new int[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6 };
- int[] a2 = new int[] { 5, 2 };
- assertTrue(Arrays.equals(new int[] { 1, 1, 3, 3, 4, 4, 6, 6 }, ArrayTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllIntArrayIntArray_Empty1() {
- int[] a1 = new int[0];
- int[] a2 = new int[] { 5, 2 };
- assertTrue(Arrays.equals(a1, ArrayTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllIntArrayIntArray_Empty2() {
- int[] a1 = new int[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6 };
- int[] a2 = new int[0];
- assertTrue(Arrays.equals(a1, ArrayTools.removeAll(a1, a2)));
- }
-
- public void testRemoveAllIntArrayIntArray_NoMatches() {
- int[] a1 = new int[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6 };
- int[] a2 = new int[] { 52, 67 };
- assertTrue(Arrays.equals(a1, ArrayTools.removeAll(a1, a2)));
- }
-
-
- // ********** remove all occurrences **********
-
- public void testRemoveAllOccurrencesObjectArrayObject() {
- String[] a = this.buildStringArray1();
- assertEquals(3, a.length);
- a = ArrayTools.removeAllOccurrences(a, "three");
- assertEquals(3, a.length);
- a = ArrayTools.removeAllOccurrences(a, "two");
- assertEquals(2, a.length);
- a = ArrayTools.removeAllOccurrences(a, "two");
- assertEquals(2, a.length);
-
- a = ArrayTools.add(a, "five");
- a = ArrayTools.add(a, "five");
- a = ArrayTools.add(a, "five");
- assertEquals(5, a.length);
- a = ArrayTools.removeAllOccurrences(a, "five");
- assertEquals(2, a.length);
- a = ArrayTools.removeAllOccurrences(a, "five");
- assertEquals(2, a.length);
-
- a = ArrayTools.add(a, null);
- a = ArrayTools.add(a, null);
- a = ArrayTools.add(a, null);
- assertEquals(5, a.length);
- a = ArrayTools.removeAllOccurrences(a, null);
- assertEquals(2, a.length);
- a = ArrayTools.removeAllOccurrences(a, null);
- assertEquals(2, a.length);
- }
-
- public void testRemoveAllOccurrencesObjectArrayObject_Empty() {
- String[] a = new String[0];
- a = ArrayTools.removeAllOccurrences(a, "three");
- assertEquals(0, a.length);
- }
-
- public void testRemoveAllOccurrencesCharArrayChar() {
- char[] a = this.buildCharArray();
- assertEquals(3, a.length);
- a = ArrayTools.removeAllOccurrences(a, 'd');
- assertEquals(3, a.length);
- a = ArrayTools.removeAllOccurrences(a, 'b');
- assertEquals(2, a.length);
- a = ArrayTools.removeAllOccurrences(a, 'b');
- assertEquals(2, a.length);
-
- a = ArrayTools.add(a, 'g');
- a = ArrayTools.add(a, 'g');
- a = ArrayTools.add(a, 'g');
- assertEquals(5, a.length);
- a = ArrayTools.removeAllOccurrences(a, 'g');
- assertEquals(2, a.length);
- a = ArrayTools.removeAllOccurrences(a, 'g');
- assertEquals(2, a.length);
- }
-
- public void testRemoveAllOccurrencesCharArrayChar_Empty() {
- char[] a = new char[0];
- a = ArrayTools.removeAllOccurrences(a, 'a');
- assertEquals(0, a.length);
- }
-
- public void testRemoveAllOccurrencesIntArrayInt() {
- int[] a = this.buildIntArray();
- assertEquals(3, a.length);
- a = ArrayTools.removeAllOccurrences(a, 55);
- assertEquals(3, a.length);
- a = ArrayTools.removeAllOccurrences(a, 10);
- assertEquals(2, a.length);
- a = ArrayTools.removeAllOccurrences(a, 10);
- assertEquals(2, a.length);
-
- a = ArrayTools.add(a, 77);
- a = ArrayTools.add(a, 77);
- a = ArrayTools.add(a, 77);
- assertEquals(5, a.length);
- a = ArrayTools.removeAllOccurrences(a, 77);
- assertEquals(2, a.length);
- a = ArrayTools.removeAllOccurrences(a, 77);
- assertEquals(2, a.length);
- }
-
- public void testRemoveAllOccurrencesIntArrayInt_Empty() {
- int[] a = new int[0];
- a = ArrayTools.removeAllOccurrences(a, 22);
- assertEquals(0, a.length);
- }
-
-
- // ********** remove duplicate elements **********
-
- public void testRemoveDuplicateElementsObjectArray() {
- List<String> list = this.buildStringVector1();
- list.add("zero");
- list.add("zero");
- list.add("two");
- list.add("zero");
- String[] array = ArrayTools.removeDuplicateElements(list.toArray(new String[list.size()]));
- int i = 0;
- assertEquals("zero", array[i++]);
- assertEquals("one", array[i++]);
- assertEquals("two", array[i++]);
- assertEquals(i, array.length);
- }
-
- public void testRemoveDuplicateElementsObjectArray_Empty() {
- String[] array = ArrayTools.removeDuplicateElements(new String[0]);
- assertEquals(0, array.length);
- }
-
- public void testRemoveDuplicateElementsObjectArray_SingleElement() {
- String[] array = ArrayTools.removeDuplicateElements(new String[] { "foo" });
- assertEquals(1, array.length);
- }
-
- public void testRemoveDuplicateElementsObjectArray_NoDuplicates() {
- String[] a1 = new String[] { "foo", "bar", "baz" };
- String[] a2 = ArrayTools.removeDuplicateElements(a1);
- assertEquals(3, a2.length);
- assertTrue(Arrays.equals(a1, a2));
- }
-
-
- // ********** remove element at index **********
-
- public void testRemoveElementAtIndexObjectArrayInt() {
- String[] a = new String[] { "A", "B", "A", "C", "A", "D" };
- a = ArrayTools.removeElementAtIndex(a, 3);
- assertTrue(Arrays.equals(new String[] { "A", "B", "A", "A", "D" }, a));
- }
-
- public void testRemoveElementAtIndexCharArrayInt() {
- char[] a = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' };
- a = ArrayTools.removeElementAtIndex(a, 3);
- assertTrue(Arrays.equals(new char[] { 'A', 'B', 'A', 'A', 'D' }, a));
- }
-
- public void testRemoveElementAtIndexIntArrayInt() {
- int[] a = new int[] { 8, 6, 7, 33, 2, 11 };
- a = ArrayTools.removeElementsAtIndex(a, 3, 3);
- assertTrue(Arrays.equals(new int[] { 8, 6, 7 }, a));
- }
-
- public void testRemoveFirstObjectArray() {
- String[] a = new String[] { "A", "B", "A", "C", "A", "D" };
- a = ArrayTools.removeFirst(a);
- assertTrue(Arrays.equals(new String[] { "B", "A", "C", "A", "D" }, a));
- }
-
- public void testRemoveFirstCharArray() {
- char[] a = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' };
- a = ArrayTools.removeFirst(a);
- assertTrue(Arrays.equals(new char[] { 'B', 'A', 'C', 'A', 'D' }, a));
- }
-
- public void testRemoveFirstIntArray() {
- int[] a = new int[] { 8, 6, 7, 33, 2, 11 };
- a = ArrayTools.removeFirst(a);
- assertTrue(Arrays.equals(new int[] { 6, 7, 33, 2, 11 }, a));
- }
-
- public void testRemoveLastObjectArray() {
- String[] a = new String[] { "A", "B", "A", "C", "A", "D" };
- a = ArrayTools.removeLast(a);
- assertTrue(Arrays.equals(new String[] { "A", "B", "A", "C", "A" }, a));
- }
-
- public void testRemoveLastCharArray() {
- char[] a = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' };
- a = ArrayTools.removeLast(a);
- assertTrue(Arrays.equals(new char[] { 'A', 'B', 'A', 'C', 'A' }, a));
- }
-
- public void testRemoveLastIntArray() {
- int[] a = new int[] { 8, 6, 7, 33, 2, 11 };
- a = ArrayTools.removeLast(a);
- assertTrue(Arrays.equals(new int[] { 8, 6, 7, 33, 2 }, a));
- }
-
-
- // ********** remove elements at index **********
-
- public void testRemoveElementsAtIndexObjectArrayIntInt() {
- String[] a = new String[] { "A", "B", "A", "C", "A", "D" };
- a = ArrayTools.removeElementsAtIndex(a, 3, 2);
- assertTrue(Arrays.equals(new String[] { "A", "B", "A", "D" }, a));
- }
-
- public void testRemoveElementsAtIndexObjectArrayIntInt_ZeroLength() {
- String[] a1 = new String[] { "A", "B", "A", "C", "A", "D" };
- String[] a2 = ArrayTools.removeElementsAtIndex(a1, 3, 0);
- assertTrue(Arrays.equals(a1, a2));
- }
-
- public void testRemoveElementsAtIndexObjectArrayIntInt_Empty() {
- String[] a = new String[] { "A", "B", "A", "C", "A", "D" };
- a = ArrayTools.removeElementsAtIndex(a, 0, 6);
- assertEquals(0, a.length);
- }
-
- public void testRemoveElementsAtIndexCharArrayIntInt() {
- char[] a = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' };
- a = ArrayTools.removeElementsAtIndex(a, 0, 5);
- assertTrue(Arrays.equals(new char[] { 'D' }, a));
- }
-
- public void testRemoveElementsAtIndexCharArrayIntInt_ZeroLength() {
- char[] a1 = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' };
- char[] a2 = ArrayTools.removeElementsAtIndex(a1, 3, 0);
- assertTrue(Arrays.equals(a1, a2));
- }
-
- public void testRemoveElementsAtIndexCharArrayIntInt_Empty() {
- char[] a = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' };
- a = ArrayTools.removeElementsAtIndex(a, 0, 6);
- assertEquals(0, a.length);
- }
-
- public void testRemoveElementsAtIndexIntArrayIntInt() {
- int[] a = new int[] { 8, 6, 7, 33, 2, 11 };
- a = ArrayTools.removeElementsAtIndex(a, 3, 3);
- assertTrue(Arrays.equals(new int[] { 8, 6, 7 }, a));
- }
-
- public void testRemoveElementsAtIndexIntArrayIntInt_ZeroLength() {
- int[] a1 = new int[] { 8, 6, 7, 33, 2, 11 };
- int[] a2 = ArrayTools.removeElementsAtIndex(a1, 3, 0);
- assertTrue(Arrays.equals(a1, a2));
- }
-
- public void testRemoveElementsAtIndexIntArrayIntInt_Empty() {
- int[] a = new int[] { 8, 6, 7, 33, 2, 11 };
- a = ArrayTools.removeElementsAtIndex(a, 0, 6);
- assertEquals(0, a.length);
- }
-
-
- // ********** replace all **********
-
- public void testReplaceAllObjectArrayObjectObject_Object() {
- Object[] a = new Object[] { "A", "B", "A", "C", "A", "D" };
- a = ArrayTools.replaceAll(a, "A", "Z");
- assertTrue(Arrays.equals(new Object[] { "Z", "B", "Z", "C", "Z", "D" }, a));
- }
-
- public void testReplaceAllObjectArrayObjectObject_String() {
- String[] a = new String[] { "A", "B", "A", "C", "A", "D" };
- a = ArrayTools.replaceAll(a, "A", "Z");
- assertTrue(Arrays.equals(new String[] { "Z", "B", "Z", "C", "Z", "D" }, a));
- }
-
- public void testReplaceAllObjectArrayObjectObject_Null() {
- String[] a = new String[] { null, "B", null, "C", null, "D" };
- a = ArrayTools.replaceAll(a, null, "Z");
- assertTrue(Arrays.equals(new String[] { "Z", "B", "Z", "C", "Z", "D" }, a));
- }
-
- public void testReplaceAllCharArrayCharChar() {
- char[] a = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' };
- a = ArrayTools.replaceAll(a, 'A', 'Z');
- assertTrue(Arrays.equals(new char[] { 'Z', 'B', 'Z', 'C', 'Z', 'D' }, a));
- }
-
- public void testReplaceAllIntArrayIntInt() {
- int[] a = new int[] { 0, 1, 0, 7, 0, 99 };
- a = ArrayTools.replaceAll(a, 0, 13);
- assertTrue(Arrays.equals(new int[] { 13, 1, 13, 7, 13, 99 }, a));
- }
-
-
- // ********** retain all **********
-
- public void testRetainAllObjectArrayObjectArray() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Object[] a2 = new Object[] { "E", "B", new Integer(7) };
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, ArrayTools.retainAll(a1, a2)));
- }
-
- public void testRetainAllObjectArrayObjectArray_EmptyObjectArray1() {
- String[] a1 = new String[0];
- String[] a2 = new String[] { "E", "B", "" };
- String[] a3 = ArrayTools.retainAll(a1, a2);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayObjectArray_EmptyObjectArray2() {
- String[] a1 = new String[] { "E", "B", "" };
- String[] a2 = new String[0];
- String[] a3 = ArrayTools.retainAll(a1, a2);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayObjectArray_BothEmpty() {
- String[] a1 = new String[0];
- String[] a2 = new String[0];
- String[] a3 = ArrayTools.retainAll(a1, a2);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayIterable() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<String> iterable = Arrays.asList(new String[] { "E", "B", "" });
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, ArrayTools.retainAll(a1, iterable)));
- }
-
- public void testRetainAllObjectArrayIterable_EmptyObjectArray() {
- String[] a1 = new String[0];
- Iterable<String> iterable = Arrays.asList(new String[] { "E", "B", "" });
- String[] a3 = ArrayTools.retainAll(a1, iterable);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayIterableInt() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterable<String> iterable = Arrays.asList(new String[] { "E", "B", "" });
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, ArrayTools.retainAll(a1, iterable, 3)));
- }
-
- public void testRetainAllObjectArrayIterableInt_EmptyObjectArray() {
- String[] a1 = new String[0];
- Iterable<String> iterable = Arrays.asList(new String[] { "E", "B", "" });
- String[] a3 = ArrayTools.retainAll(a1, iterable, 3);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayIterator() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterator<String> iterator = Arrays.asList(new String[] { "E", "B", "" }).iterator();
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, ArrayTools.retainAll(a1, iterator)));
- }
-
- public void testRetainAllObjectArrayIterator_EmptyObjectArray() {
- String[] a1 = new String[0];
- Iterator<String> iterator = Arrays.asList(new String[] { "E", "B", "" }).iterator();
- String[] a3 = ArrayTools.retainAll(a1, iterator);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayIterator_EmptyIterator() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- assertTrue(Arrays.equals(new String[0], ArrayTools.retainAll(a1, EmptyIterator.instance())));
- }
-
- public void testRetainAllObjectArrayIteratorInt() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Iterator<String> iterator = Arrays.asList(new String[] { "E", "B", "" }).iterator();
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, ArrayTools.retainAll(a1, iterator, 3)));
- }
-
- public void testRetainAllObjectArrayIteratorInt_EmptyIterator() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- assertTrue(Arrays.equals(new String[0], ArrayTools.retainAll(a1, EmptyIterator.instance(), 3)));
- }
-
- public void testRetainAllObjectArrayIteratorInt_EmptyObjectArray() {
- String[] a1 = new String[0];
- Iterator<String> iterator = Arrays.asList(new String[] { "E", "B", "" }).iterator();
- String[] a3 = ArrayTools.retainAll(a1, iterator, 3);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayCollection() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = Arrays.asList(new String[] { "E", "B", "" });
- assertTrue(Arrays.equals(new String[] { "B", "B", "E", "E" }, ArrayTools.retainAll(a1, collection)));
- }
-
- public void testRetainAllObjectArrayCollection_EmptyObjectArray() {
- String[] a1 = new String[0];
- Collection<String> collection = Arrays.asList(new String[] { "E", "B", "" });
- String[] a3 = ArrayTools.retainAll(a1, collection);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayCollection_EmptyCollection() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = new ArrayList<String>();
- String[] a3 = ArrayTools.retainAll(a1, collection);
- assertEquals(0, a3.length);
- }
-
- public void testRetainAllObjectArrayCollection_All() {
- String[] a1 = new String[] { "A", "A", "B", "B", "C", "C", "D", "D", "E", "E", "F", "F" };
- Collection<String> collection = Arrays.asList(new String[] { "A", "B", "C", "D", "E", "F" });
- assertTrue(Arrays.equals(a1, ArrayTools.retainAll(a1, collection)));
- }
-
- public void testRetainAllCharArrayCharArray() {
- char[] a1 = new char[] { 'A', 'A', 'B', 'B', 'C', 'C', 'D', 'D', 'E', 'E', 'F', 'F' };
- char[] a2 = new char[] { 'E', 'B' };
- assertTrue(Arrays.equals(new char[] { 'B', 'B', 'E', 'E' }, ArrayTools.retainAll(a1, a2)));
- }
-
- public void testRetainAllCharArrayCharArray_EmptyCharArray1() {
- char[] a1 = new char[0];
- char[] a2 = new char[] { 'E', 'B' };
- assertSame(a1, ArrayTools.retainAll(a1, a2));
- }
-
- public void testRetainAllCharArrayCharArray_EmptyCharArray2() {
- char[] a1 = new char[] { 'E', 'B' };
- char[] a2 = new char[0];
- assertEquals(0, ArrayTools.retainAll(a1, a2).length);
- }
-
- public void testRetainAllCharArrayCharArray_RetainAll() {
- char[] a1 = new char[] { 'E', 'B', 'E', 'B', 'E', 'B', 'E', 'B', 'E' };
- char[] a2 = new char[] { 'E', 'B' };
- assertSame(a1, ArrayTools.retainAll(a1, a2));
- }
-
- public void testRetainAllIntArrayIntArray() {
- int[] a1 = new int[] { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6 };
- int[] a2 = new int[] { 5, 2 };
- assertTrue(Arrays.equals(new int[] { 2, 2, 5, 5 }, ArrayTools.retainAll(a1, a2)));
- }
-
- public void testRetainAllIntArrayIntArray_EmptyIntArray1() {
- int[] a1 = new int[0];
- int[] a2 = new int[] { 5, 2 };
- assertSame(a1, ArrayTools.retainAll(a1, a2));
- }
-
- public void testRetainAllIntArrayIntArray_EmptyIntArray2() {
- int[] a1 = new int[] { 5, 2 };
- int[] a2 = new int[0];
- assertEquals(0, ArrayTools.retainAll(a1, a2).length);
- }
-
- public void testRetainAllIntArrayIntArray_RetainAll() {
- int[] a1 = new int[] { 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5 };
- int[] a2 = new int[] { 5, 2 };
- assertSame(a1, ArrayTools.retainAll(a1, a2));
- }
-
-
- // ********** reverse **********
-
- public void testReverseObjectArray_Object() {
- Object[] a = this.buildObjectArray1();
- a = ArrayTools.reverse(a);
- assertEquals("two", a[0]);
- assertEquals("one", a[1]);
- assertEquals("zero", a[2]);
- }
-
- public void testReverseObjectArray_String() {
- String[] a = this.buildStringArray1();
- a = ArrayTools.reverse(a);
- assertEquals("two", a[0]);
- assertEquals("one", a[1]);
- assertEquals("zero", a[2]);
- }
-
- public void testReverseObjectArray_Singleton() {
- String[] a1 = new String[] { "foo" };
- String[] a2 = ArrayTools.reverse(a1);
- assertTrue(Arrays.equals(a1, a2));
- }
-
- public void testReverseCharArray() {
- char[] a = this.buildCharArray();
- a = ArrayTools.reverse(a);
- assertEquals('c', a[0]);
- assertEquals('b', a[1]);
- assertEquals('a', a[2]);
- }
-
- public void testReverseCharArray_Singleton() {
- char[] a1 = new char[] { 'f' };
- char[] a2 = ArrayTools.reverse(a1);
- assertTrue(Arrays.equals(a1, a2));
- }
-
- public void testReverseIntArray() {
- int[] a = this.buildIntArray();
- a = ArrayTools.reverse(a);
- assertEquals(20, a[0]);
- assertEquals(10, a[1]);
- assertEquals(0, a[2]);
- }
-
- public void testReverseIntArray_Singleton() {
- int[] a1 = new int[] { 7 };
- int[] a2 = ArrayTools.reverse(a1);
- assertTrue(Arrays.equals(a1, a2));
- }
-
-
- // ********** rotate **********
-
- public void testRotateObjectArray() {
- String[] a = this.buildStringArray1();
- a = ArrayTools.rotate(a);
- assertEquals("two", a[0]);
- assertEquals("zero", a[1]);
- assertEquals("one", a[2]);
- }
-
- public void testRotateObjectArray_Zero() {
- String[] a1 = new String[0];
- String[] a2 = ArrayTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateObjectArray_One() {
- String[] a1 = new String[] { "foo " };
- String[] a2 = ArrayTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateObjectArrayInt() {
- String[] a = this.buildStringArray1();
- a = ArrayTools.rotate(a, 2);
- assertEquals("one", a[0]);
- assertEquals("two", a[1]);
- assertEquals("zero", a[2]);
- }
-
- public void testRotateObjectArrayInt_ZeroDistance() {
- String[] a1 = this.buildStringArray1();
- String[] a2 = ArrayTools.rotate(a1, 0);
- assertSame(a1, a2);
- }
-
- public void testRotateObjectArrayInt_NegativeDistance() {
- String[] a1 = this.buildStringArray1();
- String[] a2 = ArrayTools.rotate(a1, -1);
- assertEquals("one", a2[0]);
- assertEquals("two", a2[1]);
- assertEquals("zero", a2[2]);
- }
-
- public void testRotateObjectArrayInt_Zero() {
- String[] a1 = new String[0];
- String[] a2 = ArrayTools.rotate(a1, 7);
- assertSame(a1, a2);
- }
-
- public void testRotateObjectArrayInt_One() {
- String[] a1 = new String[] { "foo " };
- String[] a2 = ArrayTools.rotate(a1, 8);
- assertSame(a1, a2);
- }
-
- public void testRotateCharArray() {
- char[] a = this.buildCharArray();
- a = ArrayTools.rotate(a);
- assertEquals('c', a[0]);
- assertEquals('a', a[1]);
- assertEquals('b', a[2]);
- }
-
- public void testRotateCharArray_Zero() {
- char[] a1 = new char[0];
- char[] a2 = ArrayTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateCharArray_One() {
- char[] a1 = new char[] { 'a' };
- char[] a2 = ArrayTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateCharArrayInt() {
- char[] a = this.buildCharArray();
- a = ArrayTools.rotate(a, 2);
- assertEquals('b', a[0]);
- assertEquals('c', a[1]);
- assertEquals('a', a[2]);
- }
-
- public void testRotateCharArrayInt_ZeroDistance() {
- char[] a1 = new char[] { 'a', 'b', 'c' };
- char[] a2 = ArrayTools.rotate(a1, 0);
- assertSame(a1, a2);
- }
-
- public void testRotateCharArrayInt_NegativeDistance() {
- char[] a = this.buildCharArray();
- a = ArrayTools.rotate(a, -1);
- assertEquals('b', a[0]);
- assertEquals('c', a[1]);
- assertEquals('a', a[2]);
- }
-
- public void testRotateCharArrayInt_Zero() {
- char[] a1 = new char[0];
- char[] a2 = ArrayTools.rotate(a1, 2001);
- assertSame(a1, a2);
- }
-
- public void testRotateCharArrayInt_One() {
- char[] a1 = new char[] { 'a' };
- char[] a2 = ArrayTools.rotate(a1, 22);
- assertSame(a1, a2);
- }
-
- public void testRotateIntArray() {
- int[] a = this.buildIntArray();
- a = ArrayTools.rotate(a);
- assertEquals(20, a[0]);
- assertEquals(0, a[1]);
- assertEquals(10, a[2]);
- }
-
- public void testRotateIntArray_Zero() {
- int[] a1 = new int[0];
- int[] a2 = ArrayTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateIntArray_One() {
- int[] a1 = new int[] { 77 };
- int[] a2 = ArrayTools.rotate(a1);
- assertSame(a1, a2);
- }
-
- public void testRotateIntArrayInt() {
- int[] a = this.buildIntArray();
- a = ArrayTools.rotate(a, 2);
- assertEquals(10, a[0]);
- assertEquals(20, a[1]);
- assertEquals(0, a[2]);
- }
-
- public void testRotateIntArrayInt_ZeroDistance() {
- int[] a1 = new int[] { 3, 2, 1 };
- int[] a2 = ArrayTools.rotate(a1, 0);
- assertSame(a1, a2);
- }
-
- public void testRotateIntArrayInt_NegativeDistance() {
- int[] a = this.buildIntArray();
- a = ArrayTools.rotate(a, -1);
- assertEquals(10, a[0]);
- assertEquals(20, a[1]);
- assertEquals(0, a[2]);
- }
-
- public void testRotateIntArrayInt_Zero() {
- int[] a1 = new int[0];
- int[] a2 = ArrayTools.rotate(a1, 3);
- assertSame(a1, a2);
- }
-
- public void testRotateIntArrayInt_One() {
- int[] a1 = new int[] { 77 };
- int[] a2 = ArrayTools.rotate(a1, 44);
- assertSame(a1, a2);
- }
-
-
- // ********** shuffle **********
-
- public void testShuffleObjectArray() {
- String[] array1 = this.buildStringArray1();
- String[] array2 = ArrayTools.shuffle(this.buildStringArray1());
- assertEquals(array1.length, array2.length);
- assertTrue(ArrayTools.containsAll(array1, (Object[]) array2));
- }
-
- public void testShuffleObjectArray_Singleton() {
- String[] array1 = new String[] { "foo" };
- String[] array2 = ArrayTools.shuffle(new String[] { "foo" });
- assertEquals(array1.length, array2.length);
- assertTrue(ArrayTools.containsAll(array1, (Object[]) array2));
- }
-
- public void testShuffleCharArray() {
- char[] array1 = this.buildCharArray();
- char[] array2 = ArrayTools.shuffle(this.buildCharArray());
- assertEquals(array1.length, array2.length);
- assertTrue(ArrayTools.containsAll(array1, array2));
- }
-
- public void testShuffleCharArray_Singleton() {
- char[] array1 = new char[] { 'f' };
- char[] array2 = ArrayTools.shuffle(new char[] { 'f' });
- assertEquals(array1.length, array2.length);
- assertTrue(ArrayTools.containsAll(array1, array2));
- }
-
- public void testShuffleIntArray() {
- int[] array1 = this.buildIntArray();
- int[] array2 = ArrayTools.shuffle(this.buildIntArray());
- assertEquals(array1.length, array2.length);
- assertTrue(ArrayTools.containsAll(array1, array2));
- }
-
- public void testShuffleIntArray_Singleton() {
- int[] array1 = new int[] { 7 };
- int[] array2 = ArrayTools.shuffle(new int[] { 7 });
- assertEquals(array1.length, array2.length);
- assertTrue(ArrayTools.containsAll(array1, array2));
- }
-
-
- // ********** sub-array **********
-
- public void testSubArrayObjectArrayIntInt() {
- String[] array = new String[] {"foo", "bar", "baz", "joo", "jar", "jaz"};
- String[] result = new String[] {"foo", "bar", "baz", "joo"};
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 0, 4)));
-
- result = new String[] {"jar"};
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 4, 5)));
-
- result = new String[0];
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 5, 5)));
-
- result = new String[] {"joo", "jar", "jaz"};
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 3, 6)));
- }
-
- public void testSubArrayIntArrayIntInt() {
- int[] array = new int[] {77, 99, 333, 4, 9090, 42};
- int[] result = new int[] {77, 99, 333, 4};
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 0, 4)));
-
- result = new int[] {9090};
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 4, 5)));
-
- result = new int[0];
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 5, 5)));
-
- result = new int[] {4, 9090, 42};
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 3, 6)));
- }
-
- public void testSubArrayCharArrayIntInt() {
- char[] array = new char[] {'a', 'b', 'c', 'd', 'e', 'f'};
- char[] result = new char[] {'a', 'b', 'c', 'd'};
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 0, 4)));
-
- result = new char[] {'e'};
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 4, 5)));
-
- result = new char[0];
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 5, 5)));
-
- result = new char[] {'d', 'e', 'f'};
- assertTrue(Arrays.equals(result, ArrayTools.subArray(array, 3, 6)));
- }
-
-
- // ********** swap **********
-
- public void testSwapObjectArray() {
- String[] a = this.buildStringArray1();
- a = ArrayTools.swap(a, 1, 2);
- assertEquals("zero", a[0]);
- assertEquals("two", a[1]);
- assertEquals("one", a[2]);
- }
-
- public void testSwapObjectArray_SameIndices() {
- String[] a1 = this.buildStringArray1();
- String[] a2 = this.buildStringArray1();
- a1 = ArrayTools.swap(a1, 1, 1);
- assertTrue(Arrays.equals(a1, a2));
- }
-
- public void testSwapCharArray() {
- char[] a = this.buildCharArray();
- a = ArrayTools.swap(a, 1, 2);
- assertEquals('a', a[0]);
- assertEquals('c', a[1]);
- assertEquals('b', a[2]);
- }
-
- public void testSwapCharArray_SameIndices() {
- char[] a1 = this.buildCharArray();
- char[] a2 = this.buildCharArray();
- a1 = ArrayTools.swap(a1, 1, 1);
- assertTrue(Arrays.equals(a1, a2));
- }
-
- public void testSwapIntArray() {
- int[] a = this.buildIntArray();
- a = ArrayTools.swap(a, 1, 2);
- assertEquals(0, a[0]);
- assertEquals(20, a[1]);
- assertEquals(10, a[2]);
- }
-
- public void testSwapIntArray_SameIndices() {
- int[] a1 = this.buildIntArray();
- int[] a2 = this.buildIntArray();
- a1 = ArrayTools.swap(a1, 1, 1);
- assertTrue(Arrays.equals(a1, a2));
- }
-
-
- // ********** Arrays enhancements **********
-
- public void testFillBooleanArrayBoolean() {
- boolean[] a1 = new boolean[9];
- boolean[] a2 = ArrayTools.fill(a1, true);
- for (boolean x : a1) {
- assertTrue(x);
- }
- assertSame(a1, a2);
- }
-
- public void testFillBooleanArrayIntIntBoolean() {
- boolean[] a1 = new boolean[9];
- boolean[] a2 = ArrayTools.fill(a1, false);
- int from = 3;
- int to = 6;
- boolean[] a3 = ArrayTools.fill(a2, from, to, true);
- for (int i = 0; i < a1.length; i++) {
- boolean x = a1[i];
- if (i < from || i >= to) {
- assertFalse(x);
- } else {
- assertTrue(x);
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testFillByteArrayByte() {
- byte[] a1 = new byte[9];
- byte[] a2 = ArrayTools.fill(a1, (byte) 77);
- for (byte x : a1) {
- assertEquals(77, x);
- }
- assertSame(a1, a2);
- }
-
- public void testFillByteArrayIntIntByte() {
- byte[] a1 = new byte[9];
- byte[] a2 = ArrayTools.fill(a1, (byte) 3);
- int from = 3;
- int to = 6;
- byte[] a3 = ArrayTools.fill(a2, from, to, (byte) 77);
- for (int i = 0; i < a1.length; i++) {
- byte x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3, x);
- } else {
- assertEquals(77, x);
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testFillCharArrayChar() {
- char[] a1 = new char[9];
- char[] a2 = ArrayTools.fill(a1, 'c');
- for (char x : a1) {
- assertEquals('c', x);
- }
- assertSame(a1, a2);
- }
-
- public void testFillCharArrayIntIntChar() {
- char[] a1 = new char[9];
- char[] a2 = ArrayTools.fill(a1, 'a');
- int from = 3;
- int to = 6;
- char[] a3 = ArrayTools.fill(a2, from, to, 'c');
- for (int i = 0; i < a1.length; i++) {
- char x = a1[i];
- if (i < from || i >= to) {
- assertEquals('a', x);
- } else {
- assertEquals('c', x);
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testFillDoubleArrayDouble() {
- double[] a1 = new double[9];
- double[] a2 = ArrayTools.fill(a1, 77.77);
- for (double x : a1) {
- assertEquals(77.77, x, 0.0);
- }
- assertSame(a1, a2);
- }
-
- public void testFillDoubleArrayIntIntDouble() {
- double[] a1 = new double[9];
- double[] a2 = ArrayTools.fill(a1, 3.3);
- int from = 3;
- int to = 6;
- double[] a3 = ArrayTools.fill(a2, from, to, 77.77);
- for (int i = 0; i < a1.length; i++) {
- double x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3.3, x, 0.0);
- } else {
- assertEquals(77.77, x, 0.0);
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testFillFloatArrayFloat() {
- float[] a1 = new float[9];
- float[] a2 = ArrayTools.fill(a1, 77.77f);
- for (float x : a1) {
- assertEquals(77.77f, x, 0.0);
- }
- assertSame(a1, a2);
- }
-
- public void testFillFloatArrayIntIntFloat() {
- float[] a1 = new float[9];
- float[] a2 = ArrayTools.fill(a1, 3.3f);
- int from = 3;
- int to = 6;
- float[] a3 = ArrayTools.fill(a2, from, to, 77.77f);
- for (int i = 0; i < a1.length; i++) {
- float x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3.3f, x, 0.0);
- } else {
- assertEquals(77.77f, x, 0.0);
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testFillIntArrayInt() {
- int[] a1 = new int[9];
- int[] a2 = ArrayTools.fill(a1, 77);
- for (int x : a1) {
- assertEquals(77, x);
- }
- assertSame(a1, a2);
- }
-
- public void testFillIntArrayIntIntInt() {
- int[] a1 = new int[9];
- int[] a2 = ArrayTools.fill(a1, 3);
- int from = 3;
- int to = 6;
- int[] a3 = ArrayTools.fill(a2, from, to, 77);
- for (int i = 0; i < a1.length; i++) {
- int x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3, x);
- } else {
- assertEquals(77, x);
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testFillObjectArrayObject() {
- String[] a1 = new String[9];
- String[] a2 = ArrayTools.fill(a1, "77");
- for (String x : a1) {
- assertEquals("77", x);
- }
- assertSame(a1, a2);
- }
-
- public void testFillObjectArrayIntIntObject() {
- String[] a1 = new String[9];
- String[] a2 = ArrayTools.fill(a1, "3");
- int from = 3;
- int to = 6;
- String[] a3 = ArrayTools.fill(a2, from, to, "77");
- for (int i = 0; i < a1.length; i++) {
- String x = a1[i];
- if (i < from || i >= to) {
- assertEquals("3", x);
- } else {
- assertEquals("77", x);
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testFillLongArrayLong() {
- long[] a1 = new long[9];
- long[] a2 = ArrayTools.fill(a1, 77);
- for (long x : a1) {
- assertEquals(77, x);
- }
- assertSame(a1, a2);
- }
-
- public void testFillLongArrayIntIntLong() {
- long[] a1 = new long[9];
- long[] a2 = ArrayTools.fill(a1, 3);
- int from = 3;
- int to = 6;
- long[] a3 = ArrayTools.fill(a2, from, to, 77);
- for (int i = 0; i < a1.length; i++) {
- long x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3, x);
- } else {
- assertEquals(77, x);
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testFillShortArrayShort() {
- short[] a1 = new short[9];
- short[] a2 = ArrayTools.fill(a1, (short) 77);
- for (short x : a1) {
- assertEquals(77, x);
- }
- assertSame(a1, a2);
- }
-
- public void testFillShortArrayIntIntShort() {
- short[] a1 = new short[9];
- short[] a2 = ArrayTools.fill(a1, (short) 3);
- int from = 3;
- int to = 6;
- short[] a3 = ArrayTools.fill(a2, from, to, (short) 77);
- for (int i = 0; i < a1.length; i++) {
- short x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3, x);
- } else {
- assertEquals(77, x);
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testSortByteArray() {
- byte[] a1 = new byte[3];
- a1[0] = (byte) 33;
- a1[1] = (byte) 11;
- a1[2] = (byte) 22;
- byte[] a2 = ArrayTools.sort(a1);
- byte last = (byte) 0;
- for (byte x : a1) {
- assertTrue(last < x);
- last = x;
- }
- assertSame(a1, a2);
- }
-
- public void testSortByteArrayIntInt() {
- byte[] a1 = new byte[9];
- byte[] a2 = ArrayTools.fill(a1, (byte) 3);
- a2[3] = (byte) 33;
- a2[4] = (byte) 11;
- a2[5] = (byte) 22;
- int from = 3;
- int to = 6;
- byte[] a3 = ArrayTools.sort(a2, from, to);
- byte last = (byte) 0;
- for (int i = 0; i < a1.length; i++) {
- byte x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3, x);
- } else {
- assertTrue(last < x);
- last = x;
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testSortCharArray() {
- char[] a1 = new char[3];
- a1[0] = 'z';
- a1[1] = 'b';
- a1[2] = 'm';
- char[] a2 = ArrayTools.sort(a1);
- char last = 'a';
- for (char x : a1) {
- assertTrue(last < x);
- last = x;
- }
- assertSame(a1, a2);
- }
-
- public void testSortCharArrayIntInt() {
- char[] a1 = new char[9];
- char[] a2 = ArrayTools.fill(a1, 'c');
- a2[3] = 'z';
- a2[4] = 'b';
- a2[5] = 'm';
- int from = 3;
- int to = 6;
- char[] a3 = ArrayTools.sort(a2, from, to);
- char last = 'a';
- for (int i = 0; i < a1.length; i++) {
- char x = a1[i];
- if (i < from || i >= to) {
- assertEquals('c', x);
- } else {
- assertTrue(last < x);
- last = x;
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testSortDoubleArray() {
- double[] a1 = new double[3];
- a1[0] = 33.33;
- a1[1] = 11.11;
- a1[2] = 22.22;
- double[] a2 = ArrayTools.sort(a1);
- double last = 0;
- for (double x : a1) {
- assertTrue(last < x);
- last = x;
- }
- assertSame(a1, a2);
- }
-
- public void testSortDoubleArrayIntInt() {
- double[] a1 = new double[9];
- double[] a2 = ArrayTools.fill(a1, 3.3);
- a2[3] = 33.33;
- a2[4] = 11.11;
- a2[5] = 22.22;
- int from = 3;
- int to = 6;
- double[] a3 = ArrayTools.sort(a2, from, to);
- double last = 0;
- for (int i = 0; i < a1.length; i++) {
- double x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3.3, x, 0.0);
- } else {
- assertTrue(last < x);
- last = x;
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testSortFloatArray() {
- float[] a1 = new float[3];
- a1[0] = 33.33f;
- a1[1] = 11.11f;
- a1[2] = 22.22f;
- float[] a2 = ArrayTools.sort(a1);
- float last = 0;
- for (float x : a1) {
- assertTrue(last < x);
- last = x;
- }
- assertSame(a1, a2);
- }
-
- public void testSortFloatArrayIntInt() {
- float[] a1 = new float[9];
- float[] a2 = ArrayTools.fill(a1, 3.3f);
- a2[3] = 33.33f;
- a2[4] = 11.11f;
- a2[5] = 22.22f;
- int from = 3;
- int to = 6;
- float[] a3 = ArrayTools.sort(a2, from, to);
- float last = 0;
- for (int i = 0; i < a1.length; i++) {
- float x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3.3f, x, 0.0);
- } else {
- assertTrue(last < x);
- last = x;
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testSortIntArray() {
- int[] a1 = new int[3];
- a1[0] = 33;
- a1[1] = 11;
- a1[2] = 22;
- int[] a2 = ArrayTools.sort(a1);
- int last = 0;
- for (int x : a1) {
- assertTrue(last < x);
- last = x;
- }
- assertSame(a1, a2);
- }
-
- public void testSortIntArrayIntInt() {
- int[] a1 = new int[9];
- int[] a2 = ArrayTools.fill(a1, 3);
- a2[3] = 33;
- a2[4] = 11;
- a2[5] = 22;
- int from = 3;
- int to = 6;
- int[] a3 = ArrayTools.sort(a2, from, to);
- int last = 0;
- for (int i = 0; i < a1.length; i++) {
- int x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3, x);
- } else {
- assertTrue(last < x);
- last = x;
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testSortObjectArray() {
- String[] a1 = new String[3];
- a1[0] = "y";
- a1[1] = "b";
- a1[2] = "m";
- String[] a2 = ArrayTools.sort(a1);
- String last = "a";
- for (String x : a1) {
- assertTrue(last.compareTo(x) < 0);
- last = x;
- }
- assertSame(a1, a2);
- }
-
- public void testSortObjectArrayComparator() {
- String[] a1 = new String[3];
- a1[0] = "y";
- a1[1] = "b";
- a1[2] = "m";
- String[] a2 = ArrayTools.sort(a1, new ReverseComparator<String>());
- String last = "z";
- for (String x : a1) {
- assertTrue(last.compareTo(x) > 0);
- last = x;
- }
- assertSame(a1, a2);
- }
-
- public void testSortObjectArrayIntInt() {
- String[] a1 = new String[9];
- String[] a2 = ArrayTools.fill(a1, "c");
- a2[3] = "y";
- a2[4] = "b";
- a2[5] = "m";
- int from = 3;
- int to = 6;
- String[] a3 = ArrayTools.sort(a2, from, to);
- String last = "a";
- for (int i = 0; i < a1.length; i++) {
- String x = a1[i];
- if (i < from || i >= to) {
- assertEquals("c", x);
- } else {
- assertTrue(last.compareTo(x) < 0);
- last = x;
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testSortObjectArrayIntIntComparator() {
- String[] a1 = new String[9];
- String[] a2 = ArrayTools.fill(a1, "c");
- a2[3] = "y";
- a2[4] = "b";
- a2[5] = "m";
- int from = 3;
- int to = 6;
- String[] a3 = ArrayTools.sort(a2, from, to, new ReverseComparator<String>());
- String last = "z";
- for (int i = 0; i < a1.length; i++) {
- String x = a1[i];
- if (i < from || i >= to) {
- assertEquals("c", x);
- } else {
- assertTrue(last.compareTo(x) > 0);
- last = x;
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testSortLongArray() {
- long[] a1 = new long[3];
- a1[0] = 33;
- a1[1] = 11;
- a1[2] = 22;
- long[] a2 = ArrayTools.sort(a1);
- long last = 0;
- for (long x : a1) {
- assertTrue(last < x);
- last = x;
- }
- assertSame(a1, a2);
- }
-
- public void testSortLongArrayIntInt() {
- long[] a1 = new long[9];
- long[] a2 = ArrayTools.fill(a1, 3);
- a2[3] = 33;
- a2[4] = 11;
- a2[5] = 22;
- int from = 3;
- int to = 6;
- long[] a3 = ArrayTools.sort(a2, from, to);
- long last = 0;
- for (int i = 0; i < a1.length; i++) {
- long x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3, x);
- } else {
- assertTrue(last < x);
- last = x;
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
- public void testSortShortArray() {
- short[] a1 = new short[3];
- a1[0] = (short) 33;
- a1[1] = (short) 11;
- a1[2] = (short) 22;
- short[] a2 = ArrayTools.sort(a1);
- short last = (short) 0;
- for (short x : a1) {
- assertTrue(last < x);
- last = x;
- }
- assertSame(a1, a2);
- }
-
- public void testSortShortArrayIntInt() {
- short[] a1 = new short[9];
- short[] a2 = ArrayTools.fill(a1, (short) 3);
- a2[3] = (short) 33;
- a2[4] = (short) 11;
- a2[5] = (short) 22;
- int from = 3;
- int to = 6;
- short[] a3 = ArrayTools.sort(a2, from, to);
- short last = (short) 0;
- for (int i = 0; i < a1.length; i++) {
- short x = a1[i];
- if (i < from || i >= to) {
- assertEquals(3, x);
- } else {
- assertTrue(last < x);
- last = x;
- }
- }
- assertSame(a1, a2);
- assertSame(a1, a3);
- }
-
-
- // ********** constructor **********
-
- public void testConstructor() {
- boolean exCaught = false;
- try {
- Object at = ReflectionTools.newInstance(ArrayTools.class);
- fail("bogus: " + at);
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof InvocationTargetException) {
- if (ex.getCause().getCause() instanceof UnsupportedOperationException) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
-
- // ********** utility **********
-
- private Object[] buildObjectArray1() {
- return new Object[] { "zero", "one", "two" };
- }
-
- private String[] buildStringArray1() {
- return new String[] { "zero", "one", "two" };
- }
-
- private char[] buildCharArray() {
- return new char[] { 'a', 'b', 'c' };
- }
-
- private int[] buildIntArray() {
- return new int[] { 0, 10, 20 };
- }
-
- private Object[] buildObjectArray2() {
- return new Object[] { "three", "four", "five" };
- }
-
- private String[] buildStringArray2() {
- return new String[] { "three", "four", "five" };
- }
-
- private List<String> buildStringList1() {
- List<String> l = new ArrayList<String>();
- this.addToCollection1(l);
- return l;
- }
-
- private List<Object> buildObjectList1() {
- List<Object> l = new ArrayList<Object>();
- this.addToCollection1(l);
- return l;
- }
-
- private void addToCollection1(Collection<? super String> c) {
- c.add("zero");
- c.add("one");
- c.add("two");
- }
-
- private List<String> buildStringList2() {
- List<String> l = new ArrayList<String>();
- this.addToCollection2(l);
- return l;
- }
-
- private void addToCollection2(Collection<? super String> c) {
- c.add("three");
- c.add("four");
- c.add("five");
- }
-
- private Vector<String> buildStringVector1() {
- Vector<String> v = new Vector<String>();
- this.addToCollection1(v);
- return v;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BagTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BagTests.java
deleted file mode 100644
index e018dfaeea..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BagTests.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-
-@SuppressWarnings("nls")
-public class BagTests extends TestCase {
-
- public BagTests(String name) {
- super(name);
- }
-
- public void testEmptyBag_iterator() throws Exception {
- assertFalse(Bag.Empty.instance().iterator().hasNext());
- }
-
- public void testEmptyBag_size() throws Exception {
- assertEquals(0, Bag.Empty.instance().size());
- }
-
- public void testEmptyBag_uniqueIterator() throws Exception {
- assertFalse(Bag.Empty.instance().uniqueIterator().hasNext());
- }
-
- public void testEmptyBag_uniqueCount() throws Exception {
- assertEquals(0, Bag.Empty.instance().uniqueCount());
- }
-
- public void testEmptyBag_count() throws Exception {
- assertEquals(0, Bag.Empty.instance().count("foo"));
- }
-
- public void testEmptyBag_entries() throws Exception {
- assertFalse(Bag.Empty.instance().entries().hasNext());
- }
-
- public void testEmptyBag_remove() throws Exception {
- assertFalse(Bag.Empty.instance().remove("foo", 3));
- }
-
- public void testEmptyBag_add() throws Exception {
- boolean exCaught = false;
- try {
- Bag.Empty.instance().add("foo", 3);
- fail();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testEmptyBag_equals() throws Exception {
- assertTrue(Bag.Empty.instance().equals(Bag.Empty.instance()));
- assertFalse(Bag.Empty.instance().equals("foo"));
-
- Bag<Object> bag = new HashBag<Object>();
- assertTrue(Bag.Empty.instance().equals(bag));
- bag.add("foo");
- assertFalse(Bag.Empty.instance().equals(bag));
- }
-
- public void testEmptyBag_hashCode() throws Exception {
- assertEquals(0, Bag.Empty.instance().hashCode());
- }
-
- public void testEmptyBag_serialization() throws Exception {
- Bag<?> xxx = TestTools.serialize(Bag.Empty.instance());
- assertSame(Bag.Empty.instance(), xxx);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiFilterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiFilterTests.java
deleted file mode 100644
index b2d1564479..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiFilterTests.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.BidiFilter;
-
-@SuppressWarnings("nls")
-public class BidiFilterTests extends TestCase {
-
- public BidiFilterTests(String name) {
- super(name);
- }
-
- public void testNullBidiFilter_accept() throws Exception {
- assertTrue(BidiFilter.Null.instance().accept("foo"));
- }
-
- public void testNullBidiFilter_reverseAccept() throws Exception {
- assertTrue(BidiFilter.Null.instance().reverseAccept("foo"));
- }
-
- public void testNullBidiFilter_toString() throws Exception {
- assertNotNull(BidiFilter.Null.instance().toString());
- }
-
- public void testNullBidiFilter_serialization() throws Exception {
- BidiFilter<?> xxx = TestTools.serialize(BidiFilter.Null.instance());
- assertSame(BidiFilter.Null.instance(), xxx);
- }
-
- public void testOpaqueBidiFilter_accept() throws Exception {
- assertFalse(BidiFilter.Opaque.instance().accept("foo"));
- }
-
- public void testOpaqueBidiFilter_reverseAccept() throws Exception {
- assertFalse(BidiFilter.Opaque.instance().reverseAccept("foo"));
- }
-
- public void testOpaqueBidiFilter_toString() throws Exception {
- assertNotNull(BidiFilter.Opaque.instance().toString());
- }
-
- public void testOpaqueBidiFilter_serialization() throws Exception {
- BidiFilter<?> xxx = TestTools.serialize(BidiFilter.Opaque.instance());
- assertSame(BidiFilter.Opaque.instance(), xxx);
- }
-
- public void testDisabledBidiFilter_accept() throws Exception {
- boolean exCaught = false;
- try {
- BidiFilter.Disabled.instance().accept("foo");
- fail();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testDisabledBidiFilter_reverseAccept() throws Exception {
- boolean exCaught = false;
- try {
- BidiFilter.Disabled.instance().reverseAccept("foo");
- fail();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testDisabledBidiFilter_toString() throws Exception {
- assertNotNull(BidiFilter.Disabled.instance().toString());
- }
-
- public void testDisabledBidiFilter_serialization() throws Exception {
- BidiFilter<?> xxx = TestTools.serialize(BidiFilter.Disabled.instance());
- assertSame(BidiFilter.Disabled.instance(), xxx);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiStringConverterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiStringConverterTests.java
deleted file mode 100644
index cf0400b104..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiStringConverterTests.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.BidiStringConverter;
-
-@SuppressWarnings("nls")
-public class BidiStringConverterTests extends TestCase {
-
- public BidiStringConverterTests(String name) {
- super(name);
- }
-
- public void testDefaultBidiStringConverter_convertToString() throws Exception {
- assertEquals("foo", BidiStringConverter.Default.instance().convertToString("foo"));
- assertNull(BidiStringConverter.Default.instance().convertToString(null));
- }
-
- public void testDefaultBidiStringConverter_convertToObject() throws Exception {
- assertEquals("foo", BidiStringConverter.Default.instance().convertToObject("foo"));
- assertNull(BidiStringConverter.Default.instance().convertToString(null));
- }
-
- public void testDefaultBidiStringConverter_toString() throws Exception {
- assertNotNull(BidiStringConverter.Default.instance().toString());
- }
-
- public void testDefaultBidiStringConverter_serialization() throws Exception {
- BidiStringConverter<?> xxx = TestTools.serialize(BidiStringConverter.Default.instance());
- assertSame(BidiStringConverter.Default.instance(), xxx);
- }
-
- public void testDisabledBidiStringConverter_convertToString() throws Exception {
- boolean exCaught = false;
- try {
- BidiStringConverter.Disabled.instance().convertToString("foo");
- fail();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testDisabledBidiStringConverter_convertToObject() throws Exception {
- boolean exCaught = false;
- try {
- BidiStringConverter.Disabled.instance().convertToObject("foo");
- fail();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testDisabledBidiStringConverter_toString() throws Exception {
- assertNotNull(BidiStringConverter.Disabled.instance().toString());
- }
-
- public void testDisabledBidiStringConverter_serialization() throws Exception {
- BidiStringConverter<?> xxx = TestTools.serialize(BidiStringConverter.Disabled.instance());
- assertSame(BidiStringConverter.Disabled.instance(), xxx);
- }
-
- public void testBooleanBidiStringConverter_convertToString() throws Exception {
- assertEquals("true", BidiStringConverter.BooleanConverter.instance().convertToString(Boolean.TRUE));
- assertEquals("false", BidiStringConverter.BooleanConverter.instance().convertToString(Boolean.FALSE));
- assertNull(BidiStringConverter.BooleanConverter.instance().convertToString(null));
- }
-
- public void testBooleanBidiStringConverter_convertToObject() throws Exception {
- assertEquals(Boolean.TRUE, BidiStringConverter.BooleanConverter.instance().convertToObject("true"));
- assertEquals(Boolean.TRUE, BidiStringConverter.BooleanConverter.instance().convertToObject("TRUE"));
- assertEquals(Boolean.FALSE, BidiStringConverter.BooleanConverter.instance().convertToObject("false"));
- assertEquals(Boolean.FALSE, BidiStringConverter.BooleanConverter.instance().convertToObject("xxxx"));
- assertNull(BidiStringConverter.BooleanConverter.instance().convertToObject(null));
- }
-
- public void testBooleanBidiStringConverter_toString() throws Exception {
- assertNotNull(BidiStringConverter.BooleanConverter.instance().toString());
- }
-
- public void testBooleanBidiStringConverter_serialization() throws Exception {
- BidiStringConverter<?> xxx = TestTools.serialize(BidiStringConverter.BooleanConverter.instance());
- assertSame(BidiStringConverter.BooleanConverter.instance(), xxx);
- }
-
- public void testIntegerBidiStringConverter_convertToString() throws Exception {
- assertEquals("7", BidiStringConverter.IntegerConverter.instance().convertToString(Integer.valueOf(7)));
- assertNull(BidiStringConverter.IntegerConverter.instance().convertToString(null));
- }
-
- public void testIntegerBidiStringConverter_convertToObject() throws Exception {
- assertEquals(Integer.valueOf(7), BidiStringConverter.IntegerConverter.instance().convertToObject("7"));
- assertNull(BidiStringConverter.IntegerConverter.instance().convertToObject(null));
- }
-
- public void testIntegerBidiStringConverter_toString() throws Exception {
- assertNotNull(BidiStringConverter.IntegerConverter.instance().toString());
- }
-
- public void testIntegerBidiStringConverter_serialization() throws Exception {
- BidiStringConverter<?> xxx = TestTools.serialize(BidiStringConverter.IntegerConverter.instance());
- assertSame(BidiStringConverter.IntegerConverter.instance(), xxx);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiTransformerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiTransformerTests.java
deleted file mode 100644
index 973f153f45..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BidiTransformerTests.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.BidiTransformer;
-
-@SuppressWarnings("nls")
-public class BidiTransformerTests extends TestCase {
-
- public BidiTransformerTests(String name) {
- super(name);
- }
-
- public void testNullBidiTransformer_transform() throws Exception {
- assertEquals("foo", BidiTransformer.Null.instance().transform("foo"));
- assertNull(BidiTransformer.Null.instance().transform(null));
- }
-
- public void testNullBidiTransformer_reverseTransform() throws Exception {
- assertEquals("foo", BidiTransformer.Null.instance().reverseTransform("foo"));
- assertNull(BidiTransformer.Null.instance().transform(null));
- }
-
- public void testNullBidiTransformer_toString() throws Exception {
- assertNotNull(BidiTransformer.Null.instance().toString());
- }
-
- public void testNullBidiTransformer_serialization() throws Exception {
- BidiTransformer<?, ?> xxx = TestTools.serialize(BidiTransformer.Null.instance());
- assertSame(BidiTransformer.Null.instance(), xxx);
- }
-
- public void testDisabledBidiTransformer_transform() throws Exception {
- boolean exCaught = false;
- try {
- BidiTransformer.Disabled.instance().transform("foo");
- fail();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testDisabledBidiTransformer_reverseTransform() throws Exception {
- boolean exCaught = false;
- try {
- BidiTransformer.Disabled.instance().reverseTransform("foo");
- fail();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testDisabledBidiTransformer_toString() throws Exception {
- assertNotNull(BidiTransformer.Disabled.instance().toString());
- }
-
- public void testDisabledBidiTransformer_serialization() throws Exception {
- BidiTransformer<?, ?> xxx = TestTools.serialize(BidiTransformer.Disabled.instance());
- assertSame(BidiTransformer.Disabled.instance(), xxx);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BitToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BitToolsTests.java
deleted file mode 100644
index dd1941237b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BitToolsTests.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.lang.reflect.InvocationTargetException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.BitTools;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-
-public class BitToolsTests extends TestCase {
-
- public BitToolsTests(String name) {
- super(name);
- }
-
- public void testFlagIsSetIntInt() {
- assertTrue(BitTools.flagIsSet(0x0003, 0x0001));
- assertTrue(BitTools.flagIsSet(0x0303, 0x0001));
- assertTrue(BitTools.flagIsSet(0x0303, 0x0101));
- assertTrue(BitTools.flagIsSet(0x0303, 0x0103));
-
- assertFalse(BitTools.flagIsSet(0x0303, 0x1103));
- assertFalse(BitTools.flagIsSet(0x0000, 0x1103));
- }
-
- public void testFlagIsOffIntInt() {
- assertFalse(BitTools.flagIsOff(0x0003, 0x0001));
- assertFalse(BitTools.flagIsOff(0x0303, 0x0001));
- assertFalse(BitTools.flagIsOff(0x0303, 0x0101));
- assertFalse(BitTools.flagIsOff(0x0303, 0x0103));
-
- assertTrue(BitTools.flagIsOff(0x2204, 0x1103));
- assertTrue(BitTools.flagIsOff(0x0000, 0x1103));
- }
-
- public void testOnlyFlagIsSetIntInt() {
- assertFalse(BitTools.onlyFlagIsSet(0x0003, 0x0001));
- assertTrue(BitTools.onlyFlagIsSet(0x0001, 0x0001));
-
- assertFalse(BitTools.onlyFlagIsSet(0x0303, 0x0001));
- assertTrue(BitTools.onlyFlagIsSet(0x0001, 0x0001));
-
- assertFalse(BitTools.onlyFlagIsSet(0x0303, 0x0101));
- assertTrue(BitTools.onlyFlagIsSet(0x0101, 0x0101));
-
- assertFalse(BitTools.onlyFlagIsSet(0x0303, 0x0103));
- assertTrue(BitTools.onlyFlagIsSet(0x0103, 0x0103));
-
- assertFalse(BitTools.onlyFlagIsSet(0x0303, 0x1103));
- assertTrue(BitTools.onlyFlagIsSet(0x1103, 0x1103));
-
- assertFalse(BitTools.onlyFlagIsSet(0x0000, 0x1103));
- assertTrue(BitTools.onlyFlagIsSet(0x0103, 0x0103));
- }
-
- public void testOnlyFlagIsOffIntInt() {
- assertFalse(BitTools.onlyFlagIsOff(0x0003, 0x0001));
- assertFalse(BitTools.onlyFlagIsOff(0x0303, 0x0001));
- assertTrue(BitTools.onlyFlagIsOff(0xFFFFFFFE, 0x0001));
-
- assertFalse(BitTools.onlyFlagIsOff(0x0303, 0x0101));
- assertTrue(BitTools.onlyFlagIsOff(0xFFFFFEFE, 0x0101));
-
- assertFalse(BitTools.onlyFlagIsOff(0x0303, 0x0103));
- assertTrue(BitTools.onlyFlagIsOff(0xFFFFFEFC, 0x0103));
-
- assertFalse(BitTools.onlyFlagIsOff(0x0303, 0x1103));
- assertTrue(BitTools.onlyFlagIsOff(0xFFFFEEFC, 0x1103));
- }
-
- public void testAllFlagsAreSetIntInt() {
- assertTrue(BitTools.allFlagsAreSet(0x0003, 0x0001));
- assertTrue(BitTools.allFlagsAreSet(0x0303, 0x0001));
- assertTrue(BitTools.allFlagsAreSet(0x0303, 0x0101));
- assertTrue(BitTools.allFlagsAreSet(0x0303, 0x0103));
-
- assertFalse(BitTools.allFlagsAreSet(0x0303, 0x1103));
- assertFalse(BitTools.allFlagsAreSet(0x0000, 0x1103));
- }
-
- public void testAllFlagsAreOffIntInt() {
- assertFalse(BitTools.allFlagsAreOff(0x0003, 0x0001));
- assertFalse(BitTools.allFlagsAreOff(0x0303, 0x0001));
- assertFalse(BitTools.allFlagsAreOff(0x0303, 0x0101));
- assertFalse(BitTools.allFlagsAreOff(0x0303, 0x0103));
-
- assertTrue(BitTools.allFlagsAreOff(0x2204, 0x1103));
- assertTrue(BitTools.allFlagsAreOff(0x0000, 0x1103));
- }
-
- public void testOnlyFlagsAreSetIntInt() {
- assertFalse(BitTools.onlyFlagsAreSet(0x0003, 0x0001));
- assertTrue(BitTools.onlyFlagsAreSet(0x0001, 0x0001));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, 0x0001));
- assertTrue(BitTools.onlyFlagsAreSet(0x0001, 0x0001));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, 0x0101));
- assertTrue(BitTools.onlyFlagsAreSet(0x0101, 0x0101));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, 0x0103));
- assertTrue(BitTools.onlyFlagsAreSet(0x0103, 0x0103));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, 0x1103));
- assertTrue(BitTools.onlyFlagsAreSet(0x1103, 0x1103));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0000, 0x1103));
- assertTrue(BitTools.onlyFlagsAreSet(0x0103, 0x0103));
- }
-
- public void testOnlyFlagsAreOffIntInt() {
- assertFalse(BitTools.onlyFlagsAreOff(0x0003, 0x0001));
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, 0x0001));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFFFE, 0x0001));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, 0x0101));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFEFE, 0x0101));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, 0x0103));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFEFC, 0x0103));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, 0x1103));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFEEFC, 0x1103));
- }
-
- public void testAnyFlagsAreSetIntInt() {
- assertTrue(BitTools.anyFlagsAreSet(0x0003, 0x0001));
- assertTrue(BitTools.anyFlagsAreSet(0xFFFF, 0x0001));
- assertTrue(BitTools.anyFlagsAreSet(0x0003, 0xFFFF));
-
- assertFalse(BitTools.anyFlagsAreSet(0x0303, 0x1010));
- assertFalse(BitTools.anyFlagsAreSet(0x0000, 0xFFFF));
- }
-
- public void testAnyFlagsAreOffIntInt() {
- assertTrue(BitTools.anyFlagsAreOff(0x333E, 0x0001));
- assertTrue(BitTools.anyFlagsAreOff(0xFFFE, 0x0001));
- assertTrue(BitTools.anyFlagsAreOff(0x0003, 0xFFFF));
-
- assertFalse(BitTools.anyFlagsAreOff(0x7373, 0x1010));
- assertFalse(BitTools.anyFlagsAreOff(0xFFFF, 0xFFFF));
- }
-
- public void testAllFlagsAreSetIntIntArray() {
- assertTrue(BitTools.allFlagsAreSet(0x0003, new int[] { 0x0001 }));
- assertTrue(BitTools.allFlagsAreSet(0x0303, new int[] { 0x0001 }));
- assertTrue(BitTools.allFlagsAreSet(0x0303, new int[] { 0x0100, 0x0001 }));
- assertTrue(BitTools.allFlagsAreSet(0x0303, new int[] { 0x0100, 0x0002, 0x0001 }));
-
- assertFalse(BitTools.allFlagsAreSet(0x0303, new int[] { 0x1000, 0x0100, 0x0002, 0x0001 }));
- assertFalse(BitTools.allFlagsAreSet(0x0000, new int[] { 0x1000, 0x0100, 0x0002, 0x0001 }));
- }
-
- public void testAllFlagsAreOffIntIntArray() {
- assertFalse(BitTools.allFlagsAreOff(0x0003, new int[] { 0x0001 }));
- assertFalse(BitTools.allFlagsAreOff(0x0303, new int[] { 0x0001 }));
- assertFalse(BitTools.allFlagsAreOff(0x0303, new int[] { 0x0100, 0x0001 }));
- assertFalse(BitTools.allFlagsAreOff(0x0303, new int[] { 0x0100, 0x0002, 0x0001 }));
-
- assertTrue(BitTools.allFlagsAreOff(0x0303, new int[] { 0x1000, 0x0400, 0x0020, 0x0000 }));
- assertTrue(BitTools.allFlagsAreOff(0x0000, new int[] { 0x1000, 0x0100, 0x0002, 0x0001 }));
- }
-
- public void testOnlyFlagsAreSetIntIntArray() {
- assertFalse(BitTools.onlyFlagsAreSet(0x0003, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x0001, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x0001, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, new int[] { 0x001, 0x0100, 0x0000, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x0101, new int[] { 0x001, 0x0100, 0x0000, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, new int[] { 0x001, 0x0100, 0x0002, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x0103, new int[] { 0x001, 0x0100, 0x0002, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0303, new int[] { 0x011, 0x0100, 0x0002, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x1103, new int[] { 0x1100, 0x0100, 0x0002, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreSet(0x0000, new int[] { 0x011, 0x0100, 0x0002, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreSet(0x0103, new int[] { 0x0101, 0x0100, 0x0002, 0x0001 }));
- }
-
- public void testOnlyFlagsAreOffIntIntArray() {
- assertFalse(BitTools.onlyFlagsAreOff(0x0003, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFFFE, new int[] { 0x001, 0x0000, 0x0000, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, new int[] { 0x001, 0x0100, 0x0000, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFEFE, new int[] { 0x001, 0x0100, 0x0000, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, new int[] { 0x001, 0x0100, 0x0002, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFFEFC, new int[] { 0x001, 0x0100, 0x0002, 0x0001 }));
-
- assertFalse(BitTools.onlyFlagsAreOff(0x0303, new int[] { 0x1100, 0x0100, 0x0002, 0x0001 }));
- assertTrue(BitTools.onlyFlagsAreOff(0xFFFFEEFC, new int[] { 0x1100, 0x0100, 0x0002, 0x0001 }));
- }
-
- public void testAnyFlagsAreSetIntIntArray() {
- assertTrue(BitTools.anyFlagsAreSet(0x0003, new int[] { 0x0001 }));
- assertTrue(BitTools.anyFlagsAreSet(0xFFFF, new int[] { 0x0001 }));
- assertTrue(BitTools.anyFlagsAreSet(0x0303, new int[] { 0xF000, 0x0F00, 0x00F0, 0x000F }));
-
- assertFalse(BitTools.anyFlagsAreSet(0x0303, new int[] { 0x1000, 0x0010 }));
- assertFalse(BitTools.anyFlagsAreSet(0x0000, new int[] { 0xF000, 0x0F00, 0x00F0, 0x000F }));
- }
-
- public void testAnyFlagsAreOffIntIntArray() {
- assertFalse(BitTools.anyFlagsAreOff(0x0003, new int[] { 0x0001 }));
- assertFalse(BitTools.anyFlagsAreOff(0xFFFF, new int[] { 0x0001 }));
- assertFalse(BitTools.anyFlagsAreOff(0x0303, new int[] { 0x0100, 0x0200, 0x0003, 0x0002 }));
-
- assertTrue(BitTools.anyFlagsAreOff(0x0303, new int[] { 0x0100, 0x0010 }));
- assertTrue(BitTools.anyFlagsAreOff(0x0000, new int[] { 0xF000, 0x0F00, 0x00F0, 0x000F }));
- }
-
- public void testOrFlags() {
- assertEquals(0x0001, BitTools.orFlags(new int[] { 0x0001, 0x0000 }));
- assertEquals(0x0011, BitTools.orFlags(new int[] { 0x0001, 0x0011 }));
- assertEquals(0xF011, BitTools.orFlags(new int[] { 0x0001, 0x0011, 0xF000 }));
- }
-
- public void testAndFlags() {
- assertEquals(0x0001, BitTools.andFlags(new int[] { 0x0001, 0x0001 }));
- assertEquals(0x0001, BitTools.andFlags(new int[] { 0x0001, 0x0011 }));
- assertEquals(0x0000, BitTools.andFlags(new int[] { 0x0001, 0x0011, 0xF000 }));
- assertEquals(0x0001, BitTools.andFlags(new int[] { 0x0001, 0x0011, 0xF001 }));
- }
-
- public void testXorFlags() {
- assertEquals(0x0001, BitTools.xorFlags(new int[] { 0x0001, 0x0000 }));
- assertEquals(0x0010, BitTools.xorFlags(new int[] { 0x0001, 0x0011 }));
- assertEquals(0xF010, BitTools.xorFlags(new int[] { 0x0001, 0x0011, 0xF000 }));
- assertEquals(0xFF11, BitTools.xorFlags(new int[] { 0x0001, 0x0011, 0xF000, 0x0F01 }));
- assertEquals(0xF010, BitTools.xorFlags(new int[] { 0x0001, 0x0011, 0xF000, 0x0F01, 0x0F01 }));
- }
-
- public void testConstructor() {
- boolean exCaught = false;
- try {
- Object at = ReflectionTools.newInstance(BitTools.class);
- fail("bogus: " + at); //$NON-NLS-1$
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof InvocationTargetException) {
- if (ex.getCause().getCause() instanceof UnsupportedOperationException) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BooleanToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BooleanToolsTests.java
deleted file mode 100644
index f134a70e87..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/BooleanToolsTests.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.lang.reflect.InvocationTargetException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.BooleanTools;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-
-public class BooleanToolsTests extends TestCase {
- private static final Boolean TRUE = Boolean.TRUE;
- private static final Boolean FALSE = Boolean.FALSE;
-
- public BooleanToolsTests(String name) {
- super(name);
- }
-
- public void testNOT() {
- assertEquals(FALSE, BooleanTools.not(TRUE));
- assertEquals(TRUE, BooleanTools.not(FALSE));
- }
-
- public void testAND() {
- assertEquals(TRUE, BooleanTools.and(TRUE, TRUE));
- assertEquals(FALSE, BooleanTools.and(TRUE, FALSE));
- assertEquals(FALSE, BooleanTools.and(FALSE, TRUE));
- assertEquals(FALSE, BooleanTools.and(FALSE, FALSE));
- }
-
- public void testOR() {
- assertEquals(TRUE, BooleanTools.or(TRUE, TRUE));
- assertEquals(TRUE, BooleanTools.or(TRUE, FALSE));
- assertEquals(TRUE, BooleanTools.or(FALSE, TRUE));
- assertEquals(FALSE, BooleanTools.or(FALSE, FALSE));
- }
-
- public void testXOR() {
- assertEquals(FALSE, BooleanTools.xor(TRUE, TRUE));
- assertEquals(TRUE, BooleanTools.xor(TRUE, FALSE));
- assertEquals(TRUE, BooleanTools.xor(FALSE, TRUE));
- assertEquals(FALSE, BooleanTools.xor(FALSE, FALSE));
- }
-
- public void testNAND() {
- assertEquals(FALSE, BooleanTools.nand(TRUE, TRUE));
- assertEquals(TRUE, BooleanTools.nand(TRUE, FALSE));
- assertEquals(TRUE, BooleanTools.nand(FALSE, TRUE));
- assertEquals(TRUE, BooleanTools.nand(FALSE, FALSE));
- }
-
- public void testNOR() {
- assertEquals(FALSE, BooleanTools.nor(TRUE, TRUE));
- assertEquals(FALSE, BooleanTools.nor(TRUE, FALSE));
- assertEquals(FALSE, BooleanTools.nor(FALSE, TRUE));
- assertEquals(TRUE, BooleanTools.nor(FALSE, FALSE));
- }
-
- public void testXNOR() {
- assertEquals(TRUE, BooleanTools.xnor(TRUE, TRUE));
- assertEquals(FALSE, BooleanTools.xnor(TRUE, FALSE));
- assertEquals(FALSE, BooleanTools.xnor(FALSE, TRUE));
- assertEquals(TRUE, BooleanTools.xnor(FALSE, FALSE));
- }
-
- public void testConstructor() {
- boolean exCaught = false;
- try {
- Object at = ReflectionTools.newInstance(BooleanTools.class);
- fail("bogus: " + at); //$NON-NLS-1$
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof InvocationTargetException) {
- if (ex.getCause().getCause() instanceof UnsupportedOperationException) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ClassNameTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ClassNameTests.java
deleted file mode 100644
index 8e070b6d18..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ClassNameTests.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationTargetException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.ClassName;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-
-@SuppressWarnings("nls")
-public class ClassNameTests extends TestCase {
-
- public ClassNameTests(String name) {
- super(name);
- }
-
- public void testIsArray() {
- assertFalse(ClassName.isArray(int.class.getName()));
- assertTrue(ClassName.isArray(int[].class.getName()));
- assertTrue(ClassName.isArray(int[][].class.getName()));
-
- assertFalse(ClassName.isArray(java.lang.String.class.getName()));
- assertTrue(ClassName.isArray(java.lang.String[].class.getName()));
- assertTrue(ClassName.isArray(java.lang.String[][].class.getName()));
- }
-
- public void testGetElementTypeName() {
- assertEquals(java.util.Vector.class.getName(), ClassName.getElementTypeName(java.util.Vector.class.getName()));
- assertEquals(int.class.getName(), ClassName.getElementTypeName(int.class.getName()));
- assertEquals(void.class.getName(), ClassName.getElementTypeName(void.class.getName()));
- assertEquals(java.util.Vector.class.getName(), ClassName.getElementTypeName(java.util.Vector[].class.getName()));
- assertEquals(int.class.getName(), ClassName.getElementTypeName(int[].class.getName()));
- assertEquals(java.util.Vector.class.getName(), ClassName.getElementTypeName(java.util.Vector[][][].class.getName()));
- assertEquals(int.class.getName(), ClassName.getElementTypeName(int[][][].class.getName()));
- }
-
- public void testGetArrayDepth() {
- assertEquals(0, ClassName.getArrayDepth(java.util.Vector.class.getName()));
- assertEquals(0, ClassName.getArrayDepth(int.class.getName()));
- assertEquals(0, ClassName.getArrayDepth(void.class.getName()));
- assertEquals(1, ClassName.getArrayDepth(java.util.Vector[].class.getName()));
- assertEquals(1, ClassName.getArrayDepth(int[].class.getName()));
- assertEquals(3, ClassName.getArrayDepth(java.util.Vector[][][].class.getName()));
- assertEquals(3, ClassName.getArrayDepth(int[][][].class.getName()));
- }
-
- public void testGetComponentTypeName() {
- assertEquals(null, ClassName.getComponentTypeName(java.lang.Object.class.getName()));
- assertEquals(java.lang.Object.class.getName(), ClassName.getComponentTypeName(java.lang.Object[].class.getName()));
- assertEquals(java.lang.Object[].class.getName(), ClassName.getComponentTypeName(java.lang.Object[][].class.getName()));
-
- assertEquals(null, ClassName.getComponentTypeName(int.class.getName()));
- assertEquals(int.class.getName(), ClassName.getComponentTypeName(int[].class.getName()));
- assertEquals(int[].class.getName(), ClassName.getComponentTypeName(int[][].class.getName()));
- }
-
- public void testGetSimpleName() throws Exception {
- assertEquals("Object", ClassName.getSimpleName(java.lang.Object.class.getName()));
- assertEquals("Object[]", ClassName.getSimpleName(java.lang.Object[].class.getName()));
- assertEquals("Object[][]", ClassName.getSimpleName(java.lang.Object[][].class.getName()));
-
- assertEquals(java.util.Map.class.getSimpleName(), ClassName.getSimpleName(java.util.Map.class.getName()));
- assertEquals(java.util.Map.Entry.class.getSimpleName(), ClassName.getSimpleName(java.util.Map.Entry.class.getName()));
-
- assertEquals("int", ClassName.getSimpleName(int.class.getName()));
- assertEquals("int[]", ClassName.getSimpleName(int[].class.getName()));
- assertEquals("int[][]", ClassName.getSimpleName(int[][].class.getName()));
-
- Object anonObject = new Object() {
- // anonymous class
- };
- assertEquals("", ClassName.getSimpleName(anonObject.getClass().getName()));
-
- class Local {
- // anonymous class
- }
- Local localObject = new Local();
- assertEquals("Local", ClassName.getSimpleName(localObject.getClass().getName()));
- }
-
- public void testGetPackageName() throws Exception {
- assertEquals(java.lang.Object.class.getPackage().getName(), ClassName.getPackageName(java.lang.Object.class.getName()));
- assertEquals("", ClassName.getPackageName(java.lang.Object[].class.getName()));
- assertEquals("", ClassName.getPackageName(java.lang.Object[][].class.getName()));
-
- assertEquals(java.util.Map.class.getPackage().getName(), ClassName.getPackageName(java.util.Map.class.getName()));
- assertEquals(java.util.Map.Entry.class.getPackage().getName(), ClassName.getPackageName(java.util.Map.Entry.class.getName()));
-
- assertEquals("", ClassName.getPackageName(int.class.getName()));
- assertEquals("", ClassName.getPackageName(int[].class.getName()));
- assertEquals("", ClassName.getPackageName(int[][].class.getName()));
-
- assertEquals("", ClassName.getPackageName(void.class.getName()));
-
- Object anonObject = new Object() {
- // anonymous class
- };
- assertEquals(anonObject.getClass().getPackage().getName(), ClassName.getPackageName(anonObject.getClass().getName()));
- }
-
- public void testIsTopLevel() throws Exception {
- assertTrue(ClassName.isTopLevel(java.util.Map.class.getName())); // top-level
- assertFalse(ClassName.isTopLevel(java.util.Map.Entry.class.getName())); // member
- assertFalse(ClassName.isTopLevel(Class.forName(this.getClass().getName() + "$1LocalClass").getName())); // local
- assertFalse(ClassName.isTopLevel(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassName.isTopLevel(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassName.isTopLevel(array.getClass().getName()));
- Class<?> localClass = Class.forName(this.getClass().getName() + "$1LocalClass"); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassName.isTopLevel(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassName.isTopLevel(array.getClass().getName()));
- }
-
- public void testIsMember() throws Exception {
- assertFalse(ClassName.isMember(java.util.Map.class.getName())); // top-level
- assertTrue(ClassName.isMember(java.util.Map.Entry.class.getName())); // member
- assertFalse(ClassName.isMember(Class.forName(this.getClass().getName() + "$1LocalClass").getName())); // local
- assertFalse(ClassName.isMember(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassName.isMember(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassName.isMember(array.getClass().getName()));
- Class<?> localClass = Class.forName(this.getClass().getName() + "$1LocalClass"); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassName.isMember(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassName.isMember(array.getClass().getName()));
-
- // test a few edge cases
- assertTrue(ClassName.isMember("java.util.Map$a1"));
- assertTrue(ClassName.isMember("java.util.Map$1aa$aaa")); // member inside local
- assertTrue(ClassName.isMember("java.util.Map$1$aaa")); // member inside anonymous
- assertTrue(ClassName.isMember("java.util.Map$a1$aaa$bbb"));
- assertTrue(ClassName.isMember("java.util.Map$1a1$aaa")); // member inside local
- assertFalse(ClassName.isMember("java.util.Map$1a"));
- assertTrue(ClassName.isMember("java.util.Map$a12345$b12345"));
- assertFalse(ClassName.isMember("java.util.Map$12345a"));
- assertFalse(ClassName.isMember("java.util.Map$333"));
- assertFalse(ClassName.isMember("java.util.Map3$333"));
- }
-
- public void testIsLocal() throws Exception {
- class LocalClass {
- void foo() {
- System.getProperty("foo");
- }
- }
- new LocalClass().foo();
- assertFalse(ClassName.isLocal(java.util.Map.class.getName())); // top-level
- assertFalse(ClassName.isLocal(java.util.Map.Entry.class.getName())); // member
- assertTrue(ClassName.isLocal(Class.forName(this.getClass().getName() + "$1LocalClass").getName())); // local
- assertFalse(ClassName.isLocal(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassName.isLocal(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassName.isLocal(array.getClass().getName()));
- Class<?> localClass = Class.forName(this.getClass().getName() + "$1LocalClass"); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassName.isLocal(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassName.isLocal(array.getClass().getName()));
-
- // test a few edge cases
- assertFalse(ClassName.isLocal("java.util.Map$a1"));
- assertFalse(ClassName.isLocal("java.util.Map$a1$aaa$bbb"));
- assertFalse(ClassName.isLocal("java.util.Map$11$aaa"));
- assertTrue(ClassName.isLocal("java.util.Map$1a"));
- assertTrue(ClassName.isLocal("java.util.Map$2abc"));
- assertTrue(ClassName.isLocal("java.util.Map$2abc1"));
- assertFalse(ClassName.isLocal("java.util.Map$a12345$b12345"));
- assertTrue(ClassName.isLocal("java.util.Map$12345$1234a"));
- assertFalse(ClassName.isLocal("java.util.Map$333"));
- assertFalse(ClassName.isLocal("java.util.Map3$333"));
- }
-
- public void testIsAnonymous() throws Exception {
- assertFalse(ClassName.isAnonymous(java.util.Map.class.getName())); // top-level
- assertFalse(ClassName.isAnonymous(java.util.Map.Entry.class.getName())); // member
- assertFalse(ClassName.isAnonymous(Class.forName(this.getClass().getName() + "$1LocalClass").getName())); // local
- assertTrue(ClassName.isAnonymous(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertFalse(ClassName.isAnonymous(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertFalse(ClassName.isAnonymous(array.getClass().getName()));
- Class<?> localClass = Class.forName(this.getClass().getName() + "$1LocalClass"); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertFalse(ClassName.isAnonymous(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertFalse(ClassName.isAnonymous(array.getClass().getName()));
-
- // test a few edge cases
- assertFalse(ClassName.isAnonymous("java.util.Map$a1"));
- assertFalse(ClassName.isAnonymous("java.util.Map$a1$aaa$bbb"));
- assertFalse(ClassName.isAnonymous("java.util.Map$1a1$aaa"));
- assertFalse(ClassName.isAnonymous("java.util.Map$1$a"));
- assertFalse(ClassName.isAnonymous("java.util.Map$1a"));
- assertFalse(ClassName.isAnonymous("java.util.Map$a12345$b12345"));
- assertFalse(ClassName.isAnonymous("java.util.Map$12345$a1234"));
- assertTrue(ClassName.isAnonymous("java.util.Map$333"));
- assertTrue(ClassName.isAnonymous("java.util.Map3$333"));
- }
-
- public void testIsReference() throws Exception {
- assertFalse(ClassName.isReference(int.class.getName())); // top-level
-
- assertTrue(ClassName.isReference(java.util.Map.class.getName())); // top-level
- assertTrue(ClassName.isReference(java.util.Map.Entry.class.getName())); // member
- assertTrue(ClassName.isReference(Class.forName(this.getClass().getName() + "$1LocalClass").getName())); // local
- assertTrue(ClassName.isReference(Class.forName("java.util.Vector$1").getName())); // anonymous
-
- Object[] array = new java.util.Map[0]; // top-level
- assertTrue(ClassName.isReference(array.getClass().getName()));
- array = new java.util.Map.Entry[0]; // member
- assertTrue(ClassName.isReference(array.getClass().getName()));
- Class<?> localClass = Class.forName(this.getClass().getName() + "$1LocalClass"); // local
- array = (Object[]) Array.newInstance(localClass, 0);
- assertTrue(ClassName.isReference(array.getClass().getName()));
- Class<?> anonClass = Class.forName("java.util.Vector$1"); // local
- array = (Object[]) Array.newInstance(anonClass, 0);
- assertTrue(ClassName.isReference(array.getClass().getName()));
- }
-
- public void testIsPrimitive() {
- assertTrue(void.class.isPrimitive());
-
- assertTrue(ClassName.isPrimitive(void.class.getName()));
- assertTrue(ClassName.isPrimitive(int.class.getName()));
- assertTrue(ClassName.isPrimitive(float.class.getName()));
- assertTrue(ClassName.isPrimitive(boolean.class.getName()));
-
- assertFalse(ClassName.isPrimitive(java.lang.Number.class.getName()));
- assertFalse(ClassName.isPrimitive(java.lang.String.class.getName()));
- assertFalse(ClassName.isPrimitive(java.lang.Boolean.class.getName()));
- assertFalse(ClassName.isPrimitive(java.lang.Integer.class.getName()));
- }
-
- public void testIsPrimitiveWrapper() {
- assertFalse(ClassName.isPrimitiveWrapper(void.class.getName()));
- assertFalse(ClassName.isPrimitiveWrapper(int.class.getName()));
- assertFalse(ClassName.isPrimitiveWrapper(float.class.getName()));
- assertFalse(ClassName.isPrimitiveWrapper(boolean.class.getName()));
-
- assertFalse(ClassName.isPrimitiveWrapper(java.lang.reflect.Field.class.getName()));
- assertFalse(ClassName.isPrimitiveWrapper(java.lang.String.class.getName()));
- assertTrue(ClassName.isPrimitiveWrapper(java.lang.Boolean.class.getName()));
- assertTrue(ClassName.isPrimitiveWrapper(java.lang.Integer.class.getName()));
- }
-
- public void testIsVariablePrimitive() {
- assertFalse(ClassName.isVariablePrimitive(void.class.getName()));
-
- assertTrue(ClassName.isVariablePrimitive(int.class.getName()));
- assertTrue(ClassName.isVariablePrimitive(float.class.getName()));
- assertTrue(ClassName.isVariablePrimitive(boolean.class.getName()));
-
- assertFalse(ClassName.isVariablePrimitive(java.lang.Number.class.getName()));
- assertFalse(ClassName.isVariablePrimitive(java.lang.String.class.getName()));
- assertFalse(ClassName.isVariablePrimitive(java.lang.Boolean.class.getName()));
- }
-
- public void testIsVariablePrimitiveWrapper() {
- assertFalse(ClassName.isVariablePrimitiveWrapper(java.lang.Void.class.getName()));
-
- assertTrue(ClassName.isVariablePrimitiveWrapper(java.lang.Integer.class.getName()));
- assertTrue(ClassName.isVariablePrimitiveWrapper(java.lang.Float.class.getName()));
- assertTrue(ClassName.isVariablePrimitiveWrapper(java.lang.Boolean.class.getName()));
-
- assertFalse(ClassName.isVariablePrimitiveWrapper(java.lang.Number.class.getName()));
- assertFalse(ClassName.isVariablePrimitiveWrapper(java.lang.String.class.getName()));
- assertFalse(ClassName.isVariablePrimitiveWrapper(java.lang.Object.class.getName()));
- }
-
- public void testGetWrapperClassName() {
- assertEquals(java.lang.Void.class.getName(), ClassName.getWrapperClassName(void.class.getName()));
- assertEquals(java.lang.Integer.class.getName(), ClassName.getWrapperClassName(int.class.getName()));
- assertEquals(java.lang.Float.class.getName(), ClassName.getWrapperClassName(float.class.getName()));
- assertEquals(java.lang.Boolean.class.getName(), ClassName.getWrapperClassName(boolean.class.getName()));
-
- assertNull(ClassName.getWrapperClassName(java.lang.String.class.getName()));
- }
-
- public void testGetPrimitiveClassName() {
- assertEquals(void.class.getName(), ClassName.getPrimitiveClassName(java.lang.Void.class.getName()));
- assertEquals(int.class.getName(), ClassName.getPrimitiveClassName(java.lang.Integer.class.getName()));
- assertEquals(float.class.getName(), ClassName.getPrimitiveClassName(java.lang.Float.class.getName()));
- assertEquals(boolean.class.getName(), ClassName.getPrimitiveClassName(java.lang.Boolean.class.getName()));
-
- assertNull(ClassName.getPrimitiveClassName(java.lang.String.class.getName()));
- }
-
- public void testAreAutoboxEquivalents() {
- assertTrue(ClassName.areAutoboxEquivalents(Integer.class.getName(), Integer.class.getName()));
- assertTrue(ClassName.areAutoboxEquivalents(int.class.getName(), Integer.class.getName()));
- assertTrue(ClassName.areAutoboxEquivalents(Integer.class.getName(), int.class.getName()));
- assertFalse(ClassName.areAutoboxEquivalents(int.class.getName(), Boolean.class.getName()));
- assertTrue(ClassName.areAutoboxEquivalents(String.class.getName(), String.class.getName()));
- }
-
- public void testForCode() {
- assertEquals("byte", ClassName.forCode('B'));
- assertEquals("char", ClassName.forCode('C'));
- assertEquals("double", ClassName.forCode('D'));
- assertEquals("float", ClassName.forCode('F'));
- assertEquals("int", ClassName.forCode('I'));
- assertEquals("long", ClassName.forCode('J'));
- assertEquals("short", ClassName.forCode('S'));
- assertEquals("boolean", ClassName.forCode('Z'));
- assertEquals("void", ClassName.forCode('V'));
-
- assertNull(ClassName.forCode('X'));
-
- assertEquals("byte", ClassName.forCode((int) 'B'));
- assertEquals("char", ClassName.forCode((int) 'C'));
- assertEquals("double", ClassName.forCode((int) 'D'));
- assertEquals("float", ClassName.forCode((int) 'F'));
- assertEquals("int", ClassName.forCode((int) 'I'));
- assertEquals("long", ClassName.forCode((int) 'J'));
- assertEquals("short", ClassName.forCode((int) 'S'));
- assertEquals("boolean", ClassName.forCode((int) 'Z'));
- assertEquals("void", ClassName.forCode((int) 'V'));
-
- assertNull(ClassName.forCode((int) 'X'));
- }
-
- public void testGetCodeForClassName() {
- assertEquals('I', ClassName.getCodeForClassName(int.class.getName()));
- assertEquals('I', ClassName.getCodeForClassName("int"));
- assertEquals('B', ClassName.getCodeForClassName(byte.class.getName()));
- assertEquals('B', ClassName.getCodeForClassName("byte"));
-
- assertEquals((char) 0, ClassName.getCodeForClassName(java.lang.Object.class.getName()));
- }
-
- public void testConstructor() {
- boolean exCaught = false;
- try {
- Object at = ReflectionTools.newInstance(ClassName.class);
- fail("bogus: " + at); //$NON-NLS-1$
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof InvocationTargetException) {
- if (ex.getCause().getCause() instanceof UnsupportedOperationException) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ClasspathTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ClasspathTests.java
deleted file mode 100644
index 6542662416..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ClasspathTests.java
+++ /dev/null
@@ -1,402 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.Classpath;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-
-@SuppressWarnings("nls")
-public class ClasspathTests extends TestCase {
- private static final String JAVA_HOME = System.getProperty("java.home");
-
- public ClasspathTests(String name) {
- super(name);
- }
-
- public void testCompressed() {
- String path = "";
-
- // no changes
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;;;;C:\\jdk\\jaws.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;;;")).compressed().getPath();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- // no changes
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\..\\jdk\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
- assertEquals(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- path = new Classpath(this.morph("C:\\jdk1\\jdk2\\jdk3\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk1\\jdk2\\jdk3\\..\\..\\..\\jdk1\\jdk2\\jdk3\\i18n.jar;C:\\jdk\\jaws.jar")).compressed().getPath();
- assertEquals(this.morph("C:\\jdk1\\jdk2\\jdk3\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar"), path);
-
- }
-
- public void testConvertToClassName() {
- String fileName = "java/lang/String.class";
- File file = new File(fileName);
- String className = Classpath.convertToClassName(file);
- assertEquals(java.lang.String.class.getName(), className);
- }
-
- public void testConvertToClass() throws ClassNotFoundException {
- String fileName = "java/lang/String.class";
- File file = new File(fileName);
- Class<?> javaClass = Classpath.convertToClass(file);
- assertEquals(java.lang.String.class, javaClass);
- }
-
- public void testConvertToArchiveClassFileEntryName() {
- String fileName = Classpath.convertToArchiveClassFileEntryName(java.lang.String.class);
- assertEquals("java/lang/String.class", fileName);
- }
-
- public void testConvertToArchiveEntryNameBase() {
- String fileName = Classpath.convertToArchiveEntryNameBase(java.lang.String.class);
- assertEquals("java/lang/String", fileName);
- }
-
- public void testConvertToClassFileName() {
- char sc = File.separatorChar;
- String fileName = Classpath.convertToClassFileName(java.lang.String.class);
- assertEquals("java" + sc + "lang" + sc + "String.class", fileName);
- }
-
- public void testConvertToClassFileString() {
- char sc = File.separatorChar;
- File file = Classpath.convertToClassFile(java.lang.String.class.getName());
- assertEquals("java" + sc + "lang" + sc + "String.class", file.getPath());
- }
-
- public void testConvertToClassFileClass() {
- char sc = File.separatorChar;
- File file = Classpath.convertToClassFile(java.lang.String.class);
- assertEquals("java" + sc + "lang" + sc + "String.class", file.getPath());
- }
-
- public void testConvertToJavaFileName() {
- char sc = File.separatorChar;
- String fileName = Classpath.convertToJavaFileName(java.lang.String.class);
- assertEquals("java" + sc + "lang" + sc + "String.java", fileName);
- }
-
- public void testConvertToJavaFileString() {
- char sc = File.separatorChar;
- File file = Classpath.convertToJavaFile(java.lang.String.class.getName());
- assertEquals("java" + sc + "lang" + sc + "String.java", file.getPath());
- }
-
- public void testConvertToJavaFileClass() {
- char sc = File.separatorChar;
- File file = Classpath.convertToJavaFile(java.lang.String.class);
- assertEquals("java" + sc + "lang" + sc + "String.java", file.getPath());
- }
-
- public void testConvertToFileNameBase() {
- char sc = File.separatorChar;
- String fileName = Classpath.convertToFileNameBase(java.lang.String.class);
- assertEquals("java" + sc + "lang" + sc + "String", fileName);
- }
-
- public void testConvertToURLs() {
- Iterator<URL> entries = new Classpath(this.morph("C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getURLs().iterator();
- assertEquals(this.morphURL("/C:/jdk/rt.jar"), entries.next().getPath());
- assertEquals(this.morphURL("/C:/jdk/i18n.jar"), entries.next().getPath());
- assertEquals(this.morphURL("/C:/jdk/jaws.jar"), entries.next().getPath());
- assertEquals(this.morphURL("/C:/foo/classes"), entries.next().getPath());
- assertEquals(this.morphURL("/C:/bar/bar.jar"), entries.next().getPath());
- assertFalse(entries.hasNext());
- }
-
- public void testGetEntries() {
- Classpath cp = new Classpath(this.morph("C:\\jdk\\rt.jar;;.;C:\\jdk\\i18n.jar;;;C:\\jdk\\jaws.jar;;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\bar\\bar.jar;"));
- Iterator<Classpath.Entry> entries = cp.getEntries().iterator();
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entries.next().getFileName());
- assertEquals(this.morph("."), entries.next().getFileName());
- assertEquals(this.morph("C:\\jdk\\i18n.jar"), entries.next().getFileName());
- assertEquals(this.morph("C:\\jdk\\jaws.jar"), entries.next().getFileName());
- assertEquals(this.morph("C:\\foo\\classes"), entries.next().getFileName());
- assertEquals(this.morph("C:\\bar\\bar.jar"), entries.next().getFileName());
- assertEquals(this.morph("C:\\bar\\bar.jar"), entries.next().getFileName());
- assertFalse(entries.hasNext());
-
- cp = cp.compressed();
- entries = cp.getEntries().iterator();
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entries.next().getFileName());
- assertEquals(this.morph("."), entries.next().getFileName());
- assertEquals(this.morph("C:\\jdk\\i18n.jar"), entries.next().getFileName());
- assertEquals(this.morph("C:\\jdk\\jaws.jar"), entries.next().getFileName());
- assertEquals(this.morph("C:\\foo\\classes"), entries.next().getFileName());
- assertEquals(this.morph("C:\\bar\\bar.jar"), entries.next().getFileName());
- assertFalse(entries.hasNext());
- }
-
- public void testGetEntryForFileNamed() {
- Classpath.Entry entry = null;
-
- // in the middle - qualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\rt.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
-
- // in the middle - unqualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;rt.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.getFileName());
-
- // at the beginning - qualified
- entry = new Classpath(this.morph("C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
-
- // at the beginning - unqualified
- entry = new Classpath(this.morph("rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.getFileName());
-
- // at the end - qualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rt.jar")).getEntryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
-
- // at the end - unqualified
- entry = new Classpath(this.morph("C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;rt.jar")).getEntryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.getFileName());
-
- // alone - qualified
- entry = new Classpath(this.morph("C:\\jdk\\rt.jar")).getEntryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
-
- // alone - unqualified
- entry = new Classpath("rt.jar").getEntryForFileNamed("rt.jar");
- assertEquals("rt.jar", entry.getFileName());
-
- // trick entry at the beginning
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
-
- // trick entry in the middle
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar")).getEntryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
-
- // trick entry at the end
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\rt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rtrtrt.jar")).getEntryForFileNamed("rt.jar");
- assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.getFileName());
-
- // missing
- entry = new Classpath(this.morph("rt.jar.new;C:\\jdk\\rtrtrt.jar;C:\\jdk\\i18n.jar;C:\\jdk\\jaws.jar;C:\\foo\\classes;C:\\bar\\bar.jar;C:\\jdk\\rtrtrt.jar")).getEntryForFileNamed("rt.jar");
- assertEquals("path entry should not be found", null, entry);
-
- }
-
- public void testGetEntryForClassNamed() {
- assertNotNull(Classpath.completeClasspath().getEntryForClassNamed(java.lang.String.class.getName()));
- assertNull(Classpath.completeClasspath().getEntryForClassNamed("foo.bar.Baz"));
- }
-
- public void testLocationForClass() {
- Class<?> javaClass = Classpath.class;
- File entry = new File(Classpath.locationFor(javaClass));
- if (entry.isFile() || entry.isDirectory()) {
- assertTrue(entry.exists());
- }
- if (entry.isDirectory()) {
- assertTrue(new File(entry, Classpath.convertToClassFileName(javaClass)).exists());
- }
- }
-
- public void testRtJarName() throws IOException {
- File rtFile = new File(Classpath.rtJarName());
- assertTrue("rt.jar does not exist", rtFile.exists());
-
- JarFile rtJarFile = new JarFile(rtFile);
- JarEntry entry = rtJarFile.getJarEntry("java/lang/Object.class");
- rtJarFile.close();
- assertTrue("bogus rt.jar", entry != null);
- }
-
- public void testJREClassNames() {
- assertTrue("Vector is missing from JRE class names", CollectionTools.contains(Classpath.bootClasspath().getClassNames(), java.util.Vector.class.getName()));
- assertTrue("File is missing from JRE class names", CollectionTools.contains(Classpath.bootClasspath().getClassNames(), java.io.File.class.getName()));
- }
-
- public void testJavaExtensionDirectoryNames() {
- char sep = File.separatorChar;
- String stdExtDirName = JAVA_HOME + sep + "lib" + sep + "ext";
- assertTrue("standard extension dir name missing: " + stdExtDirName, ArrayTools.contains(Classpath.javaExtensionDirectoryNames(), stdExtDirName));
- }
-
- public void testJavaExtensionDirectories() {
- char sep = File.separatorChar;
- File stdExtDir = new File(JAVA_HOME + sep + "lib" + sep + "ext");
- assertTrue("standard extension dir missing: " + stdExtDir.getParent(), ArrayTools.contains(Classpath.javaExtensionDirectories(), stdExtDir));
- }
-
- public void testJavaExtensionClasspathEntries() {
- char sep = File.separatorChar;
- String jdk = System.getProperty("java.version");
- if (jdk.startsWith("1.4") || jdk.startsWith("1.5") || jdk.startsWith("1.6")) {
- Collection<String> jarNames = new ArrayList<String>();
- Iterable<Classpath.Entry> entries = Classpath.javaExtensionClasspath().getEntries();
- for (Classpath.Entry entry : entries) {
- jarNames.add(entry.getFileName());
- }
- String stdExtJarName = JAVA_HOME + sep + "lib" + sep + "ext" + sep + "dnsns.jar";
- String msg = "jdk 1.4.x standard extension jar missing: " + stdExtJarName;
- boolean jarPresent = jarNames.contains(stdExtJarName);
- if (Tools.jvmIsSun() || (Tools.jvmIsIBM() && jdk.startsWith("1.6"))) {
- assertTrue(msg, jarPresent);
- }
- } else {
- fail("we need to update this test for the current jdk");
- }
- }
-
- public void testJavaExtensionClassNames() {
- String jdk = System.getProperty("java.version");
- if (jdk.startsWith("1.4") || jdk.startsWith("1.5") || jdk.startsWith("1.6")) {
- String className = "sun.net.spi.nameservice.dns.DNSNameService";
- String msg = "jdk 1.4.x standard extension class missing: " + className;
- boolean classPresent = CollectionTools.contains(Classpath.javaExtensionClasspath().classNames(), className);
- if (Tools.jvmIsSun() || (Tools.jvmIsIBM() && jdk.startsWith("1.6"))) {
- assertTrue(msg, classPresent);
- }
- } else {
- fail("we need to update this test for the current jdk");
- }
- }
-
- public void testJavaClasspathClassNames() {
- String className = this.getClass().getName();
- ClassLoader cl = this.getClass().getClassLoader();
- // make sure we are running under the "normal" class loader;
- // when the tests are executed as an ANT task, they are run under
- // an ANT class loader and the "Java" classpath does not include this class
- if (cl.getClass().getName().startsWith("sun.misc")) {
- assertTrue("class missing: " + className, CollectionTools.contains(Classpath.javaClasspath().getClassNames(), className));
- }
- }
-
- public void testCompleteClasspathClassNames() {
- String className = this.getClass().getName();
- ClassLoader cl = this.getClass().getClassLoader();
- // make sure we are running under the "normal" class loader;
- // when the tests are executed as an ANT task, they are run under
- // an ANT class loader and the "Java" classpath does not include this class
- if (cl.getClass().getName().startsWith("sun.misc")) {
- assertTrue("class missing: " + className, CollectionTools.contains(Classpath.completeClasspath().getClassNames(), className));
- }
- }
-
- public void testClasspathForClass() {
- assertNotNull(Classpath.classpathFor(java.lang.String.class));
- }
-
- public void testAddClassNamesTo() {
- Collection<String> classNames = new ArrayList<String>(1000);
- Classpath.bootClasspath().addClassNamesTo(classNames);
- assertTrue(classNames.contains(java.util.Vector.class.getName()));
- }
-
- public void testToString() {
- assertNotNull(Classpath.bootClasspath().toString());
- }
-
- public void testEntry_getCanonicalFile() {
- Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
- assertTrue(entry.getCanonicalFile().getPath().endsWith(".jar"));
- }
-
- public void testEntry_getCanonicalFileName() {
- Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
- String name = entry.getCanonicalFileName();
- if (Tools.jvmIsSun()) {
- assertTrue(name.endsWith("rt.jar"));
- } else if (Tools.jvmIsIBM()) {
- assertTrue(name.endsWith("vm.jar"));
- }
- }
-
- public void testEntry_equals() {
- Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
- assertFalse(entry.equals("foo"));
- }
-
- public void testEntry_containsClass() {
- Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
- assertTrue(entry.contains(java.lang.String.class));
- }
-
- public void testEntry_containsString() {
- Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
- assertTrue(entry.contains(java.lang.String.class.getName()));
- }
-
- public void testEntry_getClassNames() {
- Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
- assertTrue(CollectionTools.contains(entry.getClassNames(), java.lang.String.class.getName()));
- }
-
- public void testEntry_classNames() {
- Classpath.Entry entry = Classpath.bootClasspath().getEntryForClassNamed(java.lang.String.class.getName());
- assertTrue(CollectionTools.contains(entry.classNames(), java.lang.String.class.getName()));
- }
-
- /**
- * morph the specified path to a platform-independent path
- */
- private String morph(String path) {
- String result = path;
- result = result.replace('\\', File.separatorChar);
- result = result.replace(';', File.pathSeparatorChar);
- if (!ArrayTools.contains(File.listRoots(), new File("C:\\"))) {
- result = result.replaceAll("C:", "");
- }
- return result;
- }
-
- /**
- * morph the specified URL to a platform-independent path
- */
- private String morphURL(String url) {
- String result = url;
- if (!ArrayTools.contains(File.listRoots(), new File("C:\\"))) {
- result = result.replaceAll("/C:", "");
- }
- return result;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/CollectionToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/CollectionToolsTests.java
deleted file mode 100644
index 5bb02201fd..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/CollectionToolsTests.java
+++ /dev/null
@@ -1,2418 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import java.util.Random;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.Vector;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.Range;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.ReverseComparator;
-import org.eclipse.jpt.common.utility.internal.enumerations.EmptyEnumeration;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-
-@SuppressWarnings("nls")
-public class CollectionToolsTests extends TestCase {
-
- public CollectionToolsTests(String name) {
- super(name);
- }
-
-
- // ********** add all **********
-
- public void testAddAllCollectionIterable_StringModified() {
- List<String> list1 = this.buildStringList1();
- Iterable<String> iterable2 = this.buildStringList2();
- assertTrue(CollectionTools.addAll(list1, iterable2.iterator()));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll(this.buildStringList2()));
- }
-
- public void testAddAllCollectionIterable_StringUnmodified() {
- Set<String> set1 = this.buildStringSet1();
- Iterable<String> iterable3 = this.buildStringList1(); // same elements as set1
- assertFalse(CollectionTools.addAll(set1, iterable3.iterator()));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll(this.buildStringList1()));
- }
-
- public void testAddAllCollectionIterable_ObjectModified() {
- List<Object> list1 = this.buildObjectList1();
- Iterable<String> iterable2 = this.buildStringList2();
- assertTrue(CollectionTools.addAll(list1, iterable2));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll((List<String>) iterable2));
- }
-
- public void testAddAllCollectionIterable_ObjectUnmodified() {
- Set<Object> set1 = this.buildObjectSet1();
- Iterable<String> iterable3 = this.buildStringList1(); // same elements as set1
- assertFalse(CollectionTools.addAll(set1, iterable3));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll((List<String>) iterable3));
- }
-
- public void testAddAllCollectionIterable_EmptyIterable() {
- Set<Object> set1 = this.buildObjectSet1();
- assertFalse(CollectionTools.addAll(set1, EmptyIterable.instance()));
- assertEquals(3, set1.size());
- }
-
- public void testAddAllCollectionIterableInt_Modified() {
- List<String> list1 = this.buildStringList1();
- List<String> list2 = this.buildStringList2();
- Iterable<String> iterable2 = list2;
- assertTrue(CollectionTools.addAll(list1, iterable2, list2.size()));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll(this.buildStringList2()));
- }
-
- public void testAddAllCollectionIterableInt_Unmodified() {
- Set<String> set1 = this.buildStringSet1();
- List<String> list1 = this.buildStringList1(); // same elements as set1
- Iterable<String> iterable3 = list1;
- assertFalse(CollectionTools.addAll(set1, iterable3, list1.size()));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll(this.buildStringList1()));
- }
-
- public void testAddAllCollectionIterator_StringModified() {
- List<String> list1 = this.buildStringList1();
- List<String> list2 = this.buildStringList2();
- assertTrue(CollectionTools.addAll(list1, list2.iterator()));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll(list2));
- }
-
- public void testAddAllCollectionIterator_StringUnmodified() {
- Set<String> set1 = this.buildStringSet1();
- List<String> list3 = this.buildStringList1(); // same elements as s1
- assertFalse(CollectionTools.addAll(set1, list3.iterator()));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll(list3));
- }
-
- public void testAddAllCollectionIterator_ObjectModified() {
- List<Object> list1 = this.buildObjectList1();
- List<String> list2 = this.buildStringList2();
- assertTrue(CollectionTools.addAll(list1, list2.iterator()));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll(list2));
- }
-
- public void testAddAllCollectionIterator_ObjectUnmodified() {
- Set<Object> set1 = this.buildObjectSet1();
- List<String> list3 = this.buildStringList1(); // same elements as s1
- assertFalse(CollectionTools.addAll(set1, list3.iterator()));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll(list3));
- }
-
- public void testAddAllCollectionIterator_EmptyIterator() {
- List<String> list1 = this.buildStringList1();
- assertFalse(CollectionTools.addAll(list1, EmptyIterator.<String>instance()));
- assertEquals(3, list1.size());
- }
-
- public void testAddAllCollectionIteratorInt_Modified() {
- List<String> list1 = this.buildStringList1();
- List<String> list2 = this.buildStringList2();
- assertTrue(CollectionTools.addAll(list1, list2.iterator(), 3));
- assertEquals(6, list1.size());
- assertTrue(list1.containsAll(list2));
- }
-
- public void testAddAllCollectionIteratorInt_Unmodified() {
- Set<String> set1 = this.buildStringSet1();
- List<String> list3 = this.buildStringList1(); // same elements as s1
- assertFalse(CollectionTools.addAll(set1, list3.iterator(), 3));
- assertEquals(3, set1.size());
- assertTrue(set1.containsAll(list3));
- }
-
- public void testAddAllCollectionIteratorInt_EmptyIterator() {
- List<String> list1 = this.buildStringList1();
- assertFalse(CollectionTools.addAll(list1, EmptyIterator.<String>instance(), 0));
- assertEquals(3, list1.size());
- }
-
- public void testAddAllCollectionObjectArray_StringModified() {
- List<String> list = this.buildStringList1();
- String[] a = this.buildStringArray1();
- assertTrue(CollectionTools.addAll(list, a));
- assertEquals(6, list.size());
- assertTrue(list.containsAll(CollectionTools.collection(a)));
- }
-
- public void testAddAllCollectionObjectArray_StringListEmptyArray() {
- List<String> list = this.buildStringList1();
- assertFalse(CollectionTools.addAll(list, new String[0]));
- }
-
- public void testAddAllCollectionObjectArray_StringUnmodified() {
- Set<String> set = this.buildStringSet1();
- String[] a = this.buildStringArray1();
- assertFalse(CollectionTools.addAll(set, a));
- assertEquals(3, set.size());
- assertTrue(set.containsAll(CollectionTools.collection(a)));
-
- assertFalse(CollectionTools.addAll(set, new String[0]));
- }
-
- public void testAddAllCollectionObjectArray_StringSetEmptyArray() {
- Set<String> set = this.buildStringSet1();
- assertFalse(CollectionTools.addAll(set, new String[0]));
- }
-
- public void testAddAllCollectionObjectArray_ObjectModified() {
- List<Object> list = this.buildObjectList1();
- String[] a = this.buildStringArray1();
-
- assertTrue(CollectionTools.addAll(list, a));
- assertEquals(6, list.size());
- assertTrue(list.containsAll(CollectionTools.collection(a)));
- }
-
- public void testAddAllCollectionObjectArray_ObjectUnmodified() {
- String[] a = this.buildStringArray1();
- Set<Object> set = this.buildObjectSet1();
- assertFalse(CollectionTools.addAll(set, a));
- assertEquals(3, set.size());
- assertTrue(set.containsAll(CollectionTools.collection(a)));
- }
-
- public void testAddAllListIntObjectArray() {
- List<String> list = this.buildStringList1();
- CollectionTools.addAll(list, 2, new String[] { "X", "X", "X" });
- assertEquals(6, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "X", "X", "X", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntObjectArray_Zero() {
- List<String> list = new ArrayList<String>();
- CollectionTools.addAll(list, 0, new String[] { "X", "X", "X" });
- assertEquals(3, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, list.toArray()));
- }
-
- public void testAddAllListIntObjectArray_EmptyArray() {
- List<String> list = this.buildStringList1();
- CollectionTools.addAll(list, 2, new String[0]);
- assertEquals(3, list.size());
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterable() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = Arrays.asList(new String[] { "X", "X", "X" });
- CollectionTools.addAll(list, 2, iterable);
- assertEquals(6, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "X", "X", "X", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterable_Zero() {
- List<String> list = new ArrayList<String>();
- Iterable<String> iterable = Arrays.asList(new String[] { "X", "X", "X" });
- CollectionTools.addAll(list, 0, iterable);
- assertEquals(3, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, list.toArray()));
- }
-
- public void testAddAllListIntIterable_EmptyIterable() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = EmptyIterable.instance();
- CollectionTools.addAll(list, 2, iterable);
- assertEquals(3, list.size());
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterableInt() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = Arrays.asList(new String[] { "X", "X", "X" });
- CollectionTools.addAll(list, 2, iterable, 3);
- assertEquals(6, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "X", "X", "X", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterableInt_Zero() {
- List<String> list = new ArrayList<String>();
- Iterable<String> iterable = Arrays.asList(new String[] { "X", "X", "X" });
- CollectionTools.addAll(list, 0, iterable, 3);
- assertEquals(3, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, list.toArray()));
- }
-
- public void testAddAllListIntIterableInt_EmptyIterable() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = EmptyIterable.instance();
- CollectionTools.addAll(list, 2, iterable, 0);
- assertEquals(3, list.size());
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterator() {
- List<String> list = this.buildStringList1();
- Iterator<String> iterator = Arrays.asList(new String[] { "X", "X", "X" }).iterator();
- CollectionTools.addAll(list, 2, iterator);
- assertEquals(6, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "X", "X", "X", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIterator_Zero() {
- List<String> list = new ArrayList<String>();
- Iterator<String> iterator = Arrays.asList(new String[] { "X", "X", "X" }).iterator();
- CollectionTools.addAll(list, 0, iterator);
- assertEquals(3, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, list.toArray()));
- }
-
- public void testAddAllListIntIterator_EmptyIterator() {
- List<String> list = this.buildStringList1();
- Iterator<String> iterator = EmptyIterator.instance();
- CollectionTools.addAll(list, 2, iterator);
- assertEquals(3, list.size());
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIteratorInt() {
- List<String> list = this.buildStringList1();
- Iterator<String> iterator = Arrays.asList(new String[] { "X", "X", "X" }).iterator();
- CollectionTools.addAll(list, 2, iterator, 3);
- assertEquals(6, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "X", "X", "X", "two" }, list.toArray()));
- }
-
- public void testAddAllListIntIteratorInt_Zero() {
- List<String> list = new ArrayList<String>();
- Iterator<String> iterator = Arrays.asList(new String[] { "X", "X", "X" }).iterator();
- CollectionTools.addAll(list, 0, iterator, 3);
- assertEquals(3, list.size());
- assertTrue(list.contains("X"));
- assertTrue(Arrays.equals(new Object[] { "X", "X", "X" }, list.toArray()));
- }
-
- public void testAddAllListIntIteratorInt_EmptyIterator() {
- List<String> list = this.buildStringList1();
- Iterator<String> iterator = EmptyIterator.instance();
- CollectionTools.addAll(list, 2, iterator, 0);
- assertEquals(3, list.size());
- assertTrue(Arrays.equals(new Object[] { "zero", "one", "two" }, list.toArray()));
- }
-
-
- // ********** bag **********
-
- public void testBagEnumeration_String() {
- Bag<String> b = CollectionTools.bag(this.buildStringVector1().elements());
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringVector1()));
- }
-
- public void testBagEnumeration_Object() {
- Bag<Object> b = CollectionTools.<Object>bag(this.buildStringVector1().elements());
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringVector1()));
- }
-
- public void testBagEnumeration_Empty() {
- Bag<Object> b = CollectionTools.<Object>bag(EmptyEnumeration.instance());
- assertEquals(0, b.size());
- }
-
- public void testBagEnumerationInt() {
- Bag<String> b = CollectionTools.bag(this.buildStringVector1().elements(), 3);
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringVector1()));
- }
-
- public void testBagEnumerationInt_Empty() {
- Bag<String> b = CollectionTools.bag(EmptyEnumeration.<String>instance(), 3);
- assertEquals(0, b.size());
- }
-
- public void testBagIterable() {
- Iterable<String> iterable = this.buildStringList1();
- Bag<String> b = CollectionTools.bag(iterable);
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringList1()));
- }
-
- public void testBagIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- Bag<String> b = CollectionTools.bag(iterable, 3);
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringList1()));
- }
-
- public void testBagIterator_String() {
- Bag<String> b = CollectionTools.bag(this.buildStringList1().iterator());
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringList1()));
- }
-
- public void testBagIterator_StringObject() {
- Collection<String> c = new ArrayList<String>();
- c.add("zero");
- c.add("one");
- c.add("two");
- c.add("three");
- Bag<Object> b = CollectionTools.<Object>bag(c.iterator());
- assertEquals(4, b.size());
- assertTrue(b.containsAll(c));
- }
-
- public void testBagIterator_Empty() {
- Bag<String> b = CollectionTools.bag(EmptyIterator.<String>instance());
- assertEquals(0, b.size());
- }
-
- public void testBagIteratorInt() {
- Bag<String> b = CollectionTools.bag(this.buildStringList1().iterator(), 3);
- assertEquals(3, b.size());
- assertTrue(b.containsAll(this.buildStringList1()));
- }
-
- public void testBagIteratorInt_Empty() {
- Bag<String> b = CollectionTools.bag(EmptyIterator.<String>instance(), 3);
- assertEquals(0, b.size());
- }
-
- public void testBagObjectArray() {
- Bag<String> b = CollectionTools.bag(this.buildStringArray1());
- assertEquals(3, b.size());
- assertTrue(CollectionTools.containsAll(b, (Object[]) this.buildStringArray1()));
- }
-
- public void testBagObjectArray_Vararg() {
- Bag<String> b = CollectionTools.bag("foo", "bar", "baz");
- assertEquals(3, b.size());
- assertTrue(CollectionTools.containsAll(b, new Object[]{"foo", "bar", "baz"}));
- }
-
- public void testBagObjectArray_Empty() {
- Bag<String> b = CollectionTools.bag(Bag.Empty.<String>instance());
- assertEquals(0, b.size());
- }
-
-
- // ********** collection **********
-
- public void testCollectionEnumeration() {
- Collection<String> c = CollectionTools.collection(this.buildStringVector1().elements());
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringVector1()));
- }
-
- public void testCollectionEnumeration_ObjectString() {
- Collection<Object> c = CollectionTools.<Object>collection(this.buildStringVector1().elements());
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringVector1()));
- }
-
- public void testCollectionEnumerationInt() {
- Collection<String> c = CollectionTools.collection(this.buildStringVector1().elements(), 3);
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringVector1()));
- }
-
- public void testCollectionIterable() {
- Iterable<String> iterable = this.buildStringList1();
- Collection<String> c = CollectionTools.collection(iterable);
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringList1()));
- }
-
- public void testCollectionIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- Collection<String> c = CollectionTools.collection(iterable, 3);
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringList1()));
- }
-
- public void testCollectionIterator() {
- Collection<String> c = CollectionTools.collection(this.buildStringList1().iterator());
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringList1()));
- }
-
- public void testCollectionIterator_ObjectString() {
- Collection<Object> c = CollectionTools.<Object>collection(this.buildStringList1().iterator());
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringList1()));
- }
-
- public void testCollectionIteratorInt() {
- Collection<String> c = CollectionTools.collection(this.buildStringList1().iterator(), 3);
- assertEquals(3, c.size());
- assertTrue(c.containsAll(this.buildStringList1()));
- }
-
- public void testCollectionObjectArray() {
- Collection<String> c = CollectionTools.collection(this.buildStringArray1());
- assertEquals(3, c.size());
- assertTrue(CollectionTools.containsAll(c, (Object[]) this.buildStringArray1()));
- }
-
-
- // ********** contains **********
-
- public void testContainsEnumerationObject_String() {
- Vector<String> v = this.buildStringVector1();
- assertTrue(CollectionTools.contains(v.elements(), "one"));
- assertFalse(CollectionTools.contains(v.elements(), null));
- v.add(null);
- assertTrue(CollectionTools.contains(v.elements(), null));
- }
-
- public void testContainsEnumerationObject_Object() {
- Vector<Object> c = new Vector<Object>();
- c.add("zero");
- c.add("one");
- c.add("two");
- c.add("three");
- String one = "one";
- assertTrue(CollectionTools.contains(c.elements(), one));
- assertFalse(CollectionTools.contains(c.elements(), null));
- c.add(null);
- assertTrue(CollectionTools.contains(c.elements(), null));
- }
-
- public void testContainsIterableObject() {
- Collection<String> c = this.buildStringList1();
- Iterable<String> iterable = c;
- assertTrue(CollectionTools.contains(iterable, "one"));
- assertFalse(CollectionTools.contains(iterable, null));
- c.add(null);
- assertTrue(CollectionTools.contains(iterable, null));
- }
-
- public void testContainsIteratorObject_String() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.contains(c.iterator(), "one"));
- assertFalse(CollectionTools.contains(c.iterator(), null));
- c.add(null);
- assertTrue(CollectionTools.contains(c.iterator(), null));
- }
-
- public void testContainsIteratorObject_Object() {
- Collection<Object> c = new HashBag<Object>();
- c.add("zero");
- c.add("one");
- c.add("two");
- c.add("three");
- String one = "one";
- assertTrue(CollectionTools.contains(c.iterator(), one));
- assertFalse(CollectionTools.contains(c.iterator(), null));
- c.add(null);
- assertTrue(CollectionTools.contains(c.iterator(), null));
- }
-
-
- // ********** contains all **********
-
- public void testContainsAllCollectionIterable() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(this.buildStringList1(), iterable));
- }
-
- public void testContainsAllCollectionIterator_String() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1(), this.buildStringList1().iterator()));
- }
-
- public void testContainsAllCollectionIterator_Object() {
- Collection<Object> c1 = new ArrayList<Object>();
- c1.add("zero");
- c1.add("one");
- c1.add("two");
- Collection<String> c2 = new ArrayList<String>();
- c2.add("two");
- c2.add("zero");
- c2.add("one");
- assertTrue(CollectionTools.containsAll(c1, c2.iterator()));
- }
-
- public void testContainsAllCollectionObjectArray_StringObject() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1(), this.buildObjectArray1()));
- }
-
- public void testContainsAllCollectionObjectArray() {
- Object[] a = new Object[] { "zero", "one", "two" };
- assertTrue(CollectionTools.containsAll(this.buildStringList1(), a));
- }
-
- public void testContainsAllIterableCollection() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, this.buildStringList1()));
- }
-
- public void testContainsAllIterableIntCollection() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, 3, this.buildStringList1()));
- }
-
- public void testContainsAllIterableIterable() {
- Iterable<String> iterable1 = this.buildStringList1();
- Iterable<String> iterable2 = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable1, iterable2));
- }
-
- public void testContainsAllIterableIntIterable() {
- Iterable<String> iterable1 = this.buildStringList1();
- Iterable<String> iterable2 = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable1, 3, iterable2));
- }
-
- public void testContainsAllIterableIterator() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, this.buildStringList1().iterator()));
- }
-
- public void testContainsAllIterableIntIterator() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, 3, this.buildStringList1().iterator()));
- }
-
- public void testContainsAllIterableObjectArray() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, this.buildObjectArray1()));
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.containsAll(iterable, this.buildObjectArray1()));
- }
-
- public void testContainsAllIterableIntObjectArray() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(iterable, 3, this.buildObjectArray1()));
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.containsAll(iterable, 3, this.buildObjectArray1()));
- }
-
- public void testContainsAllIteratorCollection_StringString() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildStringList1()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildStringList2()));
- }
-
- public void testContainsAllIteratorCollection_ObjectString() {
- Collection<Object> c1 = new ArrayList<Object>();
- c1.add("zero");
- c1.add("one");
- c1.add("two");
- Collection<String> c2 = new ArrayList<String>();
- c2.add("zero");
- c2.add("one");
- c2.add("two");
- assertTrue(CollectionTools.containsAll(c1.iterator(), c2));
- }
-
- public void testContainsAllIteratorIntCollection() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), 5, this.buildStringList1()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), 5, this.buildStringList2()));
- }
-
- public void testContainsAllIteratorIterable() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), iterable));
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), iterable));
- }
-
- public void testContainsAllIteratorIntIterable() {
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, iterable));
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, iterable));
- }
-
- public void testContainsAllIteratorIterator_StringString() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildStringList1().iterator()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildStringList2().iterator()));
- }
-
- public void testContainsAllIteratorIterator_ObjectString() {
- Collection<Object> c1 = new ArrayList<Object>();
- c1.add("zero");
- c1.add("one");
- c1.add("two");
- Collection<String> c2 = new ArrayList<String>();
- c2.add("zero");
- c2.add("one");
- c2.add("two");
- assertTrue(CollectionTools.containsAll(c1.iterator(), c2.iterator()));
- }
-
- public void testContainsAllIteratorIntIterator() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, this.buildStringList1().iterator()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, this.buildStringList2().iterator()));
- }
-
- public void testContainsAllIteratorObjectArray() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildObjectArray1()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildObjectArray2()));
- }
-
- public void testContainsAllIteratorIntObjectArray() {
- assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, this.buildObjectArray1()));
- assertFalse(CollectionTools.containsAll(this.buildStringList1().iterator(), 3, this.buildObjectArray2()));
- }
-
-
- // ********** diff **********
-
- public void testDiffEndListList() {
- List<String> list1 = new ArrayList<String>();
- list1.add("a");
- list1.add("b");
- list1.add("c");
- List<String> list2 = new ArrayList<String>();
- list2.add(new String("a"));
- list2.add(new String("b"));
- list2.add(new String("c"));
- assertEquals(-1, CollectionTools.diffEnd(list1, list2));
- }
-
- public void testDiffRangeListList() {
- List<String> list1 = new ArrayList<String>();
- list1.add("a");
- list1.add("b");
- list1.add("c");
- List<String> list2 = new ArrayList<String>();
- list2.add(new String("a"));
- list2.add(new String("b"));
- list2.add(new String("c"));
- assertEquals(new Range(3, -1), CollectionTools.diffRange(list1, list2));
- }
-
- public void testDiffStartListList() {
- List<String> list1 = new ArrayList<String>();
- list1.add("a");
- list1.add("b");
- list1.add("c");
- List<String> list2 = new ArrayList<String>();
- list2.add(new String("a"));
- list2.add(new String("b"));
- list2.add(new String("c"));
- assertEquals(3, CollectionTools.diffStart(list1, list2));
- }
-
-
- // ********** identity diff **********
-
- public void testIdentityDiffEndListList() {
- List<String> list1 = new ArrayList<String>();
- list1.add("a");
- list1.add("b");
- list1.add("c");
- List<String> list2 = new ArrayList<String>();
- list2.add("a");
- list2.add("b");
- list2.add("c");
- assertEquals(-1, CollectionTools.identityDiffEnd(list1, list2));
- }
-
- public void testIdentityDiffRangeListList() {
- List<String> list1 = new ArrayList<String>();
- list1.add("a");
- list1.add("b");
- list1.add("c");
- List<String> list2 = new ArrayList<String>();
- list2.add("a");
- list2.add("b");
- list2.add("c");
- assertEquals(new Range(3, -1), CollectionTools.identityDiffRange(list1, list2));
- }
-
- public void testIdentityDiffStartListList() {
- List<String> list1 = new ArrayList<String>();
- list1.add("a");
- list1.add("b");
- list1.add("c");
- List<String> list2 = new ArrayList<String>();
- list2.add("a");
- list2.add("b");
- list2.add("c");
- assertEquals(3, CollectionTools.identityDiffStart(list1, list2));
- }
-
-
- // ********** elements are equal **********
-
- public void testElementsAreDifferentIterableIterable() {
- List<String> list1 = new ArrayList<String>();
- list1.add("1000");
- list1.add("2000");
- list1.add("3000");
- list1.add("4000");
-
- List<String> list2 = new ArrayList<String>();
-
- assertTrue(CollectionTools.elementsAreDifferent(list1, list2));
- assertFalse(CollectionTools.elementsAreEqual(list1, list2));
- }
-
- public void testElementsAreDifferentIteratorIterator() {
- List<String> list1 = new ArrayList<String>();
- list1.add("1000");
- list1.add("2000");
- list1.add("3000");
- list1.add("4000");
-
- List<String> list2 = new ArrayList<String>();
-
- assertTrue(CollectionTools.elementsAreDifferent(list1.iterator(), list2.iterator()));
- assertFalse(CollectionTools.elementsAreEqual(list1, list2));
- }
-
- public void testElementsAreEqualIterableIterable() {
- List<String> list1 = new ArrayList<String>();
- list1.add("1000");
- list1.add("2000");
- list1.add("3000");
- list1.add("4000");
-
- List<String> list2 = new ArrayList<String>();
- for (int i = 0; i < list1.size(); i++) {
- list2.add(String.valueOf((i + 1) * 1000));
- }
- assertFalse(CollectionTools.elementsAreIdentical(list1, list2));
- assertFalse(CollectionTools.elementsAreDifferent(list1, list2));
- assertTrue(CollectionTools.elementsAreEqual(list1, list2));
- }
-
- public void testElementsAreEqualIteratorIterator() {
- List<String> list1 = new ArrayList<String>();
- list1.add("1000");
- list1.add("2000");
- list1.add("3000");
- list1.add("4000");
-
- List<String> list2 = new ArrayList<String>();
- for (int i = 0; i < list1.size(); i++) {
- list2.add(String.valueOf((i + 1) * 1000));
- }
- assertFalse(CollectionTools.elementsAreIdentical(list1.iterator(), list2.iterator()));
- assertFalse(CollectionTools.elementsAreDifferent(list1.iterator(), list2.iterator()));
- assertTrue(CollectionTools.elementsAreEqual(list1.iterator(), list2.iterator()));
- }
-
-
- // ********** elements are identical **********
-
- public void testElementsAreIdenticalIterableIterable() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
- Iterable<String> iterable1 = list1;
-
- List<String> list2 = new ArrayList<String>();
- for (String s : list1) {
- list2.add(s);
- }
- Iterable<String> iterable2 = list2;
- assertTrue(CollectionTools.elementsAreIdentical(iterable1, iterable2));
- assertTrue(CollectionTools.elementsAreEqual(iterable1, iterable2));
- }
-
- public void testElementsAreIdenticalIteratorIterator() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
-
- List<String> list2 = new ArrayList<String>();
- for (String s : list1) {
- list2.add(s);
- }
- assertTrue(CollectionTools.elementsAreIdentical(list1.iterator(), list2.iterator()));
- assertTrue(CollectionTools.elementsAreEqual(list1.iterator(), list2.iterator()));
- }
-
- public void testElementsAreIdenticalIteratorIterator_Not() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
-
- List<String> list2 = new ArrayList<String>();
- for (String s : list1) {
- list2.add(s);
- }
- list2.remove(0);
- assertFalse(CollectionTools.elementsAreIdentical(list1.iterator(), list2.iterator()));
- assertFalse(CollectionTools.elementsAreEqual(list1.iterator(), list2.iterator()));
- }
-
- public void testElementsAreIdenticalIteratorIterator_DifferentSizes() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
-
- List<String> list2 = new ArrayList<String>();
- for (String s : list1) {
- list2.add(s);
- }
- list2.remove(3);
- assertFalse(CollectionTools.elementsAreIdentical(list1.iterator(), list2.iterator()));
- assertFalse(CollectionTools.elementsAreEqual(list1.iterator(), list2.iterator()));
- }
-
- public void testElementsAreNotIdenticalIterableIterable() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
- Iterable<String> iterable1 = list1;
-
- List<String> list2 = new ArrayList<String>();
- for (String s : list1) {
- list2.add(s);
- }
- Iterable<String> iterable2 = list2;
- assertFalse(CollectionTools.elementsAreNotIdentical(iterable1, iterable2));
- assertTrue(CollectionTools.elementsAreEqual(iterable1, iterable2));
- }
-
- public void testElementsAreNotIdenticalIteratorIterator() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
-
- List<String> list2 = new ArrayList<String>();
- for (String s : list1) {
- list2.add(s);
- }
- assertFalse(CollectionTools.elementsAreNotIdentical(list1.iterator(), list2.iterator()));
- assertTrue(CollectionTools.elementsAreEqual(list1.iterator(), list2.iterator()));
- }
-
- public void testElementsAreNotIdenticalIteratorIterator_Not() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
-
- List<String> list2 = new ArrayList<String>();
- for (String s : list1) {
- list2.add(s);
- }
- list2.remove(0);
- assertTrue(CollectionTools.elementsAreNotIdentical(list1.iterator(), list2.iterator()));
- assertFalse(CollectionTools.elementsAreEqual(list1.iterator(), list2.iterator()));
- }
-
- public void testElementsAreNotIdenticalIteratorIterator_DifferentSizes() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
-
- List<String> list2 = new ArrayList<String>();
- for (String s : list1) {
- list2.add(s);
- }
- list2.remove(3);
- assertTrue(CollectionTools.elementsAreNotIdentical(list1.iterator(), list2.iterator()));
- assertFalse(CollectionTools.elementsAreEqual(list1.iterator(), list2.iterator()));
- }
-
-
- // ********** get **********
-
- public void testGetIterableInt() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = list;
- String o = CollectionTools.get(iterable, 1);
- assertEquals("one", o);
- list.add(null);
- o = CollectionTools.get(iterable, 3);
- assertNull(o);
- }
-
- public void testGetIteratorInt1() {
- List<String> list = this.buildStringList1();
- String o = CollectionTools.get(list.iterator(), 1);
- assertEquals("one", o);
- list.add(null);
- o = CollectionTools.get(list.iterator(), list.size() - 1);
- assertNull(o);
- }
-
- public void testGetIteratorInt2() {
- List<String> list = this.buildStringList1();
- boolean exCaught = false;
- try {
- CollectionTools.get(list.iterator(), list.size());
- fail();
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- // ********** hash code **********
-
- public void testHashCodeIterable1() {
- Iterable<String> iterable = null;
- assertEquals(0, CollectionTools.hashCode(iterable));
- }
-
- public void testHashCodeIterable2() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = list;
- int hashCode = CollectionTools.hashCode(iterable);
- assertEquals(list.hashCode(), hashCode);
-
- list.add(null);
- hashCode = CollectionTools.hashCode(iterable);
- assertEquals(list.hashCode(), hashCode);
- }
-
-
- // ********** index of **********
-
- public void testIndexOfIterableObject_String() {
- Iterable<String> iterable = this.buildStringList1();
- assertEquals(1, CollectionTools.indexOf(iterable, "one"));
- }
-
- public void testIndexOfIteratorObject_String() {
- List<String> list = this.buildStringList1();
- assertEquals(1, CollectionTools.indexOf(list.iterator(), "one"));
- }
-
- public void testIndexOfIteratorObject_String_Not() {
- List<String> list = this.buildStringList1();
- assertEquals(-1, CollectionTools.indexOf(list.iterator(), null));
- assertEquals(-1, CollectionTools.indexOf(list.iterator(), "shazam"));
- }
-
- public void testIndexOfIteratorObject_Null() {
- List<String> list = this.buildStringList1();
- list.add(null);
- assertEquals(list.size() - 1, CollectionTools.indexOf(list.iterator(), null));
- }
-
- public void testIndexOfIteratorObject_Object() {
- List<Object> list = new ArrayList<Object>();
- list.add("0");
- list.add("1");
- list.add("2");
- list.add("3");
-
- String one = "1";
- assertEquals(1, CollectionTools.indexOf(list.iterator(), one));
- list.add(null);
- assertEquals(list.size() - 1, CollectionTools.indexOf(list.iterator(), null));
- }
-
-
- // ********** insertion index of **********
-
- public void testInsertionIndexOfListComparableRandomAccess() {
- List<String> list = Arrays.asList(new String[] { "A", "C", "D" });
- assertEquals(1, CollectionTools.insertionIndexOf(list, "B"));
-
- list = Arrays.asList(new String[] { "A", "B", "C", "D" });
- assertEquals(2, CollectionTools.insertionIndexOf(list, "B"));
-
- list = Arrays.asList(new String[] { "A", "B", "B", "B", "C", "D" });
- assertEquals(4, CollectionTools.insertionIndexOf(list, "B"));
-
- list = Arrays.asList(new String[] { "A", "B", "B", "B", "C", "D" });
- assertEquals(6, CollectionTools.insertionIndexOf(list, "E"));
-
- list = Arrays.asList(new String[] { "B", "B", "B", "C", "D" });
- assertEquals(0, CollectionTools.insertionIndexOf(list, "A"));
-
- list = Arrays.asList(new String[] { "A", "A", "B", "B", "C", "D" });
- assertEquals(2, CollectionTools.insertionIndexOf(list, "A"));
- }
-
- public void testInsertionIndexOfListComparableNonRandomAccess() {
- List<String> list = new LinkedList<String>(Arrays.asList(new String[] { "A", "C", "D" }));
- assertEquals(1, CollectionTools.insertionIndexOf(list, "B"));
-
- list = new LinkedList<String>(Arrays.asList(new String[] { "A", "B", "C", "D" }));
- assertEquals(1, CollectionTools.insertionIndexOf(list, "B"));
-
- list = new LinkedList<String>(Arrays.asList(new String[] { "A", "B", "B", "B", "C", "D" }));
- assertEquals(1, CollectionTools.insertionIndexOf(list, "B"));
-
- list = new LinkedList<String>(Arrays.asList(new String[] { "A", "B", "B", "B", "C", "D" }));
- assertEquals(6, CollectionTools.insertionIndexOf(list, "E"));
-
- list = new LinkedList<String>(Arrays.asList(new String[] { "B", "B", "B", "C", "D" }));
- assertEquals(0, CollectionTools.insertionIndexOf(list, "A"));
-
- list = new LinkedList<String>(Arrays.asList(new String[] { "A", "A", "B", "B", "C", "D" }));
- assertEquals(0, CollectionTools.insertionIndexOf(list, "A"));
- }
-
- public void testInsertionIndexOfListObjectComparatorRandomAccess() {
- Comparator<String> c = new ReverseComparator<String>();
- List<String> list = Arrays.asList(new String[] { "D", "C", "A" });
- assertEquals(2, CollectionTools.insertionIndexOf(list, "B", c));
-
- list = Arrays.asList(new String[] { "D", "C", "B", "A" });
- assertEquals(3, CollectionTools.insertionIndexOf(list, "B", c));
-
- list = Arrays.asList(new String[] { "D", "C", "B", "B", "B", "A" });
- assertEquals(5, CollectionTools.insertionIndexOf(list, "B", c));
-
- list = Arrays.asList(new String[] { "D", "C", "B", "B", "B", "A" });
- assertEquals(0, CollectionTools.insertionIndexOf(list, "E", c));
-
- list = Arrays.asList(new String[] { "D", "C", "B", "B", "B" });
- assertEquals(5, CollectionTools.insertionIndexOf(list, "A", c));
-
- list = Arrays.asList(new String[] { "D", "C", "B", "B", "A", "A" });
- assertEquals(6, CollectionTools.insertionIndexOf(list, "A", c));
- }
-
- public void testInsertionIndexOfListObjectComparatorNonRandomAccess() {
- Comparator<String> c = new ReverseComparator<String>();
- List<String> list = new LinkedList<String>(Arrays.asList(new String[] { "D", "C", "A" }));
- assertEquals(2, CollectionTools.insertionIndexOf(list, "B", c));
-
- list = new LinkedList<String>(Arrays.asList(new String[] { "D", "C", "B", "A" }));
- assertEquals(2, CollectionTools.insertionIndexOf(list, "B", c));
-
- list = new LinkedList<String>(Arrays.asList(new String[] { "D", "C", "B", "B", "B", "A" }));
- assertEquals(2, CollectionTools.insertionIndexOf(list, "B", c));
-
- list = new LinkedList<String>(Arrays.asList(new String[] { "D", "C", "B", "B", "B", "A" }));
- assertEquals(0, CollectionTools.insertionIndexOf(list, "E", c));
-
- list = new LinkedList<String>(Arrays.asList(new String[] { "D", "C", "B", "B", "B" }));
- assertEquals(5, CollectionTools.insertionIndexOf(list, "A", c));
-
- list = new LinkedList<String>(Arrays.asList(new String[] { "D", "C", "B", "B", "A", "A" }));
- assertEquals(4, CollectionTools.insertionIndexOf(list, "A", c));
- }
-
-
- // ********** is empty **********
-
- public void testIsEmptyIterable() {
- assertFalse(CollectionTools.isEmpty(buildObjectList1()));
- assertTrue(CollectionTools.isEmpty(EmptyIterable.instance()));
- }
-
- public void testIsEmptyIterator() {
- assertFalse(CollectionTools.isEmpty(buildObjectList1().iterator()));
- assertTrue(CollectionTools.isEmpty(EmptyIterator.instance()));
- }
-
-
- // ********** iterable/iterator **********
-
- public void testIterableObjectArray() {
- String[] strings = this.buildStringArray1();
- int i = 0;
- for (String string : CollectionTools.iterable(strings)) {
- assertEquals(strings[i++], string);
- }
- }
-
- public void testIteratorObjectArray() {
- String[] a = this.buildStringArray1();
- int i = 0;
- for (Iterator<String> stream = CollectionTools.iterator(a); stream.hasNext(); i++) {
- assertEquals(a[i], stream.next());
- }
- }
-
-
- // ********** last **********
-
- public void testLastIterable1() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = list;
- assertEquals("two", CollectionTools.last(iterable));
- list.add(null);
- assertEquals(null, CollectionTools.last(iterable));
- }
-
- public void testLastIterable2() {
- Iterable<String> iterable = new ArrayList<String>();
- boolean exCaught = false;
- try {
- CollectionTools.last(iterable);
- fail();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testLastIterator1() {
- List<String> list = this.buildStringList1();
- assertEquals("two", CollectionTools.last(list.iterator()));
- list.add(null);
- assertEquals(null, CollectionTools.last(list.iterator()));
- }
-
- public void testLastIterator2() {
- List<String> list = new ArrayList<String>();
- boolean exCaught = false;
- try {
- CollectionTools.last(list.iterator());
- fail();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- // ********** last index of **********
-
- public void testLastIndexOfIterableObject() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = list;
- assertEquals(1, CollectionTools.lastIndexOf(iterable, "one"));
- list.add(null);
- assertEquals(list.size() - 1, CollectionTools.lastIndexOf(iterable, null));
- }
-
- public void testLastIndexOfIterableIntObject() {
- List<String> list = this.buildStringList1();
- Iterable<String> iterable = list;
- assertEquals(1, CollectionTools.lastIndexOf(iterable, 23, "one"));
- list.add(null);
- assertEquals(list.size() - 1, CollectionTools.lastIndexOf(iterable, 42, null));
- }
-
- public void testLastIndexOfIteratorObject() {
- List<String> list = this.buildStringList1();
- assertEquals(1, CollectionTools.lastIndexOf(list.iterator(), "one"));
- list.add(null);
- assertEquals(list.size() - 1, CollectionTools.lastIndexOf(list.iterator(), null));
- }
-
- public void testLastIndexOfIteratorObject_Empty() {
- assertEquals(-1, CollectionTools.lastIndexOf(EmptyIterator.instance(), "foo"));
- }
-
- public void testLastIndexOfIteratorIntObject() {
- List<String> list = this.buildStringList1();
- assertEquals(1, CollectionTools.lastIndexOf(list.iterator(), 3, "one"));
- list.add(null);
- assertEquals(list.size() - 1, CollectionTools.lastIndexOf(list.iterator(), 4, null));
- }
-
- public void testLastIndexOfIteratorIntObject_Empty() {
- assertEquals(-1, CollectionTools.lastIndexOf(EmptyIterator.instance(), 42, "foo"));
- }
-
-
- // ********** list **********
-
- public void testListIterable() {
- Iterable<String> iterable = this.buildStringList1();
- assertEquals(this.buildStringList1(), CollectionTools.list(iterable));
- }
-
- public void testListIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- assertEquals(this.buildStringList1(), CollectionTools.list(iterable, 3));
- }
-
- public void testListIterator_String() {
- List<String> list = CollectionTools.list(this.buildStringList1().iterator());
- assertEquals(this.buildStringList1(), list);
- }
-
- public void testListIterator_StringObject() {
- List<String> list1 = new ArrayList<String>();
- list1.add("0");
- list1.add("1");
- list1.add("2");
- list1.add("3");
-
- List<Object> list2 = CollectionTools.<Object>list(list1.iterator());
- assertEquals(list1, list2);
- }
-
- public void testListIterator_Empty() {
- assertEquals(0, CollectionTools.list(EmptyIterator.instance()).size());
- }
-
- public void testListIteratorInt() {
- List<String> list = CollectionTools.list(this.buildStringList1().iterator(), 3);
- assertEquals(this.buildStringList1(), list);
- }
-
- public void testListIteratorInt_Empty() {
- assertEquals(0, CollectionTools.list(EmptyIterator.instance(), 5).size());
- }
-
- public void testListObjectArray() {
- List<String> list = CollectionTools.list(this.buildStringArray1());
- assertEquals(this.buildStringList1(), list);
- }
-
- public void testListIteratorObjectArray() {
- String[] a = this.buildStringArray1();
- int i = 0;
- for (ListIterator<String> stream = CollectionTools.listIterator(a); stream.hasNext(); i++) {
- assertEquals(a[i], stream.next());
- }
- }
-
- public void testListIteratorObjectArrayInt() {
- String[] a = this.buildStringArray1();
- int i = 1;
- for (ListIterator<String> stream = CollectionTools.listIterator(a, 1); stream.hasNext(); i++) {
- assertEquals(a[i], stream.next());
- }
- }
-
-
- // ********** move **********
-
- public void testMoveListIntIntRandomAccess() {
- List<String> list = new ArrayList<String>();
- CollectionTools.addAll(list, new String[] { "0", "1", "2", "3", "4", "5" });
-
- List<String> result = CollectionTools.move(list, 4, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 5);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
- }
-
- public void testMoveListIntIntSequentialAccess() {
- List<String> list = new LinkedList<String>();
- CollectionTools.addAll(list, new String[] { "0", "1", "2", "3", "4", "5" });
-
- List<String> result = CollectionTools.move(list, 4, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 5);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
- }
-
- public void testMoveListIntIntIntRandomAccess() {
- List<String> list = new ArrayList<String>(Arrays.asList(new String[] { "0", "1", "2", "3", "4", "5" }));
-
- List<String> result = CollectionTools.move(list, 4, 2, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 5, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 1, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "3", "2", "4", "5", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 0, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 1, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 0, 0);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
- }
-
- public void testMoveListIntIntIntSequentialAccess() {
- List<String> list = new LinkedList<String>(Arrays.asList(new String[] { "0", "1", "2", "3", "4", "5" }));
-
- List<String> result = CollectionTools.move(list, 4, 2, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "1", "3", "4", "2", "5" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 5, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "1", "3", "4", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4, 1);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "4", "1", "3", "2" }, result.toArray()));
-
- result = CollectionTools.move(list, 2, 4, 2);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 0, 1, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "0", "3", "2", "4", "5", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 0, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 1, 4);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
-
- result = CollectionTools.move(list, 1, 0, 0);
- assertSame(list, result); // the array is modified in place and returned
- assertTrue(Arrays.equals(new String[] { "5", "0", "3", "2", "4", "1" }, result.toArray()));
- }
-
-
- // ********** remove all **********
-
- public void testRemoveAllCollectionIterable() {
- Collection<String> c = this.buildStringList1();
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.removeAll(c, iterable));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
-
- c = this.buildStringList1();
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.removeAll(c, iterable));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
- }
-
- public void testRemoveAllCollectionIterableInt() {
- Collection<String> c = this.buildStringList1();
- Iterable<String> iterable = this.buildStringList1();
- assertTrue(CollectionTools.removeAll(c, iterable, 4));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
-
- c = this.buildStringList1();
- iterable = this.buildStringList2();
- assertFalse(CollectionTools.removeAll(c, iterable, 55));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
- }
-
- public void testRemoveAllCollectionIterator_Empty() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.removeAll(c, this.buildStringList1().iterator()));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
-
- c = this.buildStringList1();
- assertFalse(CollectionTools.removeAll(c, this.buildStringList2().iterator()));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- c = this.buildStringList1();
- assertFalse(CollectionTools.removeAll(c, EmptyIterator.instance()));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
- }
-
- public void testRemoveAllCollectionIteratorInt_Empty() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.removeAll(c, this.buildStringList1().iterator(), 5));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
-
- c = this.buildStringList1();
- assertFalse(CollectionTools.removeAll(c, this.buildStringList2().iterator(), 5));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- c = this.buildStringList1();
- assertFalse(CollectionTools.removeAll(c, EmptyIterator.instance(), 0));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
- }
-
- public void testRemoveAllCollectionIterator_Duplicates() {
- Collection<String> c = new ArrayList<String>();
- c.add("a");
- c.add("a");
- c.add("b");
- c.add("c");
- c.add("d");
- c.add("d");
- String[] a = new String[] { "a", "d" };
- Iterator<String> iterator = new ArrayIterator<String>(a);
- assertTrue(CollectionTools.removeAll(c, iterator));
- assertEquals(2, c.size());
- assertFalse(c.contains("a"));
- assertTrue(c.contains("b"));
- assertTrue(c.contains("c"));
- assertFalse(c.contains("d"));
-
- iterator = new ArrayIterator<String>(a);
- assertFalse(CollectionTools.removeAll(c, iterator));
- }
-
- public void testRemoveAllCollectionIterator_ObjectString() {
- Collection<Object> c = new ArrayList<Object>();
- c.add("a");
- c.add("a");
- c.add("b");
- c.add("c");
- c.add("d");
- c.add("d");
- String[] a = new String[] { "a", "d" };
- Iterator<String> iterator = new ArrayIterator<String>(a);
- assertTrue(CollectionTools.removeAll(c, iterator));
- assertEquals(2, c.size());
- assertFalse(c.contains("a"));
- assertTrue(c.contains("b"));
- assertTrue(c.contains("c"));
- assertFalse(c.contains("d"));
-
- iterator = new ArrayIterator<String>(a);
- assertFalse(CollectionTools.removeAll(c, iterator));
- }
-
- public void testRemoveAllCollectionObjectArray_Empty() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.removeAll(c, this.buildObjectArray1()));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
-
- c = this.buildStringList1();
- assertFalse(CollectionTools.removeAll(c, this.buildObjectArray2()));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- c = this.buildStringList1();
- assertFalse(CollectionTools.removeAll(c, new Object[0]));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
- }
-
- public void testRemoveAllCollectionObjectArray_Duplicates() {
- Collection<String> c = new ArrayList<String>();
- c.add("a");
- c.add("a");
- c.add("b");
- c.add("c");
- c.add("d");
- c.add("d");
- String[] a = new String[] { "a", "d" };
- assertTrue(CollectionTools.removeAll(c, (Object[]) a));
- assertEquals(2, c.size());
- assertFalse(c.contains("a"));
- assertTrue(c.contains("b"));
- assertTrue(c.contains("c"));
- assertFalse(c.contains("d"));
-
- assertFalse(CollectionTools.removeAll(c,(Object[]) a));
- }
-
- public void testRemoveAllCollectionObjectArray_MoreDuplicates() {
- Collection<String> c = new ArrayList<String>();
- c.add("a");
- c.add("b");
- c.add("c");
- c.add("d");
- c.add("a");
- c.add("d");
- c.add("d");
- c.add("a");
- c.add("c");
- String[] a = new String[] { "a", "d" };
- assertTrue(CollectionTools.removeAll(c, (Object[]) a));
- assertEquals(3, c.size());
- assertFalse(c.contains("a"));
- assertTrue(c.contains("b"));
- assertTrue(c.contains("c"));
- assertFalse(c.contains("d"));
-
- assertFalse(CollectionTools.removeAll(c, (Object[]) a));
- }
-
-
- // ********** remove all occurrences **********
-
- public void testRemoveAllOccurrencesCollectionObject() {
- Collection<String> c = this.buildStringList1();
- assertEquals(3, c.size());
- assertFalse(CollectionTools.removeAllOccurrences(c, "three"));
- assertTrue(CollectionTools.removeAllOccurrences(c, "two"));
- assertFalse(CollectionTools.removeAllOccurrences(c, "two"));
- assertEquals(2, c.size());
-
- c.add("five");
- c.add("five");
- c.add("five");
- assertEquals(5, c.size());
- assertTrue(CollectionTools.removeAllOccurrences(c, "five"));
- assertFalse(CollectionTools.removeAllOccurrences(c, "five"));
- assertEquals(2, c.size());
-
- c.add(null);
- c.add(null);
- c.add(null);
- assertEquals(5, c.size());
- assertTrue(CollectionTools.removeAllOccurrences(c, null));
- assertFalse(CollectionTools.removeAllOccurrences(c, null));
- assertEquals(2, c.size());
- }
-
-
- // ********** remove elements at index **********
-
- public void testRemoveElementsAtIndexListIntInt() {
- List<String> list = new ArrayList<String>(Arrays.asList(new String[] { "A", "B", "A", "C", "A", "D" }));
- List<String> removed = CollectionTools.removeElementsAtIndex(list, 3, 2);
- assertTrue(Arrays.equals(new String[] { "A", "B", "A", "D" }, list.toArray()));
- assertTrue(Arrays.equals(new String[] { "C", "A" }, removed.toArray()));
-
- list = new ArrayList<String>(Arrays.asList(new String[] { "A", "B", "C", "D", "E", "F" }));
- removed = CollectionTools.removeElementsAtIndex(list, 3, 3);
- assertTrue(Arrays.equals(new String[] { "A", "B", "C" }, list.toArray()));
- assertTrue(Arrays.equals(new String[] { "D", "E", "F" }, removed.toArray()));
-
- list = new ArrayList<String>(Arrays.asList(new String[] { "A", "B", "C", "D", "E", "F" }));
- removed = CollectionTools.removeElementsAtIndex(list, 0, 3);
- assertTrue(Arrays.equals(new String[] { "D", "E", "F" }, list.toArray()));
- assertTrue(Arrays.equals(new String[] { "A", "B", "C" }, removed.toArray()));
- }
-
-
- // ********** remove duplicate elements **********
-
- public void testRemoveDuplicateElementsList1() {
- List<String> list = this.buildStringVector1();
- list.add("zero");
- list.add("zero");
- list.add("two");
- list.add("zero");
- assertTrue(CollectionTools.removeDuplicateElements(list));
- int i = 0;
- assertEquals("zero", list.get(i++));
- assertEquals("one", list.get(i++));
- assertEquals("two", list.get(i++));
- assertEquals(i, list.size());
- }
-
- public void testRemoveDuplicateElementsList2() {
- List<String> list = this.buildStringVector1();
- assertFalse(CollectionTools.removeDuplicateElements(list));
- int i = 0;
- assertEquals("zero", list.get(i++));
- assertEquals("one", list.get(i++));
- assertEquals("two", list.get(i++));
- assertEquals(i, list.size());
- }
-
- public void testRemoveDuplicateElementsList_Empty() {
- List<String> list = new ArrayList<String>();
- assertFalse(CollectionTools.removeDuplicateElements(list));
- assertEquals(0, list.size());
- }
-
- public void testRemoveDuplicateElementsList_SingleElement() {
- List<String> list = new ArrayList<String>();
- list.add("zero");
- assertFalse(CollectionTools.removeDuplicateElements(list));
- assertEquals(1, list.size());
- }
-
-
- // ********** retain all **********
-
- public void testRetainAllCollectionIterable() {
- Collection<String> c = this.buildStringList1();
- Iterable<String> iterable = this.buildStringList1();
- assertFalse(CollectionTools.retainAll(c, iterable));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- iterable = this.buildStringList2();
- assertTrue(CollectionTools.retainAll(c, iterable));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
- }
-
- public void testRetainAllCollectionIterableInt() {
- Collection<String> c = this.buildStringList1();
- Iterable<String> iterable = this.buildStringList1();
- assertFalse(CollectionTools.retainAll(c, iterable));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- iterable = this.buildStringList2();
- assertTrue(CollectionTools.retainAll(c, iterable, 7));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
- }
-
- public void testRetainAllCollectionIterator() {
- Collection<String> c = this.buildStringList1();
- assertFalse(CollectionTools.retainAll(c, this.buildStringList1().iterator()));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- assertTrue(CollectionTools.retainAll(c, this.buildStringList2().iterator()));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
- }
-
- public void testRetainAllCollectionIterator_ObjectString() {
- Collection<Object> c1 = new ArrayList<Object>();
- c1.add("zero");
- c1.add("one");
- c1.add("two");
-
- Collection<String> c2 = new ArrayList<String>();
- c2.add("zero");
- c2.add("one");
- c2.add("two");
-
- assertFalse(CollectionTools.retainAll(c1, c2.iterator()));
- assertEquals(c2.size(), c1.size());
- assertEquals(c2, c1);
-
- Collection<String> c3 = new ArrayList<String>();
- c3.add("three");
- c3.add("four");
- c3.add("five");
- }
-
- public void testRetainAllCollectionIterator_EmptyIterator() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.retainAll(c, EmptyIterator.instance()));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionIterator_EmptyCollection() {
- Collection<String> c = new ArrayList<String>();
- assertFalse(CollectionTools.retainAll(c, this.buildStringList1().iterator()));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionIterator_EmptyCollectionEmptyIterator() {
- Collection<String> c = new ArrayList<String>();
- assertFalse(CollectionTools.retainAll(c, EmptyIterator.instance()));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionIteratorInt() {
- Collection<String> c = this.buildStringList1();
- assertFalse(CollectionTools.retainAll(c, this.buildStringList1().iterator(), 8));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- assertTrue(CollectionTools.retainAll(c, this.buildStringList2().iterator(), 9));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
- }
-
- public void testRetainAllCollectionIteratorInt_EmptyIterator() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.retainAll(c, EmptyIterator.instance(), 0));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionIteratorInt_EmptyCollection() {
- Collection<String> c = new ArrayList<String>();
- assertFalse(CollectionTools.retainAll(c, this.buildStringList1().iterator(), 3));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionIteratorInt_EmptyCollectionEmptyIterator() {
- Collection<String> c = new ArrayList<String>();
- assertFalse(CollectionTools.retainAll(c, EmptyIterator.instance(), 0));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionObjectArray() {
- Collection<String> c = this.buildStringList1();
- assertFalse(CollectionTools.retainAll(c, this.buildObjectArray1()));
- assertEquals(this.buildStringList1().size(), c.size());
- assertEquals(this.buildStringList1(), c);
-
- assertTrue(CollectionTools.retainAll(c, this.buildObjectArray2()));
- assertEquals(0, c.size());
- assertFalse(c.contains("one"));
- assertFalse(c.contains("two"));
- assertFalse(c.contains("three"));
- }
-
- public void testRetainAllCollectionObjectArray_EmptyObjectArray() {
- Collection<String> c = this.buildStringList1();
- assertTrue(CollectionTools.retainAll(c, new Object[0]));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionObjectArray_EmptyCollection() {
- Collection<String> c = new ArrayList<String>();
- assertFalse(CollectionTools.retainAll(c, (Object[]) new String[] { "foo" }));
- assertEquals(0, c.size());
- }
-
- public void testRetainAllCollectionObjectArray_EmptyCollectionEmptyObjectArray() {
- Collection<String> c = new ArrayList<String>();
- assertFalse(CollectionTools.retainAll(c, (Object[]) new String[0]));
- assertEquals(0, c.size());
- }
-
-
- // ********** reverse list **********
-
- public void testReverseListIterable() {
- Iterable<String> iterable = this.buildStringList1();
- List<String> actual = CollectionTools.reverseList(iterable);
- List<String> expected = this.buildStringList1();
- Collections.reverse(expected);
- assertEquals(expected, actual);
- }
-
- public void testReverseListIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- List<String> actual = CollectionTools.reverseList(iterable, 10);
- List<String> expected = this.buildStringList1();
- Collections.reverse(expected);
- assertEquals(expected, actual);
- }
-
- public void testReverseListIterator_String() {
- List<String> actual = CollectionTools.reverseList(this.buildStringList1().iterator());
- List<String> expected = this.buildStringList1();
- Collections.reverse(expected);
- assertEquals(expected, actual);
- }
-
- public void testReverseListIterator_Object() {
- List<Object> actual = CollectionTools.<Object>reverseList(this.buildStringList1().iterator());
- List<Object> expected = this.buildObjectList1();
- Collections.reverse(expected);
- assertEquals(expected, actual);
- }
-
- public void testReverseListIteratorInt() {
- List<String> actual = CollectionTools.reverseList(this.buildStringList1().iterator(), 33);
- List<String> expected = this.buildStringList1();
- Collections.reverse(expected);
- assertEquals(expected, actual);
- }
-
-
- // ********** rotate **********
-
- public void testRotateList() {
- List<String> actual = CollectionTools.rotate(this.buildStringList1());
- List<String> expected = this.buildStringList1();
- Collections.rotate(expected, 1);
- assertEquals(expected, actual);
- }
-
-
- // ********** set **********
-
- public void testSetIterable() {
- Iterable<String> iterable = this.buildStringSet1();
- assertEquals(this.buildStringSet1(), CollectionTools.set(iterable));
- }
-
- public void testSetIterableInt() {
- Iterable<String> iterable = this.buildStringSet1();
- assertEquals(this.buildStringSet1(), CollectionTools.set(iterable, 22));
- }
-
- public void testSetIterator_String() {
- assertEquals(this.buildStringSet1(), CollectionTools.set(this.buildStringSet1().iterator()));
- }
-
- public void testSetIterator_Object() {
- List<String> list = new ArrayList<String>();
- list.add("0");
- list.add("1");
- list.add("2");
- list.add("3");
- list.add("0");
- list.add("1");
- list.add("2");
- list.add("3");
- Set<String> set = new HashSet<String>();
- set.addAll(list);
-
- assertEquals(set, CollectionTools.<Object>set(list.iterator()));
- }
-
- public void testSetIteratorInt() {
- assertEquals(this.buildStringSet1(), CollectionTools.set(this.buildStringSet1().iterator(), 3));
- }
-
- public void testSetObjectArray() {
- assertEquals(this.buildStringSet1(), CollectionTools.set(this.buildStringSet1().toArray()));
- }
-
-
- // ********** singleton iterator **********
-
- public void testSingletonIterator_String() {
- Iterator<String> stream = CollectionTools.singletonIterator("foo");
- assertTrue(stream.hasNext());
- assertEquals("foo", stream.next());
- }
-
- public void testSingletonIterator_Object() {
- Iterator<Object> stream = CollectionTools.<Object>singletonIterator("foo");
- assertTrue(stream.hasNext());
- assertEquals("foo", stream.next());
- }
-
- public void testSingletonIterator_Cast() {
- Iterator<Object> stream = CollectionTools.singletonIterator((Object) "foo");
- assertTrue(stream.hasNext());
- assertEquals("foo", stream.next());
- }
-
- public void testSingletonListIterator_String() {
- ListIterator<String> stream = CollectionTools.singletonListIterator("foo");
- assertTrue(stream.hasNext());
- assertEquals("foo", stream.next());
- assertFalse(stream.hasNext());
- assertTrue(stream.hasPrevious());
- assertEquals("foo", stream.previous());
- }
-
-
- // ********** size **********
-
- public void testSizeIterable() {
- Iterable<Object> iterable = this.buildObjectList1();
- assertEquals(3, CollectionTools.size(iterable));
- }
-
- public void testSizeIterator() {
- assertEquals(3, CollectionTools.size(this.buildObjectList1().iterator()));
- }
-
-
- // ********** sort **********
-
- public void testSortIterable() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss = new TreeSet<String>();
- ss.addAll(list);
-
- Iterable<String> iterable1 = list;
- Iterable<String> iterable2 = CollectionTools.<String>sort(iterable1);
- assertTrue(CollectionTools.elementsAreEqual(ss, iterable2));
- }
-
- public void testSortIterableInt() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss = new TreeSet<String>();
- ss.addAll(list);
-
- Iterable<String> iterable1 = list;
- Iterable<String> iterable2 = CollectionTools.<String>sort(iterable1, 77);
- assertTrue(CollectionTools.elementsAreEqual(ss, iterable2));
- }
-
- public void testSortIterableComparator() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss = new TreeSet<String>(new ReverseComparator<String>());
- ss.addAll(list);
-
- Iterable<String> iterable1 = list;
- Iterable<String> iterable2 = CollectionTools.<String>sort(iterable1, new ReverseComparator<String>());
- assertTrue(CollectionTools.elementsAreEqual(ss, iterable2));
- }
-
- public void testSortIterableComparatorInt() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss = new TreeSet<String>(new ReverseComparator<String>());
- ss.addAll(list);
-
- Iterable<String> iterable1 = list;
- Iterable<String> iterable2 = CollectionTools.<String>sort(iterable1, new ReverseComparator<String>(), 77);
- assertTrue(CollectionTools.elementsAreEqual(ss, iterable2));
- }
-
- public void testSortIterator() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss = new TreeSet<String>();
- ss.addAll(list);
-
- Iterator<String> iterator1 = list.iterator();
- Iterator<String> iterator2 = CollectionTools.<String>sort(iterator1);
- assertTrue(CollectionTools.elementsAreEqual(ss.iterator(), iterator2));
- }
-
- public void testSortIteratorInt() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss = new TreeSet<String>();
- ss.addAll(list);
-
- Iterator<String> iterator1 = list.iterator();
- Iterator<String> iterator2 = CollectionTools.<String>sort(iterator1, 77);
- assertTrue(CollectionTools.elementsAreEqual(ss.iterator(), iterator2));
- }
-
- public void testSortIteratorComparator() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss = new TreeSet<String>(new ReverseComparator<String>());
- ss.addAll(list);
-
- Iterator<String> iterator1 = list.iterator();
- Iterator<String> iterator2 = CollectionTools.<String>sort(iterator1, new ReverseComparator<String>());
- assertTrue(CollectionTools.elementsAreEqual(ss.iterator(), iterator2));
- }
-
- public void testSortIteratorComparatorInt() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss = new TreeSet<String>(new ReverseComparator<String>());
- ss.addAll(list);
-
- Iterator<String> iterator1 = list.iterator();
- Iterator<String> iterator2 = CollectionTools.<String>sort(iterator1, new ReverseComparator<String>(), 77);
- assertTrue(CollectionTools.elementsAreEqual(ss.iterator(), iterator2));
- }
-
-
- // ********** sorted set **********
-
- public void testSortedSetIterable() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss1 = new TreeSet<String>();
- ss1.addAll(list);
-
- Iterable<String> iterable = list;
- SortedSet<String> ss2 = CollectionTools.<String>sortedSet(iterable);
- assertEquals(ss1, ss2);
- }
-
- public void testSortedSetIterableInt() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss1 = new TreeSet<String>();
- ss1.addAll(list);
-
- Iterable<String> iterable = list;
- SortedSet<String> ss2 = CollectionTools.<String>sortedSet(iterable, 5);
- assertEquals(ss1, ss2);
- }
-
- public void testSortedSetIterableComparator() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss1 = new TreeSet<String>(new ReverseComparator<String>());
- ss1.addAll(list);
-
- Iterable<String> iterable = list;
- SortedSet<String> ss2 = CollectionTools.<String>sortedSet(iterable, new ReverseComparator<String>());
- assertEquals(ss1, ss2);
- }
-
- public void testSortedSetIterableComparatorInt() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss1 = new TreeSet<String>(new ReverseComparator<String>());
- ss1.addAll(list);
-
- Iterable<String> iterable = list;
- SortedSet<String> ss2 = CollectionTools.<String>sortedSet(iterable, new ReverseComparator<String>(), 5);
- assertEquals(ss1, ss2);
- }
-
- public void testSortedSetIterator() {
- assertEquals(this.buildSortedStringSet1(), CollectionTools.sortedSet(this.buildSortedStringSet1().iterator()));
- }
-
- public void testSortedSetIterator_TreeSet() {
- SortedSet<String> ss1 = new TreeSet<String>();
- ss1.add("0");
- ss1.add("2");
- ss1.add("3");
- ss1.add("1");
-
- SortedSet<String> set2 = CollectionTools.<String>sortedSet(ss1.iterator());
- assertEquals(ss1, set2);
- }
-
- public void testSortedSetIteratorInt() {
- assertEquals(this.buildSortedStringSet1(), CollectionTools.sortedSet(this.buildSortedStringSet1().iterator(), 8));
- }
-
- public void testSortedSetObjectArray() {
- assertEquals(this.buildSortedStringSet1(), CollectionTools.sortedSet(this.buildStringSet1().toArray(new String[0])));
- }
-
- public void testSortedSetObjectArrayComparator() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("0");
- list.add("2");
- list.add("3");
- list.add("1");
-
- SortedSet<String> ss1 = new TreeSet<String>(new ReverseComparator<String>());
- ss1.addAll(list);
-
- String[] array = list.toArray(new String[list.size()]);
- SortedSet<String> ss2 = CollectionTools.<String>sortedSet(array, new ReverseComparator<String>());
- assertEquals(ss1, ss2);
- }
-
-
- // ********** Old School Vector **********
-
- public void testVectorIterable() {
- Iterable<String> iterable = this.buildStringList1();
- Vector<String> v = CollectionTools.vector(iterable);
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
- public void testVectorIterableInt() {
- Iterable<String> iterable = this.buildStringList1();
- Vector<String> v = CollectionTools.vector(iterable, 8);
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
- public void testVectorIterator_String() {
- Vector<String> v = CollectionTools.vector(this.buildStringList1().iterator());
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
- public void testVectorIterator_Object() {
- Vector<Object> v = CollectionTools.<Object>vector(this.buildStringList1().iterator());
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
- public void testVectorIteratorInt() {
- Vector<String> v = CollectionTools.vector(this.buildStringList1().iterator(), 7);
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
- public void testVectorObjectArray() {
- Vector<String> v = CollectionTools.vector(this.buildStringArray1());
- assertEquals(3, v.size());
- assertTrue(v.containsAll(this.buildStringList1()));
- }
-
-
- // ********** single-use iterable **********
-
- public void testIterableIterator() {
- Iterator<Object> emptyIterator = EmptyIterator.instance();
- Iterable<Object> emptyIterable = CollectionTools.iterable(emptyIterator);
-
- assertFalse(emptyIterable.iterator().hasNext());
-
- boolean exceptionThrown = false;
- try {
- emptyIterator = emptyIterable.iterator();
- fail("invalid iterator: " + emptyIterator);
- } catch (IllegalStateException ise) {
- exceptionThrown = true;
- }
- assertTrue("IllegalStateException not thrown.", exceptionThrown);
- }
-
- public void testIterableIterator_NPE() {
- Iterator<Object> nullIterator = null;
- boolean exceptionThrown = false;
- try {
- Iterable<Object> emptyIterable = CollectionTools.iterable(nullIterator);
- fail("invalid iterable: " + emptyIterable);
- } catch (NullPointerException ise) {
- exceptionThrown = true;
- }
- assertTrue(exceptionThrown);
- }
-
- public void testIterableIterator_ToString() {
- Iterator<Object> emptyIterator = EmptyIterator.instance();
- Iterable<Object> emptyIterable = CollectionTools.iterable(emptyIterator);
- assertNotNull(emptyIterable.toString());
- }
-
-
- // ********** java.util.Collections enhancements **********
-
- public void testCopyListList() {
- List<String> src = this.buildStringList1();
- List<String> dest = new ArrayList<String>();
- for (String s : src) {
- dest.add(s.toUpperCase());
- }
- List<String> result = CollectionTools.copy(dest, src);
- assertSame(dest, result);
- assertTrue(CollectionTools.elementsAreIdentical(src, dest));
- }
-
- public void testFillListObject() {
- List<String> list = this.buildStringList1();
- List<String> result = CollectionTools.fill(list, "foo");
- assertSame(list, result);
- for (String string : result) {
- assertEquals("foo", string);
- }
- }
-
- public void testShuffleList() {
- List<String> list = this.buildStringList1();
- List<String> result = CollectionTools.shuffle(list);
- assertSame(list, result);
- }
-
- public void testShuffleListRandom() {
- List<String> list = this.buildStringList1();
- List<String> result = CollectionTools.shuffle(list, new Random());
- assertSame(list, result);
- }
-
- public void testSortList() {
- List<String> list = this.buildStringList1();
- SortedSet<String> ss = new TreeSet<String>();
- ss.addAll(list);
- List<String> result = CollectionTools.sort(list);
- assertSame(list, result);
- assertTrue(CollectionTools.elementsAreEqual(ss, result));
- }
-
- public void testSwapListIntInt() {
- List<String> list = this.buildStringList1();
- List<String> result = CollectionTools.swap(list, 0, 1);
- assertSame(list, result);
- List<String> original = this.buildStringList1();
- assertEquals(original.get(0), result.get(1));
- assertEquals(original.get(1), result.get(0));
- assertEquals(original.get(2), result.get(2));
- }
-
- public void testConstructor() {
- boolean exCaught = false;
- try {
- Object at = ReflectionTools.newInstance(CollectionTools.class);
- fail("bogus: " + at); //$NON-NLS-1$
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof InvocationTargetException) {
- if (ex.getCause().getCause() instanceof UnsupportedOperationException) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
-
- // ********** test harness **********
-
- private Object[] buildObjectArray1() {
- return new Object[] { "zero", "one", "two" };
- }
-
- private String[] buildStringArray1() {
- return new String[] { "zero", "one", "two" };
- }
-
- private Object[] buildObjectArray2() {
- return new Object[] { "three", "four", "five" };
- }
-
- private Vector<String> buildStringVector1() {
- Vector<String> v = new Vector<String>();
- this.addToCollection1(v);
- return v;
- }
-
- private List<String> buildStringList1() {
- List<String> l = new ArrayList<String>();
- this.addToCollection1(l);
- return l;
- }
-
- private List<Object> buildObjectList1() {
- List<Object> l = new ArrayList<Object>();
- this.addToCollection1(l);
- return l;
- }
-
- private void addToCollection1(Collection<? super String> c) {
- c.add("zero");
- c.add("one");
- c.add("two");
- }
-
- private List<String> buildStringList2() {
- List<String> l = new ArrayList<String>();
- this.addToCollection2(l);
- return l;
- }
-
- private void addToCollection2(Collection<? super String> c) {
- c.add("three");
- c.add("four");
- c.add("five");
- }
-
- private Set<String> buildStringSet1() {
- Set<String> s = new HashSet<String>();
- this.addToCollection1(s);
- return s;
- }
-
- private Set<Object> buildObjectSet1() {
- Set<Object> s = new HashSet<Object>();
- this.addToCollection1(s);
- return s;
- }
-
- private SortedSet<String> buildSortedStringSet1() {
- SortedSet<String> s = new TreeSet<String>();
- this.addToCollection1(s);
- return s;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ExceptionHandlerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ExceptionHandlerTests.java
deleted file mode 100644
index 90f9977935..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ExceptionHandlerTests.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-
-public class ExceptionHandlerTests extends TestCase {
-
- public ExceptionHandlerTests(String name) {
- super(name);
- }
-
- public void testNullExceptionHandler() {
- ExceptionHandler exceptionHandler = ExceptionHandler.Null.instance();
- exceptionHandler.handleException(new NullPointerException()); // just make sure it doesn't blow up?
- }
-
- public void testNullExceptionHandlerToString() {
- ExceptionHandler exceptionHandler = ExceptionHandler.Null.instance();
- assertNotNull(exceptionHandler.toString());
- }
-
- public void testRuntimeExceptionHandler1() {
- Exception npe = new Exception();
- ExceptionHandler exceptionHandler = ExceptionHandler.Runtime.instance();
- boolean exCaught = false;
- try {
- exceptionHandler.handleException(npe);
- fail();
- } catch (RuntimeException ex) {
- assertSame(npe, ex.getCause());
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRuntimeExceptionHandler2() {
- Exception npe = new NullPointerException();
- ExceptionHandler exceptionHandler = ExceptionHandler.Runtime.instance();
- boolean exCaught = false;
- try {
- exceptionHandler.handleException(npe);
- fail();
- } catch (RuntimeException ex) {
- assertSame(npe, ex);
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRuntimeExceptionHandlerToString() {
- ExceptionHandler exceptionHandler = ExceptionHandler.Runtime.instance();
- assertNotNull(exceptionHandler.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/FileToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/FileToolsTests.java
deleted file mode 100644
index 5483b8588d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/FileToolsTests.java
+++ /dev/null
@@ -1,593 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.io.File;
-import java.io.FileFilter;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.FileTools;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-
-@SuppressWarnings("nls")
-public class FileToolsTests extends TestCase {
- private File tempDir;
-
- public FileToolsTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.tempDir = this.buildTempDir();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- this.deleteDir(this.tempDir);
- }
-
- public void testFilesIn() {
- Collection<File> files = CollectionTools.collection(FileTools.filesIn(this.tempDir.getPath()));
- assertEquals("invalid file count", 3, files.size());
- }
-
- public void testDirectoriesIn() {
- Collection<File> files = CollectionTools.collection(FileTools.directoriesIn(this.tempDir.getPath()));
- assertEquals("invalid directory count", 2, files.size());
- }
-
- public void testFilesInTree() {
- Collection<File> files = CollectionTools.collection(FileTools.filesInTree(this.tempDir.getPath()));
- assertEquals("invalid file count", 9, files.size());
- }
-
- public void testDirectoriesInTree() {
- Collection<File> files = CollectionTools.collection(FileTools.directoriesInTree(this.tempDir.getPath()));
- assertEquals("invalid directory count", 3, files.size());
- }
-
- public void testDeleteDirectory() throws IOException {
- // build another temporary directory just for this test
- File dir = this.buildTempDir();
- assertTrue("temporary directory not created", dir.exists());
- FileTools.deleteDirectory(dir.getPath());
- assertFalse("temporary directory not deleted", dir.exists());
- }
-
- public void testDeleteDirectoryContents() throws IOException {
- // build another temporary directory just for this test
- File dir = this.buildTempDir();
- assertTrue("temporary directory not created", dir.exists());
- FileTools.deleteDirectoryContents(dir.getPath());
- assertTrue("temporary directory should not have been deleted", dir.exists());
- assertTrue("temporary directory contents not deleted", dir.listFiles().length == 0);
- dir.delete();
- }
-
- public void testCopyToFile() throws IOException {
- File destFile = new File(this.tempDir, "destfile.txt");
- this.copyToFile(destFile, "testCopyToFile");
- }
-
- public void testCopyToPreExistingFile() throws IOException {
- File destFile = new File(this.tempDir, "destfile.txt");
- Writer writer = new OutputStreamWriter(new FileOutputStream(destFile));
- writer.write("this text should be replaced...");
- writer.close();
- this.copyToFile(destFile, "testCopyToPreExistingFile");
- }
-
- private void copyToFile(File destFile, String writeString) throws IOException {
- File sourceFile = new File(this.tempDir, "sourcefile.txt");
- char[] readBuffer = new char[writeString.length()];
-
- Writer writer = new OutputStreamWriter(new FileOutputStream(sourceFile));
- writer.write(writeString);
- writer.close();
-
- FileTools.copyToFile(sourceFile, destFile);
-
- Reader reader = new InputStreamReader(new FileInputStream(destFile));
- reader.read(readBuffer);
- reader.close();
- String readString = new String(readBuffer);
- assertEquals(writeString, readString);
- }
-
- public void testCopyToDirectory() throws IOException {
- File sourceFile = new File(this.tempDir, "sourcefile.txt");
- String writeString = "testCopyToDirectory";
-
- File destDir = new File(this.tempDir, "destdir");
- destDir.mkdir();
- File destFile = new File(destDir, "sourcefile.txt");
- char[] readBuffer = new char[writeString.length()];
-
- Writer writer = new OutputStreamWriter(new FileOutputStream(sourceFile));
- writer.write(writeString);
- writer.close();
-
- FileTools.copyToDirectory(sourceFile, destDir);
-
- Reader reader = new InputStreamReader(new FileInputStream(destFile));
- reader.read(readBuffer);
- reader.close();
- String readString = new String(readBuffer);
- assertEquals(writeString, readString);
-
- FileTools.copyToDirectory(sourceFile, destDir); //Try again with the directory is already created
- reader = new InputStreamReader(new FileInputStream(destFile));
- reader.read(readBuffer);
- reader.close();
- readString = new String(readBuffer);
- assertEquals(writeString, readString);
- }
-
- public void testFilter() throws IOException {
- String prefix = "XXXtestFileXXX";
- File testFile1 = new File(this.tempDir, prefix + "1");
- testFile1.createNewFile();
- File testFile2 = new File(this.tempDir, prefix + "2");
- testFile2.createNewFile();
-
- FileFilter filter = this.buildFileFilter(prefix);
- Iterator<File> filteredFilesIterator = FileTools.filter(FileTools.filesIn(this.tempDir), filter);
- Collection<File> filteredFiles = CollectionTools.collection(filteredFilesIterator);
- assertEquals(2, filteredFiles.size());
- assertTrue(filteredFiles.contains(testFile1));
- assertTrue(filteredFiles.contains(testFile2));
- }
-
- private FileFilter buildFileFilter(final String prefix) {
- return new FileFilter() {
- public boolean accept(File file) {
- return file.getName().startsWith(prefix);
- }
- };
- }
-
- public void testStripExtension() {
- assertEquals("foo", FileTools.stripExtension("foo.xml"));
- assertEquals("foo.bar", FileTools.stripExtension("foo.bar.xml"));
- assertEquals("foo", FileTools.stripExtension("foo"));
- assertEquals("foo", FileTools.stripExtension("foo."));
- }
-
- public void testExtension() {
- assertEquals(".xml", FileTools.extension("foo.xml"));
- assertEquals(".xml", FileTools.extension("foo.bar.xml"));
- assertEquals("", FileTools.extension("foo"));
- assertEquals("", FileTools.extension("foo,xml"));
- assertEquals(".", FileTools.extension("foo."));
- }
-
- public void testEmptyTemporaryDirectory() throws IOException {
- File tempDir1 = FileTools.temporaryDirectory();
- File testFile1 = new File(tempDir1, "junk");
- testFile1.createNewFile();
-
- File tempDir2 = FileTools.emptyTemporaryDirectory();
- assertEquals(tempDir1, tempDir2);
- assertTrue(tempDir2.isDirectory());
- assertEquals(0, tempDir2.listFiles().length);
- tempDir2.delete();
- }
-
- public void testCanonicalFileName() {
- File file1 = new File("foo");
- file1 = new File(file1, "bar");
- file1 = new File(file1, "baz");
- file1 = new File(file1, "..");
- file1 = new File(file1, "..");
- file1 = new File(file1, "bar");
- file1 = new File(file1, "baz");
- File file2 = new File(System.getProperty("user.dir"));
- file2 = new File(file2, "foo");
- file2 = new File(file2, "bar");
- file2 = new File(file2, "baz");
- File file3 = FileTools.canonicalFile(file1);
- assertEquals(file2, file3);
- }
-
- public void testPathFiles() {
- File[] expected;
- File[] actual;
-
- if (Tools.osIsWindows()) {
- expected = new File[] { new File("C:/"), new File("C:/foo"), new File("C:/foo/bar"), new File("C:/foo/bar/baz.txt") };
- actual = this.pathFiles(new File("C:/foo/bar/baz.txt"));
- assertTrue(Arrays.equals(expected, actual));
- }
-
- expected = new File[] { new File("/"), new File("/foo"), new File("/foo/bar"), new File("/foo/bar/baz.txt") };
- actual = this.pathFiles(new File("/foo/bar/baz.txt"));
- assertTrue(Arrays.equals(expected, actual));
-
- expected = new File[] { new File("foo"), new File("foo/bar"), new File("foo/bar/baz.txt") };
- actual = this.pathFiles(new File("foo/bar/baz.txt"));
- assertTrue(Arrays.equals(expected, actual));
-
- expected = new File[] { new File(".."), new File("../foo"), new File("../foo/bar"), new File("../foo/bar/baz.txt") };
- actual = this.pathFiles(new File("../foo/bar/baz.txt"));
- assertTrue(Arrays.equals(expected, actual));
-
- expected = new File[] { new File("."), new File("./foo"), new File("./foo/bar"), new File("./foo/bar/baz.txt") };
- actual = this.pathFiles(new File("./foo/bar/baz.txt"));
- assertTrue(Arrays.equals(expected, actual));
- }
-
- private File[] pathFiles(File file) {
- return (File[]) ReflectionTools.executeStaticMethod(FileTools.class, "pathFiles", File.class, file);
- }
-
- public void testRelativeParentFile() {
- assertEquals(new File(".."), this.relativeParentFile(1));
- assertEquals(new File("../.."), this.relativeParentFile(2));
- assertEquals(new File("../../.."), this.relativeParentFile(3));
-
- boolean exCaught = false;
- try {
- File file = this.relativeParentFile(0);
- fail("invalid return: " + file);
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof InvocationTargetException) {
- InvocationTargetException ite = (InvocationTargetException) ex.getCause();
- if (ite.getTargetException() instanceof IllegalArgumentException) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
- private File relativeParentFile(int len) {
- return (File) ReflectionTools.executeStaticMethod(FileTools.class, "relativeParentFile", int.class, new Integer(len));
- }
-
- public void testConvertToRelativeFile() {
- String prefix = Tools.osIsWindows() ? "C:" : "";
- File file;
- File dir;
- File relativeFile;
-
- if (Tools.osIsWindows()) {
- // on Windows, a drive must be specified for a file to be absolute (i.e. not relative)
- this.verifyUnchangedRelativeFile("/dir1/dir2/file.txt", "C:/dir1/dir2");
- // different drives
- this.verifyUnchangedRelativeFile("D:/dir1/dir2/file.txt", "C:/dir1/dir2");
- }
- this.verifyUnchangedRelativeFile("dir1/dir2/file.txt", prefix + "/dir1/dir2");
- this.verifyUnchangedRelativeFile("./dir1/dir2/file.txt", prefix + "/dir1/dir2");
- this.verifyUnchangedRelativeFile("../../dir1/dir2/file.txt", prefix + "/dir1/dir2");
-
- file = new File(prefix + "/dir1/dir2");
- dir = new File(prefix + "/dir1/dir2");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("."), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/file.txt");
- dir = new File(prefix + "/dir1/dir2");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/../dir2/file.txt");
- dir = new File(prefix + "/dir1/dir2");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/dir3/dir4/dir5/file.txt");
- dir = new File(prefix + "/dir1/dir2");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("dir3/dir4/dir5/file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("../../../file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("../file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2/dirA/dirB/dirC/file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("../../../dirA/dirB/dirC/file.txt"), relativeFile);
-
- file = new File(prefix + "/dir1/dir2");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("../../.."), relativeFile);
-
- file = new File(prefix + "/My Documents/My Workspace/Project 1/lib/toplink.jar");
- dir = new File(prefix + "/My Documents/My Workspace/Project 1");
- relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(new File("lib/toplink.jar"), relativeFile);
- }
-
- private void verifyUnchangedRelativeFile(String fileName, String dirName) {
- File file = new File(fileName);
- File dir = new File(dirName);
- File relativeFile = FileTools.convertToRelativeFile(file, dir);
- assertEquals(file, relativeFile);
- }
-
- public void testConvertToAbsoluteFile() {
- String prefix = Tools.osIsWindows() ? "C:" : "";
- File file;
- File dir;
- File absoluteFile;
-
- if (Tools.osIsWindows()) {
- // on Windows, a drive must be specified for a file to be absolute (i.e. not relative)
- this.verifyUnchangedAbsoluteFile("C:/dir1/dir2/file.txt", "C:/dir1/dir2");
- // different drives
- this.verifyUnchangedAbsoluteFile("D:/dir1/dir2/file.txt", "C:/dir1/dir2");
- }
- this.verifyUnchangedAbsoluteFile(prefix + "/dir1/dir2/file.txt", prefix + "/dir1/dir2");
- this.verifyUnchangedAbsoluteFile(prefix + "/./dir1/dir2/file.txt", prefix + "/dir1/dir2");
- this.verifyUnchangedAbsoluteFile(prefix + "/dir1/dir2/../../dir1/dir2/file.txt", prefix + "/dir1/dir2");
-
- file = new File(".");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2"), absoluteFile);
-
- file = new File("./file.txt");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/file.txt"), absoluteFile);
-
- file = new File("file.txt");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/file.txt"), absoluteFile);
-
- file = new File("../dir2/file.txt");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/file.txt"), absoluteFile);
-
- file = new File("dir3/dir4/dir5/file.txt");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/dir3/dir4/dir5/file.txt"), absoluteFile);
-
- file = new File("../../../file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/file.txt"), absoluteFile);
-
- // too many ".." directories will resolve to the root;
- // this is consistent with Windows and Linux command shells
- file = new File("../../../../../../../../file.txt");
- dir = new File(prefix + "/dir1/dir2");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/file.txt"), absoluteFile);
-
- file = new File("../file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/file.txt"), absoluteFile);
-
- file = new File("../../../dirA/dirB/dirC/file.txt");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2/dirA/dirB/dirC/file.txt"), absoluteFile);
-
- file = new File("../../..");
- dir = new File(prefix + "/dir1/dir2/dir3/dir4/dir5");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/dir1/dir2"), absoluteFile);
-
- file = new File("lib/toplink.jar");
- dir = new File(prefix + "/My Documents/My Workspace/Project 1");
- absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(new File(prefix + "/My Documents/My Workspace/Project 1/lib/toplink.jar"), absoluteFile);
- }
-
- public void testFileNameIsReserved() {
- boolean expected = Tools.osIsWindows();
- assertEquals(expected, FileTools.fileNameIsReserved("CON"));
- assertEquals(expected, FileTools.fileNameIsReserved("con"));
- assertEquals(expected, FileTools.fileNameIsReserved("cON"));
- assertEquals(expected, FileTools.fileNameIsReserved("AUX"));
- assertEquals(expected, FileTools.fileNameIsReserved("COM3"));
- assertEquals(expected, FileTools.fileNameIsReserved("LPT3"));
- assertEquals(expected, FileTools.fileNameIsReserved("nUL"));
- assertEquals(expected, FileTools.fileNameIsReserved("Prn"));
- }
-
- public void testFileHasAnyReservedComponents() {
- boolean expected = Tools.osIsWindows();
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("C:/CON")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("/con/foo")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("c:/temp/cON")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("bar//baz//AUX")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("COM3//ttt")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("d:/LPT3/xxx")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("c:/my docs and stuff/tuesday/nUL")));
- assertEquals(expected, FileTools.fileHasAnyReservedComponents(new File("Prn")));
- }
-
- public void testShortenFileNameFile() {
- if (Tools.osIsWindows()) {
- this.verifyShortenFileNameFileWin();
- } else {
- this.verifyShortenFileNameFileNonWin();
- }
- }
-
- private void verifyShortenFileNameFileWin() {
- File file = new File("C:\\Documents and Settings\\Administrator\\Desktop\\Project\\Text.txt");
- String fileName = FileTools.shortenFileName(file);
- assertEquals("C:\\Documents and Settings\\...\\Desktop\\Project\\Text.txt", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
-
- file = new File("C:/");
- fileName = FileTools.shortenFileName(file);
- assertEquals("C:\\", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- private void verifyShortenFileNameFileNonWin() {
- File file = new File("/home/administrator/documents and settings/desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(file);
- assertEquals("/home/administrator/.../desktop/Project/Text.txt", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
-
- file = new File("/home");
- fileName = FileTools.shortenFileName(file);
- assertEquals("/home", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- public void testShortenFileNameFileInt() {
- if (Tools.osIsWindows()) {
- this.verifyShortenFileNameFileIntWin();
- } else {
- this.verifyShortenFileNameFileIntNonWin();
- }
- }
-
- private void verifyShortenFileNameFileIntWin() {
- File file = new File("C:\\Documents and Settings\\Administrator\\Desktop\\Project\\Text.txt");
- String fileName = FileTools.shortenFileName(file, 31);
- assertEquals("C:\\...\\Desktop\\Project\\Text.txt", fileName);
- assertEquals(31, fileName.length());
-
- file = new File("C:/This is the file name.txt");
- fileName = FileTools.shortenFileName(file, 10);
- assertEquals("C:\\This is the file name.txt", fileName);
- assertEquals(28, fileName.length());
- }
-
- private void verifyShortenFileNameFileIntNonWin() {
- File file = new File("/home/administrator/documents and settings/desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(file, 31);
- assertEquals("/home/.../desktop/Project/Text.txt", fileName);
- assertEquals(34, fileName.length());
-
- file = new File("/This is the file name.txt");
- fileName = FileTools.shortenFileName(file, 10);
- assertEquals("/This is the file name.txt", fileName);
- assertEquals(26, fileName.length());
- }
-
- public void testShortenFileNameURL() throws Exception {
- if (Tools.osIsWindows()) {
- this.verifyShortenFileNameURLWin();
- } else {
- this.verifyShortenFileNameURLNonWin();
- }
- }
-
- private void verifyShortenFileNameURLWin() throws Exception {
- URL url = new URL("file", "", "C:/Documents and Settings/Administrator/Desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(url);
- assertEquals("C:\\Documents and Settings\\...\\Desktop\\Project\\Text.txt", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- private void verifyShortenFileNameURLNonWin() throws Exception {
- URL url = new URL("file", "", "/home/administrator/documents and settings/desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(url);
- assertEquals("/home/administrator/.../desktop/Project/Text.txt", fileName);
- assertTrue(fileName.length() <= FileTools.MAXIMUM_SHORTENED_FILE_NAME_LENGTH);
- }
-
- public void testShortenFileNameURLInt() throws Exception {
- if (Tools.osIsWindows()) {
- this.verifyShortenFileNameURLIntWin();
- } else {
- this.verifyShortenFileNameURLIntNonWin();
- }
- }
-
- private void verifyShortenFileNameURLIntWin() throws Exception {
- URL url = new URL("file", "", "/C:/Documents and Settings/Administrator/Desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(url, 31);
- assertEquals("C:\\...\\Desktop\\Project\\Text.txt", fileName);
- assertEquals(31, fileName.length());
- }
-
- private void verifyShortenFileNameURLIntNonWin() throws Exception {
- URL url = new URL("file", "", "/home/administrator/documents and settings/desktop/Project/Text.txt");
- String fileName = FileTools.shortenFileName(url, 31);
- assertEquals("/home/.../desktop/Project/Text.txt", fileName);
- assertEquals(34, fileName.length());
- }
-
- private void verifyUnchangedAbsoluteFile(String fileName, String dirName) {
- File file = new File(fileName);
- File dir = new File(dirName);
- File absoluteFile = FileTools.convertToAbsoluteFile(file, dir);
- assertEquals(file, absoluteFile);
- }
-
- private File buildTempDir() throws IOException {
- // build a new directory for each test, to prevent any cross-test effects
- File dir = FileTools.newTemporaryDirectory(this.getClass().getSimpleName() + "." + this.getName());
-
- File file0a = new File(dir, "file0a");
- file0a.createNewFile();
- File file0b = new File(dir, "file0b");
- file0b.createNewFile();
- File file0c = new File(dir, "file0c");
- file0c.createNewFile();
-
- File subdir1 = new File(dir, "subdir1");
- subdir1.mkdir();
- File file1a = new File(subdir1, "file1a");
- file1a.createNewFile();
- File file1b = new File(subdir1, "file1b");
- file1b.createNewFile();
-
- File subdir2 = new File(dir, "subdir2");
- subdir2.mkdir();
- File file2a = new File(subdir2, "file2a");
- file2a.createNewFile();
- File file2b = new File(subdir2, "file2b");
- file2b.createNewFile();
-
- File subdir3 = new File(subdir2, "subdir3");
- subdir3.mkdir();
- File file3a = new File(subdir3, "file3a");
- file3a.createNewFile();
- File file3b = new File(subdir3, "file3b");
- file3b.createNewFile();
-
- return dir;
- }
-
- private void deleteDir(File dir) {
- FileTools.deleteDirectory(dir);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/FilterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/FilterTests.java
deleted file mode 100644
index 44ec8ce09a..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/FilterTests.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.Filter;
-
-@SuppressWarnings("nls")
-public class FilterTests extends TestCase {
-
- public FilterTests(String name) {
- super(name);
- }
-
- public void testNullFilter() {
- Filter<String> filter = Filter.Transparent.instance();
- assertTrue(filter.accept(""));
- assertTrue(filter.accept("foo"));
- assertTrue(filter.accept("bar"));
- }
-
- public void testNullFilter_toString() {
- Filter<String> filter = Filter.Transparent.instance();
- assertNotNull(filter.toString());
- }
-
- public void testNullFilter_serialization() throws Exception {
- Filter<String> filter = Filter.Transparent.instance();
- assertSame(filter, TestTools.serialize(filter));
- }
-
- public void testOpaqueFilter() {
- Filter<String> filter = Filter.Opaque.instance();
- assertFalse(filter.accept(""));
- assertFalse(filter.accept("foo"));
- assertFalse(filter.accept("bar"));
- }
-
- public void testOpaqueFilter_toString() {
- Filter<String> filter = Filter.Opaque.instance();
- assertNotNull(filter.toString());
- }
-
- public void testOpaqueFilter_serialization() throws Exception {
- Filter<String> filter = Filter.Opaque.instance();
- assertSame(filter, TestTools.serialize(filter));
- }
-
- public void testDisabledFilter() {
- Filter<String> filter = Filter.Disabled.instance();
- boolean exCaught = false;
- try {
- assertFalse(filter.accept("foo"));
- fail();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testDisabledFilter_toString() {
- Filter<String> filter = Filter.Disabled.instance();
- assertNotNull(filter.toString());
- }
-
- public void testDisabledFilter_serialization() throws Exception {
- Filter<String> filter = Filter.Disabled.instance();
- assertSame(filter, TestTools.serialize(filter));
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/HashBagTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/HashBagTests.java
deleted file mode 100644
index df2a10bd28..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/HashBagTests.java
+++ /dev/null
@@ -1,555 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.Tools;
-
-@SuppressWarnings("nls")
-public class HashBagTests extends TestCase {
- private HashBag<String> bag;
-
- public HashBagTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.bag = this.buildBag();
- }
-
- private HashBag<String> buildBag() {
- HashBag<String> b = new HashBag<String>();
- b.add(null);
- b.add(new String("one"));
- b.add(new String("two"));
- b.add(new String("two"));
- b.add(new String("three"));
- b.add(new String("three"));
- b.add(new String("three"));
- b.add(new String("four"));
- b.add(new String("four"));
- b.add(new String("four"));
- b.add(new String("four"));
- return b;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- private Collection<String> buildCollection() {
- Collection<String> c = new ArrayList<String>();
- c.add(new String("foo"));
- c.add(new String("foo"));
- c.add(new String("bar"));
- c.add(new String("bar"));
- c.add(new String("bar"));
- return c;
- }
-
- public void testCtorCollection() {
- Collection<String> c = this.buildCollection();
- Bag<String> b = new HashBag<String>(c);
- for (String s : c) {
- assertTrue(b.contains(s));
- }
- }
-
- public void testCtorIntFloat() {
- boolean exCaught;
-
- exCaught = false;
- try {
- this.bag = new HashBag<String>(-20, 0.66f);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- this.bag = new HashBag<String>(20, -0.66f);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAdd() {
- // the other adds took place in setUp
- assertTrue(this.bag.add("five"));
-
- assertTrue(this.bag.contains("one"));
- assertTrue(this.bag.contains("two"));
- assertTrue(this.bag.contains("three"));
- assertTrue(this.bag.contains("four"));
- assertTrue(this.bag.contains("five"));
- }
-
- public void testAddCount() {
- // the other adds took place in setUp
- this.bag.add("minus3", -3);
- this.bag.add("zero", 0);
- this.bag.add("five", 5);
-
- assertFalse(this.bag.contains("minus3"));
- assertFalse(this.bag.contains("zero"));
- assertEquals(1, this.bag.count("one"));
- assertEquals(2, this.bag.count("two"));
- assertEquals(3, this.bag.count("three"));
- assertEquals(4, this.bag.count("four"));
- assertEquals(5, this.bag.count("five"));
-
- this.bag.add("three", 2);
- assertEquals(5, this.bag.count("three"));
- }
-
- public void testAddAll() {
- Collection<String> c = this.buildCollection();
- assertTrue(this.bag.addAll(c));
- for (String s : c) {
- assertTrue(this.bag.contains(s));
- }
- }
-
- public void testClear() {
- assertTrue(this.bag.contains("one"));
- assertTrue(this.bag.contains("two"));
- assertTrue(this.bag.contains("three"));
- assertTrue(this.bag.contains("four"));
- assertTrue(this.bag.contains(null));
- assertEquals(11, this.bag.size());
- this.bag.clear();
- assertFalse(this.bag.contains("one"));
- assertFalse(this.bag.contains("two"));
- assertFalse(this.bag.contains("three"));
- assertFalse(this.bag.contains("four"));
- assertFalse(this.bag.contains(null));
- assertEquals(0, this.bag.size());
- }
-
- public void testClone() {
- Bag<String> bag2 = this.bag.clone();
- assertTrue(this.bag != bag2);
- assertEquals(this.bag, bag2);
- assertTrue(this.bag.hashCode() == bag2.hashCode());
- }
-
- public void testContains() {
- assertTrue(this.bag.contains(null));
- assertTrue(this.bag.contains("one"));
- assertTrue(this.bag.contains("two"));
- assertTrue(this.bag.contains("three"));
- assertTrue(this.bag.contains("four"));
- assertTrue(this.bag.contains(new String("four")));
- assertTrue(this.bag.contains("fo" + "ur"));
- assertFalse(this.bag.contains("five"));
- }
-
- public void testContainsAll() {
- Collection<String> c = new ArrayList<String>();
- c.add(null);
- c.add(new String("one"));
- c.add(new String("two"));
- c.add(new String("three"));
- c.add(new String("four"));
- assertTrue(this.bag.containsAll(c));
- }
-
- public void testCount() {
- assertEquals(0, this.bag.count("zero"));
- assertEquals(1, this.bag.count("one"));
- assertEquals(2, this.bag.count("two"));
- assertEquals(3, this.bag.count("three"));
- assertEquals(4, this.bag.count("four"));
- assertEquals(0, this.bag.count("five"));
- }
-
- public void testEquals() {
- Bag<String> bag2 = this.buildBag();
- assertEquals(this.bag, bag2);
- bag2.add("five");
- assertFalse(this.bag.equals(bag2));
- Collection<String> c = new ArrayList<String>(this.bag);
- assertFalse(this.bag.equals(c));
- }
-
- public void testHashCode() {
- Bag<String> bag2 = this.buildBag();
- assertEquals(this.bag.hashCode(), bag2.hashCode());
- }
-
- public void testIsEmpty() {
- assertFalse(this.bag.isEmpty());
- this.bag.clear();
- assertTrue(this.bag.isEmpty());
- this.bag.add("foo");
- assertFalse(this.bag.isEmpty());
- }
-
- public void testEmptyIterator() {
- this.bag.clear();
- Iterator<String> iterator = this.bag.iterator();
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- fail(element.toString());
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testIterator() {
- int i = 0;
- Iterator<String> iterator = this.bag.iterator();
- assertTrue(iterator.hasNext());
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(11, i);
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- fail(element.toString());
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- iterator.remove();
- assertEquals(10, this.bag.size());
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.iterator();
- this.bag.add("five");
- exCaught = false;
- try {
- iterator.next();
- } catch (ConcurrentModificationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testUniqueIterator() {
- int i = 0;
- Iterator<String> iterator = this.bag.uniqueIterator();
- assertTrue(iterator.hasNext());
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(5, i);
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- fail(element.toString());
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.uniqueIterator();
- Object next = null;
- while (iterator.hasNext() && !"four".equals(next)) {
- next = iterator.next();
- }
- iterator.remove();
- assertEquals(7, this.bag.size());
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.uniqueIterator();
- this.bag.add("five");
- exCaught = false;
- try {
- iterator.next();
- } catch (ConcurrentModificationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testEntries() {
- int i = 0;
- Iterator<Bag.Entry<String>> iterator = this.bag.entries();
- assertTrue(iterator.hasNext());
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(5, i);
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- fail(element.toString());
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.entries();
- Bag.Entry<String> next = null;
- while (iterator.hasNext()) {
- next = iterator.next();
- if (next.getElement().equals("four")) {
- iterator.remove();
- break;
- }
- }
- assertEquals(7, this.bag.size());
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.entries();
- this.bag.add("five");
- exCaught = false;
- try {
- iterator.next();
- } catch (ConcurrentModificationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testHashingDistribution() throws Exception {
- Bag<String> bigBag = new HashBag<String>();
- for (int i = 0; i < 10000; i++) {
- bigBag.add("object" + i);
- }
-
- java.lang.reflect.Field field = bigBag.getClass().getDeclaredField("table");
- field.setAccessible(true);
- Object[] table = (Object[]) field.get(bigBag);
- int bucketCount = table.length;
- int filledBucketCount = 0;
- for (Object o : table) {
- if (o != null) {
- filledBucketCount++;
- }
- }
- float loadFactor = ((float) filledBucketCount) / ((float) bucketCount);
- if ((loadFactor < 0.20) || (loadFactor > 0.80)) {
- String msg = "poor load factor: " + loadFactor;
- if (Tools.jvmIsSun()) {
- fail(msg);
- } else {
- // poor load factor is seen in the Eclipse build environment for some reason...
- System.out.println(this.getClass().getName() + '.' + this.getName() + " - " + msg);
- TestTools.printSystemProperties();
- }
- }
- }
-
- public void testRemove() {
- assertTrue(this.bag.remove("one"));
- assertFalse(this.bag.contains("one"));
- assertFalse(this.bag.remove("one"));
-
- assertTrue(this.bag.remove("two"));
- assertTrue(this.bag.remove("two"));
- assertFalse(this.bag.contains("two"));
- assertFalse(this.bag.remove("two"));
- }
-
- public void testRemoveCount() {
- assertFalse(this.bag.remove("one", 0));
- assertTrue(this.bag.contains("one"));
-
- assertTrue(this.bag.remove("one", 1));
- assertFalse(this.bag.contains("one"));
- assertFalse(this.bag.remove("one"));
-
- assertFalse(this.bag.remove("two", -3));
- assertTrue(this.bag.remove("two", 1));
- assertTrue(this.bag.contains("two"));
-
- assertTrue(this.bag.remove("two", 1));
- assertFalse(this.bag.contains("two"));
- assertFalse(this.bag.remove("two"));
-
- assertTrue(this.bag.remove("three", 3));
- assertFalse(this.bag.contains("three"));
- assertFalse(this.bag.remove("three"));
- }
-
- public void testRemoveAll() {
- Collection<String> c = new ArrayList<String>();
- c.add("one");
- c.add("three");
- assertTrue(this.bag.removeAll(c));
- assertFalse(this.bag.contains("one"));
- assertFalse(this.bag.contains("three"));
- assertFalse(this.bag.remove("one"));
- assertFalse(this.bag.remove("three"));
- assertFalse(this.bag.removeAll(c));
- }
-
- public void testRetainAll() {
- Collection<String> c = new ArrayList<String>();
- c.add("one");
- c.add("three");
- assertTrue(this.bag.retainAll(c));
- assertTrue(this.bag.contains("one"));
- assertTrue(this.bag.contains("three"));
- assertFalse(this.bag.contains("two"));
- assertFalse(this.bag.contains("four"));
- assertFalse(this.bag.remove("two"));
- assertFalse(this.bag.remove("four"));
- assertFalse(this.bag.retainAll(c));
- }
-
- public void testSize() {
- assertTrue(this.bag.size() == 11);
- this.bag.add("five");
- this.bag.add("five");
- this.bag.add("five");
- this.bag.add("five");
- this.bag.add("five");
- assertEquals(16, this.bag.size());
- }
-
- public void testSerialization() throws Exception {
- Bag<String> bag2 = TestTools.serialize(this.bag);
-
- assertTrue("same object?", this.bag != bag2);
- assertEquals(11, bag2.size());
- assertEquals(this.bag, bag2);
- // look for similar elements
- assertTrue(bag2.contains(null));
- assertTrue(bag2.contains("one"));
- assertTrue(bag2.contains("two"));
- assertTrue(bag2.contains("three"));
- assertTrue(bag2.contains("four"));
-
- int nullCount = 0, oneCount = 0, twoCount = 0, threeCount = 0, fourCount = 0;
- for (String s : bag2) {
- if (s == null) {
- nullCount++;
- } else if (s.equals("one")) {
- oneCount++;
- } else if (s.equals("two")) {
- twoCount++;
- } else if (s.equals("three")) {
- threeCount++;
- } else if (s.equals("four")) {
- fourCount++;
- }
- }
- assertEquals(1, nullCount);
- assertEquals(1, oneCount);
- assertEquals(2, twoCount);
- assertEquals(3, threeCount);
- assertEquals(4, fourCount);
- }
-
- public void testToArray() {
- Object[] a = this.bag.toArray();
- assertEquals(11, a.length);
- assertTrue(ArrayTools.contains(a, null));
- assertTrue(ArrayTools.contains(a, "one"));
- assertTrue(ArrayTools.contains(a, "two"));
- assertTrue(ArrayTools.contains(a, "three"));
- assertTrue(ArrayTools.contains(a, "four"));
- }
-
- public void testToArrayObjectArray() {
- String[] a = new String[12];
- a[11] = "not null";
- String[] b = this.bag.toArray(a);
- assertEquals(a, b);
- assertEquals(12, a.length);
- assertTrue(ArrayTools.contains(a, null));
- assertTrue(ArrayTools.contains(a, "one"));
- assertTrue(ArrayTools.contains(a, "two"));
- assertTrue(ArrayTools.contains(a, "three"));
- assertTrue(ArrayTools.contains(a, "four"));
- assertTrue(a[11] == null);
- }
-
- public void testToString() {
- String s = this.bag.toString();
- assertTrue(s.startsWith("["));
- assertTrue(s.endsWith("]"));
- int commaCount = 0;
- for (int i = 0; i < s.length(); i++) {
- if (s.charAt(i) == ',') {
- commaCount++;
- }
- }
- assertEquals(10, commaCount);
- assertTrue(s.indexOf("one") != -1);
- assertTrue(s.indexOf("two") != -1);
- assertTrue(s.indexOf("three") != -1);
- assertTrue(s.indexOf("four") != -1);
- assertTrue(s.indexOf("null") != -1);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/IdentityHashBagTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/IdentityHashBagTests.java
deleted file mode 100644
index f1738bdeb5..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/IdentityHashBagTests.java
+++ /dev/null
@@ -1,573 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.IdentityHashBag;
-import org.eclipse.jpt.common.utility.internal.Tools;
-
-@SuppressWarnings("nls")
-public class IdentityHashBagTests extends TestCase {
- private IdentityHashBag<String> bag;
- private String one = "one";
- private String two = "two";
- private String three = "three";
- private String four = "four";
- private String foo = "foo";
- private String bar = "bar";
-
- public IdentityHashBagTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.bag = this.buildBag();
- }
-
- protected IdentityHashBag<String> buildBag() {
- IdentityHashBag<String> result = new IdentityHashBag<String>();
- result.add(null);
- result.add(this.one);
- result.add(this.two);
- result.add(this.two);
- result.add(this.three);
- result.add(this.three);
- result.add(this.three);
- result.add(this.four);
- result.add(this.four);
- result.add(this.four);
- result.add(this.four);
- return result;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- private Collection<String> buildCollection() {
- Collection<String> c = new ArrayList<String>();
- c.add(this.foo);
- c.add(this.foo);
- c.add(this.bar);
- c.add(this.bar);
- c.add(this.bar);
- return c;
- }
-
- public void testCtorCollection() {
- Collection<String> c = this.buildCollection();
- IdentityHashBag<String> localBag = new IdentityHashBag<String>(c);
- for (String s : c) {
- assertTrue(localBag.contains(s));
- }
- }
-
- public void testCtorIntFloat() {
- boolean exCaught;
-
- exCaught = false;
- try {
- this.bag = new IdentityHashBag<String>(-20, 0.66f);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue("IllegalArgumentException not thrown", exCaught);
-
- exCaught = false;
- try {
- this.bag = new IdentityHashBag<String>(20, -0.66f);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue("IllegalArgumentException not thrown", exCaught);
- }
-
- public void testAdd() {
- // the other adds took place in setUp
- String five = "five";
- assertTrue(this.bag.add(five));
-
- assertTrue(this.bag.contains(this.one));
- assertTrue(this.bag.contains(this.two));
- assertTrue(this.bag.contains(this.three));
- assertTrue(this.bag.contains(this.four));
- assertTrue(this.bag.contains(five));
- }
-
- public void testAddCount() {
- String minus3 = "minus3";
- String zero = "zero";
- String five = "five";
- // the other adds took place in setUp
- this.bag.add(minus3, -3);
- this.bag.add(zero, 0);
- this.bag.add(five, 5);
-
- assertFalse(this.bag.contains(minus3));
- assertFalse(this.bag.contains(zero));
- assertEquals(1, this.bag.count(this.one));
- assertEquals(2, this.bag.count(this.two));
- assertEquals(3, this.bag.count(this.three));
- assertEquals(4, this.bag.count(this.four));
- assertEquals(5, this.bag.count(five));
-
- this.bag.add(this.three, 2);
- assertEquals(5, this.bag.count(this.three));
- }
-
- public void testAddAll() {
- Collection<String> c = this.buildCollection();
- assertTrue(this.bag.addAll(c));
- for (String s : c) {
- assertTrue(this.bag.contains(s));
- }
- }
-
- public void testClear() {
- assertTrue(this.bag.contains(this.one));
- assertTrue(this.bag.contains(this.two));
- assertTrue(this.bag.contains(this.three));
- assertTrue(this.bag.contains(this.four));
- assertTrue(this.bag.contains(null));
- assertEquals(11, this.bag.size());
- this.bag.clear();
- assertFalse(this.bag.contains(this.one));
- assertFalse(this.bag.contains(this.two));
- assertFalse(this.bag.contains(this.three));
- assertFalse(this.bag.contains(this.four));
- assertFalse(this.bag.contains(null));
- assertEquals(0, this.bag.size());
- }
-
- public void testClone() {
- IdentityHashBag<String> bag2 = this.bag.clone();
- assertTrue("bad clone", this.bag != bag2);
- assertEquals("bad clone", this.bag, bag2);
- assertTrue("bad clone", this.bag.hashCode() == bag2.hashCode());
- }
-
- public void testContains() {
- assertTrue(this.bag.contains(null));
- assertTrue(this.bag.contains(this.one));
- assertTrue(this.bag.contains(this.two));
- assertTrue(this.bag.contains(this.three));
- assertTrue(this.bag.contains(this.four));
-
- assertFalse(this.bag.contains(new String("four")));
- assertFalse(this.bag.contains("five"));
- }
-
- public void testContainsAll() {
- Collection<String> c = new ArrayList<String>();
- c.add(null);
- c.add(this.one);
- c.add(this.two);
- c.add(this.three);
- c.add(this.four);
- assertTrue(this.bag.containsAll(c));
- c.add(new String(this.four));
- assertFalse(this.bag.containsAll(c));
- }
-
- public void testCount() {
- assertEquals(0, this.bag.count("zero"));
- assertEquals(1, this.bag.count("one"));
- assertEquals(2, this.bag.count("two"));
- assertEquals(3, this.bag.count("three"));
- assertEquals(4, this.bag.count("four"));
- assertEquals(0, this.bag.count("five"));
- }
-
- public void testEquals() {
- IdentityHashBag<String> bag2 = this.buildBag();
- assertEquals(this.bag, bag2);
- bag2.add("five");
- assertFalse(this.bag.equals(bag2));
- Collection<String> c = new ArrayList<String>(this.bag);
- assertFalse(this.bag.equals(c));
- }
-
- public void testHashCode() {
- IdentityHashBag<String> bag2 = this.buildBag();
- assertEquals(this.bag.hashCode(), bag2.hashCode());
- }
-
- public void testIsEmpty() {
- assertFalse(this.bag.isEmpty());
- this.bag.clear();
- assertTrue(this.bag.isEmpty());
- this.bag.add("foo");
- assertFalse(this.bag.isEmpty());
- }
-
- public void testEmptyIterator() {
- this.bag.clear();
- Iterator<String> iterator = this.bag.iterator();
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + element, exCaught);
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
-
- public void testIterator() {
- int i = 0;
- Iterator<String> iterator = this.bag.iterator();
- assertTrue(iterator.hasNext());
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(11, i);
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + element, exCaught);
-
- iterator.remove();
- assertEquals(10, this.bag.size());
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
-
- // start over
- iterator = this.bag.iterator();
- this.bag.add("five");
- exCaught = false;
- try {
- iterator.next();
- } catch (ConcurrentModificationException ex) {
- exCaught = true;
- }
- assertTrue("ConcurrentModificationException not thrown", exCaught);
- }
-
- public void testUniqueIterator() {
- int i = 0;
- Iterator<String> iterator = this.bag.uniqueIterator();
- assertTrue(iterator.hasNext());
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(5, i);
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- fail(element.toString());
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.uniqueIterator();
- Object next = null;
- while (iterator.hasNext() && !this.four.equals(next)) {
- next = iterator.next();
- }
- iterator.remove();
- assertEquals(7, this.bag.size());
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.uniqueIterator();
- String five = "five";
- this.bag.add(five);
- exCaught = false;
- try {
- iterator.next();
- } catch (ConcurrentModificationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testEntries() {
- int i = 0;
- Iterator<org.eclipse.jpt.common.utility.internal.Bag.Entry<String>> iterator = this.bag.entries();
- assertTrue(iterator.hasNext());
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(5, i);
- assertFalse(iterator.hasNext());
-
- boolean exCaught = false;
- Object element = null;
- try {
- element = iterator.next();
- fail(element.toString());
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.entries();
- org.eclipse.jpt.common.utility.internal.Bag.Entry<String> next = null;
- while (iterator.hasNext()) {
- next = iterator.next();
- if (next.getElement().equals(this.four)) {
- iterator.remove();
- break;
- }
- }
- assertEquals(7, this.bag.size());
-
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- // start over
- iterator = this.bag.entries();
- String five = "five";
- this.bag.add(five);
- exCaught = false;
- try {
- iterator.next();
- } catch (ConcurrentModificationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testHashingDistribution() throws Exception {
- IdentityHashBag<String> bigBag = new IdentityHashBag<String>();
- for (int i = 0; i < 10000; i++) {
- bigBag.add("object" + i);
- }
-
- java.lang.reflect.Field field = bigBag.getClass().getDeclaredField("table");
- field.setAccessible(true);
- Object[] table = (Object[]) field.get(bigBag);
- int bucketCount = table.length;
- int filledBucketCount = 0;
- for (int i = 0; i < bucketCount; i++) {
- if (table[i] != null) {
- filledBucketCount++;
- }
- }
- float loadFactor = ((float) filledBucketCount) / ((float) bucketCount);
- if ((loadFactor < 0.20) || (loadFactor > 0.80)) {
- String msg = "poor load factor: " + loadFactor;
- if (Tools.jvmIsSun()) {
- fail(msg);
- } else {
- // poor load factor is seen in the Eclipse build environment for some reason...
- System.out.println(this.getClass().getName() + '.' + this.getName() + " - " + msg);
- TestTools.printSystemProperties();
- }
- }
- }
-
- public void testRemove() {
- assertTrue(this.bag.remove(this.one));
- assertFalse(this.bag.contains(this.one));
- assertFalse(this.bag.remove(this.one));
-
- assertTrue(this.bag.remove(this.two));
- assertTrue(this.bag.remove(this.two));
- assertFalse(this.bag.contains(this.two));
- assertFalse(this.bag.remove(this.two));
-
- assertFalse(this.bag.remove(new String(this.three)));
- }
-
- public void testRemoveCount() {
- assertFalse(this.bag.remove(this.one, 0));
- assertTrue(this.bag.contains(this.one));
-
- assertTrue(this.bag.remove(this.one, 1));
- assertFalse(this.bag.contains(this.one));
- assertFalse(this.bag.remove(this.one));
-
- assertFalse(this.bag.remove(this.two, -3));
- assertTrue(this.bag.remove(this.two, 1));
- assertTrue(this.bag.contains(this.two));
-
- assertTrue(this.bag.remove(this.two, 1));
- assertFalse(this.bag.contains(this.two));
- assertFalse(this.bag.remove(this.two));
-
- assertTrue(this.bag.remove(this.three, 3));
- assertFalse(this.bag.contains(this.three));
- assertFalse(this.bag.remove(this.three));
- }
-
- public void testRemoveAll() {
- Collection<String> c = new ArrayList<String>();
- c.add(this.one);
- c.add(new String(this.two));
- c.add(this.three);
- assertTrue(this.bag.removeAll(c));
- assertFalse(this.bag.contains(this.one));
- assertTrue(this.bag.contains(this.two));
- assertFalse(this.bag.contains(this.three));
- assertFalse(this.bag.remove(this.one));
- assertTrue(this.bag.remove(this.two));
- assertFalse(this.bag.remove(this.three));
- assertFalse(this.bag.removeAll(c));
- }
-
- public void testRetainAll() {
- Collection<String> c = new ArrayList<String>();
- c.add(this.one);
- c.add(new String(this.two));
- c.add(this.three);
- assertTrue(this.bag.retainAll(c));
- assertTrue(this.bag.contains(this.one));
- assertFalse(this.bag.contains(this.two));
- assertTrue(this.bag.contains(this.three));
- assertFalse(this.bag.contains(this.four));
- assertFalse(this.bag.remove(this.two));
- assertFalse(this.bag.remove(this.four));
- assertFalse(this.bag.retainAll(c));
- }
-
- public void testSize() {
- assertTrue(this.bag.size() == 11);
- String five = "five";
- this.bag.add(five);
- this.bag.add(five);
- this.bag.add(five);
- this.bag.add(five);
- this.bag.add(new String(five));
- assertEquals(16, this.bag.size());
- }
-
- public void testSerialization() throws Exception {
- IdentityHashBag<String> bag2 = TestTools.serialize(this.bag);
-
- assertTrue("same object?", this.bag != bag2);
- assertEquals(11, bag2.size());
- assertEquals(CollectionTools.bag(this.bag.iterator()), CollectionTools.bag(bag2.iterator()));
- // look for similar elements
- assertTrue(CollectionTools.bag(bag2.iterator()).contains(null));
- assertTrue(CollectionTools.bag(bag2.iterator()).contains("one"));
- assertTrue(CollectionTools.bag(bag2.iterator()).contains("two"));
- assertTrue(CollectionTools.bag(bag2.iterator()).contains("three"));
- assertTrue(CollectionTools.bag(bag2.iterator()).contains("four"));
-
- int nullCount = 0, oneCount = 0, twoCount = 0, threeCount = 0, fourCount = 0;
- for (String next : bag2) {
- if (next == null)
- nullCount++;
- else if (next.equals("one"))
- oneCount++;
- else if (next.equals("two"))
- twoCount++;
- else if (next.equals("three"))
- threeCount++;
- else if (next.equals("four"))
- fourCount++;
- }
- assertEquals(1, nullCount);
- assertEquals(1, oneCount);
- assertEquals(2, twoCount);
- assertEquals(3, threeCount);
- assertEquals(4, fourCount);
- }
-
- public void testToArray() {
- Object[] a = this.bag.toArray();
- assertEquals(11, a.length);
- assertTrue(ArrayTools.contains(a, null));
- assertTrue(ArrayTools.contains(a, this.one));
- assertTrue(ArrayTools.contains(a, this.two));
- assertTrue(ArrayTools.contains(a, this.three));
- assertTrue(ArrayTools.contains(a, this.four));
- }
-
- public void testToArrayObjectArray() {
- String[] a = new String[12];
- a[11] = "not null";
- String[] b = this.bag.toArray(a);
- assertEquals(a, b);
- assertEquals(12, a.length);
- assertTrue(ArrayTools.contains(a, null));
- assertTrue(ArrayTools.contains(a, this.one));
- assertTrue(ArrayTools.contains(a, this.two));
- assertTrue(ArrayTools.contains(a, this.three));
- assertTrue(ArrayTools.contains(a, this.four));
- assertTrue(a[11] == null);
- }
-
- public void testToString() {
- String s = this.bag.toString();
- assertTrue(s.startsWith("["));
- assertTrue(s.endsWith("]"));
- int commaCount = 0;
- for (int i = 0; i < s.length(); i++) {
- if (s.charAt(i) == ',') {
- commaCount++;
- }
- }
- assertEquals("invalid number of commas", 10, commaCount);
- assertTrue(s.indexOf("one") != -1);
- assertTrue(s.indexOf("two") != -1);
- assertTrue(s.indexOf("three") != -1);
- assertTrue(s.indexOf("four") != -1);
- assertTrue(s.indexOf("null") != -1);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/IndentingPrintWriterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/IndentingPrintWriterTests.java
deleted file mode 100644
index 33d331b5f6..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/IndentingPrintWriterTests.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.io.StringWriter;
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.IndentingPrintWriter;
-
-@SuppressWarnings("nls")
-public class IndentingPrintWriterTests extends TestCase {
- StringWriter sw1;
- StringWriter sw2;
- IndentingPrintWriter ipw1;
- IndentingPrintWriter ipw2;
-
- static final String CR = System.getProperty("line.separator");
-
- public IndentingPrintWriterTests(String name) {
- super(name);
- }
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- this.sw1 = new StringWriter();
- this.ipw1 = new IndentingPrintWriter(this.sw1);
- this.sw2 = new StringWriter();
- this.ipw2 = new IndentingPrintWriter(this.sw2, " "); // indent with 4 spaces instead of a tab
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIndent() {
- assertEquals("wrong indent level", 0, this.ipw1.getIndentLevel());
- this.ipw1.indent();
- assertEquals("wrong indent level", 1, this.ipw1.getIndentLevel());
- }
-
- public void testUndent() {
- assertEquals("wrong indent level", 0, this.ipw1.getIndentLevel());
- this.ipw1.indent();
- assertEquals("wrong indent level", 1, this.ipw1.getIndentLevel());
- this.ipw1.undent();
- assertEquals("wrong indent level", 0, this.ipw1.getIndentLevel());
- }
-
- public void testIncrementIndentLevel() {
- assertEquals("wrong indent level", 0, this.ipw1.getIndentLevel());
- this.ipw1.incrementIndentLevel();
- assertEquals("wrong indent level", 1, this.ipw1.getIndentLevel());
- }
-
- public void testDecrementIndentLevel() {
- assertEquals("wrong indent level", 0, this.ipw1.getIndentLevel());
- this.ipw1.incrementIndentLevel();
- assertEquals("wrong indent level", 1, this.ipw1.getIndentLevel());
- this.ipw1.decrementIndentLevel();
- assertEquals("wrong indent level", 0, this.ipw1.getIndentLevel());
- }
-
- public void testPrintTab() {
- String expected = "foo0" + CR + "\tfoo1" + CR + "\tfoo1" + CR + "\t\tfoo2" + CR + "\tfoo1" + CR + "\tfoo1" + CR + "foo0" + CR;
-
- this.ipw1.println("foo0");
- this.ipw1.indent();
- this.ipw1.println("foo1");
- this.ipw1.println("foo1");
- this.ipw1.indent();
- this.ipw1.println("foo2");
- this.ipw1.undent();
- this.ipw1.println("foo1");
- this.ipw1.println("foo1");
- this.ipw1.undent();
- this.ipw1.println("foo0");
-
- assertEquals("bogus output", expected, this.sw1.toString());
- }
-
- public void testPrintSpaces() {
- String expected = "foo0" + CR + " foo1" + CR + " foo1" + CR + " foo2" + CR + " foo1" + CR + " foo1" + CR + "foo0" + CR;
-
- this.ipw2.println("foo0");
- this.ipw2.indent();
- this.ipw2.println("foo1");
- this.ipw2.println("foo1");
- this.ipw2.indent();
- this.ipw2.println("foo2");
- this.ipw2.undent();
- this.ipw2.println("foo1");
- this.ipw2.println("foo1");
- this.ipw2.undent();
- this.ipw2.println("foo0");
-
- assertEquals("bogus output", expected, this.sw2.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JDBCTypeTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JDBCTypeTests.java
deleted file mode 100644
index 7853463449..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JDBCTypeTests.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.sql.Types;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.JDBCType;
-
-@SuppressWarnings("nls")
-public class JDBCTypeTests extends TestCase {
-
- public JDBCTypeTests(String name) {
- super(name);
- }
-
- public void testTypesSize() {
- assertEquals(Types.class.getDeclaredFields().length, JDBCType.types().length);
- }
-
- public void testName() {
- JDBCType jdbcType;
- jdbcType = JDBCType.type(Types.VARCHAR);
- assertEquals("VARCHAR", jdbcType.name());
-
- jdbcType = JDBCType.type(Types.INTEGER);
- assertEquals("INTEGER", jdbcType.name());
- }
-
- public void testCode() {
- JDBCType jdbcType;
- jdbcType = JDBCType.type(Types.VARCHAR);
- assertEquals(Types.VARCHAR, jdbcType.code());
-
- jdbcType = JDBCType.type(Types.INTEGER);
- assertEquals(Types.INTEGER, jdbcType.code());
- }
-
- public void testInvalidTypeCode() throws Exception {
- boolean exCaught = false;
- try {
- JDBCType jdbcType = JDBCType.type(55);
- fail("invalid JDBCType: " + jdbcType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidTypeName() throws Exception {
- boolean exCaught = false;
- try {
- JDBCType jdbcType = JDBCType.type("VARCHAR2");
- fail("invalid JDBCType: " + jdbcType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JavaTypeTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JavaTypeTests.java
deleted file mode 100644
index da07a02a38..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JavaTypeTests.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.JavaType;
-import org.eclipse.jpt.common.utility.internal.SimpleJavaType;
-
-@SuppressWarnings("nls")
-public class JavaTypeTests extends TestCase {
-
- public JavaTypeTests(String name) {
- super(name);
- }
-
- public void testInvalidElementTypeNull() throws Exception {
- boolean exCaught = false;
- try {
- JavaType javaType = new SimpleJavaType(null, 0);
- fail("invalid JavaType: " + javaType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidElementTypeEmpty() throws Exception {
- boolean exCaught = false;
- try {
- JavaType javaType = new SimpleJavaType("", 0);
- fail("invalid JavaType: " + javaType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidElementTypeArray() throws Exception {
- boolean exCaught = false;
- try {
- JavaType javaType = new SimpleJavaType(java.lang.Object[].class.getName(), 0);
- fail("invalid JavaType: " + javaType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidArrayDepthNegative() throws Exception {
- boolean exCaught = false;
- try {
- JavaType javaType = new SimpleJavaType(java.lang.Object.class.getName(), -2);
- fail("invalid JavaType: " + javaType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidVoidArray() throws Exception {
- boolean exCaught = false;
- try {
- JavaType javaType = new SimpleJavaType(void.class.getName(), 2);
- fail("invalid JavaType: " + javaType);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testElementTypeName() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertEquals("java.lang.Object", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertEquals("java.lang.Object", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(int.class);
- assertEquals("int", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(int[].class);
- assertEquals("int", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(void.class);
- assertEquals("void", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertEquals("java.util.Map$Entry", javaType.getElementTypeName());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertEquals("java.util.Map$Entry", javaType.getElementTypeName());
- }
-
- public void testArrayDepth() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertEquals(0, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertEquals(1, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(int.class);
- assertEquals(0, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(int[].class);
- assertEquals(1, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(void.class);
- assertEquals(0, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertEquals(0, javaType.getArrayDepth());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertEquals(2, javaType.getArrayDepth());
- }
-
- public void testIsArray() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertFalse(javaType.isArray());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertTrue(javaType.isArray());
-
- javaType = new SimpleJavaType(int.class);
- assertFalse(javaType.isArray());
-
- javaType = new SimpleJavaType(int[].class);
- assertTrue(javaType.isArray());
-
- javaType = new SimpleJavaType(void.class);
- assertFalse(javaType.isArray());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertFalse(javaType.isArray());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertTrue(javaType.isArray());
- }
-
- public void testJavaClass() throws Exception {
- this.verifyJavaClass(java.lang.Object.class);
- this.verifyJavaClass(java.lang.Object[].class);
- this.verifyJavaClass(int.class);
- this.verifyJavaClass(int[].class);
- this.verifyJavaClass(void.class);
- this.verifyJavaClass(java.util.Map.Entry.class);
- this.verifyJavaClass(java.util.Map.Entry[][].class);
- }
-
- private void verifyJavaClass(Class<?> javaClass) throws Exception {
- JavaType javaType = new SimpleJavaType(javaClass);
- assertEquals(javaClass, javaType.getJavaClass());
- }
-
- public void testJavaClassName() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertEquals("java.lang.Object", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertEquals("[Ljava.lang.Object;", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(int.class);
- assertEquals("int", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(int[].class);
- assertEquals("[I", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(void.class);
- assertEquals("void", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertEquals("java.util.Map$Entry", javaType.getJavaClassName());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertEquals("[[Ljava.util.Map$Entry;", javaType.getJavaClassName());
- }
-
- public void testDescribes() throws Exception {
- this.verifyDescribes(java.lang.Object.class);
- this.verifyDescribes(java.lang.Object[].class);
- this.verifyDescribes(int.class);
- this.verifyDescribes(int[].class);
- this.verifyDescribes(void.class);
- this.verifyDescribes(java.util.Map.Entry.class);
- this.verifyDescribes(java.util.Map.Entry[][].class);
- }
-
- private void verifyDescribes(Class<?> javaClass) throws Exception {
- JavaType javaType = new SimpleJavaType(javaClass);
- assertTrue(javaType.describes(javaClass));
- }
-
- public void testDeclaration() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertEquals("java.lang.Object", javaType.declaration());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertEquals("java.lang.Object[]", javaType.declaration());
-
- javaType = new SimpleJavaType(int.class);
- assertEquals("int", javaType.declaration());
-
- javaType = new SimpleJavaType(int[].class);
- assertEquals("int[]", javaType.declaration());
-
- javaType = new SimpleJavaType(void.class);
- assertEquals("void", javaType.declaration());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertEquals("java.util.Map.Entry", javaType.declaration());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertEquals("java.util.Map.Entry[][]", javaType.declaration());
- }
-
- public void testIsPrimitive() throws Exception {
- JavaType javaType;
- javaType = new SimpleJavaType(java.lang.Object.class);
- assertFalse(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(java.lang.Object[].class);
- assertFalse(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(int.class);
- assertTrue(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(int[].class);
- assertFalse(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(void.class);
- assertTrue(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(java.util.Map.Entry.class);
- assertFalse(javaType.isPrimitive());
-
- javaType = new SimpleJavaType(java.util.Map.Entry[][].class);
- assertFalse(javaType.isPrimitive());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JptCommonUtilityTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JptCommonUtilityTests.java
deleted file mode 100644
index c62bad8a82..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/JptCommonUtilityTests.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.common.utility.tests.internal.command.JptUtilityCommandTests;
-import org.eclipse.jpt.common.utility.tests.internal.enumerations.JptUtilityEnumerationsTests;
-import org.eclipse.jpt.common.utility.tests.internal.iterables.JptUtilityIterablesTests;
-import org.eclipse.jpt.common.utility.tests.internal.iterators.JptUtilityIteratorsTests;
-import org.eclipse.jpt.common.utility.tests.internal.model.JptUtilityModelTests;
-import org.eclipse.jpt.common.utility.tests.internal.node.JptUtilityNodeTests;
-import org.eclipse.jpt.common.utility.tests.internal.synchronizers.JptUtilitySynchronizersTests;
-
-/**
- * decentralize test creation code
- */
-public class JptCommonUtilityTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptCommonUtilityTests.class.getPackage().getName());
-
- suite.addTest(JptUtilityCommandTests.suite());
- suite.addTest(JptUtilityEnumerationsTests.suite());
- suite.addTest(JptUtilityIterablesTests.suite());
- suite.addTest(JptUtilityIteratorsTests.suite());
- suite.addTest(JptUtilityModelTests.suite());
- suite.addTest(JptUtilityNodeTests.suite());
- suite.addTest(JptUtilitySynchronizersTests.suite());
-
- suite.addTestSuite(ArrayToolsTests.class);
- suite.addTestSuite(BagTests.class);
- suite.addTestSuite(BidiFilterTests.class);
- suite.addTestSuite(BidiStringConverterTests.class);
- suite.addTestSuite(BidiTransformerTests.class);
- suite.addTestSuite(BitToolsTests.class);
- suite.addTestSuite(SimpleBooleanReferenceTests.class);
- suite.addTestSuite(BooleanToolsTests.class);
- suite.addTestSuite(ClasspathTests.class);
- suite.addTestSuite(ClassNameTests.class);
- suite.addTestSuite(CollectionToolsTests.class);
- suite.addTestSuite(ExceptionHandlerTests.class);
- suite.addTestSuite(FileToolsTests.class);
- suite.addTestSuite(FilterTests.class);
- suite.addTestSuite(HashBagTests.class);
- suite.addTestSuite(IdentityHashBagTests.class);
- suite.addTestSuite(IndentingPrintWriterTests.class);
- suite.addTestSuite(SimpleIntReferenceTests.class);
- suite.addTestSuite(JavaTypeTests.class);
- suite.addTestSuite(JDBCTypeTests.class);
- suite.addTestSuite(KeyedSetTests.class);
- suite.addTestSuite(ListenerListTests.class);
- suite.addTestSuite(MethodSignatureTests.class);
- suite.addTestSuite(NameToolsTests.class);
- suite.addTestSuite(NotNullFilterTests.class);
- suite.addTestSuite(RangeTests.class);
- suite.addTestSuite(ReflectionToolsTests.class);
- suite.addTestSuite(ReverseComparatorTests.class);
- suite.addTestSuite(SimpleAssociationTests.class);
- suite.addTestSuite(SimpleObjectReferenceTests.class);
- suite.addTestSuite(SimpleQueueTests.class);
- suite.addTestSuite(SimpleStackTests.class);
- suite.addTestSuite(StringToolsTests.class);
- suite.addTestSuite(SynchronizedBooleanTests.class);
- suite.addTestSuite(SynchronizedIntTests.class);
- suite.addTestSuite(SynchronizedObjectTests.class);
- suite.addTestSuite(SynchronizedQueueTests.class);
- suite.addTestSuite(SynchronizedStackTests.class);
- suite.addTestSuite(ToolsTests.class);
- suite.addTestSuite(VersionComparatorTests.class);
- suite.addTestSuite(XMLStringEncoderTests.class);
-
- return suite;
- }
-
- private JptCommonUtilityTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/KeyedSetTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/KeyedSetTests.java
deleted file mode 100644
index 7c27e5d2a6..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/KeyedSetTests.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.KeyedSet;
-
-@SuppressWarnings("nls")
-public class KeyedSetTests
- extends TestCase {
-
- private KeyedSet<String, String> nicknames;
-
-
- public KeyedSetTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.nicknames = this.buildNicknames();
- }
-
- private KeyedSet<String, String> buildNicknames() {
- KeyedSet<String, String> ks = new KeyedSet<String, String>();
- ks.addItem("Jimmy", "James Sullivan");
- ks.addKey("Sully", "James Sullivan");
- ks.addItem("Bob", "Robert McKenna");
- ks.addKey("Mac", "Robert McKenna");
- return ks;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testAddItem() {
- // items added in setup
- assertTrue(this.nicknames.containsItem("James Sullivan"));
- assertTrue(this.nicknames.containsItem("Robert McKenna"));
-
- assertFalse(this.nicknames.containsItem("John Teasdale"));
- this.nicknames.addItem("Jack", "John Teasdale");
- assertTrue(this.nicknames.containsItem("John Teasdale"));
-
- this.nicknames.addItem("Teaser", "John Teasdale");
- assertTrue(this.nicknames.containsItem("John Teasdale"));
- assertTrue(this.nicknames.containsKey("Teaser"));
- }
-
- public void testAddKey() {
- // items added in setup
- assertTrue(this.nicknames.containsKey("Jimmy"));
- assertTrue(this.nicknames.containsKey("Sully"));
- assertTrue(this.nicknames.containsKey("Bob"));
- assertTrue(this.nicknames.containsKey("Mac"));
-
- assertFalse(this.nicknames.containsKey("Robbie"));
- this.nicknames.addKey("Robbie", "Robert McKenna");
- assertTrue(this.nicknames.containsKey("Robbie"));
-
- boolean exceptionCaught = false;
- try {
- this.nicknames.addKey("Teaser", "John Teasdale");
- }
- catch (IllegalArgumentException iae) {
- exceptionCaught = true;
- }
- assertTrue(exceptionCaught);
- }
-
- public void testGetItem() {
- // items added in setup
- assertEquals(this.nicknames.getItem("Jimmy"), "James Sullivan");
- assertEquals(this.nicknames.getItem("Sully"), "James Sullivan");
- assertEquals(this.nicknames.getItem("Bob"), "Robert McKenna");
- assertEquals(this.nicknames.getItem("Mac"), "Robert McKenna");
- assertNull(this.nicknames.getItem("Jack"));
- }
-
- public void testRemoveItem() {
- // items added in setup
- assertTrue(this.nicknames.containsItem("James Sullivan"));
- assertTrue(this.nicknames.containsKey("Jimmy"));
- assertTrue(this.nicknames.containsKey("Sully"));
-
- assertTrue(this.nicknames.removeItem("James Sullivan"));
- assertFalse(this.nicknames.containsItem("James Sullivan"));
- assertFalse(this.nicknames.containsKey("Jimmy"));
- assertFalse(this.nicknames.containsKey("Sully"));
-
- assertFalse(this.nicknames.removeItem("William Goldberg"));
- }
-
- public void testRemoveKey() {
- // items added in setup
- assertTrue(this.nicknames.containsItem("James Sullivan"));
- assertTrue(this.nicknames.containsKey("Jimmy"));
- assertTrue(this.nicknames.containsKey("Sully"));
-
- assertTrue(this.nicknames.removeKey("Jimmy"));
- assertTrue(this.nicknames.containsItem("James Sullivan"));
- assertFalse(this.nicknames.containsKey("Jimmy"));
- assertTrue(this.nicknames.containsKey("Sully"));
-
- assertTrue(this.nicknames.removeKey("Sully"));
- assertFalse(this.nicknames.containsItem("James Sullivan"));
- assertFalse(this.nicknames.containsKey("Jimmy"));
- assertFalse(this.nicknames.containsKey("Sully"));
-
- assertFalse(this.nicknames.removeKey("Billy"));
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ListenerListTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ListenerListTests.java
deleted file mode 100644
index 7dd0f52e9f..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ListenerListTests.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.io.Serializable;
-import java.util.EventListener;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-import org.eclipse.jpt.common.utility.internal.Tools;
-
-@SuppressWarnings("nls")
-public class ListenerListTests extends TestCase {
-
- public ListenerListTests(String name) {
- super(name);
- }
-
- public void testGetListeners() throws Exception {
- ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
- Listener listener1 = new LocalListener();
- Listener listener2 = new LocalListener();
- Iterable<Listener> listeners = listenerList.getListeners();
- assertEquals(0, CollectionTools.size(listeners));
-
- listenerList.add(listener1);
- listenerList.add(listener2);
- listeners = listenerList.getListeners();
- assertEquals(2, CollectionTools.size(listeners));
- assertTrue(CollectionTools.contains(listeners, listener1));
- assertTrue(CollectionTools.contains(listeners, listener2));
- }
-
- public void testSize() throws Exception {
- ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
- Listener listener1 = new LocalListener();
- Listener listener2 = new LocalListener();
- assertEquals(0, listenerList.size());
-
- listenerList.add(listener1);
- listenerList.add(listener2);
- assertEquals(2, listenerList.size());
- }
-
- public void testIsEmpty() throws Exception {
- ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
- Listener listener1 = new LocalListener();
- Listener listener2 = new LocalListener();
- assertTrue(listenerList.isEmpty());
-
- listenerList.add(listener1);
- listenerList.add(listener2);
- assertFalse(listenerList.isEmpty());
- }
-
- public void testAdd_null() throws Exception {
- ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
- boolean exCaught = false;
- try {
- listenerList.add(null);
- fail("invalid listener list: " + listenerList);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAdd_duplicate() throws Exception {
- ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
- Listener listener = new LocalListener();
- listenerList.add(listener);
-
- boolean exCaught = false;
- try {
- listenerList.add(listener);
- fail("invalid listener list: " + listenerList);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemove() throws Exception {
- ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
- Listener listener1 = new LocalListener();
- Listener listener2 = new LocalListener();
- listenerList.add(listener1);
- listenerList.add(listener2);
- assertTrue(CollectionTools.contains(listenerList.getListeners(), listener1));
- assertTrue(CollectionTools.contains(listenerList.getListeners(), listener2));
-
- listenerList.remove(listener1);
- assertFalse(CollectionTools.contains(listenerList.getListeners(), listener1));
- assertTrue(CollectionTools.contains(listenerList.getListeners(), listener2));
-
- listenerList.remove(listener2);
- assertFalse(CollectionTools.contains(listenerList.getListeners(), listener2));
- }
-
- public void testRemove_null() throws Exception {
- ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
- boolean exCaught = false;
- try {
- listenerList.remove(null);
- fail("invalid listener list: " + listenerList);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemove_unregistered() throws Exception {
- ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
- Listener listener = new LocalListener();
- listenerList.add(listener);
- listenerList.remove(listener);
-
- boolean exCaught = false;
- try {
- listenerList.remove(listener);
- fail("invalid listener list: " + listenerList);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testClear() throws Exception {
- ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
- Listener listener1 = new LocalListener();
- Listener listener2 = new LocalListener();
- listenerList.add(listener1);
- listenerList.add(listener2);
- assertTrue(CollectionTools.contains(listenerList.getListeners(), listener1));
- assertTrue(CollectionTools.contains(listenerList.getListeners(), listener2));
-
- listenerList.clear();
- assertFalse(CollectionTools.contains(listenerList.getListeners(), listener1));
- assertFalse(CollectionTools.contains(listenerList.getListeners(), listener2));
- }
-
- public void testSerialization() throws Exception {
- // This test doesn't pass in the Eclipse build environment (Linux/IBM VM) for some reason
- if (Tools.jvmIsSun()) {
- this.verifySerialization();
- }
- }
-
- private void verifySerialization() throws Exception {
- ListenerList<Listener> listenerList = new ListenerList<Listener>(Listener.class);
- Listener listener1 = new LocalListener();
- Listener listener2 = new LocalListener();
- listenerList.add(listener1);
- listenerList.add(listener2);
-
- ListenerList<Listener> listenerList2 = TestTools.serialize(listenerList);
- assertNotSame(listenerList, listenerList2);
- assertEquals(2, listenerList2.size());
-
- Listener listener3 = new NonSerializableListener();
- listenerList.add(listener3);
-
- listenerList2 = TestTools.serialize(listenerList);
- assertNotSame(listenerList, listenerList2);
- assertEquals(2, listenerList2.size());
-
- }
-
- interface Listener extends EventListener {
- void somethingHappened();
- }
-
- static class LocalListener implements Listener, Serializable {
- public void somethingHappened() {
- // do nothing
- }
- }
-
- static class NonSerializableListener implements Listener {
- public void somethingHappened() {
- // do nothing
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/MethodSignatureTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/MethodSignatureTests.java
deleted file mode 100644
index 6558e2f45f..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/MethodSignatureTests.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.JavaType;
-import org.eclipse.jpt.common.utility.MethodSignature;
-import org.eclipse.jpt.common.utility.internal.SimpleJavaType;
-import org.eclipse.jpt.common.utility.internal.SimpleMethodSignature;
-
-@SuppressWarnings("nls")
-public class MethodSignatureTests extends TestCase {
-
- public MethodSignatureTests(String name) {
- super(name);
- }
-
- public void testInvalidNameNull() throws Exception {
- boolean exCaught = false;
- try {
- MethodSignature methodSignature = new SimpleMethodSignature((String) null);
- fail("invalid MethodSignature: " + methodSignature);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidNameEmpty() throws Exception {
- boolean exCaught = false;
- try {
- MethodSignature methodSignature = new SimpleMethodSignature("");
- fail("invalid MethodSignature: " + methodSignature);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidParameterTypesNull() throws Exception {
- boolean exCaught = false;
- try {
- MethodSignature methodSignature = new SimpleMethodSignature("foo", (JavaType[]) null);
- fail("invalid MethodSignature: " + methodSignature);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidParameterTypesNullItem() throws Exception {
- boolean exCaught = false;
- try {
- MethodSignature methodSignature = new SimpleMethodSignature("foo", new JavaType[1]);
- fail("invalid MethodSignature: " + methodSignature);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidParameterTypesVoidItem() throws Exception {
- JavaType jt = new SimpleJavaType(void.class.getName());
- boolean exCaught = false;
- try {
- MethodSignature methodSignature = new SimpleMethodSignature("foo", new JavaType[] {jt});
- fail("invalid MethodSignature: " + methodSignature);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidParameterTypeNamesNull() throws Exception {
- boolean exCaught = false;
- try {
- MethodSignature methodSignature = new SimpleMethodSignature("foo", (String[]) null);
- fail("invalid MethodSignature: " + methodSignature);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidParameterTypeNamesNullItem() throws Exception {
- boolean exCaught = false;
- try {
- MethodSignature methodSignature = new SimpleMethodSignature("foo", new String[1]);
- fail("invalid MethodSignature: " + methodSignature);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidParameterJavaClassesNull() throws Exception {
- boolean exCaught = false;
- try {
- MethodSignature methodSignature = new SimpleMethodSignature("foo", (Class<?>[]) null);
- fail("invalid MethodSignature: " + methodSignature);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidParameterJavaClassesNullItem() throws Exception {
- boolean exCaught = false;
- try {
- MethodSignature methodSignature = new SimpleMethodSignature("foo", new Class[1]);
- fail("invalid MethodSignature: " + methodSignature);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testGetSignature0() throws Exception {
- MethodSignature ms = new SimpleMethodSignature(this.getMethod("method0"));
- assertEquals("method0()", ms.getSignature());
- }
-
- public void testGetSignature1() throws Exception {
- MethodSignature ms = new SimpleMethodSignature(this.getMethod("method1"));
- assertEquals("method1(int)", ms.getSignature());
- }
-
- public void testGetSignature2() throws Exception {
- MethodSignature ms = new SimpleMethodSignature(this.getMethod("method2"));
- assertEquals("method2(int, java.lang.String)", ms.getSignature());
- }
-
- public void testGetSignature3() throws Exception {
- MethodSignature ms = new SimpleMethodSignature(this.getMethod("method3"));
- assertEquals("method3(int, java.lang.String, java.lang.Object[][])", ms.getSignature());
- }
-
- public void testGetName() throws Exception {
- MethodSignature ms = new SimpleMethodSignature(this.getMethod("method2"));
- assertEquals("method2", ms.getName());
- }
-
- public void testGetParameterTypes() throws Exception {
- MethodSignature ms = new SimpleMethodSignature(this.getMethod("method3"));
- JavaType[] expected = new JavaType[3];
- expected[0] = new SimpleJavaType("int");
- expected[1] = new SimpleJavaType("java.lang.String");
- expected[2] = new SimpleJavaType("java.lang.Object", 2);
- assertTrue(Arrays.equals(expected, ms.getParameterTypes()));
- }
-
- public void testEquals() throws Exception {
- Object ms1 = new SimpleMethodSignature(this.getMethod("method3"));
- Object ms2 = new SimpleMethodSignature(this.getMethod("method3"));
- assertNotSame(ms1, ms2);
- assertEquals(ms1, ms1);
- assertEquals(ms1, ms2);
- assertEquals(ms1.hashCode(), ms2.hashCode());
-
- Object ms3 = new SimpleMethodSignature(this.getMethod("method2"));
- assertNotSame(ms1, ms3);
- assertFalse(ms1.equals(ms3));
- }
-
- public void testClone() throws Exception {
- SimpleMethodSignature ms1 = new SimpleMethodSignature(this.getMethod("method3"));
- SimpleMethodSignature ms2 = (SimpleMethodSignature) ms1.clone();
- assertNotSame(ms1, ms2);
- assertEquals(ms1, ms2);
- }
-
- public void testSerialization() throws Exception {
- SimpleMethodSignature ms1 = new SimpleMethodSignature(this.getMethod("method3"));
- SimpleMethodSignature ms2 = TestTools.serialize(ms1);
- assertNotSame(ms1, ms2);
- assertEquals(ms1, ms2);
- }
-
- private Method getMethod(String methodName) {
- for (Method method : this.getClass().getMethods()) {
- if (method.getName().equals(methodName)) {
- return method;
- }
- }
- throw new IllegalArgumentException("method not found: " + methodName);
- }
-
- public void method0() { /* used by tests */ }
- @SuppressWarnings("unused") public void method1(int foo) { /* used by tests */ }
- @SuppressWarnings("unused") public void method2(int foo, String bar) { /* used by tests */ }
- @SuppressWarnings("unused") public void method3(int foo, String bar, Object[][] baz) { /* used by tests */ }
-
- @SuppressWarnings("unused") public void methodA(int foo, String bar) { /* used by tests */ }
- @SuppressWarnings("unused") public void methodA(int foo, String bar, String baz) { /* used by tests */ }
-
- @SuppressWarnings("unused") public void methodB(int foo, Object bar) { /* used by tests */ }
- @SuppressWarnings("unused") public void methodB(int foo, String bar) { /* used by tests */ }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/MultiThreadedTestCase.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/MultiThreadedTestCase.java
deleted file mode 100644
index 749253a198..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/MultiThreadedTestCase.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.util.ArrayList;
-import java.util.Vector;
-import java.util.concurrent.ThreadFactory;
-
-import org.eclipse.jpt.common.utility.internal.CompositeException;
-
-import junit.framework.TestCase;
-
-/**
- * This test case helps simplify the testing of multi-threaded code.
- */
-@SuppressWarnings("nls")
-public abstract class MultiThreadedTestCase
- extends TestCase
-{
- private final ArrayList<Thread> threads = new ArrayList<Thread>();
- /* private */ final Vector<Throwable> exceptions = new Vector<Throwable>();
-
- /**
- * The default "tick" is one second.
- * Specify the appropriate system property to override.
- */
- public static final String TICK_SYSTEM_PROPERTY_NAME = "org.eclipse.jpt.common.utility.tests.tick";
- public static final long TICK = Long.getLong(TICK_SYSTEM_PROPERTY_NAME, 1000).longValue();
- public static final long TWO_TICKS = 2 * TICK;
- public static final long THREE_TICKS = 3 * TICK;
-
- /**
- * Default constructor.
- */
- public MultiThreadedTestCase() {
- super();
- }
-
- /**
- * Named constructor.
- */
- public MultiThreadedTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * Stop all the threads constructed during the test case.
- * If any exceptions were thrown by the threads, re-throw them here.
- */
- @Override
- protected void tearDown() throws Exception {
- for (Thread thread : this.threads) {
- if (thread.isAlive()) {
- throw new IllegalStateException("thread is still alive: " + thread);
- }
- }
- if ( ! this.exceptions.isEmpty()) {
- throw new CompositeException(this.exceptions);
- }
- TestTools.clear(this);
- super.tearDown();
- }
-
- protected Thread buildThread(Runnable runnable) {
- return this.buildThread(runnable, null);
- }
-
- protected Thread buildThread(Runnable runnable, String name) {
- Thread thread = new Thread(new RunnableWrapper(runnable));
- if (name != null) {
- thread.setName(name);
- }
- this.threads.add(thread);
- return thread;
- }
-
- protected ThreadFactory buildThreadFactory() {
- return new TestThreadFactory();
- }
-
- /**
- * Convenience method that handles {@link InterruptedException}.
- */
- public void sleep(long millis) {
- TestTools.sleep(millis);
- }
-
-
- /**
- * Wrap a runnable and log any exception it throws.
- */
- public class TestThreadFactory implements ThreadFactory {
- public Thread newThread(Runnable r) {
- return MultiThreadedTestCase.this.buildThread(r);
- }
- }
-
- /**
- * Simplify runnables that execute call that throws checked exceptions.
- */
- public abstract class TestRunnable implements Runnable {
- public final void run() {
- try {
- this.run_();
- } catch (Throwable ex) {
- throw new RuntimeException(ex);
- }
- }
- protected abstract void run_() throws Throwable;
- }
-
- /**
- * Wrap a runnable and log any exception it throws.
- */
- private class RunnableWrapper implements Runnable {
- private final Runnable runnable;
- RunnableWrapper(Runnable runnable) {
- super();
- this.runnable = runnable;
- }
- public void run() {
- try {
- this.runnable.run();
- } catch (RuntimeException ex) {
- MultiThreadedTestCase.this.exceptions.add(ex);
- }
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/NameToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/NameToolsTests.java
deleted file mode 100644
index d486aab6b7..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/NameToolsTests.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.NameTools;
-
-@SuppressWarnings("nls")
-public class NameToolsTests extends TestCase {
-
- public NameToolsTests(String name) {
- super(name);
- }
-
- public void testStringAbsentIgnoreCase() {
- List<String> colorCollection = this.buildColorCollection();
- String returned = NameTools.uniqueNameForIgnoreCase("Taupe", colorCollection);
- assertEquals("Taupe", returned);
- }
-
- public void testStringPresentCaseDiffers() {
- List<String> colorCollection = this.buildColorCollection();
- String returned = NameTools.uniqueNameFor("green", colorCollection);
- assertEquals("green", returned);
- }
-
- public void testStringPresentIgnoreCase() {
- List<String> colorCollection = this.buildColorCollection();
- String returned = NameTools.uniqueNameForIgnoreCase("green", colorCollection);
- assertEquals("green2", returned);
- }
-
- public void testStringPresentWithAppendices() {
- List<String> colorCollection = this.buildColorCollection();
- colorCollection.add("Red1");
- colorCollection.add("red2");
- String returned = NameTools.uniqueNameForIgnoreCase("red", colorCollection);
- colorCollection.remove("Red1");
- colorCollection.remove("red2");
- assertEquals("red3", returned);
- }
-
- private List<String> buildColorCollection() {
- List<String> colorCollection = new ArrayList<String>();
- colorCollection.add("Red");
- colorCollection.add("Orange");
- colorCollection.add("Yellow");
- colorCollection.add("Green");
- colorCollection.add("Blue");
- colorCollection.add("Indigo");
- colorCollection.add("Violet");
- return colorCollection;
- }
-
- public void testUniqueNameForCollection1() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("Oracle Corporation");
- strings.add("Oracle2");
- strings.add("oracle1");
- strings.add("Oracl");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings));
- assertEquals("Test", NameTools.uniqueNameFor("Test", strings));
-
- assertEquals("Oracle3", NameTools.uniqueNameForIgnoreCase("Oracle", strings));
- assertEquals("oracle3", NameTools.uniqueNameForIgnoreCase("oracle", strings));
- assertEquals("Test", NameTools.uniqueNameForIgnoreCase("Test", strings));
- }
-
- public void testUniqueNameForCollection2() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("oracle");
- strings.add("Oracle2");
- strings.add("Oracle1");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings));
- assertEquals("Test", NameTools.uniqueNameFor("Test", strings));
-
- strings.add("Oracle Corporation");
- assertEquals("Oracle3", NameTools.uniqueNameForIgnoreCase("Oracle", strings));
- assertEquals("oracle3", NameTools.uniqueNameForIgnoreCase("oracle", strings));
- assertEquals("Test", NameTools.uniqueNameForIgnoreCase("Test", strings));
- }
-
- public void testUniqueNameForCollection3() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("Oracle");
- strings.add("Oracle2");
- strings.add("Oracle1");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings));
- }
-
- public void testUniqueNameForIterator1() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("Oracle Corporation");
- strings.add("Oracle2");
- strings.add("oracle1");
- strings.add("Oracl");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings.iterator()));
- assertEquals("Test", NameTools.uniqueNameFor("Test", strings.iterator()));
-
- assertEquals("Oracle3", NameTools.uniqueNameForIgnoreCase("Oracle", strings.iterator()));
- assertEquals("oracle3", NameTools.uniqueNameForIgnoreCase("oracle", strings.iterator()));
- assertEquals("Test", NameTools.uniqueNameForIgnoreCase("Test", strings.iterator()));
- }
-
- public void testUniqueNameForIterator2() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("oracle");
- strings.add("Oracle2");
- strings.add("Oracle1");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings.iterator()));
- assertEquals("Test", NameTools.uniqueNameFor("Test", strings.iterator()));
-
- strings.add("Oracle Corporation");
- assertEquals("Oracle3", NameTools.uniqueNameForIgnoreCase("Oracle", strings.iterator()));
- assertEquals("oracle3", NameTools.uniqueNameForIgnoreCase("oracle", strings.iterator()));
- assertEquals("Test", NameTools.uniqueNameForIgnoreCase("Test", strings.iterator()));
- }
-
- public void testUniqueNameForIterator3() {
- Collection<String> strings = new ArrayList<String>();
- strings.add("Oracle");
- strings.add("Oracle");
- strings.add("Oracle2");
- strings.add("Oracle1");
-
- assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings.iterator()));
- }
-
- public void testBuildQualifiedDatabaseObjectName() {
- assertEquals("catalog.schema.name", NameTools.buildQualifiedDatabaseObjectName("catalog", "schema", "name"));
- assertEquals("catalog..name", NameTools.buildQualifiedDatabaseObjectName("catalog", null, "name"));
- assertEquals("schema.name", NameTools.buildQualifiedDatabaseObjectName(null, "schema", "name"));
- assertEquals("name", NameTools.buildQualifiedDatabaseObjectName(null, null, "name"));
- }
-
- public void testJavaReservedWords() {
- assertTrue(CollectionTools.contains(NameTools.javaReservedWords(), "class"));
- assertFalse(CollectionTools.contains(NameTools.javaReservedWords(), "Class"));
- assertTrue(CollectionTools.contains(NameTools.javaReservedWords(), "private"));
- }
-
- public void testconvertToJavaIdentifierString() {
- assertEquals("foo", NameTools.convertToJavaIdentifier("foo"));
- assertEquals("foo1", NameTools.convertToJavaIdentifier("foo1"));
- assertEquals("private_", NameTools.convertToJavaIdentifier("private"));
- assertEquals("throw_", NameTools.convertToJavaIdentifier("throw"));
- assertEquals("_foo", NameTools.convertToJavaIdentifier("1foo"));
- assertEquals("foo_", NameTools.convertToJavaIdentifier("foo%"));
- assertEquals("foo__bar__", NameTools.convertToJavaIdentifier("foo bar "));
- }
-
- public void testconvertToJavaIdentifierStringChar() {
- assertEquals("foo", NameTools.convertToJavaIdentifier("foo", '$'));
- assertEquals("foo1", NameTools.convertToJavaIdentifier("foo1", '$'));
- assertEquals("private$", NameTools.convertToJavaIdentifier("private", '$'));
- assertEquals("throwss", NameTools.convertToJavaIdentifier("throw", 's'));
- assertEquals("$foo", NameTools.convertToJavaIdentifier("1foo", '$'));
- assertEquals("foo$", NameTools.convertToJavaIdentifier("foo%", '$'));
- assertEquals("foo$$bar$$", NameTools.convertToJavaIdentifier("foo bar ", '$'));
-
- boolean exCaught = false;
- try {
- String s = NameTools.convertToJavaIdentifier("1foo", '7');
- fail("invalid string: \"" + s + "\"");
- } catch (IllegalArgumentException ex) {
- if (ex.getMessage().indexOf('7') != -1) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- String s = NameTools.convertToJavaIdentifier("foo%", '^');
- fail("invalid string: \"" + s + "\"");
- } catch (IllegalArgumentException ex) {
- if (ex.getMessage().indexOf('^') != -1) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- String s = NameTools.convertToJavaIdentifier("private", '^');
- fail("invalid string: \"" + s + "\"");
- } catch (IllegalArgumentException ex) {
- if (ex.getMessage().indexOf('^') != -1) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
-
- }
-
- public void testStringIsLegalJavaIdentifier() {
- assertFalse(NameTools.stringIsLegalJavaIdentifier("class"));
- assertTrue(NameTools.stringIsLegalJavaIdentifier("clasS"));
-
- assertFalse(NameTools.stringIsLegalJavaIdentifier("7foo"));
- assertFalse(NameTools.stringIsLegalJavaIdentifier("foo@bar"));
- assertTrue(NameTools.stringIsLegalJavaIdentifier("_foo"));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/NotNullFilterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/NotNullFilterTests.java
deleted file mode 100644
index caf06708ae..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/NotNullFilterTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.NotNullFilter;
-
-@SuppressWarnings("nls")
-public class NotNullFilterTests extends TestCase {
-
- public NotNullFilterTests(String name) {
- super(name);
- }
-
- public void testNotNullFilter() {
- Filter<String> filter = NotNullFilter.instance();
- assertTrue(filter.accept(""));
- assertFalse(filter.accept(null));
- assertTrue(filter.accept("foo"));
- assertTrue(filter.accept("bar"));
- }
-
- public void testToString() {
- Filter<String> filter = NotNullFilter.instance();
- assertNotNull(filter.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/RangeTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/RangeTests.java
deleted file mode 100644
index dcd959295a..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/RangeTests.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.Range;
-
-public class RangeTests extends TestCase {
-
- public RangeTests(String name) {
- super(name);
- }
-
- public void testIncludes() {
- Range range = new Range(5, 17);
- assertFalse(range.includes(-55));
- assertFalse(range.includes(0));
- assertFalse(range.includes(4));
- assertTrue(range.includes(5));
- assertTrue(range.includes(6));
- assertTrue(range.includes(16));
- assertTrue(range.includes(17));
- assertFalse(range.includes(18));
- assertFalse(range.includes(200));
- }
-
- public void testEquals() {
- Range range1 = new Range(5, 17);
- Range range2 = new Range(5, 17);
- assertNotSame(range1, range2);
- assertEquals(range1, range1);
- assertEquals(range1, range2);
- assertEquals(range2, range1);
- assertEquals(range1.hashCode(), range2.hashCode());
-
- range2 = new Range(17, 5);
- assertFalse(range1.equals(range2));
- assertFalse(range2.equals(range1));
- // although they are unequal, they can have the same hash code
- assertEquals(range1.hashCode(), range2.hashCode());
-
- range2 = new Range(5, 15);
- assertFalse(range1.equals(range2));
- assertFalse(range2.equals(range1));
- }
-
- public void testClone() {
- Range range1 = new Range(5, 17);
- Range range2 = range1.clone();
- assertNotSame(range1, range2);
- assertEquals(range1, range1);
- assertEquals(range1, range2);
- assertEquals(range2, range1);
- assertEquals(range1.hashCode(), range2.hashCode());
- }
-
- public void testSerialization() throws Exception {
- Range range1 = new Range(5, 17);
- Range range2 = TestTools.serialize(range1);
- assertNotSame(range1, range2);
- assertEquals(range1, range1);
- assertEquals(range1, range2);
- assertEquals(range2, range1);
- assertEquals(range1.hashCode(), range2.hashCode());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ReflectionToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ReflectionToolsTests.java
deleted file mode 100644
index d210cb0f5f..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ReflectionToolsTests.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-
-@SuppressWarnings("nls")
-public class ReflectionToolsTests extends TestCase {
-
- private static String testStaticField;
-
- public ReflectionToolsTests(String name) {
- super(name);
- }
-
-// this is no longer true - it appears the JLS now defines the generated names...
-// /**
-// * Return the compiler-generated class name. The Eclipse compiler generates
-// * "local" classes with names in the form "com.foo.Outer$1$Local"; while the
-// * JDK compiler generates "com.foo.Outer$1Local". There might be other
-// * differences.... ~bjv
-// */
-// public static String compilerDependentClassNameFor(String className) {
-// int index = className.indexOf("$1$");
-// if (index == -1) {
-// return className;
-// }
-// try {
-// Class.forName(className);
-// } catch (ClassNotFoundException ex) {
-// return className.substring(0, index + 2) + className.substring(index + 3);
-// }
-// return className;
-// }
-//
-// private static String munge(String className) {
-// return compilerDependentClassNameFor(className);
-// }
-
- public void testAllFields() {
- int fieldCount = 0;
- fieldCount += java.util.Vector.class.getDeclaredFields().length;
- fieldCount += java.util.AbstractList.class.getDeclaredFields().length;
- fieldCount += java.util.AbstractCollection.class.getDeclaredFields().length;
- fieldCount += java.lang.Object.class.getDeclaredFields().length;
- Iterable<Field> fields = ReflectionTools.getAllFields(java.util.Vector.class);
- assertEquals(fieldCount, CollectionTools.size(fields));
- assertTrue(CollectionTools.contains(this.fieldNames(fields), "modCount"));
- assertTrue(CollectionTools.contains(this.fieldNames(fields), "serialVersionUID"));
- assertTrue(CollectionTools.contains(this.fieldNames(fields), "capacityIncrement"));
- assertTrue(CollectionTools.contains(this.fieldNames(fields), "elementCount"));
- assertTrue(CollectionTools.contains(this.fieldNames(fields), "elementData"));
- assertTrue(fields.iterator().next().isAccessible());
- }
-
- public void testAllMethods() {
- int methodCount = 0;
- methodCount += java.util.Vector.class.getDeclaredMethods().length;
- methodCount += java.util.AbstractList.class.getDeclaredMethods().length;
- methodCount += java.util.AbstractCollection.class.getDeclaredMethods().length;
- methodCount += java.lang.Object.class.getDeclaredMethods().length;
- Iterable<Method> methods = ReflectionTools.getAllMethods(java.util.Vector.class);
- assertEquals(methodCount, CollectionTools.size(methods));
- assertTrue(CollectionTools.contains(this.methodNames(methods), "wait"));
- assertTrue(CollectionTools.contains(this.methodNames(methods), "addElement"));
- assertTrue(methods.iterator().next().isAccessible());
- }
-
- public void testNewInstanceClass() {
- Vector<?> v = ReflectionTools.newInstance(java.util.Vector.class);
- assertNotNull(v);
- assertEquals(0, v.size());
- }
-
- public void testNewInstanceClassClassObject() {
- int initialCapacity = 200;
- Vector<?> v = ReflectionTools.newInstance(java.util.Vector.class, int.class, new Integer(initialCapacity));
- assertNotNull(v);
- assertEquals(0, v.size());
- Object[] elementData = (Object[]) ReflectionTools.getFieldValue(v, "elementData");
- assertEquals(initialCapacity, elementData.length);
- }
-
- public void testNewInstanceClassClassArrayObjectArray() {
- int initialCapacity = 200;
- Class<?>[] parmTypes = new Class[1];
- parmTypes[0] = int.class;
- Object[] parms = new Object[1];
- parms[0] = new Integer(initialCapacity);
- Vector<?> v = ReflectionTools.newInstance(java.util.Vector.class, parmTypes, parms);
- assertNotNull(v);
- assertEquals(0, v.size());
- Object[] elementData = (Object[]) ReflectionTools.getFieldValue(v, "elementData");
- assertEquals(initialCapacity, elementData.length);
-
- parms[0] = new Integer(-1);
- boolean exCaught = false;
- try {
- v = ReflectionTools.newInstance(java.util.Vector.class, parmTypes, parms);
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- assertTrue("RuntimeException not thrown", exCaught);
-
- parmTypes[0] = java.lang.String.class;
- parms[0] = "foo";
- exCaught = false;
- try {
- v = ReflectionTools.newInstance(java.util.Vector.class, parmTypes, parms);
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof NoSuchMethodException) {
- exCaught = true;
- }
- }
- assertTrue("NoSuchMethodException not thrown", exCaught);
- }
-
- public void testFieldValue() {
- int initialCapacity = 200;
- Vector<?> v = new Vector<Object>(initialCapacity);
- Object[] elementData = (Object[]) ReflectionTools.getFieldValue(v, "elementData");
- assertEquals(initialCapacity, elementData.length);
-
- // test inherited field
- Integer modCountInteger = (Integer) ReflectionTools.getFieldValue(v, "modCount");
- int modCount = modCountInteger.intValue();
- assertEquals(0, modCount);
-
- boolean exCaught = false;
- Object bogusFieldValue = null;
- try {
- bogusFieldValue = ReflectionTools.getFieldValue(v, "bogusField");
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof NoSuchFieldException) {
- exCaught = true;
- }
- }
- assertTrue("NoSuchFieldException not thrown: " + bogusFieldValue, exCaught);
- }
-
- public void testExecuteMethodObjectString() {
- Vector<String> v = new Vector<String>();
- int size = ((Integer) ReflectionTools.executeMethod(v, "size")).intValue();
- assertEquals(0, size);
-
- v.addElement("foo");
- size = ((Integer) ReflectionTools.executeMethod(v, "size")).intValue();
- assertEquals(1, size);
- }
-
- public void testExecuteMethodObjectStringClassObject() {
- Vector<String> v = new Vector<String>();
- boolean booleanResult = ((Boolean) ReflectionTools.executeMethod(v, "add", Object.class, "foo")).booleanValue();
- assertTrue(booleanResult);
- assertTrue(v.contains("foo"));
- Object voidResult = ReflectionTools.executeMethod(v, "addElement", Object.class, "bar");
- assertNull(voidResult);
- }
-
- public void testExecuteMethodObjectStringClassArrayObjectArray() {
- Vector<String> v = new Vector<String>();
- Class<?>[] parmTypes = new Class[1];
- parmTypes[0] = java.lang.Object.class;
- Object[] parms = new Object[1];
- parms[0] = "foo";
- boolean booleanResult = ((Boolean) ReflectionTools.executeMethod(v, "add", parmTypes, parms)).booleanValue();
- assertTrue(booleanResult);
- assertTrue(v.contains("foo"));
-
- boolean exCaught = false;
- Object bogusMethodReturnValue = null;
- try {
- bogusMethodReturnValue = ReflectionTools.executeMethod(v, "bogusMethod", parmTypes, parms);
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof NoSuchMethodException) {
- exCaught = true;
- }
- }
- assertTrue("NoSuchMethodException not thrown: " + bogusMethodReturnValue, exCaught);
- }
-
- public void testExecuteStaticMethodClassString() {
- Double randomObject = (Double) ReflectionTools.executeStaticMethod(java.lang.Math.class, "random");
- assertNotNull(randomObject);
- double random = randomObject.doubleValue();
- assertTrue(random >= 0);
- assertTrue(random < 1);
- }
-
- public void testExecuteStaticMethodClassStringClassObject() {
- String s = (String) ReflectionTools.executeStaticMethod(java.lang.String.class, "valueOf", boolean.class, Boolean.TRUE);
- assertNotNull(s);
- assertEquals("true", s);
- }
-
- public void testExecuteStaticMethodClassStringClassArrayObjectArray() {
- Class<?>[] parmTypes = new Class[1];
- parmTypes[0] = boolean.class;
- Object[] parms = new Object[1];
- parms[0] = Boolean.TRUE;
- String s = (String) ReflectionTools.executeStaticMethod(java.lang.String.class, "valueOf", parmTypes, parms);
- assertNotNull(s);
- assertEquals("true", s);
-
- boolean exCaught = false;
- Object bogusStaticMethodReturnValue = null;
- try {
- bogusStaticMethodReturnValue = ReflectionTools.executeStaticMethod(java.lang.String.class, "bogusStaticMethod", parmTypes, parms);
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof NoSuchMethodException) {
- exCaught = true;
- }
- }
- assertTrue("NoSuchMethodException not thrown: " + bogusStaticMethodReturnValue, exCaught);
-
- // test non-static method
- exCaught = false;
- try {
- bogusStaticMethodReturnValue = ReflectionTools.executeStaticMethod(java.lang.String.class, "toString");
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof NoSuchMethodException) {
- exCaught = true;
- }
- }
- assertTrue("NoSuchMethodException not thrown: " + bogusStaticMethodReturnValue, exCaught);
- }
-
- public void testSetFieldValue() {
- Vector<String> v = new Vector<String>();
- Object[] newElementData = new Object[5];
- newElementData[0] = "foo";
- ReflectionTools.setFieldValue(v, "elementData", newElementData);
- ReflectionTools.setFieldValue(v, "elementCount", new Integer(1));
- // test inherited field
- ReflectionTools.setFieldValue(v, "modCount", new Integer(1));
- assertTrue(v.contains("foo"));
-
- boolean exCaught = false;
- try {
- ReflectionTools.setFieldValue(v, "bogusField", "foo");
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof NoSuchFieldException) {
- exCaught = true;
- }
- }
- assertTrue("NoSuchFieldException not thrown", exCaught);
- }
-
- public void testSetStaticFieldValue() {
- ReflectionTools.setStaticFieldValue(this.getClass(), "testStaticField", "new value");
- assertEquals(testStaticField, "new value");
-
- boolean exCaught = false;
- try {
- ReflectionTools.setStaticFieldValue(this.getClass(), "bogusStaticField", "new value");
- } catch (RuntimeException ex) {
- if (ex.getCause() instanceof NoSuchFieldException) {
- exCaught = true;
- }
- }
- assertTrue("NoSuchFieldException not thrown", exCaught);
- }
-
- public void testSimpleName() {
- assertEquals("Vector", java.util.Vector.class.getSimpleName());
- assertEquals("Entry", java.util.Map.Entry.class.getSimpleName());
- assertEquals("int", int.class.getSimpleName());
- assertEquals("int[]", int[].class.getSimpleName());
- assertEquals("int[][]", int[][].class.getSimpleName());
- assertEquals("void", void.class.getSimpleName());
- }
-
- public void testPackageName() {
- assertEquals("java.util", java.util.Vector.class.getPackage().getName());
- assertEquals("java.util", java.util.Map.Entry.class.getPackage().getName());
- }
-
- public void testArrayDepthFor() {
- assertEquals(0, ReflectionTools.getArrayDepth(java.util.Vector.class));
- assertEquals(0, ReflectionTools.getArrayDepth(int.class));
- assertEquals(0, ReflectionTools.getArrayDepth(void.class));
- assertEquals(1, ReflectionTools.getArrayDepth(java.util.Vector[].class));
- assertEquals(1, ReflectionTools.getArrayDepth(int[].class));
- assertEquals(3, ReflectionTools.getArrayDepth(java.util.Vector[][][].class));
- assertEquals(3, ReflectionTools.getArrayDepth(int[][][].class));
- }
-
- public void testElementTypeFor() {
- assertEquals(java.util.Vector.class, ReflectionTools.getElementType(java.util.Vector.class));
- assertEquals(int.class, ReflectionTools.getElementType(int.class));
- assertEquals(void.class, ReflectionTools.getElementType(void.class));
- assertEquals(java.util.Vector.class, ReflectionTools.getElementType(java.util.Vector[].class));
- assertEquals(int.class, ReflectionTools.getElementType(int[].class));
- assertEquals(java.util.Vector.class, ReflectionTools.getElementType(java.util.Vector[][][].class));
- assertEquals(int.class, ReflectionTools.getElementType(int[][][].class));
- }
-
- public void testClassIsPrimitiveWrapperClass() {
- assertTrue(ReflectionTools.classIsPrimitiveWrapper(java.lang.Void.class));
- assertTrue(ReflectionTools.classIsPrimitiveWrapper(java.lang.Boolean.class));
- assertTrue(ReflectionTools.classIsPrimitiveWrapper(java.lang.Integer.class));
- assertTrue(ReflectionTools.classIsPrimitiveWrapper(java.lang.Float.class));
-
- assertFalse(ReflectionTools.classIsPrimitiveWrapper(java.lang.String.class));
- assertFalse(ReflectionTools.classIsPrimitiveWrapper(void.class));
- assertFalse(ReflectionTools.classIsPrimitiveWrapper(int.class));
- }
-
- public void testClassIsVariablePrimitiveWrapperClass() {
- assertFalse(ReflectionTools.classIsVariablePrimitiveWrapper(java.lang.Void.class));
-
- assertTrue(ReflectionTools.classIsVariablePrimitiveWrapper(java.lang.Boolean.class));
- assertTrue(ReflectionTools.classIsVariablePrimitiveWrapper(java.lang.Integer.class));
- assertTrue(ReflectionTools.classIsVariablePrimitiveWrapper(java.lang.Float.class));
-
- assertFalse(ReflectionTools.classIsVariablePrimitiveWrapper(java.lang.String.class));
- assertFalse(ReflectionTools.classIsVariablePrimitiveWrapper(void.class));
- assertFalse(ReflectionTools.classIsVariablePrimitiveWrapper(int.class));
- }
-
- public void testWrapperClass() {
- assertEquals(java.lang.Void.class, ReflectionTools.getWrapperClass(void.class));
- assertEquals(java.lang.Integer.class, ReflectionTools.getWrapperClass(int.class));
- assertEquals(java.lang.Float.class, ReflectionTools.getWrapperClass(float.class));
- assertEquals(java.lang.Boolean.class, ReflectionTools.getWrapperClass(boolean.class));
-
- assertNull(ReflectionTools.getWrapperClass(java.lang.String.class));
- }
-
- public void testClassForTypeDeclarationStringInt() throws Exception {
- assertEquals(int.class, ReflectionTools.getClassForTypeDeclaration("int", 0));
- assertEquals(int[].class, ReflectionTools.getClassForTypeDeclaration("int", 1));
- assertEquals(int[][][].class, ReflectionTools.getClassForTypeDeclaration("int", 3));
-
- assertEquals(Object.class, ReflectionTools.getClassForTypeDeclaration("java.lang.Object", 0));
- assertEquals(Object[][][].class, ReflectionTools.getClassForTypeDeclaration("java.lang.Object", 3));
-
- assertEquals(void.class, ReflectionTools.getClassForTypeDeclaration("void", 0));
- try {
- ReflectionTools.getClassForTypeDeclaration(void.class.getName(), 1);
- fail("should not get here...");
- } catch (RuntimeException ex) {
- // expected
- }
- }
-
- public void testCodeForClass() {
- assertEquals('I', ReflectionTools.getCodeForClass(int.class));
- assertEquals('B', ReflectionTools.getCodeForClass(byte.class));
- }
-
- public void testClassNameForTypeDeclarationString() throws Exception {
- assertEquals("int", ReflectionTools.getClassNameForTypeDeclaration("int"));
- assertEquals("[I", ReflectionTools.getClassNameForTypeDeclaration("int[]"));
- assertEquals("[[I", ReflectionTools.getClassNameForTypeDeclaration("int [ ] [ ]"));
-
- assertEquals("java.lang.Object", ReflectionTools.getClassNameForTypeDeclaration("java.lang.Object"));
- assertEquals("[Ljava.lang.Object;", ReflectionTools.getClassNameForTypeDeclaration("java.lang.Object\t[]"));
- assertEquals("[[Ljava.lang.Object;", ReflectionTools.getClassNameForTypeDeclaration("java.lang.Object\t[]\t[]"));
- }
-
- public void testArrayDepthForTypeDeclarationString() throws Exception {
- assertEquals(0, ReflectionTools.getArrayDepthForTypeDeclaration("java.lang.Object"));
- assertEquals(1, ReflectionTools.getArrayDepthForTypeDeclaration("java.lang.Object[]"));
- assertEquals(3, ReflectionTools.getArrayDepthForTypeDeclaration("java.lang.Object[][][]"));
-
- assertEquals(0, ReflectionTools.getArrayDepthForTypeDeclaration("int"));
- assertEquals(1, ReflectionTools.getArrayDepthForTypeDeclaration("int[]"));
- assertEquals(3, ReflectionTools.getArrayDepthForTypeDeclaration("int[][][]"));
-
- assertEquals(0, ReflectionTools.getArrayDepthForTypeDeclaration("float"));
- assertEquals(1, ReflectionTools.getArrayDepthForTypeDeclaration("float [ ]"));
- assertEquals(3, ReflectionTools.getArrayDepthForTypeDeclaration("float[] [] []"));
- }
-
- public void testElementTypeNameForTypeDeclarationString() throws Exception {
- assertEquals("java.lang.Object", ReflectionTools.getElementTypeNameForTypeDeclaration("java.lang.Object"));
- assertEquals("java.lang.Object", ReflectionTools.getElementTypeNameForTypeDeclaration("java.lang.Object[]"));
- assertEquals("java.lang.Object", ReflectionTools.getElementTypeNameForTypeDeclaration("java.lang.Object[][][]"));
-
- assertEquals("int", ReflectionTools.getElementTypeNameForTypeDeclaration("int"));
- assertEquals("int", ReflectionTools.getElementTypeNameForTypeDeclaration("int[]"));
- assertEquals("int", ReflectionTools.getElementTypeNameForTypeDeclaration("int[][][]"));
-
- assertEquals("float", ReflectionTools.getElementTypeNameForTypeDeclaration("float"));
- assertEquals("float", ReflectionTools.getElementTypeNameForTypeDeclaration("float [ ]"));
- assertEquals("float", ReflectionTools.getElementTypeNameForTypeDeclaration("float[] [] []"));
- }
-
- public void testClassNameForTypeDeclarationStringInt() throws Exception {
- assertEquals(int.class.getName(), ReflectionTools.getClassNameForTypeDeclaration("int", 0));
- assertEquals(int[].class.getName(), ReflectionTools.getClassNameForTypeDeclaration("int", 1));
- assertEquals(int[][][].class.getName(), ReflectionTools.getClassNameForTypeDeclaration("int", 3));
-
- assertEquals(Object.class.getName(), ReflectionTools.getClassNameForTypeDeclaration("java.lang.Object", 0));
- assertEquals(Object[][][].class.getName(), ReflectionTools.getClassNameForTypeDeclaration("java.lang.Object", 3));
-
- assertEquals(void.class.getName(), ReflectionTools.getClassNameForTypeDeclaration("void", 0));
- try {
- ReflectionTools.getClassNameForTypeDeclaration(void.class.getName(), 1);
- fail("should not get here...");
- } catch (IllegalArgumentException ex) {
- // expected
- }
- }
-
- private Iterable<String> fieldNames(Iterable<Field> fields) {
- return new TransformationIterable<Field, String>(fields) {
- @Override
- protected String transform(Field field) {
- return field.getName();
- }
- };
- }
-
- private Iterable<String> methodNames(Iterable<Method> methods) {
- return new TransformationIterable<Method, String>(methods) {
- @Override
- protected String transform(Method method) {
- return method.getName();
- }
- };
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ReverseComparatorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ReverseComparatorTests.java
deleted file mode 100644
index 1287868a13..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ReverseComparatorTests.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.ReverseComparator;
-
-@SuppressWarnings("nls")
-public class ReverseComparatorTests extends TestCase {
- private Comparator<String> naturalReverseComparator;
- private Comparator<String> customComparator;
- private Comparator<String> customReverseComparator;
-
- public ReverseComparatorTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.naturalReverseComparator = new ReverseComparator<String>();
- this.customComparator = this.buildCustomComparator();
- this.customReverseComparator = new ReverseComparator<String>(this.customComparator);
- }
-
- private Comparator<String> buildCustomComparator() {
- return new Comparator<String>() {
- public int compare(String s1, String s2) {
- String lower1 = s1.toLowerCase();
- String lower2 = s2.toLowerCase();
- int result = lower1.compareTo(lower2);
- if (result == 0) {
- return s1.compareTo(s2); // use case to differentiate "equal" strings
- }
- return result;
- }
- };
- }
-
- private List<String> buildUnsortedList() {
- List<String> result = new ArrayList<String>();
- result.add("T");
- result.add("Z");
- result.add("Y");
- result.add("M");
- result.add("m");
- result.add("a");
- result.add("B");
- result.add("b");
- result.add("A");
- return result;
- }
-
- private List<String> buildNaturallySortedList() {
- List<String> result = new ArrayList<String>(this.buildUnsortedList());
- Collections.sort(result);
- return result;
- }
-
- private List<String> buildCustomSortedList() {
- List<String> result = new ArrayList<String>(this.buildUnsortedList());
- Collections.sort(result, this.customComparator);
- return result;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testNatural() {
- List<String> list = this.buildUnsortedList();
- Collections.sort(list, this.naturalReverseComparator);
- this.verifyList(this.buildNaturallySortedList(), list);
- }
-
- public void testCustom() {
- List<String> list = this.buildUnsortedList();
- Collections.sort(list, this.customReverseComparator);
- this.verifyList(this.buildCustomSortedList(), list);
- }
-
- private void verifyList(List<String> normal, List<String> reverse) {
- int size = normal.size();
- int max = size - 1;
- for (int i = 0; i < size; i++) {
- assertEquals(normal.get(i), reverse.get(max - i));
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleAssociationTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleAssociationTests.java
deleted file mode 100644
index 96fe163217..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleAssociationTests.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.common.utility.internal.Association;
-import org.eclipse.jpt.common.utility.internal.SimpleAssociation;
-
-@SuppressWarnings("nls")
-public class SimpleAssociationTests extends TestCase {
- private SimpleAssociation<String, String> assoc;
-
- public static Test suite() {
- return new TestSuite(SimpleAssociationTests.class);
- }
-
- public SimpleAssociationTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.assoc = new SimpleAssociation<String, String>("foo", "bar");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGetKey() {
- assertEquals("foo", this.assoc.getKey());
- }
-
- public void testGetValue() {
- assertEquals("bar", this.assoc.getValue());
- }
-
- public void testSetValue() {
- assertEquals("bar", this.assoc.getValue());
- this.assoc.setValue("baz");
- assertEquals("baz", this.assoc.getValue());
- }
-
- public void testEquals() {
- assertFalse(this.assoc.equals("foo"));
-
- assertEquals(this.assoc, this.copy(this.assoc));
-
- SimpleAssociation<String, String> assoc2 = new SimpleAssociation<String, String>("foo", "baz");
- assertFalse(this.assoc.equals(assoc2));
-
- assoc2 = new SimpleAssociation<String, String>("fop", "bar");
- assertFalse(this.assoc.equals(assoc2));
-
- SimpleAssociation<String, String> assoc3 = new SimpleAssociation<String, String>(null, null);
- SimpleAssociation<String, String> assoc4 = new SimpleAssociation<String, String>(null, null);
- assertEquals(assoc3, assoc4);
- }
-
- public void testHashCode() {
- assertEquals(this.assoc.hashCode(), this.copy(this.assoc).hashCode());
-
- SimpleAssociation<String, String> assoc2 = new SimpleAssociation<String, String>(null, null);
- assertEquals(assoc2.hashCode(), this.copy(assoc2).hashCode());
- }
-
- public void testToString() {
- assertNotNull(this.assoc.toString());
- }
-
- public void testClone() {
- this.verifyClone(this.assoc, this.assoc.clone());
- }
-
- private void verifyClone(Association<String, String> expected, Association<String, String> actual) {
- assertEquals(expected, actual);
- assertNotSame(expected, actual);
- assertEquals(expected.getKey(), actual.getKey());
- assertSame(expected.getKey(), actual.getKey());
- assertEquals(expected.getValue(), actual.getValue());
- assertSame(expected.getValue(), actual.getValue());
- }
-
- public void testSerialization() throws Exception {
- @SuppressWarnings("cast")
- Association<String, String> assoc2 = (Association<String, String>) TestTools.serialize(this.assoc);
-
- assertEquals(this.assoc, assoc2);
- assertNotSame(this.assoc, assoc2);
- assertEquals(this.assoc.getKey(), assoc2.getKey());
- assertNotSame(this.assoc.getKey(), assoc2.getKey());
- assertEquals(this.assoc.getValue(), assoc2.getValue());
- assertNotSame(this.assoc.getValue(), assoc2.getValue());
- }
-
- private SimpleAssociation<String, String> copy(SimpleAssociation<String, String> sa) {
- return new SimpleAssociation<String, String>(sa.getKey(), sa.getValue());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleBooleanReferenceTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleBooleanReferenceTests.java
deleted file mode 100644
index 04c06ddde3..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleBooleanReferenceTests.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.SimpleBooleanReference;
-
-@SuppressWarnings("nls")
-public class SimpleBooleanReferenceTests extends TestCase {
-
- public SimpleBooleanReferenceTests(String name) {
- super(name);
- }
-
- public void testGetValue() {
- SimpleBooleanReference br = new SimpleBooleanReference(true);
- assertTrue(br.getValue());
- }
-
- public void testGetValueDefault() {
- SimpleBooleanReference br = new SimpleBooleanReference();
- assertFalse(br.getValue());
- }
-
- public void testIs() {
- SimpleBooleanReference br = new SimpleBooleanReference(true);
- assertTrue(br.is(true));
- assertFalse(br.is(false));
- }
-
- public void testIsNot() {
- SimpleBooleanReference br = new SimpleBooleanReference(true);
- assertFalse(br.isNot(true));
- assertTrue(br.isNot(false));
- }
-
- public void testIsTrue() {
- SimpleBooleanReference br = new SimpleBooleanReference(true);
- assertTrue(br.isTrue());
- }
-
- public void testIsFalse() {
- SimpleBooleanReference br = new SimpleBooleanReference(true);
- assertFalse(br.isFalse());
- br.setFalse();
- assertTrue(br.isFalse());
- }
-
- public void testSetValue() {
- SimpleBooleanReference br = new SimpleBooleanReference(true);
- assertTrue(br.getValue());
- br.setValue(false);
- assertFalse(br.getValue());
- }
-
- public void testFlip() {
- SimpleBooleanReference br = new SimpleBooleanReference(true);
- assertTrue(br.getValue());
- assertFalse(br.flip());
- assertFalse(br.getValue());
- assertTrue(br.flip());
- assertTrue(br.getValue());
- }
-
- public void testSetNotBoolean() {
- SimpleBooleanReference br = new SimpleBooleanReference(false);
- assertFalse(br.getValue());
- br.setNot(true);
- assertFalse(br.getValue());
- br.setNot(true);
- assertFalse(br.getValue());
- br.setNot(false);
- assertTrue(br.getValue());
- }
-
- public void testSetTrue() {
- SimpleBooleanReference br = new SimpleBooleanReference(false);
- assertFalse(br.getValue());
- br.setTrue();
- assertTrue(br.getValue());
- }
-
- public void testSetFalse() {
- SimpleBooleanReference br = new SimpleBooleanReference(true);
- assertTrue(br.getValue());
- br.setFalse();
- assertFalse(br.getValue());
- }
-
- public void testClone() {
- SimpleBooleanReference br = new SimpleBooleanReference(true);
- SimpleBooleanReference clone = br.clone();
- assertTrue(clone.getValue());
- }
-
- public void testToString() {
- SimpleBooleanReference br1 = new SimpleBooleanReference(true);
- assertEquals("[true]", br1.toString());
- br1.setFalse();
- assertEquals("[false]", br1.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleIntReferenceTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleIntReferenceTests.java
deleted file mode 100644
index 196570b6de..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleIntReferenceTests.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.SimpleIntReference;
-
-@SuppressWarnings("nls")
-public class SimpleIntReferenceTests extends TestCase {
-
- public SimpleIntReferenceTests(String name) {
- super(name);
- }
-
- public void testCtors() {
- SimpleIntReference ir;
- ir = new SimpleIntReference();
- assertEquals(0, ir.getValue());
- ir = new SimpleIntReference(7);
- assertEquals(7, ir.getValue());
- ir = new SimpleIntReference(-7);
- assertEquals(-7, ir.getValue());
- }
-
- public void testEqualsInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference();
- assertTrue(ir.equals(0));
- assertFalse(ir.equals(7));
-
- ir = new SimpleIntReference(7);
- assertTrue(ir.equals(7));
- assertFalse(ir.equals(0));
- }
-
- public void testNotEqualInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference();
- assertFalse(ir.notEqual(0));
- assertTrue(ir.notEqual(7));
-
- ir = new SimpleIntReference(7);
- assertFalse(ir.notEqual(7));
- assertTrue(ir.notEqual(0));
- }
-
- public void testIsZero() {
- SimpleIntReference ir;
- ir = new SimpleIntReference();
- assertTrue(ir.isZero());
-
- ir = new SimpleIntReference(7);
- assertFalse(ir.isZero());
- }
-
- public void testIsNotZero() {
- SimpleIntReference ir;
- ir = new SimpleIntReference();
- assertFalse(ir.isNotZero());
-
- ir = new SimpleIntReference(7);
- assertTrue(ir.isNotZero());
- }
-
- public void testIsGreaterThanInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference();
- assertTrue(ir.isGreaterThan(-1));
- assertFalse(ir.isGreaterThan(0));
- assertFalse(ir.isGreaterThan(7));
- }
-
- public void testIsGreaterThanOrEqualInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference();
- assertTrue(ir.isGreaterThanOrEqual(-1));
- assertTrue(ir.isGreaterThanOrEqual(0));
- assertFalse(ir.isGreaterThanOrEqual(7));
- }
-
- public void testIsLessThanInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference();
- assertFalse(ir.isLessThan(-1));
- assertFalse(ir.isLessThan(0));
- assertTrue(ir.isLessThan(7));
- }
-
- public void testIsLessThanOrEqualInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference();
- assertFalse(ir.isLessThanOrEqual(-1));
- assertTrue(ir.isLessThanOrEqual(0));
- assertTrue(ir.isLessThanOrEqual(7));
- }
-
- public void testIsPositive() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(-3);
- assertFalse(ir.isPositive());
-
- ir = new SimpleIntReference();
- assertFalse(ir.isPositive());
-
- ir = new SimpleIntReference(7);
- assertTrue(ir.isPositive());
- }
-
- public void testIsNotPositive() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(-3);
- assertTrue(ir.isNotPositive());
-
- ir = new SimpleIntReference();
- assertTrue(ir.isNotPositive());
-
- ir = new SimpleIntReference(7);
- assertFalse(ir.isNotPositive());
- }
-
- public void testIsNegative() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(-3);
- assertTrue(ir.isNegative());
-
- ir = new SimpleIntReference();
- assertFalse(ir.isNegative());
-
- ir = new SimpleIntReference(7);
- assertFalse(ir.isNegative());
- }
-
- public void testIsNotNegative() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(-3);
- assertFalse(ir.isNotNegative());
-
- ir = new SimpleIntReference();
- assertTrue(ir.isNotNegative());
-
- ir = new SimpleIntReference(7);
- assertTrue(ir.isNotNegative());
- }
-
- public void testSetValueInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(-3);
- assertEquals(-3, ir.getValue());
- assertEquals(-3, ir.setValue(4));
- assertEquals(4, ir.getValue());
- }
-
- public void testAbs() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(-3);
- assertEquals(-3, ir.getValue());
- assertEquals(3, ir.abs());
-
- ir.setValue(3);
- assertEquals(3, ir.getValue());
- assertEquals(3, ir.abs());
- }
-
- public void testNeg() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(-3);
- assertEquals(-3, ir.getValue());
- assertEquals(3, ir.neg());
-
- ir.setValue(3);
- assertEquals(3, ir.getValue());
- assertEquals(-3, ir.neg());
- }
-
- public void testSetZero() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(-3);
- assertEquals(-3, ir.getValue());
- assertEquals(-3, ir.setZero());
- assertEquals(0, ir.getValue());
- }
-
- public void testAddInt() {
- SimpleIntReference ir;
- int value;
- ir = new SimpleIntReference();
- assertEquals(0, ir.getValue());
-
- value = ir.add(3);
- assertEquals(3, value);
-
- ir.setValue(3);
- value = ir.add(-7);
- assertEquals(-4, value);
- }
-
- public void testIncrement() {
- SimpleIntReference ir;
- int value;
- ir = new SimpleIntReference();
- assertEquals(0, ir.getValue());
-
- value = ir.increment();
- assertEquals(1, value);
- assertEquals(1, ir.getValue());
- }
-
- public void testSubtractInt() {
- SimpleIntReference ir;
- int count;
- ir = new SimpleIntReference();
- assertEquals(0, ir.getValue());
-
- count = ir.subtract(3);
- assertEquals(-3, count);
-
- ir.setValue(-3);
- count = ir.subtract(-7);
- assertEquals(4, count);
- }
-
- public void testDecrement() {
- SimpleIntReference ir;
- int count;
- ir = new SimpleIntReference();
- assertEquals(0, ir.getValue());
-
- count = ir.decrement();
- assertEquals(-1, count);
- assertEquals(-1, ir.getValue());
- }
-
- public void testMultiplyInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(3);
- assertEquals(3, ir.getValue());
- assertEquals(9, ir.multiply(3));
- }
-
- public void testDivideInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(24);
- assertEquals(24, ir.getValue());
- assertEquals(8, ir.divide(3));
- }
-
- public void testRemainderInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(25);
- assertEquals(25, ir.getValue());
- assertEquals(1, ir.remainder(3));
- }
-
- public void testMinInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(25);
- assertEquals(25, ir.getValue());
- assertEquals(3, ir.min(3));
- assertEquals(25, ir.min(33));
- }
-
- public void testMaxInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(25);
- assertEquals(25, ir.getValue());
- assertEquals(25, ir.max(3));
- assertEquals(30, ir.max(30));
- }
-
- public void testPowInt() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(5);
- assertEquals(5, ir.getValue());
- assertTrue(ir.pow(2) == 25L);
- }
-
- public void testCompareToIntReference() {
- SimpleIntReference ir1 = new SimpleIntReference(44);
- SimpleIntReference ir2 = new SimpleIntReference(44);
- assertTrue(ir1.compareTo(ir2) == 0);
- ir2 = new SimpleIntReference(55);
- assertTrue(ir1.compareTo(ir2) < 0);
- ir2 = new SimpleIntReference(33);
- assertTrue(ir1.compareTo(ir2) > 0);
- }
-
- public void testClone() {
- SimpleIntReference ir1 = new SimpleIntReference(44);
- SimpleIntReference ir2 = ir1.clone();
- assertEquals(44, ir2.getValue());
- assertNotSame(ir1, ir2);
- }
-
- public void testSerialization() throws Exception {
- SimpleIntReference ir1 = new SimpleIntReference(44);
- SimpleIntReference ir2 = TestTools.serialize(ir1);
- assertEquals(44, ir2.getValue());
- assertNotSame(ir1, ir2);
- }
-
- public void testToString() {
- SimpleIntReference ir;
- ir = new SimpleIntReference(5);
- assertEquals("[5]", ir.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleObjectReferenceTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleObjectReferenceTests.java
deleted file mode 100644
index ea91ac9f7c..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleObjectReferenceTests.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.SimpleObjectReference;
-
-@SuppressWarnings("nls")
-public class SimpleObjectReferenceTests extends TestCase {
-
- public SimpleObjectReferenceTests(String name) {
- super(name);
- }
-
- public void testGetValue() {
- SimpleObjectReference<String> or = new SimpleObjectReference<String>();
- assertNull(or.getValue());
- or.setValue("foo");
- assertEquals("foo", or.getValue());
- }
-
- public void testValueEqualsObject() {
- SimpleObjectReference<String> or = new SimpleObjectReference<String>();
- assertTrue(or.valueEquals(null));
- assertFalse(or.valueEquals("foo"));
-
- or.setValue("foo");
- assertFalse(or.valueEquals(null));
- assertTrue(or.valueEquals("foo"));
- }
-
- public void testValueNotEqualObject() {
- SimpleObjectReference<String> or = new SimpleObjectReference<String>();
- assertFalse(or.valueNotEqual(null));
- assertTrue(or.valueNotEqual("foo"));
-
- or.setValue("foo");
- assertTrue(or.valueNotEqual(null));
- assertFalse(or.valueNotEqual("foo"));
- }
-
- public void testIsNull() {
- SimpleObjectReference<String> or = new SimpleObjectReference<String>();
- assertTrue(or.isNull());
- or.setValue("foo");
- assertFalse(or.isNull());
- }
-
- public void testIsNotNull() {
- SimpleObjectReference<String> or = new SimpleObjectReference<String>();
- assertFalse(or.isNotNull());
- or.setValue("foo");
- assertTrue(or.isNotNull());
- }
-
- public void testSetNull() {
- SimpleObjectReference<String> or = new SimpleObjectReference<String>();
- assertNull(or.getValue());
- or.setValue("foo");
- assertEquals("foo", or.getValue());
- or.setNull();
- assertNull(or.getValue());
- }
-
- public void testClone() {
- SimpleObjectReference<String> or = new SimpleObjectReference<String>("foo");
- @SuppressWarnings("cast")
- SimpleObjectReference<String> clone = (SimpleObjectReference<String>) or.clone();
- assertEquals("foo", clone.getValue());
- assertNotSame(or, clone);
- }
-
- public void testToString() {
- SimpleObjectReference<String> or = new SimpleObjectReference<String>();
- assertEquals("[null]", or.toString());
- or.setValue("foo");
- assertEquals("[foo]", or.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleQueueTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleQueueTests.java
deleted file mode 100644
index 4fb99dbc5a..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleQueueTests.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.Queue;
-import org.eclipse.jpt.common.utility.internal.SimpleQueue;
-
-@SuppressWarnings("nls")
-public class SimpleQueueTests
- extends MultiThreadedTestCase
-{
-
- public SimpleQueueTests(String name) {
- super(name);
- }
-
- Queue<String> buildQueue() {
- return new SimpleQueue<String>();
- }
-
- public void testIsEmpty() {
- Queue<String> queue = this.buildQueue();
- assertTrue(queue.isEmpty());
- queue.enqueue("first");
- assertFalse(queue.isEmpty());
- queue.enqueue("second");
- assertFalse(queue.isEmpty());
- queue.dequeue();
- assertFalse(queue.isEmpty());
- queue.dequeue();
- assertTrue(queue.isEmpty());
- }
-
- public void testEnqueueAndDequeue() {
- Queue<String> queue = this.buildQueue();
- String first = "first";
- String second = "second";
-
- queue.enqueue(first);
- queue.enqueue(second);
- assertEquals(first, queue.dequeue());
- assertEquals(second, queue.dequeue());
- }
-
- public void testEnqueueAndPeek() {
- Queue<String> queue = this.buildQueue();
- String first = "first";
- String second = "second";
-
- queue.enqueue(first);
- queue.enqueue(second);
- assertEquals(first, queue.peek());
- assertEquals(first, queue.peek());
- assertEquals(first, queue.dequeue());
- assertEquals(second, queue.peek());
- assertEquals(second, queue.peek());
- assertEquals(second, queue.dequeue());
- }
-
- public void testEmptyQueueExceptionPeek() {
- Queue<String> queue = this.buildQueue();
- String first = "first";
- String second = "second";
-
- queue.enqueue(first);
- queue.enqueue(second);
- assertEquals(first, queue.peek());
- assertEquals(first, queue.dequeue());
- assertEquals(second, queue.peek());
- assertEquals(second, queue.dequeue());
-
- boolean exCaught = false;
- try {
- queue.peek();
- fail();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testEmptyQueueExceptionDequeue() {
- Queue<String> queue = this.buildQueue();
- String first = "first";
- String second = "second";
-
- queue.enqueue(first);
- queue.enqueue(second);
- assertEquals(first, queue.peek());
- assertEquals(first, queue.dequeue());
- assertEquals(second, queue.peek());
- assertEquals(second, queue.dequeue());
-
- boolean exCaught = false;
- try {
- queue.dequeue();
- fail();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testClone() {
- SimpleQueue<String> queue = (SimpleQueue<String>) this.buildQueue();
- queue.enqueue("first");
- queue.enqueue("second");
- queue.enqueue("third");
-
- this.verifyClone(queue, queue.clone());
- }
-
- public void testSerialization() throws Exception {
- Queue<String> queue = this.buildQueue();
- queue.enqueue("first");
- queue.enqueue("second");
- queue.enqueue("third");
-
- this.verifyClone(queue, TestTools.serialize(queue));
- }
-
- private void verifyClone(Queue<String> original, Queue<String> clone) {
- assertNotSame(original, clone);
- assertEquals(original.peek(), clone.peek());
- assertEquals(original.dequeue(), clone.dequeue());
- assertEquals(original.peek(), clone.peek());
- assertEquals(original.dequeue(), clone.dequeue());
- assertEquals(original.isEmpty(), clone.isEmpty());
- assertEquals(original.peek(), clone.peek());
- assertEquals(original.dequeue(), clone.dequeue());
- assertTrue(original.isEmpty());
- assertEquals(original.isEmpty(), clone.isEmpty());
-
- original.enqueue("fourth");
- assertFalse(original.isEmpty());
- // clone should still be empty
- assertTrue(clone.isEmpty());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleStackTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleStackTests.java
deleted file mode 100644
index b73d8633e3..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SimpleStackTests.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.util.EmptyStackException;
-
-import org.eclipse.jpt.common.utility.internal.SimpleStack;
-import org.eclipse.jpt.common.utility.internal.Stack;
-
-@SuppressWarnings("nls")
-public class SimpleStackTests
- extends MultiThreadedTestCase
-{
- public SimpleStackTests(String name) {
- super(name);
- }
-
- Stack<String> buildStack() {
- return new SimpleStack<String>();
- }
-
- public void testIsEmpty() {
- Stack<String> stack = this.buildStack();
- assertTrue(stack.isEmpty());
- stack.push("first");
- assertFalse(stack.isEmpty());
- stack.push("second");
- assertFalse(stack.isEmpty());
- stack.pop();
- assertFalse(stack.isEmpty());
- stack.pop();
- assertTrue(stack.isEmpty());
- }
-
- public void testPushAndPop() {
- Stack<String> stack = this.buildStack();
- String first = "first";
- String second = "second";
-
- stack.push(first);
- stack.push(second);
- assertEquals(second, stack.pop());
- assertEquals(first, stack.pop());
- }
-
- public void testPushAndPeek() {
- Stack<String> stack = this.buildStack();
- String first = "first";
- String second = "second";
-
- stack.push(first);
- stack.push(second);
- assertEquals(second, stack.peek());
- assertEquals(second, stack.peek());
- assertEquals(second, stack.pop());
- assertEquals(first, stack.peek());
- assertEquals(first, stack.peek());
- assertEquals(first, stack.pop());
- }
-
- public void testEmptyStackExceptionPeek() {
- Stack<String> stack = this.buildStack();
- String first = "first";
- String second = "second";
-
- stack.push(first);
- stack.push(second);
- assertEquals(second, stack.peek());
- assertEquals(second, stack.pop());
- assertEquals(first, stack.peek());
- assertEquals(first, stack.pop());
-
- boolean exCaught = false;
- try {
- stack.peek();
- fail();
- } catch (EmptyStackException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testEmptyStackExceptionPop() {
- Stack<String> stack = this.buildStack();
- String first = "first";
- String second = "second";
-
- stack.push(first);
- stack.push(second);
- assertEquals(second, stack.peek());
- assertEquals(second, stack.pop());
- assertEquals(first, stack.peek());
- assertEquals(first, stack.pop());
-
- boolean exCaught = false;
- try {
- stack.pop();
- fail();
- } catch (EmptyStackException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testClone() {
- SimpleStack<String> stack = (SimpleStack<String>) this.buildStack();
- stack.push("first");
- stack.push("second");
- stack.push("third");
-
- this.verifyClone(stack, stack.clone());
- }
-
- public void testSerialization() throws Exception {
- Stack<String> stack = this.buildStack();
- stack.push("first");
- stack.push("second");
- stack.push("third");
-
- this.verifyClone(stack, TestTools.serialize(stack));
- }
-
- private void verifyClone(Stack<String> original, Stack<String> clone) {
- assertNotSame(original, clone);
- assertEquals(original.peek(), clone.peek());
- assertEquals(original.pop(), clone.pop());
- assertEquals(original.peek(), clone.peek());
- assertEquals(original.pop(), clone.pop());
- assertEquals(original.isEmpty(), clone.isEmpty());
- assertEquals(original.peek(), clone.peek());
- assertEquals(original.pop(), clone.pop());
- assertTrue(original.isEmpty());
- assertEquals(original.isEmpty(), clone.isEmpty());
-
- original.push("fourth");
- assertFalse(original.isEmpty());
- // clone should still be empty
- assertTrue(clone.isEmpty());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java
deleted file mode 100644
index b34bab2474..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/StringToolsTests.java
+++ /dev/null
@@ -1,1871 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.io.StringWriter;
-import java.io.Writer;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-
-@SuppressWarnings("nls")
-public class StringToolsTests extends TestCase {
-
- public StringToolsTests(String name) {
- super(name);
- }
-
- private static void assertEquals(String expected, char[] actual) {
- assertEquals(expected, new String(actual));
- }
-
- // ********** padding/truncating **********
-
- public void testPad() {
- assertEquals("fred", StringTools.pad("fred", 4));
- assertEquals("fred ", StringTools.pad("fred", 6));
- boolean exThrown = false;
- try {
- assertEquals("fr", StringTools.pad("fred", 2));
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testPadCharArray() {
- assertEquals("fred", StringTools.pad(new char[] { 'f', 'r', 'e', 'd' }, 4));
- assertEquals("fred ", StringTools.pad(new char[] { 'f', 'r', 'e', 'd' }, 6));
- boolean exThrown = false;
- try {
- assertEquals("fr", StringTools.pad(new char[] { 'f', 'r', 'e', 'd' }, 2));
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testPadOnWriter() {
- Writer writer;
- writer = new StringWriter();
- StringTools.padOn("fred", 4, writer);
- assertEquals("fred", writer.toString());
-
- writer = new StringWriter();
- StringTools.padOn("fred", 6, writer);
- assertEquals("fred ", writer.toString());
-
- writer = new StringWriter();
- boolean exThrown = false;
- try {
- StringTools.padOn("fred", 2, writer);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testPadOnStringBuffer() {
- StringBuffer sb;
- sb = new StringBuffer();
- StringTools.padOn("fred", 4, sb);
- assertEquals("fred", sb.toString());
-
- sb = new StringBuffer();
- StringTools.padOn("fred", 6, sb);
- assertEquals("fred ", sb.toString());
-
- sb = new StringBuffer();
- boolean exThrown = false;
- try {
- StringTools.padOn("fred", 2, sb);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testPadOnStringBuilder() {
- StringBuilder sb;
- sb = new StringBuilder();
- StringTools.padOn("fred", 4, sb);
- assertEquals("fred", sb.toString());
-
- sb = new StringBuilder();
- StringTools.padOn("fred", 6, sb);
- assertEquals("fred ", sb.toString());
-
- sb = new StringBuilder();
- boolean exThrown = false;
- try {
- StringTools.padOn("fred", 2, sb);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testPadOrTruncate() {
- assertEquals("fred", StringTools.padOrTruncate("fred", 4));
- assertEquals("fred ", StringTools.padOrTruncate("fred", 6));
- assertEquals("fr", StringTools.padOrTruncate("fred", 2));
- }
-
- public void testPadOrTruncateCharArray() {
- assertEquals("fred", StringTools.padOrTruncate(new char[] { 'f', 'r', 'e', 'd' }, 4));
- assertEquals("fred ", StringTools.padOrTruncate(new char[] { 'f', 'r', 'e', 'd' }, 6));
- assertEquals("fr", StringTools.padOrTruncate(new char[] { 'f', 'r', 'e', 'd' }, 2));
- }
-
- public void testPadOrTruncateOnWriter() {
- this.verifyPadOrTruncateOnWriter("fred", "fred", 4);
- this.verifyPadOrTruncateOnWriter("fred ", "fred", 6);
- this.verifyPadOrTruncateOnWriter("fr", "fred", 2);
- }
-
- private void verifyPadOrTruncateOnWriter(String expected, String string, int length) {
- Writer writer = new StringWriter();
- StringTools.padOrTruncateOn(string, length, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testPadOrTruncateOnStringBuffer() {
- this.verifyPadOrTruncateOnStringBuffer("fred", "fred", 4);
- this.verifyPadOrTruncateOnStringBuffer("fred ", "fred", 6);
- this.verifyPadOrTruncateOnStringBuffer("fr", "fred", 2);
- }
-
- private void verifyPadOrTruncateOnStringBuffer(String expected, String string, int length) {
- StringBuffer sb = new StringBuffer();
- StringTools.padOrTruncateOn(string, length, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testPadOrTruncateOnStringBuilder() {
- this.verifyPadOrTruncateOnStringBuilder("fred", "fred", 4);
- this.verifyPadOrTruncateOnStringBuilder("fred ", "fred", 6);
- this.verifyPadOrTruncateOnStringBuilder("fr", "fred", 2);
- }
-
- private void verifyPadOrTruncateOnStringBuilder(String expected, String string, int length) {
- StringBuilder sb = new StringBuilder();
- StringTools.padOrTruncateOn(string, length, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testZeroPad() {
- assertEquals("1234", StringTools.zeroPad("1234", 4));
- assertEquals("001234", StringTools.zeroPad("1234", 6));
- boolean exThrown = false;
- try {
- assertEquals("12", StringTools.zeroPad("1234", 2));
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testZeroPadCharArray() {
- assertEquals("1234", StringTools.zeroPad(new char[] { '1', '2', '3', '4' }, 4));
- assertEquals("001234", StringTools.zeroPad(new char[] { '1', '2', '3', '4' }, 6));
- boolean exThrown = false;
- try {
- assertEquals("12", StringTools.zeroPad(new char[] { '1', '2', '3', '4' }, 2));
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testZeroPadOnWriter() {
- Writer writer;
- writer = new StringWriter();
- StringTools.zeroPadOn("1234", 4, writer);
- assertEquals("1234", writer.toString());
-
- writer = new StringWriter();
- StringTools.zeroPadOn("1234", 6, writer);
- assertEquals("001234", writer.toString());
-
- writer = new StringWriter();
- boolean exThrown = false;
- try {
- StringTools.zeroPadOn("1234", 2, writer);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testZeroPadOnStringBuffer() {
- StringBuffer sb;
- sb = new StringBuffer();
- StringTools.zeroPadOn("1234", 4, sb);
- assertEquals("1234", sb.toString());
-
- sb = new StringBuffer();
- StringTools.zeroPadOn("1234", 6, sb);
- assertEquals("001234", sb.toString());
-
- sb = new StringBuffer();
- boolean exThrown = false;
- try {
- StringTools.zeroPadOn("1234", 2, sb);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testZeroPadOnStringBuilder() {
- StringBuilder sb;
- sb = new StringBuilder();
- StringTools.zeroPadOn("1234", 4, sb);
- assertEquals("1234", sb.toString());
-
- sb = new StringBuilder();
- StringTools.zeroPadOn("1234", 6, sb);
- assertEquals("001234", sb.toString());
-
- sb = new StringBuilder();
- boolean exThrown = false;
- try {
- StringTools.zeroPadOn("1234", 2, sb);
- fail();
- } catch (IllegalArgumentException ex) {
- exThrown = true;
- }
- assertTrue(exThrown);
- }
-
- public void testZeroPadOrTruncate() {
- assertEquals("1234", StringTools.zeroPadOrTruncate("1234", 4));
- assertEquals("001234", StringTools.zeroPadOrTruncate("1234", 6));
- assertEquals("34", StringTools.zeroPadOrTruncate("1234", 2));
- }
-
- public void testZeroPadOrTruncateCharArray() {
- assertEquals("1234", StringTools.zeroPadOrTruncate(new char[] { '1', '2', '3', '4' }, 4));
- assertEquals("001234", StringTools.zeroPadOrTruncate(new char[] { '1', '2', '3', '4' }, 6));
- assertEquals("34", StringTools.zeroPadOrTruncate(new char[] { '1', '2', '3', '4' }, 2));
- }
-
- public void testZeroPadOrTruncateOnWriter() {
- this.verifyZeroPadOrTruncateOnWriter("1234", "1234", 4);
- this.verifyZeroPadOrTruncateOnWriter("001234", "1234", 6);
- this.verifyZeroPadOrTruncateOnWriter("34", "1234", 2);
- }
-
- private void verifyZeroPadOrTruncateOnWriter(String expected, String string, int length) {
- Writer writer = new StringWriter();
- StringTools.zeroPadOrTruncateOn(string, length, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testZeroPadOrTruncateOnStringBuffer() {
- this.verifyZeroPadOrTruncateOnStringBuffer("1234", "1234", 4);
- this.verifyZeroPadOrTruncateOnStringBuffer("001234", "1234", 6);
- this.verifyZeroPadOrTruncateOnStringBuffer("34", "1234", 2);
- }
-
- private void verifyZeroPadOrTruncateOnStringBuffer(String expected, String string, int length) {
- StringBuffer sb = new StringBuffer();
- StringTools.zeroPadOrTruncateOn(string, length, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testZeroPadOrTruncateOnStringBuilder() {
- this.verifyZeroPadOrTruncateOnStringBuilder("1234", "1234", 4);
- this.verifyZeroPadOrTruncateOnStringBuilder("001234", "1234", 6);
- this.verifyZeroPadOrTruncateOnStringBuilder("34", "1234", 2);
- }
-
- private void verifyZeroPadOrTruncateOnStringBuilder(String expected, String string, int length) {
- StringBuilder sb = new StringBuilder();
- StringTools.zeroPadOrTruncateOn(string, length, sb);
- assertEquals(expected, sb.toString());
- }
-
- // ********** separating **********
-
- public void testSeparateStringCharInt() {
- this.verifySeparate("012345", '-', 22, "012345");
- this.verifySeparate("012345", '-', 6, "012345");
- this.verifySeparate("012345", '-', 5, "01234-5");
- this.verifySeparate("012345", '-', 4, "0123-45");
- this.verifySeparate("012345", '-', 3, "012-345");
- this.verifySeparate("012345", '-', 2, "01-23-45");
- this.verifySeparate("012345", '-', 1, "0-1-2-3-4-5");
- }
-
- private void verifySeparate(String string, char separator, int segmentLength, String expected) {
- assertEquals(expected, StringTools.separate(string, separator, segmentLength));
- }
-
- public void testSeparateOnStringCharIntWriter() {
- this.verifySeparateOnWriter("012345", '-', 22, "012345");
- this.verifySeparateOnWriter("012345", '-', 6, "012345");
- this.verifySeparateOnWriter("012345", '-', 5, "01234-5");
- this.verifySeparateOnWriter("012345", '-', 4, "0123-45");
- this.verifySeparateOnWriter("012345", '-', 3, "012-345");
- this.verifySeparateOnWriter("012345", '-', 2, "01-23-45");
- this.verifySeparateOnWriter("012345", '-', 1, "0-1-2-3-4-5");
- }
-
- private void verifySeparateOnWriter(String string, char separator, int segmentLength, String expected) {
- Writer writer = new StringWriter();
- StringTools.separateOn(string, separator, segmentLength, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testSeparateOnStringCharIntStringBuffer() {
- this.verifySeparateOnStringBuffer("012345", '-', 22, "012345");
- this.verifySeparateOnStringBuffer("012345", '-', 6, "012345");
- this.verifySeparateOnStringBuffer("012345", '-', 5, "01234-5");
- this.verifySeparateOnStringBuffer("012345", '-', 4, "0123-45");
- this.verifySeparateOnStringBuffer("012345", '-', 3, "012-345");
- this.verifySeparateOnStringBuffer("012345", '-', 2, "01-23-45");
- this.verifySeparateOnStringBuffer("012345", '-', 1, "0-1-2-3-4-5");
- }
-
- private void verifySeparateOnStringBuffer(String string, char separator, int segmentLength, String expected) {
- StringBuffer sb = new StringBuffer();
- StringTools.separateOn(string, separator, segmentLength, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testSeparateOnStringCharIntStringBuilder() {
- this.verifySeparateOnStringBuilder("012345", '-', 22, "012345");
- this.verifySeparateOnStringBuilder("012345", '-', 6, "012345");
- this.verifySeparateOnStringBuilder("012345", '-', 5, "01234-5");
- this.verifySeparateOnStringBuilder("012345", '-', 4, "0123-45");
- this.verifySeparateOnStringBuilder("012345", '-', 3, "012-345");
- this.verifySeparateOnStringBuilder("012345", '-', 2, "01-23-45");
- this.verifySeparateOnStringBuilder("012345", '-', 1, "0-1-2-3-4-5");
- }
-
- private void verifySeparateOnStringBuilder(String string, char separator, int segmentLength, String expected) {
- StringBuilder sb = new StringBuilder();
- StringTools.separateOn(string, separator, segmentLength, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testSeparateCharArrayCharInt() {
- this.verifySeparateCharArray("012345", '-', 22, "012345");
- this.verifySeparateCharArray("012345", '-', 6, "012345");
- this.verifySeparateCharArray("012345", '-', 5, "01234-5");
- this.verifySeparateCharArray("012345", '-', 4, "0123-45");
- this.verifySeparateCharArray("012345", '-', 3, "012-345");
- this.verifySeparateCharArray("012345", '-', 2, "01-23-45");
- this.verifySeparateCharArray("012345", '-', 1, "0-1-2-3-4-5");
- }
-
- private void verifySeparateCharArray(String string, char separator, int segmentLength, String expected) {
- assertEquals(expected, StringTools.separate(string.toCharArray(), separator, segmentLength));
- }
-
- public void testSeparateOnCharArrayCharIntWriter() {
- this.verifySeparateCharArrayOnWriter("012345", '-', 22, "012345");
- this.verifySeparateCharArrayOnWriter("012345", '-', 6, "012345");
- this.verifySeparateCharArrayOnWriter("012345", '-', 5, "01234-5");
- this.verifySeparateCharArrayOnWriter("012345", '-', 4, "0123-45");
- this.verifySeparateCharArrayOnWriter("012345", '-', 3, "012-345");
- this.verifySeparateCharArrayOnWriter("012345", '-', 2, "01-23-45");
- this.verifySeparateCharArrayOnWriter("012345", '-', 1, "0-1-2-3-4-5");
- }
-
- private void verifySeparateCharArrayOnWriter(String string, char separator, int segmentLength, String expected) {
- Writer writer = new StringWriter();
- StringTools.separateOn(string.toCharArray(), separator, segmentLength, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testSeparateOnCharArrayCharIntStringBuffer() {
- this.verifySeparateCharArrayOnStringBuffer("012345", '-', 22, "012345");
- this.verifySeparateCharArrayOnStringBuffer("012345", '-', 6, "012345");
- this.verifySeparateCharArrayOnStringBuffer("012345", '-', 5, "01234-5");
- this.verifySeparateCharArrayOnStringBuffer("012345", '-', 4, "0123-45");
- this.verifySeparateCharArrayOnStringBuffer("012345", '-', 3, "012-345");
- this.verifySeparateCharArrayOnStringBuffer("012345", '-', 2, "01-23-45");
- this.verifySeparateCharArrayOnStringBuffer("012345", '-', 1, "0-1-2-3-4-5");
- }
-
- private void verifySeparateCharArrayOnStringBuffer(String string, char separator, int segmentLength, String expected) {
- StringBuffer sb = new StringBuffer();
- StringTools.separateOn(string.toCharArray(), separator, segmentLength, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testSeparateOnCharArrayCharIntStringBuilder() {
- this.verifySeparateCharArrayOnStringBuilder("012345", '-', 22, "012345");
- this.verifySeparateCharArrayOnStringBuilder("012345", '-', 6, "012345");
- this.verifySeparateCharArrayOnStringBuilder("012345", '-', 5, "01234-5");
- this.verifySeparateCharArrayOnStringBuilder("012345", '-', 4, "0123-45");
- this.verifySeparateCharArrayOnStringBuilder("012345", '-', 3, "012-345");
- this.verifySeparateCharArrayOnStringBuilder("012345", '-', 2, "01-23-45");
- this.verifySeparateCharArrayOnStringBuilder("012345", '-', 1, "0-1-2-3-4-5");
- }
-
- private void verifySeparateCharArrayOnStringBuilder(String string, char separator, int segmentLength, String expected) {
- StringBuilder sb = new StringBuilder();
- StringTools.separateOn(string.toCharArray(), separator, segmentLength, sb);
- assertEquals(expected, sb.toString());
- }
-
- // ********** delimiting **********
-
- public void testDelimit() {
- this.verifyDelimit("Employee", "123", "123Employee123");
- this.verifyDelimit("123", "123", "123123123");
- this.verifyDelimit("", "123", "123123");
- }
-
- private void verifyDelimit(String string, String delimiter, String expectedString) {
- assertEquals(expectedString, StringTools.delimit(string, delimiter));
- }
-
- public void testDelimitOnWriter() {
- this.verifyDelimitOnWriter("Employee", "123", "123Employee123");
- this.verifyDelimitOnWriter("123", "123", "123123123");
- this.verifyDelimitOnWriter("", "123", "123123");
- }
-
- private void verifyDelimitOnWriter(String string, String delimiter, String expectedString) {
- Writer writer = new StringWriter();
- StringTools.delimitOn(string, delimiter, writer);
- assertEquals(expectedString, writer.toString());
- }
-
- public void testDelimitOnStringBuffer() {
- this.verifyDelimitOnStringBuffer("Employee", "123", "123Employee123");
- this.verifyDelimitOnStringBuffer("123", "123", "123123123");
- this.verifyDelimitOnStringBuffer("", "123", "123123");
- }
-
- private void verifyDelimitOnStringBuffer(String string, String delimiter, String expectedString) {
- StringBuffer sb = new StringBuffer();
- StringTools.delimitOn(string, delimiter, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testDelimitOnStringBuilder() {
- this.verifyDelimitOnStringBuilder("Employee", "123", "123Employee123");
- this.verifyDelimitOnStringBuilder("123", "123", "123123123");
- this.verifyDelimitOnStringBuilder("", "123", "123123");
- }
-
- private void verifyDelimitOnStringBuilder(String string, String delimiter, String expectedString) {
- StringBuilder sb = new StringBuilder();
- StringTools.delimitOn(string, delimiter, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testQuote() {
- this.verifyQuote("Employee", "\"Employee\"");
- this.verifyQuote("123", "\"123\"");
- this.verifyQuote("", "\"\"");
- this.verifyQuote("Emp\"loyee", "\"Emp\"\"loyee\"");
- }
-
- private void verifyQuote(String string, String expectedString) {
- assertEquals(expectedString, StringTools.quote(string));
- }
-
- public void testQuoteOnWriter() {
- this.verifyQuoteOnWriter("Employee", "\"Employee\"");
- this.verifyQuoteOnWriter("123", "\"123\"");
- this.verifyQuoteOnWriter("", "\"\"");
- this.verifyQuoteOnWriter("Emp\"loyee", "\"Emp\"\"loyee\"");
- }
-
- private void verifyQuoteOnWriter(String string, String expectedString) {
- Writer writer = new StringWriter();
- StringTools.quoteOn(string, writer);
- assertEquals(expectedString, writer.toString());
- }
-
- public void testQuoteOnStringBuffer() {
- this.verifyQuoteOnStringBuffer("Employee", "\"Employee\"");
- this.verifyQuoteOnStringBuffer("123", "\"123\"");
- this.verifyQuoteOnStringBuffer("", "\"\"");
- this.verifyQuoteOnStringBuffer("Emp\"loyee", "\"Emp\"\"loyee\"");
- }
-
- private void verifyQuoteOnStringBuffer(String string, String expectedString) {
- StringBuffer sb = new StringBuffer();
- StringTools.quoteOn(string, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testQuoteOnStringBuilder() {
- this.verifyQuoteOnStringBuilder("Employee", "\"Employee\"");
- this.verifyQuoteOnStringBuilder("123", "\"123\"");
- this.verifyQuoteOnStringBuilder("", "\"\"");
- this.verifyQuoteOnStringBuilder("Emp\"loyee", "\"Emp\"\"loyee\"");
- }
-
- private void verifyQuoteOnStringBuilder(String string, String expectedString) {
- StringBuilder sb = new StringBuilder();
- StringTools.quoteOn(string, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- // ********** removing characters **********
-
- public void testRemoveFirstOccurrence() {
- this.verifyRemoveFirstOccurrence("Emplo&yee", '&', "Employee");
- this.verifyRemoveFirstOccurrence("Emplo&yee&", '&', "Employee&");
- this.verifyRemoveFirstOccurrence("Employee &Foo", '&', "Employee Foo");
- this.verifyRemoveFirstOccurrence("Employee&", '&', "Employee");
- this.verifyRemoveFirstOccurrence("&Employee", '&', "Employee");
- }
-
- private void verifyRemoveFirstOccurrence(String string, char charToRemove, String expectedString) {
- assertEquals(expectedString, StringTools.removeFirstOccurrence(string, charToRemove));
- }
-
- public void testRemoveFirstOccurrenceCharArray() {
- this.verifyRemoveFirstOccurrenceCharArray("Emplo&yee", '&', "Employee");
- this.verifyRemoveFirstOccurrenceCharArray("Emplo&yee&", '&', "Employee&");
- this.verifyRemoveFirstOccurrenceCharArray("Employee &Foo", '&', "Employee Foo");
- this.verifyRemoveFirstOccurrenceCharArray("Employee&", '&', "Employee");
- this.verifyRemoveFirstOccurrenceCharArray("&Employee", '&', "Employee");
- }
-
- private void verifyRemoveFirstOccurrenceCharArray(String string, char charToRemove, String expectedString) {
- assertEquals(expectedString, StringTools.removeFirstOccurrence(string.toCharArray(), charToRemove));
- }
-
- public void testRemoveFirstOccurrenceOnWriter() {
- this.verifyRemoveFirstOccurrenceOnWriter("Emplo&yee", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnWriter("Emplo&yee&", '&', "Employee&");
- this.verifyRemoveFirstOccurrenceOnWriter("Employee &Foo", '&', "Employee Foo");
- this.verifyRemoveFirstOccurrenceOnWriter("Employee&", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnWriter("&Employee", '&', "Employee");
- }
-
- private void verifyRemoveFirstOccurrenceOnWriter(String string, char charToRemove, String expectedString) {
- Writer writer = new StringWriter();
- StringTools.removeFirstOccurrenceOn(string, charToRemove, writer);
- assertEquals(expectedString, writer.toString());
- }
-
- public void testRemoveFirstOccurrenceOnStringBuffer() {
- this.verifyRemoveFirstOccurrenceOnStringBuffer("Emplo&yee", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnStringBuffer("Emplo&yee&", '&', "Employee&");
- this.verifyRemoveFirstOccurrenceOnStringBuffer("Employee &Foo", '&', "Employee Foo");
- this.verifyRemoveFirstOccurrenceOnStringBuffer("Employee&", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnStringBuffer("&Employee", '&', "Employee");
- }
-
- private void verifyRemoveFirstOccurrenceOnStringBuffer(String string, char charToRemove, String expectedString) {
- StringBuffer sb = new StringBuffer();
- StringTools.removeFirstOccurrenceOn(string, charToRemove, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testRemoveFirstOccurrenceOnStringBuilder() {
- this.verifyRemoveFirstOccurrenceOnStringBuilder("Emplo&yee", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnStringBuilder("Emplo&yee&", '&', "Employee&");
- this.verifyRemoveFirstOccurrenceOnStringBuilder("Employee &Foo", '&', "Employee Foo");
- this.verifyRemoveFirstOccurrenceOnStringBuilder("Employee&", '&', "Employee");
- this.verifyRemoveFirstOccurrenceOnStringBuilder("&Employee", '&', "Employee");
- }
-
- private void verifyRemoveFirstOccurrenceOnStringBuilder(String string, char charToRemove, String expectedString) {
- StringBuilder sb = new StringBuilder();
- StringTools.removeFirstOccurrenceOn(string, charToRemove, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testRemoveAllOccurrences() {
- this.verifyRemoveAllOccurrences("Employee Fred", ' ', "EmployeeFred");
- this.verifyRemoveAllOccurrences(" Employee ", ' ', "Employee");
- this.verifyRemoveAllOccurrences("Employee Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllOccurrences(" Emp loyee Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllOccurrences(String string, char charToRemove, String expectedString) {
- assertEquals(expectedString, StringTools.removeAllOccurrences(string, charToRemove));
- }
-
- public void testRemoveAllOccurrencesCharArray() {
- this.verifyRemoveAllOccurrencesCharArray("Employee Fred", ' ', "EmployeeFred");
- this.verifyRemoveAllOccurrencesCharArray(" Employee ", ' ', "Employee");
- this.verifyRemoveAllOccurrencesCharArray("Employee Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllOccurrencesCharArray(" Emp loyee Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllOccurrencesCharArray(String string, char charToRemove, String expectedString) {
- assertEquals(expectedString, StringTools.removeAllOccurrences(string.toCharArray(), charToRemove));
- }
-
- public void testRemoveAllOccurrencesOnWriter() {
- this.verifyRemoveAllOccurrencesOnWriter("Employee Fred", ' ', "EmployeeFred");
- this.verifyRemoveAllOccurrencesOnWriter(" Employee ", ' ', "Employee");
- this.verifyRemoveAllOccurrencesOnWriter("Employee Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllOccurrencesOnWriter(" Emp loyee Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllOccurrencesOnWriter(String string, char charToRemove, String expectedString) {
- Writer writer = new StringWriter();
- StringTools.removeAllOccurrencesOn(string, charToRemove, writer);
- assertEquals(expectedString, writer.toString());
- }
-
- public void testRemoveAllOccurrencesOnStringBuffer() {
- this.verifyRemoveAllOccurrencesOnStringBuffer("Employee Fred", ' ', "EmployeeFred");
- this.verifyRemoveAllOccurrencesOnStringBuffer(" Employee ", ' ', "Employee");
- this.verifyRemoveAllOccurrencesOnStringBuffer("Employee Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllOccurrencesOnStringBuffer(" Emp loyee Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllOccurrencesOnStringBuffer(String string, char charToRemove, String expectedString) {
- StringBuffer sb = new StringBuffer();
- StringTools.removeAllOccurrencesOn(string, charToRemove, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testRemoveAllOccurrencesOnStringBuilder() {
- this.verifyRemoveAllOccurrencesOnStringBuilder("Employee Fred", ' ', "EmployeeFred");
- this.verifyRemoveAllOccurrencesOnStringBuilder(" Employee ", ' ', "Employee");
- this.verifyRemoveAllOccurrencesOnStringBuilder("Employee Foo", ' ', "EmployeeFoo");
- this.verifyRemoveAllOccurrencesOnStringBuilder(" Emp loyee Foo", ' ', "EmployeeFoo");
- }
-
- private void verifyRemoveAllOccurrencesOnStringBuilder(String string, char charToRemove, String expectedString) {
- StringBuilder sb = new StringBuilder();
- StringTools.removeAllOccurrencesOn(string, charToRemove, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testRemoveAllWhitespace() {
- this.verifyRemoveAllWhitespace("Employee Fred\t", "EmployeeFred");
- this.verifyRemoveAllWhitespace("\tEmployee\n", "Employee");
- this.verifyRemoveAllWhitespace("Employee \t Foo", "EmployeeFoo");
- this.verifyRemoveAllWhitespace(" Emp\tloyee \n Foo", "EmployeeFoo");
- }
-
- private void verifyRemoveAllWhitespace(String string, String expectedString) {
- assertEquals(expectedString, StringTools.removeAllWhitespace(string));
- }
-
- public void testRemoveAllWhitespaceCharArray() {
- this.verifyRemoveAllWhitespaceCharArray("Employee Fred\t", "EmployeeFred");
- this.verifyRemoveAllWhitespaceCharArray("\tEmployee\n", "Employee");
- this.verifyRemoveAllWhitespaceCharArray("Employee \t Foo", "EmployeeFoo");
- this.verifyRemoveAllWhitespaceCharArray(" Emp\tloyee \n Foo", "EmployeeFoo");
- }
-
- private void verifyRemoveAllWhitespaceCharArray(String string, String expectedString) {
- assertEquals(expectedString, StringTools.removeAllWhitespace(string.toCharArray()));
- }
-
- public void testRemoveAllWhitespaceOnWriter() {
- this.verifyRemoveAllWhitespaceOnWriter("Employee Fred\t", "EmployeeFred");
- this.verifyRemoveAllWhitespaceOnWriter("\tEmployee\n", "Employee");
- this.verifyRemoveAllWhitespaceOnWriter("Employee \t Foo", "EmployeeFoo");
- this.verifyRemoveAllWhitespaceOnWriter(" Emp\tloyee \n Foo", "EmployeeFoo");
- }
-
- private void verifyRemoveAllWhitespaceOnWriter(String string, String expectedString) {
- Writer writer = new StringWriter();
- StringTools.removeAllWhitespaceOn(string, writer);
- assertEquals(expectedString, writer.toString());
- }
-
- public void testRemoveAllWhitespaceOnStringBuffer() {
- this.verifyRemoveAllWhitespaceOnStringBuffer("Employee Fred\t", "EmployeeFred");
- this.verifyRemoveAllWhitespaceOnStringBuffer("\tEmployee\n", "Employee");
- this.verifyRemoveAllWhitespaceOnStringBuffer("Employee \t Foo", "EmployeeFoo");
- this.verifyRemoveAllWhitespaceOnStringBuffer(" Emp\tloyee \n Foo", "EmployeeFoo");
- }
-
- private void verifyRemoveAllWhitespaceOnStringBuffer(String string, String expectedString) {
- StringBuffer sb = new StringBuffer();
- StringTools.removeAllWhitespaceOn(string, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testRemoveAllWhitespaceOnStringBuilder() {
- this.verifyRemoveAllWhitespaceOnStringBuilder("Employee Fred\t", "EmployeeFred");
- this.verifyRemoveAllWhitespaceOnStringBuilder("\tEmployee\n", "Employee");
- this.verifyRemoveAllWhitespaceOnStringBuilder("Employee \t Foo", "EmployeeFoo");
- this.verifyRemoveAllWhitespaceOnStringBuilder(" Emp\tloyee \n Foo", "EmployeeFoo");
- }
-
- private void verifyRemoveAllWhitespaceOnStringBuilder(String string, String expectedString) {
- StringBuilder sb = new StringBuilder();
- StringTools.removeAllWhitespaceOn(string, sb);
- assertEquals(expectedString, sb.toString());
- }
-//////////////////////////////
- public void testCompressWhitespace() {
- this.verifyCompressWhitespace("Employee Fred\t", "Employee Fred ");
- this.verifyCompressWhitespace("\tEmployee \n", " Employee ");
- this.verifyCompressWhitespace("Employee \t Foo", "Employee Foo");
- this.verifyCompressWhitespace(" Emp\tloyee \n Foo ", " Emp loyee Foo ");
- }
-
- private void verifyCompressWhitespace(String string, String expectedString) {
- assertEquals(expectedString, StringTools.compressWhitespace(string));
- }
-
- public void testCompressWhitespaceCharArray() {
- this.verifyCompressWhitespaceCharArray("Employee Fred\t", "Employee Fred ");
- this.verifyCompressWhitespaceCharArray("\tEmployee \n", " Employee ");
- this.verifyCompressWhitespaceCharArray("Employee \t Foo", "Employee Foo");
- this.verifyCompressWhitespaceCharArray(" Emp\tloyee \n Foo ", " Emp loyee Foo ");
- }
-
- private void verifyCompressWhitespaceCharArray(String string, String expectedString) {
- assertEquals(expectedString, StringTools.compressWhitespace(string.toCharArray()));
- }
-
- public void testCompressWhitespaceOnWriter() {
- this.verifyCompressWhitespaceOnWriter("Employee Fred\t", "Employee Fred ");
- this.verifyCompressWhitespaceOnWriter("\tEmployee \n", " Employee ");
- this.verifyCompressWhitespaceOnWriter("Employee \t Foo", "Employee Foo");
- this.verifyCompressWhitespaceOnWriter(" Emp\tloyee \n Foo ", " Emp loyee Foo ");
- }
-
- private void verifyCompressWhitespaceOnWriter(String string, String expectedString) {
- Writer writer = new StringWriter();
- StringTools.compressWhitespaceOn(string, writer);
- assertEquals(expectedString, writer.toString());
- }
-
- public void testCompressWhitespaceOnStringBuffer() {
- this.verifyCompressWhitespaceOnStringBuffer("Employee Fred\t", "Employee Fred ");
- this.verifyCompressWhitespaceOnStringBuffer("\tEmployee \n", " Employee ");
- this.verifyCompressWhitespaceOnStringBuffer("Employee \t Foo", "Employee Foo");
- this.verifyCompressWhitespaceOnStringBuffer(" Emp\tloyee \n Foo ", " Emp loyee Foo ");
- }
-
- private void verifyCompressWhitespaceOnStringBuffer(String string, String expectedString) {
- StringBuffer sb = new StringBuffer();
- StringTools.compressWhitespaceOn(string, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- public void testCompressWhitespaceOnStringBuilder() {
- this.verifyCompressWhitespaceOnStringBuilder("Employee Fred\t", "Employee Fred ");
- this.verifyCompressWhitespaceOnStringBuilder("\tEmployee \n", " Employee ");
- this.verifyCompressWhitespaceOnStringBuilder("Employee \t Foo", "Employee Foo");
- this.verifyCompressWhitespaceOnStringBuilder(" Emp\tloyee \n Foo ", " Emp loyee Foo ");
- }
-
- private void verifyCompressWhitespaceOnStringBuilder(String string, String expectedString) {
- StringBuilder sb = new StringBuilder();
- StringTools.compressWhitespaceOn(string, sb);
- assertEquals(expectedString, sb.toString());
- }
-
- // ********** common prefix **********
-
- public void testCommonPrefixLength() {
- assertEquals(3, StringTools.commonPrefixLength("fooZZZ", "fooBBB"));
- assertEquals(3, StringTools.commonPrefixLength("foo", "fooBBB"));
- assertEquals(3, StringTools.commonPrefixLength("fooZZZ", "foo"));
- assertEquals(3, StringTools.commonPrefixLength("foo", "foo"));
- }
-
- public void testCommonPrefixLengthMax() {
- assertEquals(2, StringTools.commonPrefixLength("fooZZZ", "fooBBB", 2));
- assertEquals(2, StringTools.commonPrefixLength("foo", "fooBBB", 2));
- assertEquals(2, StringTools.commonPrefixLength("fooZZZ", "foo", 2));
- assertEquals(2, StringTools.commonPrefixLength("foo", "foo", 2));
- }
-
- // ********** capitalization **********
-
- public void testCapitalizeCharArray() {
- this.verifyCapitalizeCharArray("Oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeCharArray("Oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeCharArray(" ", new char[] { ' ', ' ', ' ' });
- this.verifyCapitalizeCharArray("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyCapitalizeCharArray("", new char[0]);
- this.verifyCapitalizeCharArray("A", new char[] { 'a' });
- this.verifyCapitalizeCharArray("\u00C9cole", new char[] { '\u00E9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyCapitalizeCharArray(String expected, char[] string) {
- assertEquals(expected, StringTools.capitalize(string));
- }
-
- public void testCapitalizeString() {
- this.verifyCapitalizeString("Oracle", "Oracle");
- this.verifyCapitalizeString("Oracle", "oracle");
- this.verifyCapitalizeString(" ", " ");
- this.verifyCapitalizeString("ORACLE", "ORACLE");
- this.verifyCapitalizeString("", "");
- this.verifyCapitalizeString("A", "a");
- this.verifyCapitalizeString("\u00C9cole", "\u00E9cole"); // �cole->�COLE
- }
-
- private void verifyCapitalizeString(String expected, String string) {
- assertEquals(expected, StringTools.capitalize(string));
- }
-
- public void testCapitalizeOnCharArrayStringBuffer() {
- this.verifyCapitalizeOnCharArrayStringBuffer("Oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayStringBuffer("Oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayStringBuffer(" ", new char[] { ' ', ' ', ' ' });
- this.verifyCapitalizeOnCharArrayStringBuffer("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyCapitalizeOnCharArrayStringBuffer("", new char[0]);
- this.verifyCapitalizeOnCharArrayStringBuffer("A", new char[] { 'a' });
- this.verifyCapitalizeOnCharArrayStringBuffer("\u00C9cole", new char[] { '\u00E9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyCapitalizeOnCharArrayStringBuffer(String expected, char[] string) {
- StringBuffer sb = new StringBuffer();
- StringTools.capitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testCapitalizeOnCharArrayStringBuilder() {
- this.verifyCapitalizeOnCharArrayStringBuilder("Oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayStringBuilder("Oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayStringBuilder(" ", new char[] { ' ', ' ', ' ' });
- this.verifyCapitalizeOnCharArrayStringBuilder("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyCapitalizeOnCharArrayStringBuilder("", new char[0]);
- this.verifyCapitalizeOnCharArrayStringBuilder("A", new char[] { 'a' });
- this.verifyCapitalizeOnCharArrayStringBuilder("\u00C9cole", new char[] { '\u00E9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyCapitalizeOnCharArrayStringBuilder(String expected, char[] string) {
- StringBuilder sb = new StringBuilder();
- StringTools.capitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testCapitalizeOnStringStringBuffer() {
- this.verifyCapitalizeOnStringStringBuffer("Oracle", "Oracle");
- this.verifyCapitalizeOnStringStringBuffer("Oracle", "oracle");
- this.verifyCapitalizeOnStringStringBuffer(" ", " ");
- this.verifyCapitalizeOnStringStringBuffer("ORACLE", "ORACLE");
- this.verifyCapitalizeOnStringStringBuffer("", "");
- this.verifyCapitalizeOnStringStringBuffer("A", "a");
- this.verifyCapitalizeOnStringStringBuffer("\u00C9cole", "\u00E9cole"); // �cole->�COLE
- }
-
- private void verifyCapitalizeOnStringStringBuffer(String expected, String string) {
- StringBuffer sb = new StringBuffer();
- StringTools.capitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testCapitalizeOnStringStringBuilder() {
- this.verifyCapitalizeOnStringStringBuilder("Oracle", "Oracle");
- this.verifyCapitalizeOnStringStringBuilder("Oracle", "oracle");
- this.verifyCapitalizeOnStringStringBuilder(" ", " ");
- this.verifyCapitalizeOnStringStringBuilder("ORACLE", "ORACLE");
- this.verifyCapitalizeOnStringStringBuilder("", "");
- this.verifyCapitalizeOnStringStringBuilder("A", "a");
- this.verifyCapitalizeOnStringStringBuilder("\u00C9cole", "\u00E9cole"); // �cole->�COLE
- }
-
- private void verifyCapitalizeOnStringStringBuilder(String expected, String string) {
- StringBuilder sb = new StringBuilder();
- StringTools.capitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testCapitalizeOnCharArrayWriter() {
- this.verifyCapitalizeOnCharArrayWriter("Oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayWriter("Oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyCapitalizeOnCharArrayWriter(" ", new char[] { ' ', ' ', ' ' });
- this.verifyCapitalizeOnCharArrayWriter("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyCapitalizeOnCharArrayWriter("", new char[0]);
- this.verifyCapitalizeOnCharArrayWriter("A", new char[] { 'a' });
- this.verifyCapitalizeOnCharArrayWriter("\u00C9cole", new char[] { '\u00E9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyCapitalizeOnCharArrayWriter(String expected, char[] string) {
- Writer writer = new StringWriter();
- StringTools.capitalizeOn(string, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testCapitalizeOnStringWriter() {
- this.verifyCapitalizeOnStringWriter("Oracle", "Oracle");
- this.verifyCapitalizeOnStringWriter("Oracle", "oracle");
- this.verifyCapitalizeOnStringWriter(" ", " ");
- this.verifyCapitalizeOnStringWriter("ORACLE", "ORACLE");
- this.verifyCapitalizeOnStringWriter("", "");
- this.verifyCapitalizeOnStringWriter("A", "a");
- this.verifyCapitalizeOnStringWriter("\u00C9cole", "\u00E9cole"); // �cole->�COLE
- }
-
- private void verifyCapitalizeOnStringWriter(String expected, String string) {
- Writer writer = new StringWriter();
- StringTools.capitalizeOn(string, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testUnapitalizeCharArray() {
- this.verifyUncapitalizeCharArray("oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeCharArray("oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeCharArray(" ", new char[] { ' ', ' ', ' ' });
- this.verifyUncapitalizeCharArray("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyUncapitalizeCharArray("", new char[0]);
- this.verifyUncapitalizeCharArray("a", new char[] { 'A' });
- this.verifyUncapitalizeCharArray("\u00E9cole", new char[] { '\u00C9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyUncapitalizeCharArray(String expected, char[] string) {
- assertEquals(expected, StringTools.uncapitalize(string));
- }
-
- public void testUncapitalizeString() {
- this.verifyUncapitalizeString("oracle", "Oracle");
- this.verifyUncapitalizeString("oracle", "oracle");
- this.verifyUncapitalizeString(" ", " ");
- this.verifyUncapitalizeString("ORACLE", "ORACLE");
- this.verifyUncapitalizeString("", "");
- this.verifyUncapitalizeString("a", "A");
- this.verifyUncapitalizeString("\u00E9cole", "\u00C9cole"); // �cole->�COLE
- }
-
- private void verifyUncapitalizeString(String expected, String string) {
- assertEquals(expected, StringTools.uncapitalize(string));
- }
-
- public void testUncapitalizeOnCharArrayStringBuffer() {
- this.verifyUncapitalizeOnCharArrayStringBuffer("oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayStringBuffer("oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayStringBuffer(" ", new char[] { ' ', ' ', ' ' });
- this.verifyUncapitalizeOnCharArrayStringBuffer("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyUncapitalizeOnCharArrayStringBuffer("", new char[0]);
- this.verifyUncapitalizeOnCharArrayStringBuffer("a", new char[] { 'A' });
- this.verifyUncapitalizeOnCharArrayStringBuffer("\u00E9cole", new char[] { '\u00C9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyUncapitalizeOnCharArrayStringBuffer(String expected, char[] string) {
- StringBuffer sb = new StringBuffer();
- StringTools.uncapitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testUncapitalizeOnCharArrayStringBuilder() {
- this.verifyUncapitalizeOnCharArrayStringBuilder("oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayStringBuilder("oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayStringBuilder(" ", new char[] { ' ', ' ', ' ' });
- this.verifyUncapitalizeOnCharArrayStringBuilder("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyUncapitalizeOnCharArrayStringBuilder("", new char[0]);
- this.verifyUncapitalizeOnCharArrayStringBuilder("a", new char[] { 'A' });
- this.verifyUncapitalizeOnCharArrayStringBuilder("\u00E9cole", new char[] { '\u00C9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyUncapitalizeOnCharArrayStringBuilder(String expected, char[] string) {
- StringBuilder sb = new StringBuilder();
- StringTools.uncapitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testUncapitalizeOnStringStringBuffer() {
- this.verifyUncapitalizeOnStringStringBuffer("oracle", "Oracle");
- this.verifyUncapitalizeOnStringStringBuffer("oracle", "oracle");
- this.verifyUncapitalizeOnStringStringBuffer(" ", " ");
- this.verifyUncapitalizeOnStringStringBuffer("ORACLE", "ORACLE");
- this.verifyUncapitalizeOnStringStringBuffer("", "");
- this.verifyUncapitalizeOnStringStringBuffer("a", "A");
- this.verifyUncapitalizeOnStringStringBuffer("\u00E9cole", "\u00C9cole"); // �cole->�COLE
- }
-
- private void verifyUncapitalizeOnStringStringBuffer(String expected, String string) {
- StringBuffer sb = new StringBuffer();
- StringTools.uncapitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testUncapitalizeOnStringStringBuilder() {
- this.verifyUncapitalizeOnStringStringBuilder("oracle", "Oracle");
- this.verifyUncapitalizeOnStringStringBuilder("oracle", "oracle");
- this.verifyUncapitalizeOnStringStringBuilder(" ", " ");
- this.verifyUncapitalizeOnStringStringBuilder("ORACLE", "ORACLE");
- this.verifyUncapitalizeOnStringStringBuilder("", "");
- this.verifyUncapitalizeOnStringStringBuilder("a", "A");
- this.verifyUncapitalizeOnStringStringBuilder("\u00E9cole", "\u00C9cole"); // �cole->�COLE
- }
-
- private void verifyUncapitalizeOnStringStringBuilder(String expected, String string) {
- StringBuilder sb = new StringBuilder();
- StringTools.uncapitalizeOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testUncapitalizeOnCharArrayWriter() {
- this.verifyUncapitalizeOnCharArrayWriter("oracle", new char[] { 'O', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayWriter("oracle", new char[] { 'o', 'r', 'a', 'c', 'l', 'e' });
- this.verifyUncapitalizeOnCharArrayWriter(" ", new char[] { ' ', ' ', ' ' });
- this.verifyUncapitalizeOnCharArrayWriter("ORACLE", new char[] { 'O', 'R', 'A', 'C', 'L', 'E' });
- this.verifyUncapitalizeOnCharArrayWriter("", new char[0]);
- this.verifyUncapitalizeOnCharArrayWriter("a", new char[] { 'A' });
- this.verifyUncapitalizeOnCharArrayWriter("\u00E9cole", new char[] { '\u00C9', 'c', 'o', 'l', 'e' });
- }
-
- private void verifyUncapitalizeOnCharArrayWriter(String expected, char[] string) {
- Writer writer = new StringWriter();
- StringTools.uncapitalizeOn(string, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testUncapitalizeOnStringWriter() {
- this.verifyUncapitalizeOnStringWriter("oracle", "Oracle");
- this.verifyUncapitalizeOnStringWriter("oracle", "oracle");
- this.verifyUncapitalizeOnStringWriter(" ", " ");
- this.verifyUncapitalizeOnStringWriter("ORACLE", "ORACLE");
- this.verifyUncapitalizeOnStringWriter("", "");
- this.verifyUncapitalizeOnStringWriter("a", "A");
- this.verifyUncapitalizeOnStringWriter("\u00E9cole", "\u00C9cole"); // �cole->�COLE
- }
-
- private void verifyUncapitalizeOnStringWriter(String expected, String string) {
- Writer writer = new StringWriter();
- StringTools.uncapitalizeOn(string, writer);
- assertEquals(expected, writer.toString());
- }
-
- // ********** #toString() **********
-
- public void testBuildToStringClassName_anonymous() {
- Object o = new Object(){/*anonymous subclass of Object*/};
- assertEquals("Object", StringTools.buildToStringClassName(o.getClass()));
- }
-
- public void testBuildToStringClassName_member() {
- assertEquals("Map.Entry", StringTools.buildToStringClassName(java.util.Map.Entry.class));
- }
-
- public void testBuildToStringClassName_local() {
- class Foo {
- Bar bar = new Bar();
- class Bar {
- Bar() {
- super();
- }
- }
- Foo() {
- super();
- }
- }
- Foo foo = new Foo();
- assertEquals("StringToolsTests.Foo", StringTools.buildToStringClassName(foo.getClass()));
- assertEquals("StringToolsTests.Foo.Bar", StringTools.buildToStringClassName(foo.bar.getClass()));
- }
-
- // ********** queries **********
-
- public void testStringIsEmptyString() {
- assertTrue(StringTools.stringIsEmpty((String) null));
- assertTrue(StringTools.stringIsEmpty(""));
- assertTrue(StringTools.stringIsEmpty(" "));
- assertTrue(StringTools.stringIsEmpty(" \t\t "));
- assertTrue(StringTools.stringIsEmpty(" \t\t " + StringTools.CR));
- }
-
- public void testStringIsEmptyCharArray() {
- assertTrue(StringTools.stringIsEmpty((char[]) null));
- this.verifyStringIsEmptyCharArray("");
- this.verifyStringIsEmptyCharArray(" \t\t ");
- this.verifyStringIsEmptyCharArray(" ");
- this.verifyStringIsEmptyCharArray(" \t\t " + StringTools.CR);
- }
-
- private void verifyStringIsEmptyCharArray(String string) {
- assertTrue(StringTools.stringIsEmpty(string.toCharArray()));
- }
-
- public void testStringsAreEqualStringString() {
- assertTrue(StringTools.stringsAreEqual((String) null, (String) null));
- assertFalse(StringTools.stringsAreEqual(null, "asdf"));
- assertFalse(StringTools.stringsAreEqual("asdf", null));
- assertTrue(StringTools.stringsAreEqual("asdf", "asdf"));
- assertFalse(StringTools.stringsAreEqual("asdf", "ASDF"));
- }
-
- public void testStringsAreEqualCharArrayCharArray() {
- assertTrue(StringTools.stringsAreEqual((char[]) null, (char[]) null));
- assertFalse(StringTools.stringsAreEqual((char[]) null, "asdf".toCharArray()));
- assertFalse(StringTools.stringsAreEqual("asdf".toCharArray(), (char[]) null));
- assertTrue(StringTools.stringsAreEqual("asdf".toCharArray(), "asdf".toCharArray()));
- assertFalse(StringTools.stringsAreEqual("asdf".toCharArray(), "ASDF".toCharArray()));
- }
-
- public void testStringsAreEqualIgnoreCaseStringString() {
- assertTrue(StringTools.stringsAreEqualIgnoreCase((String) null, (String) null));
- assertFalse(StringTools.stringsAreEqualIgnoreCase(null, "asdf"));
- assertFalse(StringTools.stringsAreEqualIgnoreCase("asdf", null));
- assertTrue(StringTools.stringsAreEqualIgnoreCase("asdf", "asdf"));
- assertTrue(StringTools.stringsAreEqualIgnoreCase("asdf", "ASDF"));
- }
-
- public void testStringsAreEqualIgnoreCaseCharArrayCharArray() {
- assertTrue(StringTools.stringsAreEqualIgnoreCase((char[]) null, (char[]) null));
- assertFalse(StringTools.stringsAreEqualIgnoreCase((char[]) null, "asdf".toCharArray()));
- assertFalse(StringTools.stringsAreEqualIgnoreCase("asdf".toCharArray(), (char[]) null));
- assertTrue(StringTools.stringsAreEqualIgnoreCase("asdf".toCharArray(), "asdf".toCharArray()));
- assertTrue(StringTools.stringsAreEqualIgnoreCase("asdf".toCharArray(), "ASDF".toCharArray()));
- }
-
- public void testStringStartsWithIgnoreCaseStringString() {
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf", "as"));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf", "aS"));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf", ""));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf", "A"));
-
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf", "bsdf"));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf", "g"));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf", "asdg"));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf", "asdfg"));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf", "asdfgggggg"));
- }
-
- public void testStringStartsWithIgnoreCaseCharArrayCharArray() {
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "as".toCharArray()));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "aS".toCharArray()));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "".toCharArray()));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "A".toCharArray()));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "ASDF".toCharArray()));
- assertTrue(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "asdf".toCharArray()));
-
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "bsdf".toCharArray()));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "g".toCharArray()));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "asdg".toCharArray()));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "asdfg".toCharArray()));
- assertFalse(StringTools.stringStartsWithIgnoreCase("asdf".toCharArray(), "asdfgggggg".toCharArray()));
- }
-
- public void testCharactersAreEqualIgnoreCase() {
- assertTrue(StringTools.charactersAreEqualIgnoreCase('a', 'a'));
- assertTrue(StringTools.charactersAreEqualIgnoreCase('a', 'A'));
- assertTrue(StringTools.charactersAreEqualIgnoreCase('A', 'a'));
- assertTrue(StringTools.charactersAreEqualIgnoreCase('A', 'A'));
-
- assertFalse(StringTools.charactersAreEqualIgnoreCase('a', 'b'));
- assertFalse(StringTools.charactersAreEqualIgnoreCase('A', 'b'));
- }
-
- public void testStringIsUppercase() {
- this.verifyStringIsUppercase("FOO");
- this.verifyStringIsUppercase("FOO2");
- this.verifyStringIsUppercase("F O O");
- this.denyStringIsUppercase("Foo");
- this.denyStringIsUppercase("");
- }
-
- private void verifyStringIsUppercase(String s) {
- assertTrue(StringTools.stringIsUppercase(s));
- assertTrue(StringTools.stringIsUppercase(s.toCharArray()));
- }
-
- private void denyStringIsUppercase(String s) {
- assertFalse(StringTools.stringIsUppercase(s));
- assertFalse(StringTools.stringIsUppercase(s.toCharArray()));
- }
-
- public void testStringIsLowercase() {
- this.verifyStringIsLowercase("foo");
- this.verifyStringIsLowercase("foo2");
- this.verifyStringIsLowercase("f o o");
- this.denyStringIsLowercase("Foo");
- this.denyStringIsLowercase("");
- }
-
- private void verifyStringIsLowercase(String s) {
- assertTrue(StringTools.stringIsLowercase(s));
- assertTrue(StringTools.stringIsLowercase(s.toCharArray()));
- }
-
- private void denyStringIsLowercase(String s) {
- assertFalse(StringTools.stringIsLowercase(s));
- assertFalse(StringTools.stringIsLowercase(s.toCharArray()));
- }
-
- // ********** convert camel-case to all-caps **********
-
- public void testConvertCamelCaseToAllCaps() {
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("test"));
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("TEST"));
- assertEquals("TEST_TEST", StringTools.convertCamelCaseToAllCaps("testTest"));
- assertEquals("TEST_TEST", StringTools.convertCamelCaseToAllCaps("TestTest"));
- assertEquals("TEST_TEST_TEST", StringTools.convertCamelCaseToAllCaps("testTESTTest"));
- assertEquals("TEST_TEST_TEST", StringTools.convertCamelCaseToAllCaps("TestTESTTest"));
- assertEquals("TEST_TEST_TEST_T", StringTools.convertCamelCaseToAllCaps("TestTESTTestT"));
- }
-
- public void testConvertCamelCaseToAllCapsOnWriter() {
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST", "test");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST", "TEST");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST_TEST", "testTest");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST_TEST", "TestTest");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST_TEST_TEST", "testTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST_TEST_TEST", "TestTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnWriter("TEST_TEST_TEST_T", "TestTESTTestT");
- }
-
- private void verifyConvertCamelCaseToAllCapsOnWriter(String expected, String string) {
- Writer writer = new StringWriter();
- StringTools.convertCamelCaseToAllCapsOn(string, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testConvertCamelCaseToAllCapsOnStringBuffer() {
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST", "test");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST", "TEST");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST_TEST", "testTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST_TEST", "TestTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST_TEST_TEST", "testTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST_TEST_TEST", "TestTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuffer("TEST_TEST_TEST_T", "TestTESTTestT");
- }
-
- private void verifyConvertCamelCaseToAllCapsOnStringBuffer(String expected, String string) {
- StringBuffer sb = new StringBuffer();
- StringTools.convertCamelCaseToAllCapsOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testConvertCamelCaseToAllCapsOnStringBuilder() {
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST", "test");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST", "TEST");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST_TEST", "testTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST_TEST", "TestTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST_TEST_TEST", "testTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST_TEST_TEST", "TestTESTTest");
- this.verifyConvertCamelCaseToAllCapsOnStringBuilder("TEST_TEST_TEST_T", "TestTESTTestT");
- }
-
- private void verifyConvertCamelCaseToAllCapsOnStringBuilder(String expected, String string) {
- StringBuilder sb = new StringBuilder();
- StringTools.convertCamelCaseToAllCapsOn(string, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testConvertCamelCaseToAllCapsMaxLength() {
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("test", 44));
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("test", 4));
- assertEquals("TES", StringTools.convertCamelCaseToAllCaps("test", 3));
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("TEST", 5));
- assertEquals("TE", StringTools.convertCamelCaseToAllCaps("TEST", 2));
- assertEquals("TEST_TEST", StringTools.convertCamelCaseToAllCaps("testTest", 9));
- assertEquals("TEST_TES", StringTools.convertCamelCaseToAllCaps("testTest", 8));
- assertEquals("TEST_T", StringTools.convertCamelCaseToAllCaps("testTest", 6));
- assertEquals("TEST_", StringTools.convertCamelCaseToAllCaps("testTest", 5));
- assertEquals("TEST", StringTools.convertCamelCaseToAllCaps("testTest", 4));
- assertEquals("TEST_TEST", StringTools.convertCamelCaseToAllCaps("TestTest", 9));
- assertEquals("TEST_TEST", StringTools.convertCamelCaseToAllCaps("TestTest", 1100));
- assertEquals("TEST_TEST_", StringTools.convertCamelCaseToAllCaps("testTESTTest", 10));
- assertEquals("TEST_TEST_TEST", StringTools.convertCamelCaseToAllCaps("TestTESTTest", 14));
- assertEquals("TEST_TEST_TEST_T", StringTools.convertCamelCaseToAllCaps("TestTESTTestT", 16));
- assertEquals("TEST_TEST_TEST_", StringTools.convertCamelCaseToAllCaps("TestTESTTestT", 15));
- }
-
- public void testConvertCamelCaseToAllCapsMaxLengthOnWriter() {
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST", "test", 44);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST", "test", 4);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TES", "test", 3);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST", "TEST", 5);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TE", "TEST", 2);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST", "testTest", 9);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TES", "testTest", 8);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_T", "testTest", 6);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_", "testTest", 5);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST", "testTest", 4);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST", "TestTest", 9);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST", "TestTest", 1100);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST_", "testTESTTest", 10);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST_TEST", "TestTESTTest", 14);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST_TEST_T", "TestTESTTestT", 16);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnWriter("TEST_TEST_TEST_", "TestTESTTestT", 15);
- }
-
- private void verifyConvertCamelCaseToAllCapsMaxLengthOnWriter(String expected, String string, int max) {
- Writer writer = new StringWriter();
- StringTools.convertCamelCaseToAllCapsOn(string, max, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testConvertCamelCaseToAllCapsMaxLengthOnStringBuffer() {
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST", "test", 44);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST", "test", 4);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TES", "test", 3);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST", "TEST", 5);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TE", "TEST", 2);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST", "testTest", 9);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TES", "testTest", 8);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_T", "testTest", 6);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_", "testTest", 5);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST", "testTest", 4);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST", "TestTest", 9);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST", "TestTest", 1100);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST_", "testTESTTest", 10);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST_TEST", "TestTESTTest", 14);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST_TEST_T", "TestTESTTestT", 16);
- this.verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer("TEST_TEST_TEST_", "TestTESTTestT", 15);
- }
-
- private void verifyConvertCamelCaseToAllCapsMaxLengthOnStringBuffer(String expected, String string, int max) {
- StringBuffer sb = new StringBuffer();
- StringTools.convertCamelCaseToAllCapsOn(string, max, sb);
- assertEquals(expected, sb.toString());
- }
-
- // ********** convert underscores to all-caps **********
-
- public void testConvertUnderscoresToCamelCase() {
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("TEST", false));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("TEST_", false));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("TEST____", false));
- assertEquals("Test", StringTools.convertUnderscoresToCamelCase("TEST", true));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("TeST", false));
- assertEquals("testTest", StringTools.convertUnderscoresToCamelCase("TEST_TEST", false));
- assertEquals("testTest", StringTools.convertUnderscoresToCamelCase("TEST___TEST", false));
- assertEquals("TestTest", StringTools.convertUnderscoresToCamelCase("TEST_TEST", true));
- assertEquals("testTestTest", StringTools.convertUnderscoresToCamelCase("TEST_TEST_TEST", false));
- assertEquals("TestTestTest", StringTools.convertUnderscoresToCamelCase("TEST_TEST_TEST", true));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("TEST_TEST_TEST_T", false));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("_TEST_TEST_TEST_T", false));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("__TEST_TEST_TEST_T", false));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("TEST_TEST_TEST_T", true));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("_TEST_TEST_TEST_T", true));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("__TEST_TEST_TEST_T", true));
- }
-
- public void testConvertUnderscoresToCamelCaseLowercase() {
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("test", false));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("test_", false));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("test____", false));
- assertEquals("Test", StringTools.convertUnderscoresToCamelCase("test", true));
- assertEquals("test", StringTools.convertUnderscoresToCamelCase("test", false));
- assertEquals("testTest", StringTools.convertUnderscoresToCamelCase("test_test", false));
- assertEquals("testTest", StringTools.convertUnderscoresToCamelCase("test___test", false));
- assertEquals("TestTest", StringTools.convertUnderscoresToCamelCase("test_test", true));
- assertEquals("testTestTest", StringTools.convertUnderscoresToCamelCase("test_test_test", false));
- assertEquals("TestTestTest", StringTools.convertUnderscoresToCamelCase("test_test_test", true));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("test_test_test_t", false));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("_test_test_test_t", false));
- assertEquals("testTestTestT", StringTools.convertUnderscoresToCamelCase("__test_test_test_t", false));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("test_test_test_t", true));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("_test_test_test_t", true));
- assertEquals("TestTestTestT", StringTools.convertUnderscoresToCamelCase("__test_test_test_t", true));
- }
-
- public void testConvertUnderscoresToCamelCaseOnWriter() {
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "TEST_", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "TEST____", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("Test", "TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "TeST", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTest", "TEST_TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTest", "TEST___TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTest", "TEST_TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTest", "TEST_TEST_TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTest", "TEST_TEST_TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "_TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "__TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "TEST_TEST_TEST_T", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "_TEST_TEST_TEST_T", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "__TEST_TEST_TEST_T", true);
- }
-
- public void testConvertUnderscoresToCamelCaseOnWriterLowercase() {
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "test", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "test_", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "test____", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("Test", "test", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("test", "test", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTest", "test_test", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTest", "test___test", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTest", "test_test", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTest", "test_test_test", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTest", "test_test_test", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "_test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("testTestTestT", "__test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "test_test_test_t", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "_test_test_test_t", true);
- this.verifyConvertUnderscoresToCamelCaseOnWriter("TestTestTestT", "__test_test_test_t", true);
- }
-
- private void verifyConvertUnderscoresToCamelCaseOnWriter(String expected, String string, boolean capitalizeFirstLetter) {
- Writer writer = new StringWriter();
- StringTools.convertUnderscoresToCamelCaseOn(string, capitalizeFirstLetter, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testConvertUnderscoresToCamelCaseOnStringBuffer() {
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "TEST_", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "TEST____", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("Test", "TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "TeST", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTest", "TEST_TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTest", "TEST___TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTest", "TEST_TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTest", "TEST_TEST_TEST", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTest", "TEST_TEST_TEST", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "_TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "__TEST_TEST_TEST_T", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "TEST_TEST_TEST_T", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "_TEST_TEST_TEST_T", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "__TEST_TEST_TEST_T", true);
- }
-
- public void testConvertUnderscoresToCamelCaseOnStringBufferLowercase() {
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "test", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "test_", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "test____", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("Test", "test", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("test", "test", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTest", "test_test", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTest", "test___test", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTest", "test_test", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTest", "test_test_test", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTest", "test_test_test", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "_test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("testTestTestT", "__test_test_test_t", false);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "test_test_test_t", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "_test_test_test_t", true);
- this.verifyConvertUnderscoresToCamelCaseOnStringBuffer("TestTestTestT", "__test_test_test_t", true);
- }
-
- private void verifyConvertUnderscoresToCamelCaseOnStringBuffer(String expected, String string, boolean capitalizeFirstLetter) {
- StringBuffer sb = new StringBuffer();
- StringTools.convertUnderscoresToCamelCaseOn(string, capitalizeFirstLetter, sb);
- assertEquals(expected, sb.toString());
- }
-
- // ********** delimiting **********
-
- public void testStringIsQuoted() {
- this.denyStringIsQuoted("foo");
- this.verifyStringIsQuoted("\"foo\"");
-
- this.denyStringIsQuoted("");
- this.verifyStringIsQuoted("\"\"");
-
- this.denyStringIsQuoted("\"");
- this.denyStringIsQuoted(" ");
- this.denyStringIsQuoted("''");
- this.denyStringIsQuoted("'foo'");
- }
-
- private void verifyStringIsQuoted(String s) {
- assertTrue(StringTools.stringIsQuoted(s));
- assertTrue(StringTools.stringIsQuoted(s.toCharArray()));
- }
-
- private void denyStringIsQuoted(String s) {
- assertFalse(StringTools.stringIsQuoted(s));
- assertFalse(StringTools.stringIsQuoted(s.toCharArray()));
- }
-
- public void testStringIsParenthetical() {
- this.denyStringIsParenthetical("foo");
- this.verifyStringIsParenthetical("(foo)");
-
- this.denyStringIsParenthetical("");
- this.verifyStringIsParenthetical("()");
-
- this.denyStringIsParenthetical("(");
- this.denyStringIsParenthetical(" ");
- this.denyStringIsParenthetical("''");
- this.denyStringIsParenthetical("'foo'");
- }
-
- private void verifyStringIsParenthetical(String s) {
- assertTrue(StringTools.stringIsParenthetical(s));
- assertTrue(StringTools.stringIsParenthetical(s.toCharArray()));
- }
-
- private void denyStringIsParenthetical(String s) {
- assertFalse(StringTools.stringIsParenthetical(s));
- assertFalse(StringTools.stringIsParenthetical(s.toCharArray()));
- }
-
- public void testStringIsBracketed() {
- this.denyStringIsBracketed("foo");
- this.verifyStringIsBracketed("[foo]");
-
- this.denyStringIsBracketed("");
- this.verifyStringIsBracketed("[]");
-
- this.denyStringIsBracketed("[");
- this.denyStringIsBracketed(" ");
- this.denyStringIsBracketed("''");
- this.denyStringIsBracketed("'foo'");
- }
-
- private void verifyStringIsBracketed(String s) {
- assertTrue(StringTools.stringIsBracketed(s));
- assertTrue(StringTools.stringIsBracketed(s.toCharArray()));
- }
-
- private void denyStringIsBracketed(String s) {
- assertFalse(StringTools.stringIsBracketed(s));
- assertFalse(StringTools.stringIsBracketed(s.toCharArray()));
- }
-
- public void testStringIsBraced() {
- this.denyStringIsBraced("foo");
- this.verifyStringIsBraced("{foo}");
-
- this.denyStringIsBraced("");
- this.verifyStringIsBraced("{}");
-
- this.denyStringIsBraced("{");
- this.denyStringIsBraced(" ");
- this.denyStringIsBraced("''");
- this.denyStringIsBraced("'foo'");
- }
-
- private void verifyStringIsBraced(String s) {
- assertTrue(StringTools.stringIsBraced(s));
- assertTrue(StringTools.stringIsBraced(s.toCharArray()));
- }
-
- private void denyStringIsBraced(String s) {
- assertFalse(StringTools.stringIsBraced(s));
- assertFalse(StringTools.stringIsBraced(s.toCharArray()));
- }
-
- public void testStringIsChevroned() {
- this.denyStringIsChevroned("foo");
- this.verifyStringIsChevroned("<foo>");
-
- this.denyStringIsChevroned("");
- this.verifyStringIsChevroned("<>");
-
- this.denyStringIsChevroned("{");
- this.denyStringIsChevroned(" ");
- this.denyStringIsChevroned("''");
- this.denyStringIsChevroned("'foo'");
- }
-
- private void verifyStringIsChevroned(String s) {
- assertTrue(StringTools.stringIsChevroned(s));
- assertTrue(StringTools.stringIsChevroned(s.toCharArray()));
- }
-
- private void denyStringIsChevroned(String s) {
- assertFalse(StringTools.stringIsChevroned(s));
- assertFalse(StringTools.stringIsChevroned(s.toCharArray()));
- }
-
- public void testStringIsDelimited() {
- this.denyStringIsDelimited("foo", '?');
- this.verifyStringIsDelimited("?foo?", '?');
-
- this.denyStringIsDelimited("", '?');
- this.verifyStringIsDelimited("\"\"", '"');
- this.verifyStringIsDelimited("?xx?", '?');
- this.denyStringIsDelimited("?xx]", '?');
-
- this.denyStringIsDelimited("\"", '"');
- this.denyStringIsDelimited(" ", ' ');
- this.denyStringIsDelimited("''", '"');
- this.denyStringIsDelimited("'foo'", '?');
- }
-
- private void verifyStringIsDelimited(String s, char c) {
- assertTrue(StringTools.stringIsDelimited(s, c));
- assertTrue(StringTools.stringIsDelimited(s.toCharArray(), c));
- }
-
- private void denyStringIsDelimited(String s, char c) {
- assertFalse(StringTools.stringIsDelimited(s, c));
- assertFalse(StringTools.stringIsDelimited(s.toCharArray(), c));
- }
-
- public void testStringIsDelimited2() {
- this.denyStringIsDelimited2("foo", '[', ']');
- this.verifyStringIsDelimited2("{foo}", '{', '}');
-
- this.denyStringIsDelimited2("", '[', ']');
- this.verifyStringIsDelimited2("[]", '[', ']');
- this.verifyStringIsDelimited2("[xx]", '[', ']');
- this.denyStringIsDelimited2("?xx]", '[', ']');
-
- this.denyStringIsDelimited2("\"", '[', ']');
- this.denyStringIsDelimited2(" ", '[', ']');
- this.denyStringIsDelimited2("''", '[', ']');
- this.denyStringIsDelimited2("'foo'", '[', ']');
- }
-
- private void verifyStringIsDelimited2(String s, char start, char end) {
- assertTrue(StringTools.stringIsDelimited(s, start, end));
- assertTrue(StringTools.stringIsDelimited(s.toCharArray(), start, end));
- }
-
- private void denyStringIsDelimited2(String s, char start, char end) {
- assertFalse(StringTools.stringIsDelimited(s, start, end));
- assertFalse(StringTools.stringIsDelimited(s.toCharArray(), start, end));
- }
-
- // ********** undelimiting **********
-
- public void testUndelimit() {
- this.verifyUndelimit("\"foo\"", "foo");
- this.verifyUndelimit("\"\"", "");
- this.verifyUndelimit("'foo'", "foo");
- this.verifyUndelimit("\"fo\"\"o\"", "fo\"o");
- this.verifyUndelimit("\"foo\"\"\"", "foo\"");
- this.verifyUndelimit("\"\"\"foo\"", "\"foo");
- this.verifyUndelimit("[foo]", "foo");
- this.verifyUndelimit("\"\"\"", "\"");
- this.verifyUndelimit("\"foo\"bar\"", "foo\"");
- this.verifyUndelimit("\"foo\"\"", "foo\"");
- }
-
- private void verifyUndelimit(String s, String expected) {
- assertEquals(expected, StringTools.undelimit(s));
- assertEquals(expected, StringTools.undelimit(s.toCharArray()));
- }
-
- public void testUndelimitInt() {
- this.verifyUndelimitInt("\"foo\"", 2, "o");
- this.verifyUndelimitInt("\"\"foo\"\"", 2, "foo");
- this.verifyUndelimitInt("'foo'", 2, "o");
- }
-
- private void verifyUndelimitInt(String s, int count, String expected) {
- assertEquals(expected, StringTools.undelimit(s, count));
- assertEquals(expected, StringTools.undelimit(s.toCharArray(), count));
- }
-
- public void testUndelimitIntException() {
- this.denyUndelimitInt("\"\"", 2);
- this.denyUndelimitInt("'o'", 2);
- }
-
- private void denyUndelimitInt(String s, int count) {
- boolean exCaught = false;
- try {
- String bogus = StringTools.undelimit(s, count);
- fail("invalid string: " + bogus);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- char[] bogus = StringTools.undelimit(s.toCharArray(), count);
- fail("invalid string: " + new String(bogus));
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testUndelimitOnWriter() {
- this.verifyUndelimitOnWriter("\"foo\"", "foo");
- this.verifyUndelimitOnWriter("\"\"", "");
- this.verifyUndelimitOnWriter("'foo'", "foo");
- this.verifyUndelimitOnWriter("\"fo\"\"o\"", "fo\"o");
- this.verifyUndelimitOnWriter("\"foo\"\"\"", "foo\"");
- this.verifyUndelimitOnWriter("\"\"\"foo\"", "\"foo");
- this.verifyUndelimitOnWriter("[foo]", "foo");
- this.verifyUndelimitOnWriter("\"\"\"", "\"");
- this.verifyUndelimitOnWriter("\"foo\"bar\"", "foo\"");
- this.verifyUndelimitOnWriter("\"foo\"\"", "foo\"");
- }
-
- private void verifyUndelimitOnWriter(String s, String expected) {
- Writer writer = new StringWriter();
- StringTools.undelimitOn(s, writer);
- assertEquals(expected, writer.toString());
-
- writer = new StringWriter();
- StringTools.undelimitOn(s.toCharArray(), writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testUndelimitOnStringBuffer() {
- this.verifyUndelimitOnStringBuffer("\"foo\"", "foo");
- this.verifyUndelimitOnStringBuffer("\"\"", "");
- this.verifyUndelimitOnStringBuffer("'foo'", "foo");
- this.verifyUndelimitOnStringBuffer("\"fo\"\"o\"", "fo\"o");
- this.verifyUndelimitOnStringBuffer("\"foo\"\"\"", "foo\"");
- this.verifyUndelimitOnStringBuffer("\"\"\"foo\"", "\"foo");
- this.verifyUndelimitOnStringBuffer("[foo]", "foo");
- this.verifyUndelimitOnStringBuffer("\"\"\"", "\"");
- this.verifyUndelimitOnStringBuffer("\"foo\"bar\"", "foo\"");
- this.verifyUndelimitOnStringBuffer("\"foo\"\"", "foo\"");
- }
-
- private void verifyUndelimitOnStringBuffer(String s, String expected) {
- StringBuffer sb = new StringBuffer();
- StringTools.undelimitOn(s, sb);
- assertEquals(expected, sb.toString());
-
- sb = new StringBuffer();
- StringTools.undelimitOn(s.toCharArray(), sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testUndelimitOnStringBuilder() {
- this.verifyUndelimitOnStringBuilder("\"foo\"", "foo");
- this.verifyUndelimitOnStringBuilder("\"\"", "");
- this.verifyUndelimitOnStringBuilder("'foo'", "foo");
- this.verifyUndelimitOnStringBuilder("\"fo\"\"o\"", "fo\"o");
- this.verifyUndelimitOnStringBuilder("\"foo\"\"\"", "foo\"");
- this.verifyUndelimitOnStringBuilder("\"\"\"foo\"", "\"foo");
- this.verifyUndelimitOnStringBuilder("[foo]", "foo");
- this.verifyUndelimitOnStringBuilder("\"\"\"", "\"");
- this.verifyUndelimitOnStringBuilder("\"foo\"bar\"", "foo\"");
- this.verifyUndelimitOnStringBuilder("\"foo\"\"", "foo\"");
- }
-
- private void verifyUndelimitOnStringBuilder(String s, String expected) {
- StringBuilder sb = new StringBuilder();
- StringTools.undelimitOn(s, sb);
- assertEquals(expected, sb.toString());
-
- sb = new StringBuilder();
- StringTools.undelimitOn(s.toCharArray(), sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testUndelimitOnWriterCount() {
- this.verifyUndelimitOnWriterCount("\"foo\"", 2, "o");
- this.verifyUndelimitOnWriterCount("\"\"\"\"", 2, "");
- this.verifyUndelimitOnWriterCount("XXfooXX", 2, "foo");
- }
-
- private void verifyUndelimitOnWriterCount(String s, int count, String expected) {
- Writer writer = new StringWriter();
- StringTools.undelimitOn(s, count, writer);
- assertEquals(expected, writer.toString());
-
- writer = new StringWriter();
- StringTools.undelimitOn(s.toCharArray(), count, writer);
- assertEquals(expected, writer.toString());
- }
-
- public void testUndelimitOnStringBufferCount() {
- this.verifyUndelimitOnStringBufferCount("\"foo\"", 2, "o");
- this.verifyUndelimitOnStringBufferCount("\"\"\"\"", 2, "");
- this.verifyUndelimitOnStringBufferCount("XXfooXX", 2, "foo");
- }
-
- private void verifyUndelimitOnStringBufferCount(String s, int count, String expected) {
- StringBuffer sb = new StringBuffer();
- StringTools.undelimitOn(s, count, sb);
- assertEquals(expected, sb.toString());
-
- sb = new StringBuffer();
- StringTools.undelimitOn(s.toCharArray(), count, sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testUndelimitOnStringBuilderCount() {
- this.verifyUndelimitOnStringBuilderCount("\"foo\"", 2, "o");
- this.verifyUndelimitOnStringBuilderCount("\"\"\"\"", 2, "");
- this.verifyUndelimitOnStringBuilderCount("XXfooXX", 2, "foo");
- }
-
- private void verifyUndelimitOnStringBuilderCount(String s, int count, String expected) {
- StringBuilder sb = new StringBuilder();
- StringTools.undelimitOn(s, count, sb);
- assertEquals(expected, sb.toString());
-
- sb = new StringBuilder();
- StringTools.undelimitOn(s.toCharArray(), count, sb);
- assertEquals(expected, sb.toString());
- }
-
- // ********** converting to Java string literal **********
-
- public void testConvertToJavaStringLiteral() {
- this.verifyConvertToJavaStringLiteral("", "\"\"");
- this.verifyConvertToJavaStringLiteral("\"\"", "\"\\\"\\\"\"");
- this.verifyConvertToJavaStringLiteral("'foo'", "\"'foo'\"");
- this.verifyConvertToJavaStringLiteral("foo\bbar", "\"foo\\bbar\"");
- this.verifyConvertToJavaStringLiteral("foo\n\tbar", "\"foo\\n\\tbar\"");
- this.verifyConvertToJavaStringLiteral("foo\"bar", "\"foo\\\"bar\"");
- this.verifyConvertToJavaStringLiteral("foo\\bar", "\"foo\\\\bar\"");
- }
-
- private void verifyConvertToJavaStringLiteral(String s, String expected) {
- assertEquals(expected, StringTools.convertToJavaStringLiteral(s));
- assertEquals(expected, StringTools.convertToJavaStringLiteral(s.toCharArray()));
- }
-
- public void testConvertToJavaStringLiteralOnStringBuffer() {
- this.verifyConvertToJavaStringLiteralOnStringBuffer("", "\"\"");
- this.verifyConvertToJavaStringLiteralOnStringBuffer("\"\"", "\"\\\"\\\"\"");
- this.verifyConvertToJavaStringLiteralOnStringBuffer("'foo'", "\"'foo'\"");
- this.verifyConvertToJavaStringLiteralOnStringBuffer("foo\bbar", "\"foo\\bbar\"");
- this.verifyConvertToJavaStringLiteralOnStringBuffer("foo\n\tbar", "\"foo\\n\\tbar\"");
- this.verifyConvertToJavaStringLiteralOnStringBuffer("foo\"bar", "\"foo\\\"bar\"");
- this.verifyConvertToJavaStringLiteralOnStringBuffer("foo\\bar", "\"foo\\\\bar\"");
- }
-
- private void verifyConvertToJavaStringLiteralOnStringBuffer(String s, String expected) {
- StringBuffer sb = new StringBuffer();
- StringTools.convertToJavaStringLiteralOn(s, sb);
- assertEquals(expected, sb.toString());
-
- sb = new StringBuffer();
- StringTools.convertToJavaStringLiteralOn(s.toCharArray(), sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testConvertToJavaStringLiteralOnStringBuilder() {
- this.verifyConvertToJavaStringLiteralOnStringBuilder("", "\"\"");
- this.verifyConvertToJavaStringLiteralOnStringBuilder("\"\"", "\"\\\"\\\"\"");
- this.verifyConvertToJavaStringLiteralOnStringBuilder("'foo'", "\"'foo'\"");
- this.verifyConvertToJavaStringLiteralOnStringBuilder("foo\bbar", "\"foo\\bbar\"");
- this.verifyConvertToJavaStringLiteralOnStringBuilder("foo\n\tbar", "\"foo\\n\\tbar\"");
- this.verifyConvertToJavaStringLiteralOnStringBuilder("foo\"bar", "\"foo\\\"bar\"");
- this.verifyConvertToJavaStringLiteralOnStringBuilder("foo\\bar", "\"foo\\\\bar\"");
- }
-
- private void verifyConvertToJavaStringLiteralOnStringBuilder(String s, String expected) {
- StringBuilder sb = new StringBuilder();
- StringTools.convertToJavaStringLiteralOn(s, sb);
- assertEquals(expected, sb.toString());
-
- sb = new StringBuilder();
- StringTools.convertToJavaStringLiteralOn(s.toCharArray(), sb);
- assertEquals(expected, sb.toString());
- }
-
- public void testConvertToJavaStringLiteralOnWriter() {
- this.verifyConvertToJavaStringLiteralOnWriter("", "\"\"");
- this.verifyConvertToJavaStringLiteralOnWriter("\"\"", "\"\\\"\\\"\"");
- this.verifyConvertToJavaStringLiteralOnWriter("'foo'", "\"'foo'\"");
- this.verifyConvertToJavaStringLiteralOnWriter("foo\bbar", "\"foo\\bbar\"");
- this.verifyConvertToJavaStringLiteralOnWriter("foo\n\tbar", "\"foo\\n\\tbar\"");
- this.verifyConvertToJavaStringLiteralOnWriter("foo\"bar", "\"foo\\\"bar\"");
- this.verifyConvertToJavaStringLiteralOnWriter("foo\\bar", "\"foo\\\\bar\"");
- }
-
- private void verifyConvertToJavaStringLiteralOnWriter(String s, String expected) {
- Writer writer = new StringWriter();
- StringTools.convertToJavaStringLiteralOn(s, writer);
- assertEquals(expected, writer.toString());
-
- writer = new StringWriter();
- StringTools.convertToJavaStringLiteralOn(s.toCharArray(), writer);
- assertEquals(expected, writer.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedBooleanTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedBooleanTests.java
deleted file mode 100644
index d5f31f861b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedBooleanTests.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean;
-
-public class SynchronizedBooleanTests
- extends MultiThreadedTestCase
-{
- private volatile SynchronizedBoolean sb;
- volatile boolean timeoutOccurred;
- volatile long startTime;
- volatile long endTime;
-
-
- public SynchronizedBooleanTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.sb = new SynchronizedBoolean();
- this.timeoutOccurred = false;
- this.startTime = 0;
- this.endTime = 0;
- }
-
- public void testGetValue() throws Exception {
- assertFalse(this.sb.getValue());
- }
-
- public void testIs() throws Exception {
- assertTrue(this.sb.is(false));
- }
-
- public void testIsNot() throws Exception {
- assertTrue(this.sb.isNot(true));
- }
-
- public void testIsTrue() throws Exception {
- assertFalse(this.sb.isTrue());
- }
-
- public void testIsFalse() throws Exception {
- assertTrue(this.sb.isFalse());
- }
-
- public void testSetValueFalse() throws Exception {
- this.sb.setValue(false);
- assertFalse(this.sb.getValue());
- assertFalse(this.sb.isTrue());
- assertTrue(this.sb.isFalse());
- }
-
- public void testSetValueTrue() throws Exception {
- this.sb.setValue(true);
- assertTrue(this.sb.getValue());
- assertTrue(this.sb.isTrue());
- assertFalse(this.sb.isFalse());
- }
-
- public void testFlip() throws Exception {
- assertTrue(this.sb.flip());
- assertFalse(this.sb.flip());
- }
-
- public void testFalseAndTrue() throws Exception {
- assertFalse(this.sb.and(true));
- assertFalse(this.sb.getValue());
- }
-
- public void testTrueAndTrue() throws Exception {
- this.sb.setValue(true);
- assertTrue(this.sb.and(true));
- assertTrue(this.sb.getValue());
- }
-
- public void testFalseAndFalse() throws Exception {
- assertFalse(this.sb.and(false));
- assertFalse(this.sb.getValue());
- }
-
- public void testTrueAndFalse() throws Exception {
- this.sb.setValue(true);
- assertFalse(this.sb.and(false));
- assertFalse(this.sb.getValue());
- }
-
- public void testFalseOrTrue() throws Exception {
- assertTrue(this.sb.or(true));
- assertTrue(this.sb.getValue());
- }
-
- public void testTrueOrTrue() throws Exception {
- this.sb.setValue(true);
- assertTrue(this.sb.or(true));
- assertTrue(this.sb.getValue());
- }
-
- public void testFalseOrFalse() throws Exception {
- assertFalse(this.sb.or(false));
- assertFalse(this.sb.getValue());
- }
-
- public void testTrueOrFalse() throws Exception {
- this.sb.setValue(true);
- assertTrue(this.sb.or(false));
- assertTrue(this.sb.getValue());
- }
-
- public void testFalseXorTrue() throws Exception {
- assertTrue(this.sb.xor(true));
- assertTrue(this.sb.getValue());
- }
-
- public void testTrueXorTrue() throws Exception {
- this.sb.setValue(true);
- assertFalse(this.sb.xor(true));
- assertFalse(this.sb.getValue());
- }
-
- public void testFalseXorFalse() throws Exception {
- assertFalse(this.sb.xor(false));
- assertFalse(this.sb.getValue());
- }
-
- public void testTrueXorFalse() throws Exception {
- this.sb.setValue(true);
- assertTrue(this.sb.xor(false));
- assertTrue(this.sb.getValue());
- }
-
- public void testSetNotTrue() throws Exception {
- this.sb.setNot(true);
- assertFalse(this.sb.getValue());
- assertFalse(this.sb.isTrue());
- assertTrue(this.sb.isFalse());
- }
-
- public void testSetNotFalse() throws Exception {
- this.sb.setNot(false);
- assertTrue(this.sb.getValue());
- assertTrue(this.sb.isTrue());
- assertFalse(this.sb.isFalse());
- }
-
- public void testSetFalse() throws Exception {
- this.sb.setFalse();
- assertFalse(this.sb.getValue());
- assertFalse(this.sb.isTrue());
- assertTrue(this.sb.isFalse());
- }
-
- public void testSetTrue() throws Exception {
- this.sb.setTrue();
- assertTrue(this.sb.getValue());
- assertTrue(this.sb.isTrue());
- assertFalse(this.sb.isFalse());
- }
-
- public void testCommitFalseSuccess() throws Exception {
- assertTrue(this.sb.commit(false, false));
- assertFalse(this.sb.getValue());
- }
-
- public void testCommitTrueSuccess() throws Exception {
- assertTrue(this.sb.commit(false, true));
- assertTrue(this.sb.getValue());
- }
-
- public void testCommitFalseFailure() throws Exception {
- assertFalse(this.sb.commit(true, false));
- assertFalse(this.sb.getValue());
- }
-
- public void testCommitTrueFailure() throws Exception {
- assertFalse(this.sb.commit(true, true));
- assertFalse(this.sb.getValue());
- }
-
- public void testSwapSame() throws Exception {
- assertFalse(this.sb.swap(this.sb));
- assertFalse(this.sb.getValue());
- }
-
- public void testSwapSameValue() throws Exception {
- SynchronizedBoolean sb2 = new SynchronizedBoolean();
- assertFalse(this.sb.swap(sb2));
- assertFalse(this.sb.getValue());
- assertFalse(sb2.getValue());
- }
-
- public void testSwapDifferentValue() throws Exception {
- SynchronizedBoolean sb2 = new SynchronizedBoolean(true);
- assertTrue(this.sb.swap(sb2));
- assertTrue(this.sb.getValue());
- assertFalse(sb2.getValue());
- }
-
- public void testGetMutexThis() throws Exception {
- assertSame(this.sb, this.sb.getMutex());
- }
-
- public void testGetMutexObject() throws Exception {
- Object mutex = new Object();
- SynchronizedBoolean syncBool = new SynchronizedBoolean(mutex);
- assertSame(mutex, syncBool.getMutex());
- }
-
- /**
- * t2 will wait indefinitely until t1 sets the value to true
- */
- public void testWaitUntilTrue() throws Exception {
- this.verifyWaitUntilTrue(0); // 0 = indefinite wait
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the value should be set to true by t2
- assertTrue(this.sb.getValue());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() > TICK);
- }
-
- /**
- * t2 will time out waiting for t1 to set the value to true
- */
- public void testWaitUntilTrueTimeout() throws Exception {
- this.verifyWaitUntilTrue(TICK);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the value will eventually be set to true by t1
- assertTrue(this.sb.getValue());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() < THREE_TICKS);
- }
-
- private void verifyWaitUntilTrue(long t2Timeout) throws Exception {
- this.executeThreads(this.buildSetTrueCommand(), this.buildWaitUntilTrueCommand(t2Timeout));
- }
-
- /**
- * t2 will wait indefinitely until t1 sets the value to false
- */
- public void testWaitToSetFalse() throws Exception {
- this.verifyWaitToSetFalse(0); // 0 = indefinite wait
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the value should be set to false by t2
- assertFalse(this.sb.getValue());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() > TICK);
- }
-
- /**
- * t2 will time out waiting for t1 to set the value to false
- */
- public void testWaitToSetFalseTimeout() throws Exception {
- this.verifyWaitToSetFalse(TICK);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the value will eventually be set to true by t1
- assertTrue(this.sb.getValue());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() < THREE_TICKS);
- }
-
- private void verifyWaitToSetFalse(long t2Timeout) throws Exception {
- this.executeThreads(this.buildSetTrueCommand(), this.buildWaitToSetFalseCommand(t2Timeout));
- }
-
- private void executeThreads(Command t1Command, Command t2Command) throws Exception {
- this.sb.setFalse();
- Runnable r1 = this.buildRunnable(t1Command, this.sb, TWO_TICKS);
- Runnable r2 = this.buildRunnable(t2Command, this.sb, 0);
- Thread t1 = this.buildThread(r1);
- Thread t2 = this.buildThread(r2);
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- }
-
- private Command buildSetTrueCommand() {
- return new Command() {
- public void execute(SynchronizedBoolean syncBool) {
- syncBool.setTrue();
- }
- };
- }
-
- private Command buildWaitUntilTrueCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedBoolean syncBool) throws InterruptedException {
- SynchronizedBooleanTests.this.startTime = System.currentTimeMillis();
- SynchronizedBooleanTests.this.timeoutOccurred = ! syncBool.waitUntilTrue(timeout);
- SynchronizedBooleanTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Command buildWaitToSetFalseCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedBoolean syncBool) throws InterruptedException {
- SynchronizedBooleanTests.this.startTime = System.currentTimeMillis();
- SynchronizedBooleanTests.this.timeoutOccurred = ! syncBool.waitToSetFalse(timeout);
- SynchronizedBooleanTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Runnable buildRunnable(final Command command, final SynchronizedBoolean syncBool, final long delay) {
- return new TestRunnable() {
- @Override
- public void run_() throws InterruptedException {
- if (delay != 0) {
- Thread.sleep(delay);
- }
- command.execute(syncBool);
- }
- };
- }
-
- long calculateElapsedTime() {
- return this.endTime - this.startTime;
- }
-
-
- // ********** Command interface **********
-
- private interface Command {
- void execute(SynchronizedBoolean syncBool) throws InterruptedException;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedIntTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedIntTests.java
deleted file mode 100644
index b666004427..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedIntTests.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import org.eclipse.jpt.common.utility.internal.SynchronizedInt;
-
-@SuppressWarnings("nls")
-public class SynchronizedIntTests
- extends MultiThreadedTestCase
-{
- private volatile SynchronizedInt si;
- volatile boolean timeoutOccurred;
- volatile int value = 7;
- volatile long startTime;
- volatile long endTime;
- volatile int sIntValue;
-
-
- public SynchronizedIntTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.si = new SynchronizedInt();
- this.timeoutOccurred = false;
- this.startTime = 0;
- this.endTime = 0;
- this.sIntValue = 0;
- }
-
- public void testGetValue() throws Exception {
- assertEquals(0, this.si.getValue());
- }
-
- public void testEqualsInt() throws Exception {
- assertTrue(this.si.equals(0));
- this.si.setValue(this.value);
- assertTrue(this.si.equals(7));
- }
-
- public void testNotEqualInt() throws Exception {
- assertTrue(this.si.notEqual(7));
- this.si.setValue(this.value);
- assertTrue(this.si.notEqual(0));
- }
-
- public void testIsZero() throws Exception {
- assertTrue(this.si.isZero());
- this.si.setValue(this.value);
- assertFalse(this.si.isZero());
- }
-
- public void testIsNotZero() throws Exception {
- assertFalse(this.si.isNotZero());
- this.si.setValue(this.value);
- assertTrue(this.si.isNotZero());
- }
-
- public void testIsGreaterThan() throws Exception {
- assertTrue(this.si.isGreaterThan(-1));
- assertFalse(this.si.isGreaterThan(0));
- assertFalse(this.si.isGreaterThan(1));
- this.si.setValue(this.value);
- assertTrue(this.si.isGreaterThan(-1));
- assertFalse(this.si.isGreaterThan(7));
- assertFalse(this.si.isGreaterThan(8));
- }
-
- public void testIsGreaterThanOrEqual() throws Exception {
- assertTrue(this.si.isGreaterThanOrEqual(-1));
- assertTrue(this.si.isGreaterThanOrEqual(0));
- assertFalse(this.si.isGreaterThanOrEqual(1));
- this.si.setValue(this.value);
- assertTrue(this.si.isGreaterThanOrEqual(-1));
- assertTrue(this.si.isGreaterThanOrEqual(7));
- assertFalse(this.si.isGreaterThanOrEqual(8));
- }
-
- public void testIsLessThan() throws Exception {
- assertFalse(this.si.isLessThan(-1));
- assertFalse(this.si.isLessThan(0));
- assertTrue(this.si.isLessThan(1));
- this.si.setValue(this.value);
- assertFalse(this.si.isLessThan(-1));
- assertFalse(this.si.isLessThan(7));
- assertTrue(this.si.isLessThan(8));
- }
-
- public void testIsLessThanOrEqual() throws Exception {
- assertFalse(this.si.isLessThanOrEqual(-1));
- assertTrue(this.si.isLessThanOrEqual(0));
- assertTrue(this.si.isLessThanOrEqual(1));
- this.si.setValue(this.value);
- assertFalse(this.si.isLessThanOrEqual(-1));
- assertTrue(this.si.isLessThanOrEqual(7));
- assertTrue(this.si.isLessThanOrEqual(8));
- }
-
- public void testIsPositive() throws Exception {
- assertFalse(this.si.isPositive());
- this.si.setValue(this.value);
- assertTrue(this.si.isPositive());
- this.si.setValue(-3);
- assertFalse(this.si.isPositive());
- }
-
- public void testIsNotPositive() throws Exception {
- assertTrue(this.si.isNotPositive());
- this.si.setValue(this.value);
- assertFalse(this.si.isNotPositive());
- this.si.setValue(-3);
- assertTrue(this.si.isNotPositive());
- }
-
- public void testIsNegative() throws Exception {
- assertFalse(this.si.isNegative());
- this.si.setValue(this.value);
- assertFalse(this.si.isNegative());
- this.si.setValue(-3);
- assertTrue(this.si.isNegative());
- }
-
- public void testIsNotNegative() throws Exception {
- assertTrue(this.si.isNotNegative());
- this.si.setValue(this.value);
- assertTrue(this.si.isNotNegative());
- this.si.setValue(-3);
- assertFalse(this.si.isNotNegative());
- }
-
- public void testSetValue() throws Exception {
- this.si.setValue(0);
- assertEquals(0, this.si.getValue());
- assertFalse(this.si.isNotZero());
- assertTrue(this.si.isZero());
-
- this.si.setValue(this.value);
- assertEquals(this.value, this.si.getValue());
- assertTrue(this.si.isNotZero());
- assertFalse(this.si.isZero());
- }
-
- public void testAbs() throws Exception {
- assertEquals(0, this.si.abs());
- assertEquals(0, this.si.getValue());
- this.si.setValue(this.value);
- assertEquals(this.value, this.si.abs());
- assertEquals(this.value, this.si.getValue());
- this.si.setValue(-this.value);
- assertEquals(this.value, this.si.abs());
- }
-
- public void testNeg() throws Exception {
- assertEquals(0, this.si.neg());
- assertEquals(0, this.si.getValue());
- this.si.setValue(this.value);
- assertEquals(-this.value, this.si.neg());
- this.si.setValue(-this.value);
- assertEquals(this.value, this.si.neg());
- }
-
- public void testSetZero() throws Exception {
- this.si.setZero();
- assertEquals(0, this.si.getValue());
- assertFalse(this.si.isNotZero());
- assertTrue(this.si.isZero());
- }
-
- public void testGetMutexThis() throws Exception {
- assertSame(this.si, this.si.getMutex());
- }
-
- /**
- * t2 will wait indefinitely until t1 sets the value to 0
- */
- public void testWaitUntilZero() throws Exception {
- this.verifyWaitUntilZero(0); // 0 = indefinite wait
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the value should be set to 0 by t2
- assertEquals(0, this.si.getValue());
- // make a reasonable guess about how long t2 took
- long time = this.calculateElapsedTime();
- assertTrue("t2 finished a bit early (expected value should be > " + TICK + "): " + time, time > TICK);
- }
-
- /**
- * t2 will time out waiting for t1 to set the value to 0
- */
- public void testWaitUntilZeroTimeout() throws Exception {
- this.verifyWaitUntilZero(TICK);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the value will eventually be set to 0 by t1
- assertEquals(0, this.si.getValue());
- // make a reasonable guess about how long t2 took
- long time = this.calculateElapsedTime();
- assertTrue("t2 finished a bit late (expected value should be < " + THREE_TICKS + "): " + time, time < THREE_TICKS);
- }
-
- private void verifyWaitUntilZero(long t2Timeout) throws Exception {
- this.executeThreads(this.buildSetZeroCommand(), this.buildWaitUntilZeroCommand(t2Timeout));
- }
-
- /**
- * t2 will wait indefinitely until t1 sets the value to 0;
- * then t2 will set the value to 7
- */
- public void testWaitToSetValue() throws Exception {
- this.verifyWaitToSetValue(0); // 0 = indefinite wait
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the value should be set to an object by t2
- assertTrue(this.si.isNotZero());
- // make a reasonable guess about how long t2 took
- long time = this.calculateElapsedTime();
- assertTrue("t2 finished a bit early (expected value should be > " + TICK + "): " + time, time > TICK);
- }
-
- /**
- * t2 will time out waiting for t1 to set the value to 0
- */
- public void testWaitToSetValueTimeout() throws Exception {
- this.verifyWaitToSetValue(TICK);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the value will eventually be set to zero by t1
- assertTrue(this.si.isZero());
- // make a reasonable guess about how long t2 took
- long time = this.calculateElapsedTime();
- assertTrue("t2 finished a bit late (expected value should be < " + THREE_TICKS + "): " + time, time < THREE_TICKS);
- }
-
- private void verifyWaitToSetValue(long t2Timeout) throws Exception {
- this.executeThreads(this.buildSetZeroCommand(), this.buildWaitToSetValueCommand(t2Timeout));
- }
-
- /**
- * t2 will wait until t1 is finished "initializing" the value;
- * then t2 will get the newly-initialized value (42)
- */
- public void testExecute() throws Exception {
- this.si.setValue(0);
- Runnable r1 = this.buildRunnable(this.buildInitializeValueCommand(), this.si, 0);
- // give t1 a head start
- Runnable r2 = this.buildRunnable(this.buildGetValueCommand(), this.si, TICK);
- Thread t1 = this.buildThread(r1);
- Thread t2 = this.buildThread(r2);
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- assertEquals(42, this.si.getValue());
- assertEquals(42, this.sIntValue);
- // make a reasonable guess about how long t2 took
- long time = this.calculateElapsedTime();
- assertTrue("t2 finished a bit early (expected value should be > " + TWO_TICKS + "): " + time, time > TWO_TICKS);
- }
-
- private void executeThreads(Command t1Command, Command t2Command) throws Exception {
- this.si.setValue(this.value);
- Runnable r1 = this.buildRunnable(t1Command, this.si, TWO_TICKS);
- Runnable r2 = this.buildRunnable(t2Command, this.si, 0);
- Thread t1 = this.buildThread(r1);
- Thread t2 = this.buildThread(r2);
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- }
-
- private Command buildSetZeroCommand() {
- return new Command() {
- public void execute(SynchronizedInt sInt) {
- sInt.setZero();
- }
- };
- }
-
- private Command buildWaitUntilZeroCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedInt sInt) throws InterruptedException {
- SynchronizedIntTests.this.startTime = System.currentTimeMillis();
- SynchronizedIntTests.this.timeoutOccurred = ! sInt.waitUntilZero(timeout);
- SynchronizedIntTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Command buildWaitToSetValueCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedInt sInt) throws InterruptedException {
- SynchronizedIntTests.this.startTime = System.currentTimeMillis();
- SynchronizedIntTests.this.timeoutOccurred = ! sInt.waitToSetValue(SynchronizedIntTests.this.value, timeout);
- SynchronizedIntTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Command buildInitializeValueCommand() {
- return new Command() {
- public void execute(final SynchronizedInt sInt) throws InterruptedException {
- sInt.execute(
- new org.eclipse.jpt.common.utility.command.Command() {
- public void execute() {
- // pretend to perform some long initialization process
- try {
- Thread.sleep(5 * TICK);
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- sInt.setValue(42);
- }
- }
- );
- }
- };
- }
-
- private Command buildGetValueCommand() {
- return new Command() {
- public void execute(SynchronizedInt sInt) throws InterruptedException {
- SynchronizedIntTests.this.startTime = System.currentTimeMillis();
- SynchronizedIntTests.this.sIntValue = sInt.getValue();
- SynchronizedIntTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Runnable buildRunnable(final Command command, final SynchronizedInt sInt, final long sleep) {
- return new TestRunnable() {
- @Override
- protected void run_() throws InterruptedException {
- if (sleep != 0) {
- Thread.sleep(sleep);
- }
- command.execute(sInt);
- }
- };
- }
-
- private long calculateElapsedTime() {
- return this.endTime - this.startTime;
- }
-
-
- // ********** Command interface **********
-
- private interface Command {
- void execute(SynchronizedInt sInt) throws InterruptedException;
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedObjectTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedObjectTests.java
deleted file mode 100644
index d0fa703b62..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedObjectTests.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import org.eclipse.jpt.common.utility.internal.SynchronizedObject;
-
-@SuppressWarnings("nls")
-public class SynchronizedObjectTests
- extends MultiThreadedTestCase
-{
- private volatile SynchronizedObject<Object> so;
- volatile boolean timeoutOccurred;
- volatile Object value = new Object();
- volatile long startTime;
- volatile long endTime;
- volatile Object soValue;
-
-
- public SynchronizedObjectTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.so = new SynchronizedObject<Object>();
- this.timeoutOccurred = false;
- this.startTime = 0;
- this.endTime = 0;
- this.soValue = null;
- }
-
- public void testAccessors() throws Exception {
- this.so.setValue(null);
- assertNull(this.so.getValue());
- assertFalse(this.so.isNotNull());
- assertTrue(this.so.isNull());
-
- this.so.setValue(this.value);
- assertEquals(this.value, this.so.getValue());
- assertTrue(this.so.isNotNull());
- assertFalse(this.so.isNull());
-
- this.so.setNull();
- assertNull(this.so.getValue());
- assertFalse(this.so.isNotNull());
- assertTrue(this.so.isNull());
-
- assertSame(this.so, this.so.getMutex());
- }
-
- /**
- * t2 will wait indefinitely until t1 sets the value to null
- */
- public void testWaitUntilNull() throws Exception {
- this.verifyWaitUntilNull(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the value should be set to null by t2
- assertNull(this.so.getValue());
- // make a reasonable guess about how long t2 took
- long time = this.calculateElapsedTime();
- assertTrue("t2 finished a bit early (expected value should be > " + TICK + "): " + time, time > TICK);
- }
-
- /**
- * t2 will time out waiting for t1 to set the value to null
- */
- public void testWaitUntilNullTimeout() throws Exception {
- this.verifyWaitUntilNull(TICK);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the value will eventually be set to null by t1
- assertNull(this.so.getValue());
- // make a reasonable guess about how long t2 took
- long time = this.calculateElapsedTime();
- assertTrue("t2 finished a bit late (expected value should be < " + THREE_TICKS + "): " + time, time < THREE_TICKS);
- }
-
- private void verifyWaitUntilNull(long t2Timeout) throws Exception {
- this.executeThreads(this.buildSetNullCommand(), this.buildWaitUntilNullCommand(t2Timeout));
- }
-
- /**
- * t2 will wait indefinitely until t1 sets the value to null;
- * then t2 will set the value to an object
- */
- public void testWaitToSetValue() throws Exception {
- this.verifyWaitToSetValue(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the value should be set to an object by t2
- assertTrue(this.so.isNotNull());
- // make a reasonable guess about how long t2 took
- long time = this.calculateElapsedTime();
- assertTrue("t2 finished a bit early (expected value should be > " + TICK + "): " + time, time > TICK);
- }
-
- /**
- * t2 will time out waiting for t1 to set the value to null
- */
- public void testWaitToSetValueTimeout() throws Exception {
- this.verifyWaitToSetValue(TICK);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the value will eventually be set to null by t1
- assertTrue(this.so.isNull());
- // make a reasonable guess about how long t2 took
- long time = this.calculateElapsedTime();
- assertTrue("t2 finished a bit late (expected value should be < " + THREE_TICKS + "): " + time, time < THREE_TICKS);
- }
-
- private void verifyWaitToSetValue(long t2Timeout) throws Exception {
- this.executeThreads(this.buildSetNullCommand(), this.buildWaitToSetValueCommand(t2Timeout));
- }
-
- /**
- * t2 will wait until t1 is finished "initializing" the value;
- * then t2 will get the newly-initialized value ("foo")
- */
- public void testExecute() throws Exception {
- this.so.setValue(null);
- Runnable r1 = this.buildRunnable(this.buildInitializeValueCommand(), this.so, 0);
- // give t1 a head start of 100 ms
- Runnable r2 = this.buildRunnable(this.buildGetValueCommand(), this.so, TICK);
- Thread t1 = this.buildThread(r1);
- Thread t2 = this.buildThread(r2);
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- assertEquals("foo", this.so.getValue());
- assertEquals("foo", this.soValue);
- // make a reasonable guess about how long t2 took
- long time = this.calculateElapsedTime();
- assertTrue("t2 finished a bit early (expected value should be > " + TWO_TICKS + "): " + time, time > TWO_TICKS);
- }
-
- private void executeThreads(Command t1Command, Command t2Command) throws Exception {
- this.so.setValue(this.value);
- Runnable r1 = this.buildRunnable(t1Command, this.so, TWO_TICKS);
- Runnable r2 = this.buildRunnable(t2Command, this.so, 0);
- Thread t1 = this.buildThread(r1);
- Thread t2 = this.buildThread(r2);
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- }
-
- private Command buildSetNullCommand() {
- return new Command() {
- public void execute(SynchronizedObject<Object> sObject) {
- sObject.setNull();
- }
- };
- }
-
- private Command buildWaitUntilNullCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedObject<Object> sObject) throws InterruptedException {
- SynchronizedObjectTests.this.startTime = System.currentTimeMillis();
- SynchronizedObjectTests.this.timeoutOccurred = ! sObject.waitUntilNull(timeout);
- SynchronizedObjectTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Command buildWaitToSetValueCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedObject<Object> sObject) throws InterruptedException {
- SynchronizedObjectTests.this.startTime = System.currentTimeMillis();
- SynchronizedObjectTests.this.timeoutOccurred = ! sObject.waitToSetValue(SynchronizedObjectTests.this.value, timeout);
- SynchronizedObjectTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Command buildInitializeValueCommand() {
- return new Command() {
- public void execute(final SynchronizedObject<Object> sObject) throws InterruptedException {
- sObject.execute(
- new org.eclipse.jpt.common.utility.command.Command() {
- public void execute() {
- // pretend to perform some long initialization process
- try {
- Thread.sleep(5 * TICK);
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- sObject.setValue("foo");
- }
- }
- );
- }
- };
- }
-
- private Command buildGetValueCommand() {
- return new Command() {
- public void execute(SynchronizedObject<Object> sObject) throws InterruptedException {
- SynchronizedObjectTests.this.startTime = System.currentTimeMillis();
- SynchronizedObjectTests.this.soValue = sObject.getValue();
- SynchronizedObjectTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Runnable buildRunnable(final Command command, final SynchronizedObject<Object> sObject, final long sleep) {
- return new TestRunnable() {
- @Override
- protected void run_() throws InterruptedException {
- if (sleep != 0) {
- Thread.sleep(sleep);
- }
- command.execute(sObject);
- }
- };
- }
-
- private long calculateElapsedTime() {
- return this.endTime - this.startTime;
- }
-
-
- // ********** Command interface **********
-
- private interface Command {
- void execute(SynchronizedObject<Object> so) throws InterruptedException;
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedQueueTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedQueueTests.java
deleted file mode 100644
index c2d7687e17..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedQueueTests.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.Queue;
-import org.eclipse.jpt.common.utility.internal.SimpleQueue;
-import org.eclipse.jpt.common.utility.internal.SynchronizedQueue;
-
-@SuppressWarnings("nls")
-public class SynchronizedQueueTests extends SimpleQueueTests {
- private volatile SynchronizedQueue<String> sq;
- volatile boolean timeoutOccurred;
- volatile long startTime;
- volatile long endTime;
- volatile Object dequeuedObject;
-
- static final String ITEM_1 = new String();
- static final String ITEM_2 = new String();
-
- public SynchronizedQueueTests(String name) {
- super(name);
- }
-
- @Override
- Queue<String> buildQueue() {
- return new SynchronizedQueue<String>();
- }
-
- @Override
- public void testClone() {
- // synchronized queue is not cloneable
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.sq = new SynchronizedQueue<String>();
- this.timeoutOccurred = false;
- this.startTime = 0;
- this.endTime = 0;
- this.dequeuedObject = null;
- }
-
- /**
- * test first with an unsynchronized queue,
- * then with a synchronized queue
- */
- public void testConcurrentAccess() throws Exception {
- this.verifyConcurrentAccess(new SlowSimpleQueue<String>(), "first");
- this.verifyConcurrentAccess(new SlowSynchronizedQueue<String>(), "second");
- }
-
- private void verifyConcurrentAccess(SlowQueue<String> slowQueue, String expected) throws Exception {
- slowQueue.enqueue("first");
- slowQueue.enqueue("second");
-
- Thread thread = this.buildThread(this.buildRunnable(slowQueue));
- thread.start();
- Thread.sleep(TWO_TICKS);
-
- assertEquals(expected, slowQueue.dequeue());
- thread.join();
- assertTrue(slowQueue.isEmpty());
- }
-
- private Runnable buildRunnable(final SlowQueue<String> slowQueue) {
- return new Runnable() {
- public void run() {
- slowQueue.slowDequeue();
- }
- };
- }
-
-
- private interface SlowQueue<E> extends Queue<E> {
- Object slowDequeue();
- }
-
- private class SlowSimpleQueue<E> extends SimpleQueue<E> implements SlowQueue<E> {
- SlowSimpleQueue() {
- super();
- }
- public Object slowDequeue() {
- try {
- Thread.sleep(5 * TICK);
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- return this.dequeue();
- }
-
- }
-
- private class SlowSynchronizedQueue<E> extends SynchronizedQueue<E> implements SlowQueue<E> {
- SlowSynchronizedQueue() {
- super();
- }
- public synchronized Object slowDequeue() {
- try {
- Thread.sleep(5 * TICK);
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- return this.dequeue();
- }
-
- }
-
-
- // ********** waits **********
-
- public void testWaitToDequeue() throws Exception {
- this.verifyWaitToDequeue(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and an item should have been dequeued by t2...
- assertSame(ITEM_1, this.dequeuedObject);
- // ...and the queue should be empty
- assertTrue(this.sq.isEmpty());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() > TICK);
- }
-
- public void testWaitToDequeueTimeout() throws Exception {
- this.verifyWaitToDequeue(TICK);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the queue was never dequeued...
- assertNull(this.dequeuedObject);
- // ...and it still holds the item
- assertSame(ITEM_1, this.sq.peek());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() < THREE_TICKS);
- }
-
- private void verifyWaitToDequeue(long timeout) throws Exception {
- Runnable r1 = this.buildRunnable(this.buildEnqueueCommand(), this.sq, TWO_TICKS);
- Runnable r2 = this.buildRunnable(this.buildWaitToDequeueCommand(timeout), this.sq, 0);
- Thread t1 = this.buildThread(r1);
- Thread t2 = this.buildThread(r2);
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- }
-
- public void testWaitToEnqueue() throws Exception {
- this.verifyWaitToEnqueue(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the queue gets dequeued by t1...
- assertSame(ITEM_1, this.dequeuedObject);
- // ...and an item is enqueued on to the queue by t2
- assertFalse(this.sq.isEmpty());
- assertSame(ITEM_2, this.sq.peek());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() > TICK);
- }
-
- public void testWaitToEnqueueTimeout() throws Exception {
- this.verifyWaitToEnqueue(TICK);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the queue is eventually dequeued by t1...
- assertSame(ITEM_1, this.dequeuedObject);
- // ...but nothing is enqueued on to the queue by t2
- assertTrue(this.sq.isEmpty());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() < THREE_TICKS);
- }
-
- private void verifyWaitToEnqueue(long timeout) throws Exception {
- this.sq.enqueue(ITEM_1);
- Runnable r1 = this.buildRunnable(this.buildDequeueCommand(), this.sq, TWO_TICKS);
- Runnable r2 = this.buildRunnable(this.buildWaitToEnqueueCommand(timeout), this.sq, 0);
- Thread t1 = this.buildThread(r1);
- Thread t2 = this.buildThread(r2);
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- }
-
- private Command buildEnqueueCommand() {
- return new Command() {
- public void execute(SynchronizedQueue<String> synchronizedQueue) {
- synchronizedQueue.enqueue(ITEM_1);
- }
- };
- }
-
- private Command buildWaitToDequeueCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedQueue<String> synchronizedQueue) throws InterruptedException {
- SynchronizedQueueTests.this.startTime = System.currentTimeMillis();
- try {
- SynchronizedQueueTests.this.dequeuedObject = synchronizedQueue.waitToDequeue(timeout);
- } catch (NoSuchElementException ex) {
- SynchronizedQueueTests.this.timeoutOccurred = true;
- }
- SynchronizedQueueTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Command buildDequeueCommand() {
- return new Command() {
- public void execute(SynchronizedQueue<String> synchronizedQueue) {
- SynchronizedQueueTests.this.dequeuedObject = synchronizedQueue.dequeue();
- }
- };
- }
-
- private Command buildWaitToEnqueueCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedQueue<String> synchronizedQueue) throws InterruptedException {
- SynchronizedQueueTests.this.startTime = System.currentTimeMillis();
- SynchronizedQueueTests.this.timeoutOccurred = ! synchronizedQueue.waitToEnqueue(ITEM_2, timeout);
- SynchronizedQueueTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Runnable buildRunnable(final Command command, final SynchronizedQueue<String> synchronizedQueue, final long sleep) {
- return new TestRunnable() {
- @Override
- protected void run_() throws Throwable {
- if (sleep != 0) {
- Thread.sleep(sleep);
- }
- command.execute(synchronizedQueue);
- }
- };
- }
-
- long calculateElapsedTime() {
- return this.endTime - this.startTime;
- }
-
-
- // ********** Command interface **********
-
- private interface Command {
- void execute(SynchronizedQueue<String> synchronizedQueue) throws InterruptedException;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedStackTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedStackTests.java
deleted file mode 100644
index 16cb62f345..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/SynchronizedStackTests.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.util.EmptyStackException;
-import org.eclipse.jpt.common.utility.internal.SimpleStack;
-import org.eclipse.jpt.common.utility.internal.Stack;
-import org.eclipse.jpt.common.utility.internal.SynchronizedStack;
-
-@SuppressWarnings("nls")
-public class SynchronizedStackTests
- extends SimpleStackTests
-{
- private volatile SynchronizedStack<String> ss;
- volatile boolean timeoutOccurred;
- volatile long startTime;
- volatile long endTime;
- volatile Object poppedObject;
-
- static final String ITEM_1 = new String();
- static final String ITEM_2 = new String();
-
- public SynchronizedStackTests(String name) {
- super(name);
- }
-
- @Override
- Stack<String> buildStack() {
- return new SynchronizedStack<String>();
- }
-
- @Override
- public void testClone() {
- // synchronized stack is not cloneable
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.ss = new SynchronizedStack<String>();
- this.timeoutOccurred = false;
- this.startTime = 0;
- this.endTime = 0;
- this.poppedObject = null;
- }
-
- /**
- * test first with an unsynchronized stack,
- * then with a synchronized stack
- */
- public void testConcurrentAccess() throws Exception {
- this.verifyConcurrentAccess(new SlowSimpleStack<String>(), "second");
- this.verifyConcurrentAccess(new SlowSynchronizedStack<String>(), "first");
- }
-
- private void verifyConcurrentAccess(SlowStack<String> slowStack, String expected) throws Exception {
- slowStack.push("first");
- slowStack.push("second");
-
- Thread thread = this.buildThread(this.buildRunnable(slowStack));
- thread.start();
- Thread.sleep(TWO_TICKS);
-
- assertEquals(expected, slowStack.pop());
- thread.join();
- assertTrue(slowStack.isEmpty());
- }
-
- private Runnable buildRunnable(final SlowStack<String> slowStack) {
- return new Runnable() {
- public void run() {
- slowStack.slowPop();
- }
- };
- }
-
-
- private interface SlowStack<E> extends Stack<E> {
- Object slowPop();
- }
-
- private class SlowSimpleStack<E> extends SimpleStack<E> implements SlowStack<E> {
- SlowSimpleStack() {
- super();
- }
- public Object slowPop() {
- try {
- Thread.sleep(5 * TICK);
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- return this.pop();
- }
-
- }
-
- private class SlowSynchronizedStack<E> extends SynchronizedStack<E> implements SlowStack<E> {
- SlowSynchronizedStack() {
- super();
- }
- public synchronized Object slowPop() {
- try {
- Thread.sleep(5 * TICK);
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- return this.pop();
- }
-
- }
-
-
- // ********** waits **********
-
- public void testWaitToPop() throws Exception {
- this.verifyWaitToPop(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and an item should have been popped by t2...
- assertSame(ITEM_1, this.poppedObject);
- // ...and the stack should be empty
- assertTrue(this.ss.isEmpty());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() > TICK);
- }
-
- public void testWaitToPopTimeout() throws Exception {
- this.verifyWaitToPop(TICK);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the stack was never popped...
- assertNull(this.poppedObject);
- // ...and it still holds the item
- assertSame(ITEM_1, this.ss.peek());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() < THREE_TICKS);
- }
-
- private void verifyWaitToPop(long timeout) throws Exception {
- Runnable r1 = this.buildRunnable(this.buildPushCommand(), this.ss, TWO_TICKS);
- Runnable r2 = this.buildRunnable(this.buildWaitToPopCommand(timeout), this.ss, 0);
- Thread t1 = this.buildThread(r1);
- Thread t2 = this.buildThread(r2);
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- }
-
- public void testWaitToPush() throws Exception {
- this.verifyWaitToPush(0);
- // no timeout occurs...
- assertFalse(this.timeoutOccurred);
- // ...and the stack gets popped by t1...
- assertSame(ITEM_1, this.poppedObject);
- // ...and an item is pushed on to the stack by t2
- assertFalse(this.ss.isEmpty());
- assertSame(ITEM_2, this.ss.peek());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() > TICK);
- }
-
- public void testWaitToPushTimeout() throws Exception {
- this.verifyWaitToPush(TICK);
- // timeout occurs...
- assertTrue(this.timeoutOccurred);
- // ...and the stack is eventually popped by t1...
- assertSame(ITEM_1, this.poppedObject);
- // ...but nothing is pushed on to the stack by t2
- assertTrue(this.ss.isEmpty());
- // make a reasonable guess about how long t2 took
- assertTrue(this.calculateElapsedTime() < THREE_TICKS);
- }
-
- private void verifyWaitToPush(long timeout) throws Exception {
- this.ss.push(ITEM_1);
- Runnable r1 = this.buildRunnable(this.buildPopCommand(), this.ss, TWO_TICKS);
- Runnable r2 = this.buildRunnable(this.buildWaitToPushCommand(timeout), this.ss, 0);
- Thread t1 = this.buildThread(r1);
- Thread t2 = this.buildThread(r2);
- t1.start();
- t2.start();
- t1.join();
- t2.join();
- }
-
- private Command buildPushCommand() {
- return new Command() {
- public void execute(SynchronizedStack<String> synchronizedStack) {
- synchronizedStack.push(ITEM_1);
- }
- };
- }
-
- private Command buildWaitToPopCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedStack<String> synchronizedStack) throws InterruptedException {
- SynchronizedStackTests.this.startTime = System.currentTimeMillis();
- try {
- SynchronizedStackTests.this.poppedObject = synchronizedStack.waitToPop(timeout);
- } catch (EmptyStackException ex) {
- SynchronizedStackTests.this.timeoutOccurred = true;
- }
- SynchronizedStackTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Command buildPopCommand() {
- return new Command() {
- public void execute(SynchronizedStack<String> synchronizedStack) {
- SynchronizedStackTests.this.poppedObject = synchronizedStack.pop();
- }
- };
- }
-
- private Command buildWaitToPushCommand(final long timeout) {
- return new Command() {
- public void execute(SynchronizedStack<String> synchronizedStack) throws InterruptedException {
- SynchronizedStackTests.this.startTime = System.currentTimeMillis();
- SynchronizedStackTests.this.timeoutOccurred = ! synchronizedStack.waitToPush(ITEM_2, timeout);
- SynchronizedStackTests.this.endTime = System.currentTimeMillis();
- }
- };
- }
-
- private Runnable buildRunnable(final Command command, final SynchronizedStack<String> synchronizedStack, final long sleep) {
- return new TestRunnable() {
- @Override
- protected void run_() throws Throwable {
- if (sleep != 0) {
- Thread.sleep(sleep);
- }
- command.execute(synchronizedStack);
- }
- };
- }
-
- long calculateElapsedTime() {
- return this.endTime - this.startTime;
- }
-
-
- // ********** Command interface **********
-
- private interface Command {
- void execute(SynchronizedStack<String> synchronizedStack) throws InterruptedException;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/TestCommand.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/TestCommand.java
deleted file mode 100644
index 34040e489f..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/TestCommand.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-/**
- * Command that can be used to execute tests; i.e. a command that allows its
- * implementation to throw exceptions.
- */
-public interface TestCommand {
- void execute() throws Exception;
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/TestTools.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/TestTools.java
deleted file mode 100644
index 5fff2ff48b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/TestTools.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.io.StringWriter;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestFailure;
-import junit.framework.TestResult;
-import junit.textui.TestRunner;
-
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-
-/**
- * Various tools that can be used by test cases.
- */
-@SuppressWarnings("nls")
-public final class TestTools {
-
- /**
- * Convenience method that handles {@link InterruptedException}.
- */
- public static void sleep(long millis) {
- try {
- Thread.sleep(millis);
- } catch (InterruptedException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- /**
- * Execute the specified command. If it throws an exception, re-execute it
- * repeatedly until it executes without an exception.
- * There will be a one-second delay between each execution.
- * This is useful when calling third-party code that intermittently throws
- * exceptions but will <em>eventually</em> execute successfully (e.g. when
- * there are problems deleting files).
- */
- public static void execute(TestCommand command) {
- execute(command, -1);
- }
-
- /**
- * Execute the specified command. If it throws an exception, re-execute it
- * repeatedly until it executes without an exception. Execute the command
- * up to the specified number of attempts.
- * There will be a one-second delay between each execution.
- * This is useful when calling third-party code that intermittently throws
- * exceptions but will <em>eventually</em> execute successfully (e.g. when
- * there are problems deleting files).
- */
- public static void execute(TestCommand command, int attempts) {
- execute(command, attempts, 1000);
- }
-
- /**
- * Execute the specified command. If it throws an exception, re-execute it
- * repeatedly until it executes without an exception. Execute the command
- * up to the specified number of attemptsl with specified delay between
- * each execution.
- * This is useful when calling third-party code that intermittently throws
- * exceptions but will <em>eventually</em> execute successfully (e.g. when
- * there are problems deleting files).
- */
- public static void execute(TestCommand command, int attempts, long delay) {
- for (int i = 1; i <= attempts; i++) { // NB: start with 1
- try {
- command.execute();
- return;
- } catch (Exception ex) {
- if ((attempts != -1) && (i == attempts)) {
- throw new RuntimeException("attempts: " + i, ex);
- }
- sleep(delay);
- }
- }
- }
-
- /**
- * Test an object's implementation of {@link Serializable} by serializing the
- * specified object to a byte array; then de-serializing the byte array and
- * returning the resultant object.
- */
- public static <T> T serialize(T o) throws IOException, ClassNotFoundException {
- ByteArrayOutputStream baOutStream = new ByteArrayOutputStream(2000);
- ObjectOutputStream outStream = new ObjectOutputStream(baOutStream);
- outStream.writeObject(o);
- outStream.close();
-
- ByteArrayInputStream baInStream = new ByteArrayInputStream(baOutStream.toByteArray());
- ObjectInputStream inStream = new ObjectInputStream(baInStream);
- T o2 = readObject(inStream);
- inStream.close();
-
- return o2;
- }
-
- @SuppressWarnings("unchecked")
- private static <T> T readObject(ObjectInput objectInput) throws IOException, ClassNotFoundException {
- return (T) objectInput.readObject();
- }
-
- /**
- * Redirect std out and std err to the specified stream.
- */
- public static void redirectSystemStreamsTo(OutputStream outputStream) {
- redirectSystemStreamsTo(new PrintStream(outputStream));
- }
-
- /**
- * Redirect std out and std err to the specified stream.
- */
- public static void redirectSystemStreamsTo(PrintStream printStream) {
- System.setOut(printStream);
- System.setErr(printStream);
- }
-
- /**
- * Sort and print out all the current Java System properties on the
- * console.
- */
- public static void printSystemProperties() {
- synchronized (System.out) {
- printSystemPropertiesOn(System.out);
- }
- }
-
- /**
- * Sort and print out all the current Java System properties on the
- * specified print stream.
- */
- public static void printSystemPropertiesOn(PrintStream stream) {
- SortedSet<String> sortedKeys = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
- for (Object key : System.getProperties().keySet()) {
- sortedKeys.add((String) key);
- }
- for (String key : sortedKeys) {
- stream.print(key);
- stream.print(" => ");
- stream.print(System.getProperty(key));
- stream.println();
- }
- }
-
- /**
- * Execute the specified test and return a text output of its results.
- */
- public static String execute(TestCase testCase) {
- long start = System.currentTimeMillis();
- TestResult result = testCase.run();
- long end = System.currentTimeMillis();
-
- StringWriter stringWriter = new StringWriter();
- PrintWriter writer = new PrintWriter(stringWriter);
- writer.print(testCase.getName());
- writer.print(": ");
- if (result.wasSuccessful()) {
- writer.println("OK");
- } else {
- TestFailure failure = null;
- if (result.failures().hasMoreElements()) {
- failure = result.failures().nextElement();
- } else {
- failure = result.errors().nextElement();
- }
- failure.thrownException().printStackTrace(writer);
- }
- writer.print("elapsed time: ");
- long elapsed = end - start;
- writer.print(elapsed / 1000L);
- writer.println(" sec.");
- return stringWriter.toString();
- }
-
- /**
- * Clear out all the instance variable of the specified test case, allowing
- * the various test fixtures to be garbage-collected. Typically this is
- * called in the test case's implementation of {@link TestCase#tearDown()}.
- */
- public static void clear(TestCase testCase) throws IllegalAccessException {
- for (Class<?> clazz = testCase.getClass(); clazz != TestCase_class; clazz = clazz.getSuperclass()) {
- for (Field field : clazz.getDeclaredFields()) {
- // leave primitives alone - they don't get garbage-collected, and we can't set them to null...
- if (field.getType().isPrimitive()) {
- continue;
- }
- // leave static fields alone (?)
- if (Modifier.isStatic(field.getModifiers())) {
- continue;
- }
- field.setAccessible(true);
- field.set(testCase, null);
- }
- }
- }
-
- /**
- * Return the value of the specified class's <code>DEBUG</code> constant.
- */
- public static boolean debug(Class<?> clazz) {
- Boolean debug = (Boolean) ReflectionTools.getStaticFieldValue(clazz, "DEBUG");
- return debug.booleanValue();
- }
-
- /**
- * Verify the specified class's <code>DEBUG</code> constant is set to
- * <code>false</code>.
- */
- public static void assertFalseDEBUG(Class<?> clazz) {
- Assert.assertFalse("Recompile with \"DEBUG = false\": " + clazz.getName(), debug(clazz));
- }
-
- private static final Class<TestCase> TestCase_class = TestCase.class;
-
- /**
- * Workaround for a JUnit bug: JUnit does not configure the testing {@link Thread}
- * with a context class loader. This should probably happen in
- * {@link TestRunner#doRun(Test)}, just before starting the thread.
- */
- public static void setUpJUnitThreadContextClassLoader() {
- Thread.currentThread().setContextClassLoader(TestTools.class.getClassLoader());
- }
-
- /**
- * suppressed constructor
- */
- private TestTools() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ToolsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ToolsTests.java
deleted file mode 100644
index bf7fcba128..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/ToolsTests.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import org.eclipse.jpt.common.utility.internal.Tools;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("nls")
-public class ToolsTests extends TestCase {
-
- public ToolsTests(String name) {
- super(name);
- }
-
- public void testValuesAreEqual1() {
- assertTrue(Tools.valuesAreEqual(null, null));
- }
-
- public void testValuesAreEqual2() {
- assertFalse(Tools.valuesAreEqual(null, "foo"));
- }
-
- public void testValuesAreEqual3() {
- assertFalse(Tools.valuesAreEqual("foo", null));
- }
-
- public void testValuesAreEqual4() {
- assertTrue(Tools.valuesAreEqual("foo", "foo"));
- }
-
- public void testValuesAreEqual5() {
- assertFalse(Tools.valuesAreEqual("foo", "bar"));
- }
-
- public void testValuesAreDifferent1() {
- assertFalse(Tools.valuesAreDifferent(null, null));
- }
-
- public void testValuesAreDifferent2() {
- assertTrue(Tools.valuesAreDifferent(null, "foo"));
- }
-
- public void testValuesAreDifferent3() {
- assertTrue(Tools.valuesAreDifferent("foo", null));
- }
-
- public void testValuesAreDifferent4() {
- assertFalse(Tools.valuesAreDifferent("foo", "foo"));
- }
-
- public void testValuesAreDifferent5() {
- assertTrue(Tools.valuesAreDifferent("foo", "bar"));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/VersionComparatorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/VersionComparatorTests.java
deleted file mode 100644
index 3a7eff17a3..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/VersionComparatorTests.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.Comparator;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.VersionComparator;
-import org.eclipse.jpt.common.utility.internal.VersionComparator.SegmentParser;
-
-@SuppressWarnings("nls")
-public class VersionComparatorTests
- extends TestCase
-{
- public VersionComparatorTests(String name) {
- super(name);
- }
-
- public void testVersionIsEqual_integer() {
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.0.0", "2.0.0") == 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.0.0", "2.0.0.0") == 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.0.0.0.0.0.0000", "2.0") == 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.0.-1", "2.0.-1") == 0);
- }
-
- public void testVersionIsLess_integer() {
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.0.0", "2.0.1") < 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.5.0", "2.14") < 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.5.0", "2.5.0.0.1.0") < 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.5.0.0.0.-1", "2.5") < 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.0.-1", "2.0.0") < 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.0.-1", "2") < 0);
- }
-
- public void testVersionIsGreater_integer() {
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.0.2", "2.0.1") > 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.0.2", "2.0.1") > 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.5.0.0.1.0", "2.5.0") > 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.5", "2.5.0.0.0.-1") > 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.0.0", "2.0.-1") > 0);
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2", "2.0.-1") > 0);
- }
-
- public void testVersionIsEqual_integer_comma() {
- Comparator<String> versionComparator = new VersionComparator<BigDecimal>(",", DecimalSegmentParser.instance());
- assertTrue(versionComparator.compare("2,0,0", "2,0,0") == 0);
- assertTrue(versionComparator.compare("2,0.0,0", "2,0,0") == 0);
- assertTrue(versionComparator.compare("2,0.0,0", "2,0,0.0") == 0);
- assertTrue(versionComparator.compare("2.0,0.0,0", "2,0,0.0") == 0);
- }
-
- public void testVersionIsLess_integer_comma() {
- Comparator<String> versionComparator = new VersionComparator<BigDecimal>(",", DecimalSegmentParser.instance());
- assertTrue(versionComparator.compare("2,0,0", "2,0,1") < 0);
- assertTrue(versionComparator.compare("2,0.0,0", "2,0,1") < 0);
- assertTrue(versionComparator.compare("2,0,0", "2,0,1.0") < 0);
- assertTrue(versionComparator.compare("2.0,0,0", "2,0,1") < 0);
- }
-
- public void testVersionIsGreater_integer_comma() {
- Comparator<String> versionComparator = new VersionComparator<BigDecimal>(",", DecimalSegmentParser.instance());
- assertTrue(versionComparator.compare("2,0,2", "2,0,1") > 0);
- assertTrue(versionComparator.compare("2,0,2.1", "2,0,1") > 0);
- assertTrue(versionComparator.compare("2,0,2", "2,0,1.9") > 0);
- assertTrue(versionComparator.compare("2.000,0,2", "2,0,1") > 0);
- }
-
- public void testVersionIsEqual_subclass() {
- Comparator<String> versionComparator = new VersionComparator<Integer>() {
- @Override
- protected Integer parseSegment(int index, String s) {
- return Integer.valueOf(s);
- }
- @Override
- protected Integer getZero() {
- return Integer.valueOf(0);
- }
- };
- assertTrue(versionComparator.compare("2.0.0", "2.0.0") == 0);
- assertTrue(versionComparator.compare("2.0.0", "2.0.0.0") == 0);
- assertTrue(versionComparator.compare("2.0.0.0", "2.0") == 0);
- assertTrue(versionComparator.compare("2.0.-1", "2.0.-1") == 0);
- }
-
- public void testVersionIsLess_subclass() {
- Comparator<String> versionComparator = new VersionComparator<Integer>() {
- @Override
- protected Integer parseSegment(int index, String s) {
- return Integer.valueOf(s);
- }
- @Override
- protected Integer getZero() {
- return Integer.valueOf(0);
- }
- };
- assertTrue(versionComparator.compare("2.0.0", "2.0.1") < 0);
- assertTrue(versionComparator.compare("2.5.0", "2.14") < 0);
- assertTrue(versionComparator.compare("2.5.0", "2.5.0.0.1.0") < 0);
- assertTrue(versionComparator.compare("2.0.-1", "2.0.0") < 0);
- assertTrue(versionComparator.compare("2.0.-1", "2") < 0);
- }
-
- public void testVersionIsGreater_subclass() {
- Comparator<String> versionComparator = new VersionComparator<Integer>() {
- @Override
- protected Integer parseSegment(int index, String s) {
- return Integer.valueOf(s);
- }
- @Override
- protected Integer getZero() {
- return Integer.valueOf(0);
- }
- };
- assertTrue(versionComparator.compare("2.0.2", "2.0.1") > 0);
- assertTrue(versionComparator.compare("2.0.2", "2.0.1") > 0);
- assertTrue(versionComparator.compare("2.5.0.0.1.0", "2.5.0") > 0);
- assertTrue(versionComparator.compare("2.0.0", "2.0.-1") > 0);
- assertTrue(versionComparator.compare("2", "2.0.-1") > 0);
- }
-
- public void testBadString() {
- boolean exCaught = false;
- try {
- // note the letter 'O' instead of the numeral '0'
- assertTrue(VersionComparator.INTEGER_VERSION_COMPARATOR.compare("2.0.0", "2.O.O") == 0);
- } catch (NumberFormatException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testBogusSubclass1() {
- Comparator<String> versionComparator = new VersionComparator<Integer>() {
- // bogus - must override parseSegment(...)
- @Override
- protected Integer getZero() {
- return Integer.valueOf(0);
- }
- };
- boolean exCaught = false;
- try {
- assertTrue(versionComparator.compare("2.0.0", "2.0.0") == 0);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testBogusSubclass2() {
- Comparator<String> versionComparator = new VersionComparator<Integer>() {
- @Override
- protected Integer parseSegment(int index, String s) {
- return Integer.valueOf(s);
- }
- // bogus - must getZero()
- };
- boolean exCaught = false;
- try {
- assertTrue(versionComparator.compare("2.0.0", "2.0.0.0.0") == 0);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- static final class DecimalSegmentParser
- implements SegmentParser<BigDecimal>, Serializable
- {
- public static final SegmentParser<BigDecimal> INSTANCE = new DecimalSegmentParser();
- public static SegmentParser<BigDecimal> instance() {
- return INSTANCE;
- }
- // ensure single instance
- private DecimalSegmentParser() {
- super();
- }
- // simply parse the segment as an integer
- public BigDecimal parse(int segmentIndex, String segment) {
- return new BigDecimal(segment);
- }
- public BigDecimal getZero() {
- return ZERO;
- }
- private static final BigDecimal ZERO = new BigDecimal(0);
- @Override
- public String toString() {
- return StringTools.buildSingletonToString(this);
- }
- private static final long serialVersionUID = 1L;
- private Object readResolve() {
- // replace this object with the singleton
- return INSTANCE;
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/XMLStringEncoderTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/XMLStringEncoderTests.java
deleted file mode 100644
index 461313cb72..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/XMLStringEncoderTests.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.FileTools;
-import org.eclipse.jpt.common.utility.internal.XMLStringEncoder;
-
-@SuppressWarnings("nls")
-public class XMLStringEncoderTests extends TestCase {
-
- public XMLStringEncoderTests(String name) {
- super(name);
- }
-
- public void testEncodeNoCharacterSequences() {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
-
- String s = "foo";
- assertEquals(s, encoder.encode(s));
-
- s = "123foo123";
- assertEquals(s, encoder.encode(s));
- }
-
- public void testEncodeCharacterSequences() {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
-
- String s = "?foo?";
- String expected = "&#x3f;foo&#x3f;";
- assertEquals(expected, encoder.encode(s));
-
- s = "?foo&123";
- expected = "&#x3f;foo&#x26;123";
- assertEquals(expected, encoder.encode(s));
- }
-
- public void testDenormalizeValidFileName() {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
-
- String s = "foo";
- assertEquals(s, encoder.decode(s));
-
- s = "123foo123";
- assertEquals(s, encoder.decode(s));
- }
-
- public void testDenormalizeInvalidFileName() {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
-
- String s = "&#x3f;foo&#x3f;";
- String expected = "?foo?";
- assertEquals(expected, encoder.decode(s));
-
- s = "&#x3f;foo&#x26;123";
- expected = "?foo&123";
- assertEquals(expected, encoder.decode(s));
- }
-
- public void testRoundTripNoCharacterSequences() {
- this.verifyRoundTrip("foo");
- this.verifyRoundTrip("123foo456");
- }
-
- public void testRoundTripCharacterSequences() {
- this.verifyRoundTrip("?foo?");
- this.verifyRoundTrip("?foo&123&&&&&&>>>>");
- }
-
- private void verifyRoundTrip(String s) {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
- String actual = encoder.encode(s);
- assertEquals(s, encoder.decode(actual));
- }
-
- public void testInvalidCharacterSequence1() {
- this.verifyIllegalStateException("foo&");
- }
-
- public void testInvalidCharacterSequence2() {
- this.verifyIllegalStateException("foo&#");
- }
-
- public void testInvalidCharacterSequence3() {
- this.verifyIllegalStateException("foo&#x");
- }
-
- public void testInvalidCharacterSequence4() {
- this.verifyIllegalStateException("foo&#x3");
- }
-
- public void testInvalidCharacterSequence5() {
- this.verifyIllegalStateException("foo&#x;");
- }
-
- public void testInvalidCharacterSequence6() {
- this.verifyIllegalStateException("foo&A");
- }
-
- public void testInvalidCharacterSequence7() {
- this.verifyIllegalStateException("foo&#A");
- }
-
- private void verifyIllegalStateException(String s) {
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
- boolean exCaught = false;
- try {
- s = encoder.decode(s);
- fail(s);
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testInvalidCharacterSequence8() {
- String s = "foo&#xZZZZ;";
- XMLStringEncoder encoder = new XMLStringEncoder(FileTools.INVALID_FILENAME_CHARACTERS);
- boolean exCaught = false;
- try {
- s = encoder.decode(s);
- fail(s);
- } catch (NumberFormatException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/AsynchronousCommandExecutorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/AsynchronousCommandExecutorTests.java
deleted file mode 100644
index 767882fbd9..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/AsynchronousCommandExecutorTests.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.command;
-
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.StatefulCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.command.AsynchronousExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.tests.internal.MultiThreadedTestCase;
-
-public class AsynchronousCommandExecutorTests
- extends MultiThreadedTestCase
-{
- public AsynchronousCommandExecutorTests(String name) {
- super(name);
- }
-
- public void testExecution() throws Exception {
- TestCommand command = new TestCommand();
- AsynchronousExtendedCommandExecutor.SimpleConfig config = new AsynchronousExtendedCommandExecutor.SimpleConfig();
- config.setThreadFactory(this.buildThreadFactory());
- config.setExceptionHandler(ExceptionHandler.Runtime.instance());
- StatefulCommandExecutor commandExecutor = new AsynchronousExtendedCommandExecutor(config);
- commandExecutor.start();
- commandExecutor.execute(command);
- commandExecutor.execute(command);
- commandExecutor.execute(command);
- Thread.sleep(TWO_TICKS); // wait for the command to execute
- commandExecutor.stop();
- assertEquals(3, command.count);
- }
-
- static class TestCommand implements Command {
- int count = 0;
- public void execute() {
- this.count++;
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/AsynchronousRepeatingCommandWrapperTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/AsynchronousRepeatingCommandWrapperTests.java
deleted file mode 100644
index 4f4ce8dd55..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/AsynchronousRepeatingCommandWrapperTests.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.command;
-
-import org.eclipse.jpt.common.utility.ExceptionHandler;
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.RepeatingCommand;
-import org.eclipse.jpt.common.utility.internal.CollectingExceptionHandler;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.ConsumerThreadCoordinator;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.command.AsynchronousRepeatingCommandWrapper;
-import org.eclipse.jpt.common.utility.tests.internal.MultiThreadedTestCase;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class AsynchronousRepeatingCommandWrapperTests
- extends MultiThreadedTestCase
-{
- PrimaryModel1 primaryModel1;
- SecondaryModel1 secondaryModel1;
- Command command1;
- RepeatingCommand repeatingCommand1;
-
- PrimaryModel2 primaryModel2;
- SecondaryModel2 secondaryModel2;
- Command command2;
- RepeatingCommand repeatingCommand2;
-
- public AsynchronousRepeatingCommandWrapperTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.primaryModel1 = new PrimaryModel1();
- this.secondaryModel1 = new SecondaryModel1(this.primaryModel1);
- this.command1 = new SynchronizeSecondaryModelCommand1(this.secondaryModel1);
- this.repeatingCommand1 = new AsynchronousRepeatingCommandWrapper(this.command1, this.buildThreadFactory(), null, ExceptionHandler.Runtime.instance());
- this.primaryModel1.setSynchronizer(this.repeatingCommand1);
-
- this.primaryModel2 = new PrimaryModel2();
- this.secondaryModel2 = new SecondaryModel2(this.primaryModel2);
- this.command2 = new SynchronizeSecondaryModelCommand2(this.primaryModel2, this.secondaryModel2);
- this.repeatingCommand2 = new AsynchronousRepeatingCommandWrapper(this.command2, this.buildThreadFactory(), null, ExceptionHandler.Runtime.instance());
- this.primaryModel2.setSynchronizer(this.repeatingCommand2);
- }
-
- @Override
- protected void tearDown() throws Exception {
- this.repeatingCommand1.stop();
- this.repeatingCommand2.stop();
- super.tearDown();
- }
-
- public void testInitialization() {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- }
-
- public void testToString() {
- assertNotNull(this.repeatingCommand1.toString());
- }
-
- public void testChange() throws Exception {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- this.primaryModel1.setCount(7);
-
- this.sleep(TICK);
- this.repeatingCommand1.stop();
- this.sleep(TICK);
-
- assertEquals(14, this.secondaryModel1.getDoubleCount());
-
- // re-start so tear-down works
- this.repeatingCommand1.start();
- }
-
- public void testStart() throws Exception {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- this.primaryModel1.setSynchronizer(RepeatingCommand.Null.instance());
- this.primaryModel1.setCount(7);
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- this.primaryModel1.setSynchronizer(this.repeatingCommand1);
- // the async synchronizer does not synchronize at start-up
- assertEquals(4, this.secondaryModel1.getDoubleCount());
-
- this.primaryModel1.setCount(8);
-
- this.sleep(TICK);
- this.repeatingCommand1.stop();
- this.sleep(TICK);
-
- assertEquals(16, this.secondaryModel1.getDoubleCount());
-
- // re-start so tear-down works
- this.repeatingCommand1.start();
- }
-
- public void testStop() throws Exception {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- this.primaryModel1.dispose();
- this.primaryModel1.setCount(7);
- assertEquals(4, this.secondaryModel1.getDoubleCount());
-
- // re-start so tear-down works
- this.repeatingCommand1.start();
- }
-
- public void testDoubleStart() throws Exception {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- boolean exCaught = false;
- try {
- this.primaryModel1.startSynchronizer();
- fail();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- this.primaryModel1.setCount(7);
-
- this.sleep(TICK);
- this.repeatingCommand1.stop();
- this.sleep(TICK);
-
- assertEquals(14, this.secondaryModel1.getDoubleCount());
-
- // re-start so tear-down works
- this.repeatingCommand1.start();
- }
-
- public void testDoubleStop() throws Exception {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- this.primaryModel1.dispose();
- boolean exCaught = false;
- try {
- this.primaryModel1.dispose();
- fail();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- this.primaryModel1.setCount(7);
- assertEquals(4, this.secondaryModel1.getDoubleCount());
-
- // re-start so tear-down works
- this.repeatingCommand1.start();
- }
-
- public void testRecursiveChange() throws Exception {
- assertEquals(4, this.secondaryModel2.getDoubleCount());
- this.primaryModel2.setCount(7);
-
- this.sleep(TICK);
- assertEquals(10, this.primaryModel2.getCountPlus3());
- assertEquals(14, this.secondaryModel2.getDoubleCount());
-
- this.sleep(TICK);
- assertEquals(20, this.secondaryModel2.getDoubleCountPlus3());
- }
-
- public void testNullCommand() {
- boolean exCaught = false;
- try {
- RepeatingCommand s = new AsynchronousRepeatingCommandWrapper(null, this.buildThreadFactory(), null, ExceptionHandler.Runtime.instance());
- fail("bogus: " + s);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testThreadName() throws Exception {
- RepeatingCommand s = new AsynchronousRepeatingCommandWrapper(this.command1, this.buildThreadFactory(), "sync", ExceptionHandler.Runtime.instance());
- s.start();
- ConsumerThreadCoordinator ctc = (ConsumerThreadCoordinator) ReflectionTools.getFieldValue(s, "consumerThreadCoordinator");
- Thread t = (Thread) ReflectionTools.getFieldValue(ctc, "thread");
- assertEquals("sync", t.getName());
- s.stop();
- }
-
- public void testExecuteCalledBeforeStart() throws Exception {
- SimpleCommand command = new SimpleCommand();
- RepeatingCommand synchronizer = new AsynchronousRepeatingCommandWrapper(command, this.buildThreadFactory(), null, ExceptionHandler.Runtime.instance());
-
- synchronizer.execute();
- synchronizer.start();
- this.sleep(TICK);
- synchronizer.stop();
- assertEquals(1, command.count);
- }
-
- public class SimpleCommand implements Command {
- int count = 0;
- public void execute() {
- this.count++;
- }
- }
-
- public void testException() throws Exception {
- BogusCommand command = new BogusCommand();
- CollectingExceptionHandler exHandler = new CollectingExceptionHandler();
- RepeatingCommand synchronizer = new AsynchronousRepeatingCommandWrapper(command, this.buildThreadFactory(), null, exHandler);
- synchronizer.start();
-
- synchronizer.execute();
- this.sleep(TICK);
-
- synchronizer.execute();
- this.sleep(TICK);
-
- synchronizer.stop();
- assertEquals(2, CollectionTools.size(exHandler.getExceptions()));
- assertEquals(2, command.count);
- }
-
- public class BogusCommand implements Command {
- int count = 0;
- public void execute() {
- this.count++;
- throw new NullPointerException();
- }
- }
-
- /**
- * Make sure the <code>DEBUG</code> constant is <code>false</code>
- * before checking in the code.
- */
- public void testDEBUG() {
- TestTools.assertFalseDEBUG(AsynchronousRepeatingCommandWrapper.class);
- }
-
-
- // ********** synchronize commands **********
-
- public static class SynchronizeSecondaryModelCommand1
- implements Command
- {
- private final SecondaryModel1 secondaryModel;
-
- public SynchronizeSecondaryModelCommand1(SecondaryModel1 secondaryModel) {
- super();
- this.secondaryModel = secondaryModel;
- }
-
- public void execute() {
- this.secondaryModel.synchronize();
- }
- }
-
- /**
- * the primary model (subclass) has to synchronize with itself (superclass)
- */
- public static class SynchronizeSecondaryModelCommand2
- extends SynchronizeSecondaryModelCommand1
- {
- private final PrimaryModel2 primaryModel;
-
- public SynchronizeSecondaryModelCommand2(PrimaryModel2 primaryModel, SecondaryModel2 secondaryModel) {
- super(secondaryModel);
- this.primaryModel = primaryModel;
- }
-
- @Override
- public void execute() {
- super.execute();
- this.primaryModel.synchronize();
- }
- }
-
-
- // ********** primary models **********
-
- /**
- * this object will call the synchronizer whenever its count changes,
- * allowing interested parties to synchronize with the change
- */
- public static class PrimaryModel1 {
- protected RepeatingCommand synchronizer;
- protected int count = 2;
-
- public PrimaryModel1() {
- super();
- this.setSynchronizer_(RepeatingCommand.Null.instance());
- }
-
- public int getCount() {
- return this.count;
- }
- public void setCount(int count) {
- if (count != this.count) {
- this.count = count;
- this.stateChanged();
- }
- }
-
- protected void stateChanged() {
- this.synchronizer.execute();
- }
-
- public void setSynchronizer(RepeatingCommand synchronizer) throws InterruptedException {
- if (synchronizer == null) {
- throw new NullPointerException();
- }
- this.synchronizer.stop();
- this.setSynchronizer_(synchronizer);
- }
-
- protected void setSynchronizer_(RepeatingCommand synchronizer) {
- this.synchronizer = synchronizer;
- this.synchronizer.start();
- }
-
- public void startSynchronizer() {
- this.synchronizer.start(); // this should cause an exception
- }
- public void dispose() throws InterruptedException {
- this.synchronizer.stop();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(this.getClass().getSimpleName());
- sb.append('(');
- this.toString(sb);
- sb.append(')');
- return sb.toString();
- }
- public void toString(StringBuilder sb) {
- sb.append("count=");
- sb.append(this.count);
- }
- }
-
- /**
- * This model synchronizes with itself, triggering a recursive synchronization
- * with the change. Whenever the [inherited] 'count' changes, 'countPlus3'
- * is updated appropriately and another synchronize is initiated if appropriate.
- */
- public static class PrimaryModel2
- extends PrimaryModel1
- {
- private int countPlus3 = 0;
-
- public PrimaryModel2() {
- super();
- this.countPlus3 = this.count + 3;
- }
-
- public int getCountPlus3() {
- return this.countPlus3;
- }
- protected void setCountPlus3(int countPlus3) {
- if (countPlus3 != this.countPlus3) {
- this.countPlus3 = countPlus3;
- this.stateChanged();
- }
- }
-
- // synchronize with itself, so to speak
- public void synchronize() {
- this.setCountPlus3(this.count + 3);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(", countPlus3=");
- sb.append(this.countPlus3);
- }
- }
-
-
- // ********** secondary models **********
-
- /**
- * This dependent object updates its 'doubleCount' whenever the
- * PrimaryModel1's 'count' changes, via the 'synchronizer'.
- */
- public static class SecondaryModel1 {
- protected final PrimaryModel1 primaryModel;
- protected int doubleCount = 0;
-
- public SecondaryModel1(PrimaryModel1 primaryModel) {
- super();
- this.primaryModel = primaryModel;
- this.synchronize();
- }
-
- public void synchronize() {
- this.doubleCount = this.primaryModel.getCount() * 2;
- }
-
- public int getDoubleCount() {
- return this.doubleCount;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(this.getClass().getSimpleName());
- sb.append('(');
- this.toString(sb);
- sb.append(')');
- return sb.toString();
- }
- public void toString(StringBuilder sb) {
- sb.append("doubleCount=");
- sb.append(this.doubleCount);
- }
- }
-
- public static class SecondaryModel2
- extends SecondaryModel1
- {
- private int doubleCountPlus3 = 0;
-
- public SecondaryModel2(PrimaryModel2 extendedPrimaryModel) {
- super(extendedPrimaryModel);
- }
-
- protected PrimaryModel2 getExtendedPrimaryModel() {
- return (PrimaryModel2) this.primaryModel;
- }
-
- @Override
- public void synchronize() {
- super.synchronize();
- int temp = this.getExtendedPrimaryModel().getCountPlus3() * 2;
- if (this.doubleCountPlus3 != temp) {
- this.doubleCountPlus3 = temp;
- }
- }
-
- public int getDoubleCountPlus3() {
- return this.doubleCountPlus3;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(", doubleCountPlus3=");
- sb.append(this.doubleCountPlus3);
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandExecutorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandExecutorTests.java
deleted file mode 100644
index cb7d75ea1e..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandExecutorTests.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.internal.command.ThreadLocalExtendedCommandExecutor;
-import org.eclipse.jpt.common.utility.tests.internal.MultiThreadedTestCase;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-public class CommandExecutorTests
- extends MultiThreadedTestCase
-{
-
- public CommandExecutorTests(String name) {
- super(name);
- }
-
- public void testDefaultCommandExecutor_toString() throws Exception {
- CommandExecutor commandExecutor = CommandExecutor.Default.instance();
- assertNotNull(commandExecutor.toString());
- }
-
- public void testDefaultCommandExecutor_serialization() throws Exception {
- CommandExecutor commandExecutor1 = CommandExecutor.Default.instance();
- CommandExecutor commandExecutor2 = TestTools.serialize(commandExecutor1);
- assertSame(commandExecutor1, commandExecutor2);
- }
-
- public void testDefaultCommandExecutor() {
- TestCommand testCommand = new TestCommand();
- assertEquals(0, testCommand.count);
- CommandExecutor commandExecutor = CommandExecutor.Default.instance();
- commandExecutor.execute(testCommand);
- assertEquals(1, testCommand.count);
- }
-
- static class TestCommand implements Command {
- int count = 0;
- public void execute() {
- this.count++;
- }
- }
-
- public void testThreadLocalCommandExecutor_toString() throws Exception {
- CommandExecutor commandExecutor = new ThreadLocalExtendedCommandExecutor();
- assertNotNull(commandExecutor.toString());
- }
-
- public void testThreadLocalCommandExecutor() throws Exception {
- ThreadLocalExtendedCommandExecutor threadLocalCommandExecutor = new ThreadLocalExtendedCommandExecutor();
- TestRunnable testRunnable1 = new TestRunnable(threadLocalCommandExecutor, 1);
- Thread thread1 = this.buildThread(testRunnable1);
- thread1.run();
-
- TestRunnable testRunnable2 = new TestRunnable(threadLocalCommandExecutor, 2);
- Thread thread2 = this.buildThread(testRunnable2);
- thread2.run();
-
- TestRunnable testRunnable3 = new TestRunnable(threadLocalCommandExecutor, 3, null);
- Thread thread3 = this.buildThread(testRunnable3);
- thread3.run();
-
- thread1.join();
- thread2.join();
- thread3.join();
-
- assertEquals(1, testRunnable1.testCommand.count);
- assertEquals(1, testRunnable1.testCommandExecutor.count);
-
- assertEquals(2, testRunnable2.testCommand.count);
- assertEquals(2, testRunnable2.testCommandExecutor.count);
-
- assertEquals(3, testRunnable3.testCommand.count);
- assertNull(testRunnable3.testCommandExecutor);
- }
-
- static class TestCommandExecutor implements ExtendedCommandExecutor {
- int count = 0;
- public void execute(Command command) {
- this.count++;
- command.execute();
- }
- public void waitToExecute(Command command) {
- this.execute(command);
- }
- public boolean waitToExecute(Command command, long timeout) {
- this.execute(command);
- return true;
- }
- }
-
- static class TestRunnable implements Runnable {
- final ThreadLocalExtendedCommandExecutor threadLocalCommandExecutor;
- final int executionCount;
- final TestCommand testCommand = new TestCommand();
- final TestCommandExecutor testCommandExecutor;
- TestRunnable(ThreadLocalExtendedCommandExecutor threadLocalCommandExecutor, int executionCount) {
- this(threadLocalCommandExecutor, executionCount, new TestCommandExecutor());
- }
- TestRunnable(ThreadLocalExtendedCommandExecutor threadLocalCommandExecutor, int executionCount, TestCommandExecutor testCommandExecutor) {
- super();
- this.threadLocalCommandExecutor = threadLocalCommandExecutor;
- this.executionCount = executionCount;
- this.testCommandExecutor = testCommandExecutor;
- }
- public void run() {
- this.threadLocalCommandExecutor.set(this.testCommandExecutor);
- for (int i = 0; i < this.executionCount; i++) {
- this.threadLocalCommandExecutor.execute(this.testCommand);
- }
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandRunnableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandRunnableTests.java
deleted file mode 100644
index d5dce4e56c..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandRunnableTests.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.command;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.command.CommandRunnable;
-
-@SuppressWarnings("nls")
-public class CommandRunnableTests extends TestCase {
- boolean commandExecuted = false;
-
- public CommandRunnableTests(String name) {
- super(name);
- }
-
- public void testNullCommand() {
- boolean exCaught = false;
- try {
- Runnable runnable = new CommandRunnable(null);
- fail("bogus: " + runnable);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRun() {
- Runnable runnable = new CommandRunnable(this.buildCommand());
- runnable.run();
- assertTrue(this.commandExecuted);
- }
-
- public void testToString() {
- Runnable runnable = new CommandRunnable(this.buildCommand());
- assertNotNull(runnable.toString());
- }
-
- private Command buildCommand() {
- return new Command() {
- public void execute() {
- CommandRunnableTests.this.commandExecuted = true;
- }
- };
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandTests.java
deleted file mode 100644
index 266a0101e4..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CommandTests.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.command;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.command.CommandExecutor;
-import org.eclipse.jpt.common.utility.internal.command.CommandRunnable;
-import org.eclipse.jpt.common.utility.internal.command.RunnableCommand;
-import org.eclipse.jpt.common.utility.internal.command.ThreadLocalCommand;
-import org.eclipse.jpt.common.utility.tests.internal.MultiThreadedTestCase;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-public class CommandTests
- extends MultiThreadedTestCase
-{
- public CommandTests(String name) {
- super(name);
- }
-
- public void testNullCommand() {
- Command command = Command.Null.instance();
- command.execute(); // just make sure it doesn't blow up?
- }
-
- public void testNullCommand_toString() {
- Command command = Command.Null.instance();
- assertNotNull(command.toString());
- }
-
- public void testNullCommand_serialization() throws Exception {
- Command command1 = Command.Null.instance();
- Command command2 = TestTools.serialize(command1);
- assertSame(command1, command2);
- }
-
- public void testDisabledCommand() {
- Command command = Command.Disabled.instance();
- boolean exCaught = false;
- try {
- command.execute();
- fail();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testDisabledCommand_toString() {
- Command command = Command.Disabled.instance();
- assertNotNull(command.toString());
- }
-
- public void testDisabledCommand_serialization() throws Exception {
- Command command1 = Command.Disabled.instance();
- Command command2 = TestTools.serialize(command1);
- assertSame(command1, command2);
- }
-
- public void testRunnableCommand() {
- SimpleTestRunnable testRunnable = new SimpleTestRunnable();
- assertFalse(testRunnable.ran);
- Command command = new RunnableCommand(testRunnable);
- command.execute();
- assertTrue(testRunnable.ran);
- }
-
- static class SimpleTestRunnable implements Runnable {
- boolean ran = false;
- public void run() {
- this.ran = true;
- }
- }
-
- public void testCommandRunnable() {
- TestCommand testCommand = new TestCommand();
- assertEquals(0, testCommand.count);
- Runnable runnable = new CommandRunnable(testCommand);
- runnable.run();
- assertEquals(1, testCommand.count);
- }
-
- static class TestCommand implements Command {
- int count = 0;
- public void execute() {
- this.count++;
- }
- }
-
- public void testThreadLocalCommand() throws Exception {
- ThreadLocalCommand threadLocalCommand = new ThreadLocalCommand();
- TestRunnable testRunnable1 = new TestRunnable(threadLocalCommand, 1);
- Thread thread1 = this.buildThread(testRunnable1);
- thread1.run();
-
- TestRunnable testRunnable2 = new TestRunnable(threadLocalCommand, 2);
- Thread thread2 = this.buildThread(testRunnable2);
- thread2.run();
-
- thread1.join();
- thread2.join();
-
- assertEquals(1, testRunnable1.testCommand.count);
-
- assertEquals(2, testRunnable2.testCommand.count);
- }
-
- static class TestCommandExecutor implements CommandExecutor {
- int count = 0;
- public void execute(Command command) {
- this.count++;
- command.execute();
- }
- }
-
- static class TestRunnable implements Runnable {
- final ThreadLocalCommand threadLocalCommand;
- final int executionCount;
- final TestCommand testCommand = new TestCommand();
- TestRunnable(ThreadLocalCommand threadLocalCommand, int executionCount) {
- super();
- this.threadLocalCommand = threadLocalCommand;
- this.executionCount = executionCount;
- }
- public void run() {
- this.threadLocalCommand.set(this.testCommand);
- for (int i = 0; i < this.executionCount; i++) {
- this.threadLocalCommand.execute();
- }
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CompositeCommandTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CompositeCommandTests.java
deleted file mode 100644
index 69aa1f8c8d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/CompositeCommandTests.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.command;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.command.CommandRunnable;
-import org.eclipse.jpt.common.utility.internal.command.CompositeCommand;
-
-public class CompositeCommandTests extends TestCase {
- boolean command1Executed = false;
- boolean command2Executed = false;
-
- public CompositeCommandTests(String name) {
- super(name);
- }
-
- public void testRun() {
- Runnable runnable = new CommandRunnable(this.buildCompositeCommand());
- runnable.run();
- assertTrue(this.command1Executed);
- assertTrue(this.command2Executed);
- }
-
- public void testToString() {
- Runnable runnable = new CommandRunnable(this.buildCompositeCommand());
- assertNotNull(runnable.toString());
- }
-
- private Command buildCompositeCommand() {
- return new CompositeCommand(
- this.buildCommand1(),
- this.buildCommand2()
- );
- }
-
- private Command buildCommand1() {
- return new Command() {
- public void execute() {
- CompositeCommandTests.this.command1Executed = true;
- }
- };
- }
-
- private Command buildCommand2() {
- return new Command() {
- public void execute() {
- CompositeCommandTests.this.command2Executed = true;
- }
- };
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/JptUtilityCommandTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/JptUtilityCommandTests.java
deleted file mode 100644
index 6d40c97327..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/command/JptUtilityCommandTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.command;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptUtilityCommandTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityCommandTests.class.getPackage().getName());
-
- suite.addTestSuite(AsynchronousCommandExecutorTests.class);
- suite.addTestSuite(AsynchronousRepeatingCommandWrapperTests.class);
- suite.addTestSuite(CommandExecutorTests.class);
- suite.addTestSuite(CommandRunnableTests.class);
- suite.addTestSuite(CommandTests.class);
- suite.addTestSuite(CompositeCommandTests.class);
-
- return suite;
- }
-
- private JptUtilityCommandTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/EmptyEnumerationTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/EmptyEnumerationTests.java
deleted file mode 100644
index 1efc9c81bb..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/EmptyEnumerationTests.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.enumerations;
-
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.enumerations.EmptyEnumeration;
-
-@SuppressWarnings("nls")
-public class EmptyEnumerationTests extends TestCase {
-
- public EmptyEnumerationTests(String name) {
- super(name);
- }
-
- public void testHasMoreElements() {
- int i = 0;
- for (Enumeration<Object> stream = EmptyEnumeration.instance(); stream.hasMoreElements();) {
- stream.nextElement();
- i++;
- }
- assertEquals(0, i);
- }
-
- public void testNextElement() {
- for (Enumeration<Object> stream = EmptyEnumeration.instance(); stream.hasMoreElements();) {
- fail("bogus element: " + stream.nextElement());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Enumeration<Object> stream = EmptyEnumeration.instance();
- Object element = null;
- while (stream.hasMoreElements()) {
- element = stream.nextElement();
- }
- try {
- element = stream.nextElement();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + element, exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/IteratorEnumerationTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/IteratorEnumerationTests.java
deleted file mode 100644
index cd6cbaa8af..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/IteratorEnumerationTests.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.enumerations;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Vector;
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.enumerations.IteratorEnumeration;
-
-@SuppressWarnings("nls")
-public class IteratorEnumerationTests extends TestCase {
-
- public IteratorEnumerationTests(String name) {
- super(name);
- }
-
- public void testHasMoreElements() {
- int i = 0;
- for (Enumeration<String> stream = this.buildEnumeration(); stream.hasMoreElements();) {
- stream.nextElement();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testHasMoreElementsUpcast() {
- int i = 0;
- for (Enumeration<Object> stream = this.buildEnumerationUpcast(); stream.hasMoreElements();) {
- stream.nextElement();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testNextElement() {
- Iterator<String> iterator = this.buildIterator();
- for (Enumeration<String> stream = this.buildEnumeration(); stream.hasMoreElements();) {
- assertEquals("bogus element", iterator.next(), stream.nextElement());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Enumeration<String> stream = this.buildEnumeration();
- String string = null;
- while (stream.hasMoreElements()) {
- string = stream.nextElement();
- }
- try {
- string = stream.nextElement();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- private Enumeration<String> buildEnumeration() {
- return this.buildEnumeration(this.buildIterator());
- }
-
- private Enumeration<Object> buildEnumerationUpcast() {
- return this.buildEnumerationUpcast(this.buildIterator());
- }
-
- private Enumeration<String> buildEnumeration(Iterator<String> iterator) {
- return new IteratorEnumeration<String>(iterator);
- }
-
- private Enumeration<Object> buildEnumerationUpcast(Iterator<String> iterator) {
- return new IteratorEnumeration<Object>(iterator);
- }
-
- private Iterator<String> buildIterator() {
- return this.buildVector().iterator();
- }
-
- private Vector<String> buildVector() {
- Vector<String> v = new Vector<String>();
- v.addElement("one");
- v.addElement("two");
- v.addElement("three");
- v.addElement("four");
- v.addElement("five");
- v.addElement("six");
- v.addElement("seven");
- v.addElement("eight");
- return v;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/JptUtilityEnumerationsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/JptUtilityEnumerationsTests.java
deleted file mode 100644
index d5dfb0f0a8..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/enumerations/JptUtilityEnumerationsTests.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.enumerations;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptUtilityEnumerationsTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityEnumerationsTests.class.getPackage().getName());
-
- suite.addTestSuite(EmptyEnumerationTests.class);
- suite.addTestSuite(IteratorEnumerationTests.class);
-
- return suite;
- }
-
- private JptUtilityEnumerationsTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ArrayIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ArrayIterableTests.java
deleted file mode 100644
index 0c6e2da5a2..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ArrayIterableTests.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-
-@SuppressWarnings("nls")
-public class ArrayIterableTests extends TestCase {
-
- public ArrayIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- int i = 1;
- for (String string : this.buildIterable()) {
- assertEquals(i++, Integer.parseInt(string));
- }
- }
-
- public void testSubIterator() {
- int i = 3;
- for (String string : this.buildIterable(2)) {
- assertEquals(i++, Integer.parseInt(string));
- }
- }
-
- public void testIllegalArgumentException() {
- this.triggerIllegalArgumentException(-1, 1);
- this.triggerIllegalArgumentException(8, 1);
- this.triggerIllegalArgumentException(0, -1);
- this.triggerIllegalArgumentException(0, 9);
- }
-
- private void triggerIllegalArgumentException(int start, int length) {
- boolean exCaught = false;
- try {
- Iterable<String> iterable = this.buildIterable(start, length);
- fail("bogus iterable: " + iterable);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- private Iterable<String> buildIterable() {
- return this.buildIterable(0);
- }
-
- private Iterable<String> buildIterable(int start) {
- return this.buildIterable(this.buildArray(), start);
- }
-
- private Iterable<String> buildIterable(String[] array, int start) {
- return new ArrayIterable<String>(array, start);
- }
-
- private Iterable<String> buildIterable(int start, int length) {
- return this.buildIterable(this.buildArray(), start, length);
- }
-
- private Iterable<String> buildIterable(String[] array, int start, int length) {
- return new ArrayIterable<String>(array, start, length);
- }
-
- private String[] buildArray() {
- return new String[] { "1", "2", "3", "4", "5", "6", "7", "8" };
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ArrayListIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ArrayListIterableTests.java
deleted file mode 100644
index f7cd40fcb8..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ArrayListIterableTests.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.ListIterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-
-@SuppressWarnings("nls")
-public class ArrayListIterableTests extends TestCase {
-
- public ArrayListIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- int i = 1;
- ListIterable<String> iterable = this.buildIterable();
- for (String string : iterable) {
- assertEquals(i++, Integer.parseInt(string));
- }
- ListIterator<String> stream = iterable.iterator();
- while (stream.hasNext()) {
- stream.next();
- }
- while (stream.hasPrevious()) {
- assertEquals(--i, Integer.parseInt(stream.previous()));
- }
- }
-
- public void testSubIterator() {
- int i = 3;
- for (String string : this.buildIterable(2)) {
- assertEquals(i++, Integer.parseInt(string));
- }
- }
-
- public void testIllegalArgumentException() {
- this.triggerIllegalArgumentException(-1, 1);
- this.triggerIllegalArgumentException(8, 1);
- this.triggerIllegalArgumentException(0, -1);
- this.triggerIllegalArgumentException(0, 9);
- }
-
- private void triggerIllegalArgumentException(int start, int length) {
- boolean exCaught = false;
- try {
- Iterable<String> iterable = this.buildIterable(start, length);
- fail("bogus iterable: " + iterable);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- private ListIterable<String> buildIterable() {
- return this.buildIterable(0);
- }
-
- private ListIterable<String> buildIterable(int start) {
- return this.buildIterable(this.buildArray(), start);
- }
-
- private ListIterable<String> buildIterable(String[] array, int start) {
- return (start == 0) ?
- new ArrayListIterable<String>(array) :
- new ArrayListIterable<String>(array, start);
- }
-
- private ListIterable<String> buildIterable(int start, int length) {
- return this.buildIterable(this.buildArray(), start, length);
- }
-
- private ListIterable<String> buildIterable(String[] array, int start, int length) {
- return new ArrayListIterable<String>(array, start, length);
- }
-
- private String[] buildArray() {
- return new String[] { "1", "2", "3", "4", "5", "6", "7", "8" };
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ChainIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ChainIterableTests.java
deleted file mode 100644
index ae8423bfd5..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ChainIterableTests.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.AbstractCollection;
-import java.util.AbstractList;
-import java.util.Iterator;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ChainIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.ChainIterator;
-
-@SuppressWarnings("nls")
-public class ChainIterableTests extends TestCase {
- private final static Class<?>[] VECTOR_HIERARCHY = { Vector.class, AbstractList.class, AbstractCollection.class, Object.class };
-
- public ChainIterableTests(String name) {
- super(name);
- }
-
-
- public void testNextLink() {
- int i = 0;
- for (Class<?> clazz : this.buildIterable()) {
- assertEquals(VECTOR_HIERARCHY[i++], clazz);
- }
- }
-
- public void testLinker() {
- int i = 0;
- for (Class<?> clazz : new ChainIterable<Class<?>>(Vector.class, this.buildLinker())) {
- assertEquals(VECTOR_HIERARCHY[i++], clazz);
- }
- }
-
- public void testException() {
- Iterable<Class<?>> iterable = new ChainIterable<Class<?>>(Vector.class);
- Iterator<Class<?>> iterator = iterable.iterator();
- boolean exCaught = false;
- try {
- Class<?> clazz = iterator.next();
- fail("bogus class: " + clazz);
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testToString() {
- assertNotNull(this.buildIterable().toString());
- }
-
- private Iterable<Class<?>> buildIterable() {
- return this.buildChainIterable(Vector.class);
- }
-
- private Iterable<Class<?>> buildChainIterable(Class<?> startLink) {
- // chain up the class's hierarchy
- return new ChainIterable<Class<?>>(startLink) {
- @Override
- protected Class<?> nextLink(Class<?> currentLink) {
- return currentLink.getSuperclass();
- }
- };
- }
-
- private ChainIterator.Linker<Class<?>> buildLinker() {
- return new ChainIterator.Linker<Class<?>>() {
- public Class<?> nextLink(Class<?> currentLink) {
- return currentLink.getSuperclass();
- }
- };
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CloneIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CloneIterableTests.java
deleted file mode 100644
index 03292ec25d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CloneIterableTests.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
-
-@SuppressWarnings("nls")
-public abstract class CloneIterableTests extends TestCase {
- Iterable<String> iterable;
-
- public CloneIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- List<String> c = new ArrayList<String>();
- c.add("0");
- c.add("1");
- c.add("2");
- c.add("3");
- assertEquals(4, c.size());
- this.iterable = this.buildIterable(c);
- int i = 0;
- for (String s : this.iterable) {
- assertEquals(String.valueOf(i++), s);
- c.remove("3");
- }
- assertEquals(4, i);
- assertEquals(3, c.size());
- }
-
- public void testRemove() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildRemovingIterable(collection);
-
- Object removed = "three";
- assertTrue(CollectionTools.contains(this.iterable, removed));
- for (Iterator<String> iterator = this.iterable.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals(removed)) {
- iterator.remove();
- }
- }
- assertFalse(collection.contains(removed));
- }
-
- public void testRemover() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildIterableWithRemover(collection);
-
- Object removed = "three";
- assertTrue(CollectionTools.contains(this.iterable, removed));
- for (Iterator<String> iterator = this.iterable.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals(removed)) {
- iterator.remove();
- }
- }
- assertFalse(collection.contains(removed));
- }
-
- public void testMissingRemover() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildIterable(collection);
- assertNotNull(this.iterable.toString());
-
- Object removed = "three";
- assertTrue(CollectionTools.contains(this.iterable, removed));
- boolean exCaught = false;
- for (Iterator<String> iterator = this.iterable.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals(removed)) {
- try {
- iterator.remove();
- fail();
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
- public void testToString() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildIterable(collection);
- assertNotNull(iterable.toString());
- }
-
- abstract Iterable<String> buildIterable(List<String> c);
-
- abstract Iterable<String> buildRemovingIterable(List<String> c);
-
- abstract Iterable<String> buildIterableWithRemover(List<String> c);
-
- CloneIterator.Remover<String> buildRemover(final Collection<String> c) {
- return new CloneIterator.Remover<String>() {
- public void remove(String current) {
- c.remove(current);
- }
- };
- }
-
- CloneListIterator.Mutator<String> buildMutator(final List<String> list) {
- return new CloneListIterator.Mutator<String>() {
- public void add(int index, String string) {
- list.add(index, string);
- }
- public void set(int index, String string) {
- list.set(index, string);
- }
- public void remove(int index) {
- list.remove(index);
- }
- };
- }
-
- List<String> buildCollection() {
- List<String> c = new ArrayList<String>();
- c.add("one");
- c.add("two");
- c.add("three");
- c.add("four");
- c.add("five");
- c.add("six");
- c.add("seven");
- c.add("eight");
- return c;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CompositeIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CompositeIterableTests.java
deleted file mode 100644
index bd5516f161..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CompositeIterableTests.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-
-@SuppressWarnings("nls")
-public class CompositeIterableTests extends TestCase {
-
- public CompositeIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- Collection<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
-
- Collection<String> c2 = new ArrayList<String>();
- c2.add("4");
- c2.add("5");
- c2.add("6");
- c2.add("7");
-
- @SuppressWarnings("unchecked")
- Iterable<String> composite = new CompositeIterable<String>(c1, c2);
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testExtraElement1() {
- Collection<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
-
- Iterable<String> composite = new CompositeIterable<String>(c1, "4");
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testExtraElement2() {
- Collection<String> c1 = new ArrayList<String>();
- c1.add("1");
- c1.add("2");
- c1.add("3");
-
- Iterable<String> composite = new CompositeIterable<String>("0", c1);
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testCollectionOfIterables() {
- Collection<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
-
- Collection<String> c2 = new ArrayList<String>();
- c2.add("4");
- c2.add("5");
- c2.add("6");
- c2.add("7");
-
- Collection<Iterable<String>> collection = new ArrayList<Iterable<String>>();
- collection.add(c1);
- collection.add(c2);
- Iterable<String> composite = new CompositeIterable<String>(collection);
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testToString() {
- Collection<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
-
- Collection<String> c2 = new ArrayList<String>();
- c2.add("4");
- c2.add("5");
- c2.add("6");
- c2.add("7");
-
- @SuppressWarnings("unchecked")
- Iterable<String> composite = new CompositeIterable<String>(c1, c2);
- assertNotNull(composite.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CompositeListIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CompositeListIterableTests.java
deleted file mode 100644
index baf06cf3fb..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/CompositeListIterableTests.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListListIterable;
-
-@SuppressWarnings("nls")
-public class CompositeListIterableTests extends TestCase {
-
- public CompositeListIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- List<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
-
- List<String> c2 = new ArrayList<String>();
- c2.add("4");
- c2.add("5");
- c2.add("6");
- c2.add("7");
-
- @SuppressWarnings("unchecked")
- Iterable<String> composite = new CompositeListIterable<String>(c1, c2);
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testExtraElement1() {
- List<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
-
- Iterable<String> composite = new CompositeListIterable<String>(c1, "4");
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testExtraElement2() {
- List<String> c1 = new ArrayList<String>();
- c1.add("1");
- c1.add("2");
- c1.add("3");
-
- Iterable<String> composite = new CompositeListIterable<String>("0", c1);
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testCollectionOfIterables() {
- List<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
-
- List<String> c2 = new ArrayList<String>();
- c2.add("4");
- c2.add("5");
- c2.add("6");
- c2.add("7");
-
- List<ListIterable<String>> collection = new ArrayList<ListIterable<String>>();
- collection.add(new ListListIterable<String>(c1));
- collection.add(new ListListIterable<String>(c2));
- Iterable<String> composite = new CompositeListIterable<String>(collection);
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testToString() {
- List<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
-
- List<String> c2 = new ArrayList<String>();
- c2.add("4");
- c2.add("5");
- c2.add("6");
- c2.add("7");
-
- @SuppressWarnings("unchecked")
- Iterable<String> composite = new CompositeListIterable<String>(c1, c2);
- assertNotNull(composite.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/EmptyIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/EmptyIterableTests.java
deleted file mode 100644
index 1afe2303eb..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/EmptyIterableTests.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class EmptyIterableTests extends TestCase {
-
- public EmptyIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- for (String s : EmptyIterable.<String>instance()) {
- fail("bogus element: " + s);
- }
- }
-
- public void testToString() {
- assertNotNull(EmptyIterable.instance().toString());
- }
-
- public void testSerialization() throws Exception {
- Iterable<String> iterable = EmptyIterable.instance();
- assertSame(iterable, TestTools.serialize(iterable));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/EmptyListIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/EmptyListIterableTests.java
deleted file mode 100644
index 761555cbbe..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/EmptyListIterableTests.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class EmptyListIterableTests extends TestCase {
-
- public EmptyListIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- for (String s : EmptyListIterable.<String>instance()) {
- fail("bogus element: " + s);
- }
- }
-
- public void testToString() {
- assertNotNull(EmptyListIterable.instance().toString());
- }
-
- public void testSerialization() throws Exception {
- Iterable<String> iterable = EmptyListIterable.instance();
- assertSame(iterable, TestTools.serialize(iterable));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/FilteringIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/FilteringIterableTests.java
deleted file mode 100644
index fa1b5613f3..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/FilteringIterableTests.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-
-@SuppressWarnings("nls")
-public class FilteringIterableTests extends TestCase {
- private static final String PREFIX = "prefix";
-
- public FilteringIterableTests(String name) {
- super(name);
- }
-
- public void testAccept() {
- int i = 0;
- for (String s : this.buildIterable()) {
- assertTrue(s.contains(PREFIX));
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testFilter() {
- Filter<String> filter = this.buildFilter();
- int i = 0;
- for (String s : new FilteringIterable<String>(this.buildNestedIterable(), filter)) {
- assertTrue(s.contains(PREFIX));
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testToString() {
- assertNotNull(this.buildIterable().toString());
- }
-
- public void testMissingFilter() {
- boolean exCaught = false;
- Iterable<String> iterable = new FilteringIterable<String>(this.buildNestedIterable());
- try {
- Iterator<String> iterator = iterable.iterator();
- fail("bogus iterator: " + iterator);
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- private Iterable<String> buildIterable() {
- return this.buildFilteringIterable(this.buildNestedIterable());
- }
-
- private Iterable<String> buildFilteringIterable(Iterable<String> nestedIterable) {
- return new FilteringIterable<String>(nestedIterable) {
- @Override
- protected boolean accept(String s) {
- return s.startsWith(PREFIX);
- }
- };
- }
-
- private Filter<String> buildFilter() {
- return new Filter<String>() {
- public boolean accept(String s) {
- return s.startsWith(PREFIX);
- }
- };
- }
-
- private Iterable<String> buildNestedIterable() {
- Collection<String> c = new ArrayList<String>();
- c.add(PREFIX + "1");
- c.add(PREFIX + "2");
- c.add(PREFIX + "3");
- c.add("4");
- c.add(PREFIX + "5");
- c.add(PREFIX + "6");
- c.add(PREFIX + "7");
- c.add("8");
- return c;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/GraphIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/GraphIterableTests.java
deleted file mode 100644
index bb39c41b85..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/GraphIterableTests.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.GraphIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.GraphIterator;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class GraphIterableTests extends TestCase {
- /** this will be populated with all the nodes created for the test */
- Collection<GraphNode> nodes = new ArrayList<GraphNode>();
-
- public GraphIterableTests(String name) {
- super(name);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testNeighbors1() {
- for (GraphNode gn : this.buildGraphIterable1()) {
- assertTrue(this.nodes.contains(gn));
- }
- }
-
- private Iterable<GraphNode> buildGraphIterable1() {
- return new GraphIterable<GraphNode>(this.buildGraphRoot()) {
- @Override
- public Iterator<GraphNode> neighbors(GraphNode next) {
- return next.neighbors();
- }
- };
- }
-
- public void testNeighbors2() {
- for (GraphNode gn : this.buildGraphIterable2()) {
- assertTrue(this.nodes.contains(gn));
- }
- }
-
- private Iterable<GraphNode> buildGraphIterable2() {
- return new GraphIterable<GraphNode>(this.buildGraphRoot(), this.buildMisterRogers());
- }
-
- public void testNeighbors3() {
- for (GraphNode gn : this.buildGraphIterable3()) {
- assertTrue(this.nodes.contains(gn));
- }
- }
-
- private Iterable<GraphNode> buildGraphIterable3() {
- return new GraphIterable<GraphNode>(new GraphNode[] { this.buildGraphRoot() }) {
- @Override
- public Iterator<GraphNode> neighbors(GraphNode next) {
- return next.neighbors();
- }
- };
- }
-
- public void testNeighbors4() {
- for (GraphNode gn : this.buildGraphIterable4()) {
- assertTrue(this.nodes.contains(gn));
- }
- }
-
- private Iterable<GraphNode> buildGraphIterable4() {
- return new GraphIterable<GraphNode>(new GraphNode[] { this.buildGraphRoot() }, this.buildMisterRogers());
- }
-
- public void testToString() {
- assertNotNull(this.buildGraphIterable1().toString());
- }
-
- public void testMissingMisterRogers() {
- boolean exCaught = false;
- try {
- for (GraphNode gn : new GraphIterable<GraphNode>(this.buildGraphRoot())) {
- assertTrue(this.nodes.contains(gn));
- }
- fail();
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- private GraphIterator.MisterRogers<GraphNode> buildMisterRogers() {
- return new GraphIterator.MisterRogers<GraphNode>() {
- public Iterator<GraphNode> neighbors(GraphNode next) {
- return next.neighbors();
- }
- };
- }
-
- private GraphNode buildGraphRoot() {
- GraphNode ncNode = new GraphNode("North Carolina");
- GraphNode vaNode = new GraphNode("Virginia");
- GraphNode scNode = new GraphNode("South Carolina");
- GraphNode gaNode = new GraphNode("Georgia");
- GraphNode flNode = new GraphNode("Florida");
- GraphNode alNode = new GraphNode("Alabama");
- GraphNode msNode = new GraphNode("Mississippi");
- GraphNode tnNode = new GraphNode("Tennessee");
-
- ncNode.setNeighbors(new GraphNode[] { vaNode, scNode, gaNode, tnNode });
- vaNode.setNeighbors(new GraphNode[] { ncNode, tnNode });
- scNode.setNeighbors(new GraphNode[] { ncNode, gaNode });
- gaNode.setNeighbors(new GraphNode[] { ncNode, scNode, flNode, alNode, tnNode });
- flNode.setNeighbors(new GraphNode[] { gaNode });
- alNode.setNeighbors(new GraphNode[] { gaNode, msNode, tnNode });
- msNode.setNeighbors(new GraphNode[] { alNode, tnNode });
- tnNode.setNeighbors(new GraphNode[] { vaNode, ncNode, gaNode, alNode, msNode });
-
- return ncNode;
- }
-
- public class GraphNode {
- private String name;
-
- private Collection<GraphNode> neighbors = new ArrayList<GraphNode>();
-
- public GraphNode(String name) {
- super();
- GraphIterableTests.this.nodes.add(this); // log node
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- void setNeighbors(GraphNode[] neighbors) {
- this.neighbors = CollectionTools.list(neighbors);
- }
-
- public Iterator<GraphNode> neighbors() {
- return this.neighbors.iterator();
- }
-
- public int neighborsSize() {
- return this.neighbors.size();
- }
-
- @Override
- public String toString() {
- return "GraphNode(" + this.name + ")";
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/JptUtilityIterablesTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/JptUtilityIterablesTests.java
deleted file mode 100644
index 6da560d319..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/JptUtilityIterablesTests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptUtilityIterablesTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityIterablesTests.class.getPackage().getName());
-
- suite.addTestSuite(ArrayIterableTests.class);
- suite.addTestSuite(ArrayListIterableTests.class);
- suite.addTestSuite(ChainIterableTests.class);
- suite.addTestSuite(CompositeIterableTests.class);
- suite.addTestSuite(CompositeListIterableTests.class);
- suite.addTestSuite(EmptyIterableTests.class);
- suite.addTestSuite(EmptyListIterableTests.class);
- suite.addTestSuite(FilteringIterableTests.class);
- suite.addTestSuite(SuperIterableWrapperTests.class);
- suite.addTestSuite(GraphIterableTests.class);
- suite.addTestSuite(LiveCloneIterableTests.class);
- suite.addTestSuite(LiveCloneListIterableTests.class);
- suite.addTestSuite(PeekableIterableTests.class);
- suite.addTestSuite(QueueIterableTests.class);
- suite.addTestSuite(ReadOnlyCompositeListIterableTests.class);
- suite.addTestSuite(ReadOnlyIterableTests.class);
- suite.addTestSuite(ReadOnlyListIterableTests.class);
- suite.addTestSuite(SingleElementIterableTests.class);
- suite.addTestSuite(SingleElementListIterableTests.class);
- suite.addTestSuite(SnapshotCloneIterableTests.class);
- suite.addTestSuite(SnapshotCloneListIterableTests.class);
- suite.addTestSuite(StackIterableTests.class);
- suite.addTestSuite(TransformationIterableTests.class);
- suite.addTestSuite(TransformationListIterableTests.class);
- suite.addTestSuite(TreeIterableTests.class);
-
- return suite;
- }
-
- private JptUtilityIterablesTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/LiveCloneIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/LiveCloneIterableTests.java
deleted file mode 100644
index 96fde7ffde..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/LiveCloneIterableTests.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-
-@SuppressWarnings("nls")
-public class LiveCloneIterableTests extends CloneIterableTests {
-
- public LiveCloneIterableTests(String name) {
- super(name);
- }
-
- @Override
- public void testIterator() {
- super.testIterator();
- // iterable should now return only 3 strings (since it's "live")
- int i = 0;
- for (String s : this.iterable) {
- assertEquals(String.valueOf(i++), s);
- }
- assertEquals(3, i);
- }
-
- @Override
- public void testRemove() {
- super.testRemove();
- // "live" clone iterable will no longer contain the element removed from the
- // original collection
- assertFalse(CollectionTools.contains(this.iterable, "three"));
- }
-
- @Override
- public void testRemover() {
- super.testRemover();
- // "live" clone iterable will no longer contain the element removed from the
- // original collection
- assertFalse(CollectionTools.contains(this.iterable, "three"));
- }
-
- @Override
- Iterable<String> buildIterable(List<String> c) {
- return new LiveCloneIterable<String>(c);
- }
-
- @Override
- Iterable<String> buildRemovingIterable(final List<String> c) {
- return new LiveCloneIterable<String>(c) {
- @Override
- protected void remove(String current) {
- c.remove(current);
- }
- };
- }
-
- @Override
- Iterable<String> buildIterableWithRemover(List<String> c) {
- return new LiveCloneIterable<String>(c, this.buildRemover(c));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/LiveCloneListIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/LiveCloneListIterableTests.java
deleted file mode 100644
index 0d70c000ea..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/LiveCloneListIterableTests.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-
-@SuppressWarnings("nls")
-public class LiveCloneListIterableTests extends LiveCloneIterableTests {
-
- public LiveCloneListIterableTests(String name) {
- super(name);
- }
-
- public void testAdd() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildRemovingIterable(collection);
-
- String added = "xxxx";
- assertFalse(CollectionTools.contains(this.iterable, added));
- for (ListIterator<String> iterator = (ListIterator<String>) this.iterable.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals("two")) {
- iterator.add(added);
- }
- }
- assertTrue(collection.contains(added));
- // "live" clone iterable will contain the element added to the
- // original collection
- assertTrue(CollectionTools.contains(this.iterable, added));
- }
-
- public void testMissingMutatorAdd() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildIterable(collection);
- assertNotNull(this.iterable.toString());
-
- String added = "xxxx";
- assertFalse(CollectionTools.contains(this.iterable, added));
- boolean exCaught = false;
- for (ListIterator<String> iterator = (ListIterator<String>) this.iterable.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals("three")) {
- try {
- iterator.add(added);
- fail();
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
- public void testSet() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildRemovingIterable(collection);
-
- String added = "xxxx";
- assertFalse(CollectionTools.contains(this.iterable, added));
- for (ListIterator<String> iterator = (ListIterator<String>) this.iterable.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals("two")) {
- iterator.set(added);
- }
- }
- assertTrue(collection.contains(added));
- assertFalse(collection.contains("two"));
- // "live" clone iterable will contain the element added to the
- // original collection
- assertTrue(CollectionTools.contains(this.iterable, added));
- assertFalse(CollectionTools.contains(this.iterable, "two"));
- }
-
- public void testMissingMutatorSet() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildIterable(collection);
- assertNotNull(this.iterable.toString());
-
- String added = "xxxx";
- assertFalse(CollectionTools.contains(this.iterable, added));
- boolean exCaught = false;
- for (ListIterator<String> iterator = (ListIterator<String>) this.iterable.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals("three")) {
- try {
- iterator.set(added);
- fail();
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
- @Override
- Iterable<String> buildIterable(List<String> c) {
- return new LiveCloneListIterable<String>(c);
- }
-
- @Override
- Iterable<String> buildRemovingIterable(final List<String> c) {
- return new LiveCloneListIterable<String>(c) {
- @Override
- protected void add(int index, String element) {
- c.add(index, element);
- }
- @Override
- protected void remove(int index) {
- c.remove(index);
- }
- @Override
- protected void set(int index, String element) {
- c.set(index, element);
- }
- };
- }
-
- @Override
- Iterable<String> buildIterableWithRemover(List<String> c) {
- return new LiveCloneListIterable<String>(c, this.buildMutator(c));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/PeekableIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/PeekableIterableTests.java
deleted file mode 100644
index 634992e5db..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/PeekableIterableTests.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.PeekableIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.PeekableIterator;
-
-@SuppressWarnings("nls")
-public class PeekableIterableTests extends TestCase {
-
- public PeekableIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- PeekableIterable<String> iterable = this.buildIterable();
- PeekableIterator<String> iterator = iterable.iterator();
- assertEquals("one", iterator.peek());
- }
-
- public void testToString() {
- assertNotNull(this.buildIterable().toString());
- }
-
- private PeekableIterable<String> buildIterable() {
- return new PeekableIterable<String>(this.buildNestedIterable());
- }
-
- private Iterable<String> buildNestedIterable() {
- return new ArrayIterable<String>(this.buildArray());
- }
-
- private String[] buildArray() {
- return new String[] {"one", "two", "three"};
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/QueueIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/QueueIterableTests.java
deleted file mode 100644
index 649f336336..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/QueueIterableTests.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Queue;
-import org.eclipse.jpt.common.utility.internal.SimpleQueue;
-import org.eclipse.jpt.common.utility.internal.iterables.QueueIterable;
-
-@SuppressWarnings("nls")
-public class QueueIterableTests extends TestCase {
-
- public QueueIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- Iterable<String> iterable = this.buildIterable();
- for (String s : iterable) {
- assertNotNull(s);
- }
- }
-
- public void testToString() {
- assertNotNull(this.buildIterable().toString());
- }
-
- private Iterable<String> buildIterable() {
- return new QueueIterable<String>(this.buildQueue());
- }
-
- private Queue<String> buildQueue() {
- Queue<String> q = new SimpleQueue<String>();
- q.enqueue("foo");
- q.enqueue("bar");
- q.enqueue("baz");
- return q;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyCompositeListIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyCompositeListIterableTests.java
deleted file mode 100644
index f217b39b2d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyCompositeListIterableTests.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ReadOnlyCompositeListIterable;
-
-@SuppressWarnings("nls")
-public class ReadOnlyCompositeListIterableTests extends TestCase {
-
- public ReadOnlyCompositeListIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- List<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
- ListIterable<String> li1 = new ListListIterable<String>(c1);
-
- List<String> c2 = new ArrayList<String>();
- c2.add("4");
- c2.add("5");
- c2.add("6");
- c2.add("7");
- ListIterable<String> li2 = new ListListIterable<String>(c2);
-
- @SuppressWarnings("unchecked")
- Iterable<String> composite = new ReadOnlyCompositeListIterable<String>(li1, li2);
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testExtraElement1() {
- List<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
- ListIterable<String> li1 = new ListListIterable<String>(c1);
-
- Iterable<String> composite = new ReadOnlyCompositeListIterable<String>(li1, "4");
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testExtraElement2() {
- List<String> c1 = new ArrayList<String>();
- c1.add("1");
- c1.add("2");
- c1.add("3");
- ListIterable<String> li1 = new ListListIterable<String>(c1);
-
- Iterable<String> composite = new ReadOnlyCompositeListIterable<String>("0", li1);
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testCollectionOfIterables() {
- List<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
- ListIterable<String> li1 = new ListListIterable<String>(c1);
-
- List<String> c2 = new ArrayList<String>();
- c2.add("4");
- c2.add("5");
- c2.add("6");
- c2.add("7");
- ListIterable<String> li2 = new ListListIterable<String>(c2);
-
- List<ListIterable<String>> collection = new ArrayList<ListIterable<String>>();
- collection.add(li1);
- collection.add(li2);
- ListIterable<ListIterable<String>> li = new ListListIterable<ListIterable<String>>(collection);
-
- Iterable<String> composite = new ReadOnlyCompositeListIterable<String>(li);
- int i = 0;
- for (String s : composite) {
- assertEquals(String.valueOf(i++), s);
- }
- }
-
- public void testToString() {
- List<String> c1 = new ArrayList<String>();
- c1.add("0");
- c1.add("1");
- c1.add("2");
- c1.add("3");
- ListIterable<String> li1 = new ListListIterable<String>(c1);
-
- List<String> c2 = new ArrayList<String>();
- c2.add("4");
- c2.add("5");
- c2.add("6");
- c2.add("7");
- ListIterable<String> li2 = new ListListIterable<String>(c2);
-
- @SuppressWarnings("unchecked")
- Iterable<String> composite = new ReadOnlyCompositeListIterable<String>(li1, li2);
- assertNotNull(composite.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyIterableTests.java
deleted file mode 100644
index 4399851f65..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyIterableTests.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.Iterator;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ReadOnlyIterable;
-
-@SuppressWarnings("nls")
-public class ReadOnlyIterableTests extends TestCase {
-
- public ReadOnlyIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- Iterator<String> nestedIterator = this.buildVector().iterator();
- for (String s : this.buildReadOnlyIterable()) {
- assertEquals(nestedIterator.next(), s);
- }
- }
-
- public void testRemove() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildReadOnlyIterable().iterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
- public void testToString() {
- assertNotNull(this.buildReadOnlyIterable().toString());
- }
-
- private Iterable<String> buildReadOnlyIterable() {
- return new ReadOnlyIterable<String>(this.buildVector());
- }
-
- private Vector<String> buildVector() {
- Vector<String> v = new Vector<String>();
- v.addElement("one");
- v.addElement("two");
- v.addElement("three");
- v.addElement("four");
- v.addElement("five");
- v.addElement("six");
- v.addElement("seven");
- v.addElement("eight");
- return v;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyListIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyListIterableTests.java
deleted file mode 100644
index 8a923ff3e4..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/ReadOnlyListIterableTests.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.Iterator;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ReadOnlyListIterable;
-
-@SuppressWarnings("nls")
-public class ReadOnlyListIterableTests extends TestCase {
-
- public ReadOnlyListIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- Iterator<String> nestedIterator = this.buildVector().iterator();
- for (String s : this.buildReadOnlyListIterable()) {
- assertEquals(nestedIterator.next(), s);
- }
- }
-
- public void testRemove() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildReadOnlyListIterable().iterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
- public void testToString() {
- assertNotNull(this.buildReadOnlyListIterable().toString());
- }
-
- private Iterable<String> buildReadOnlyListIterable() {
- return new ReadOnlyListIterable<String>(this.buildNestedListIterable());
- }
-
- private ListIterable<String> buildNestedListIterable() {
- return new ListListIterable<String>(this.buildVector());
- }
-
- private Vector<String> buildVector() {
- Vector<String> v = new Vector<String>();
- v.addElement("one");
- v.addElement("two");
- v.addElement("three");
- v.addElement("four");
- v.addElement("five");
- v.addElement("six");
- v.addElement("seven");
- v.addElement("eight");
- return v;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SingleElementIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SingleElementIterableTests.java
deleted file mode 100644
index 49061d3773..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SingleElementIterableTests.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-
-@SuppressWarnings("nls")
-public class SingleElementIterableTests extends TestCase {
-
- public SingleElementIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- for (String s : this.buildSingleElementIterable()) {
- assertEquals(this.singleElement(), s);
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildSingleElementIterable().iterator();
- String string = stream.next();
- try {
- string = stream.next();
- fail("bogus element: " + string);
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemove() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildSingleElementIterable().iterator(); stream.hasNext(); ) {
- if (stream.next().equals(this.singleElement())) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- protected Iterable<String> buildSingleElementIterable() {
- return new SingleElementIterable<String>(this.singleElement());
- }
-
- protected String singleElement() {
- return "single element";
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SingleElementListIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SingleElementListIterableTests.java
deleted file mode 100644
index d11520f7de..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SingleElementListIterableTests.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable;
-
-@SuppressWarnings("nls")
-public class SingleElementListIterableTests extends TestCase {
-
- public SingleElementListIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- for (String s : this.buildSingleElementListIterable()) {
- assertEquals(this.singleElement(), s);
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildSingleElementListIterable().iterator();
- String string = stream.next();
- try {
- string = stream.next();
- fail("bogus element: " + string);
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemove() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildSingleElementListIterable().iterator(); stream.hasNext(); ) {
- if (stream.next().equals(this.singleElement())) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testToString() {
- assertNotNull(this.buildSingleElementListIterable().toString());
- }
-
- protected Iterable<String> buildSingleElementListIterable() {
- return new SingleElementListIterable<String>(this.singleElement());
- }
-
- protected String singleElement() {
- return "single element";
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SnapshotCloneIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SnapshotCloneIterableTests.java
deleted file mode 100644
index 384006c45e..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SnapshotCloneIterableTests.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.List;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.SnapshotCloneIterable;
-
-@SuppressWarnings("nls")
-public class SnapshotCloneIterableTests extends CloneIterableTests {
-
- public SnapshotCloneIterableTests(String name) {
- super(name);
- }
-
- @Override
- public void testIterator() {
- super.testIterator();
- // "snapshot" iterable should still return 4 strings (since the original collection was cloned)
- int i = 0;
- for (String s : this.iterable) {
- assertEquals(String.valueOf(i++), s);
- }
- assertEquals(4, i);
- }
-
- @Override
- public void testRemove() {
- super.testRemove();
- // "snapshot" clone iterable will still contain the element removed from the
- // original collection
- assertTrue(CollectionTools.contains(this.iterable, "three"));
- }
-
- @Override
- public void testRemover() {
- super.testRemover();
- // "snapshot" clone iterable will still contain the element removed from the
- // original collection
- assertTrue(CollectionTools.contains(this.iterable, "three"));
- }
-
- @Override
- Iterable<String> buildIterable(List<String> c) {
- return new SnapshotCloneIterable<String>(c);
- }
-
- @Override
- Iterable<String> buildRemovingIterable(final List<String> c) {
- return new SnapshotCloneIterable<String>(c) {
- @Override
- protected void remove(String current) {
- c.remove(current);
- }
- };
- }
-
- @Override
- Iterable<String> buildIterableWithRemover(List<String> c) {
- return new SnapshotCloneIterable<String>(c, this.buildRemover(c));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SnapshotCloneListIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SnapshotCloneListIterableTests.java
deleted file mode 100644
index a6c5c1376b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SnapshotCloneListIterableTests.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.SnapshotCloneListIterable;
-
-@SuppressWarnings("nls")
-public class SnapshotCloneListIterableTests extends SnapshotCloneIterableTests {
-
- public SnapshotCloneListIterableTests(String name) {
- super(name);
- }
-
- public void testAdd() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildRemovingIterable(collection);
-
- String added = "xxxx";
- assertFalse(CollectionTools.contains(this.iterable, added));
- for (ListIterator<String> iterator = (ListIterator<String>) this.iterable.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals("two")) {
- iterator.add(added);
- }
- }
- assertTrue(collection.contains(added));
- // "snapshot" clone iterable not will contain the element added to the
- // original collection
- assertFalse(CollectionTools.contains(this.iterable, added));
- }
-
- public void testMissingMutatorAdd() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildIterable(collection);
- assertNotNull(this.iterable.toString());
-
- String added = "xxxx";
- assertFalse(CollectionTools.contains(this.iterable, added));
- boolean exCaught = false;
- for (ListIterator<String> iterator = (ListIterator<String>) this.iterable.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals("three")) {
- try {
- iterator.add(added);
- fail();
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
- public void testSet() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildRemovingIterable(collection);
-
- String added = "xxxx";
- assertFalse(CollectionTools.contains(this.iterable, added));
- assertTrue(CollectionTools.contains(this.iterable, "two"));
- for (ListIterator<String> iterator = (ListIterator<String>) this.iterable.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals("two")) {
- iterator.set(added);
- }
- }
- assertTrue(collection.contains(added));
- assertFalse(collection.contains("two"));
- // "snapshot" clone iterable will not be changed
- assertFalse(CollectionTools.contains(this.iterable, added));
- assertTrue(CollectionTools.contains(this.iterable, "two"));
- }
-
- public void testMissingMutatorSet() {
- final List<String> collection = this.buildCollection();
- this.iterable = this.buildIterable(collection);
- assertNotNull(this.iterable.toString());
-
- String added = "xxxx";
- assertFalse(CollectionTools.contains(this.iterable, added));
- boolean exCaught = false;
- for (ListIterator<String> iterator = (ListIterator<String>) this.iterable.iterator(); iterator.hasNext(); ) {
- if (iterator.next().equals("three")) {
- try {
- iterator.set(added);
- fail();
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue(exCaught);
- }
-
- @Override
- Iterable<String> buildIterable(List<String> c) {
- return new SnapshotCloneListIterable<String>(c);
- }
-
- @Override
- Iterable<String> buildRemovingIterable(final List<String> c) {
- return new SnapshotCloneListIterable<String>(c) {
- @Override
- protected void add(int index, String element) {
- c.add(index, element);
- }
- @Override
- protected void remove(int index) {
- c.remove(index);
- }
- @Override
- protected void set(int index, String element) {
- c.set(index, element);
- }
- };
- }
-
- @Override
- Iterable<String> buildIterableWithRemover(List<String> c) {
- return new SnapshotCloneListIterable<String>(c, this.buildMutator(c));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/StackIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/StackIterableTests.java
deleted file mode 100644
index 70a95bcd8a..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/StackIterableTests.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.SimpleStack;
-import org.eclipse.jpt.common.utility.internal.Stack;
-import org.eclipse.jpt.common.utility.internal.iterables.StackIterable;
-
-@SuppressWarnings("nls")
-public class StackIterableTests extends TestCase {
-
- public StackIterableTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- Iterator<String> iterator = this.buildIterable().iterator();
- assertEquals("three", iterator.next());
- assertEquals("two", iterator.next());
- assertEquals("one", iterator.next());
- }
-
- public void testToString() {
- assertNotNull(this.buildIterable().toString());
- }
-
- private Iterable<String> buildIterable() {
- return new StackIterable<String>(this.buildStack());
- }
-
- private Stack<String> buildStack() {
- Stack<String> stack = new SimpleStack<String>();
- stack.push("one");
- stack.push("two");
- stack.push("three");
- return stack;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SuperIterableWrapperTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SuperIterableWrapperTests.java
deleted file mode 100644
index c65608ef5d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/SuperIterableWrapperTests.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.ArrayList;
-import java.util.Collections;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.SuperIterableWrapper;
-
-@SuppressWarnings("nls")
-public class SuperIterableWrapperTests extends TestCase {
-
- public SuperIterableWrapperTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- String concat = "";
- for (String s : list) {
- concat += s;
- }
- assertEquals("foobarbaz", concat);
-
- Iterable<Object> iterable = new SuperIterableWrapper<Object>(list);
- concat = "";
- for (Object s : iterable) {
- concat += s;
- }
- assertEquals("foobarbaz", concat);
- }
-
- public void testToString() {
- Iterable<Object> iterable = new SuperIterableWrapper<Object>(Collections.emptyList());
- assertNotNull(iterable.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TransformationIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TransformationIterableTests.java
deleted file mode 100644
index 5a16de67c8..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TransformationIterableTests.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-
-@SuppressWarnings("nls")
-public class TransformationIterableTests extends TestCase {
-
- public TransformationIterableTests(String name) {
- super(name);
- }
-
- public void testTransform1() {
- int i = 1;
- for (Integer integer : this.buildIterable1()) {
- assertEquals(i++, integer.intValue());
- }
- }
-
- private Iterable<Integer> buildIterable1() {
- return this.buildTransformationIterable1(this.buildNestedIterable());
- }
-
- private Iterable<Integer> buildTransformationIterable1(Iterable<String> nestedIterable) {
- // transform each string into an integer with a value of the string's length
- return new TransformationIterable<String, Integer>(nestedIterable) {
- @Override
- protected Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- public void testTransform2() {
- int i = 1;
- for (Integer integer : this.buildIterable2()) {
- assertEquals(i++, integer.intValue());
- }
- }
-
- private Iterable<Integer> buildIterable2() {
- return this.buildTransformationIterable2(this.buildNestedIterable());
- }
-
- private Iterable<Integer> buildTransformationIterable2(Iterable<String> nestedIterable) {
- // transform each string into an integer with a value of the string's length
- return new TransformationIterable<String, Integer>(nestedIterable, this.buildTransformer());
- }
-
- private Transformer<String, Integer> buildTransformer() {
- // transform each string into an integer with a value of the string's length
- return new Transformer<String, Integer>() {
- public Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- private Iterable<String> buildNestedIterable() {
- Collection<String> c = new ArrayList<String>();
- c.add("1");
- c.add("22");
- c.add("333");
- c.add("4444");
- c.add("55555");
- c.add("666666");
- c.add("7777777");
- c.add("88888888");
- return c;
- }
-
- public void testToString() {
- assertNotNull(this.buildIterable1().toString());
- }
-
- public void testMissingTransformer() {
- Iterable<Integer> iterable = new TransformationIterable<String, Integer>(this.buildNestedIterable());
- boolean exCaught = false;
- try {
- int i = 1;
- for (Integer integer : iterable) {
- assertEquals(i++, integer.intValue());
- }
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TransformationListIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TransformationListIterableTests.java
deleted file mode 100644
index 6ac6a16d07..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TransformationListIterableTests.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationListIterable;
-
-@SuppressWarnings("nls")
-public class TransformationListIterableTests extends TestCase {
-
- public TransformationListIterableTests(String name) {
- super(name);
- }
-
- public void testTransform1() {
- int i = 1;
- for (Integer integer : this.buildIterable1()) {
- assertEquals(i++, integer.intValue());
- }
- }
-
- private Iterable<Integer> buildIterable1() {
- return this.buildTransformationListIterable1(this.buildNestedList());
- }
-
- private Iterable<Integer> buildTransformationListIterable1(List<String> nestedList) {
- // transform each string into an integer with a value of the string's length
- return new TransformationListIterable<String, Integer>(nestedList) {
- @Override
- protected Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- public void testTransform2() {
- int i = 1;
- for (Integer integer : this.buildIterable2()) {
- assertEquals(i++, integer.intValue());
- }
- }
-
- private Iterable<Integer> buildIterable2() {
- return this.buildTransformationListIterable2(this.buildNestedList());
- }
-
- private Iterable<Integer> buildTransformationListIterable2(List<String> nestedList) {
- // transform each string into an integer with a value of the string's length
- return new TransformationListIterable<String, Integer>(nestedList, this.buildTransformer());
- }
-
- private Transformer<String, Integer> buildTransformer() {
- // transform each string into an integer with a value of the string's length
- return new Transformer<String, Integer>() {
- public Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- private List<String> buildNestedList() {
- List<String> c = new ArrayList<String>();
- c.add("1");
- c.add("22");
- c.add("333");
- c.add("4444");
- c.add("55555");
- c.add("666666");
- c.add("7777777");
- c.add("88888888");
- return c;
- }
-
- public void testToString() {
- assertNotNull(this.buildIterable1().toString());
- }
-
- public void testMissingTransformer() {
- Iterable<Integer> iterable = new TransformationListIterable<String, Integer>(this.buildNestedList());
- boolean exCaught = false;
- try {
- int i = 1;
- for (Integer integer : iterable) {
- assertEquals(i++, integer.intValue());
- }
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TreeIterableTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TreeIterableTests.java
deleted file mode 100644
index dda3533e2b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterables/TreeIterableTests.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterables;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterables.TreeIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.TreeIterator;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class TreeIterableTests extends TestCase {
- /** this will be populated with all the nodes created for the test */
- Collection<TreeNode> nodes = new ArrayList<TreeNode>();
-
- public TreeIterableTests(String name) {
- super(name);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator1() {
- for (TreeNode tn : this.buildTreeIterable1()) {
- assertTrue(this.nodes.contains(tn));
- }
- }
-
- public void testIterator2() {
- for (TreeNode tn : this.buildTreeIterable2()) {
- assertTrue(this.nodes.contains(tn));
- }
- }
-
- public void testMidwife1() {
- for (TreeNode tn : new TreeIterable<TreeNode>(this.buildTree(), this.buildMidwife())) {
- assertTrue(this.nodes.contains(tn));
- }
- }
-
- public void testMidwife2() {
- for (TreeNode tn : new TreeIterable<TreeNode>(new TreeNode[] { this.buildTree() }, this.buildMidwife())) {
- assertTrue(this.nodes.contains(tn));
- }
- }
-
- public void testToString() {
- assertNotNull(this.buildTreeIterable1().toString());
- }
-
- public void testMissingMidwife() {
- boolean exCaught = false;
- try {
- for (TreeNode tn : new TreeIterable<TreeNode>(this.buildTree())) {
- assertTrue(this.nodes.contains(tn));
- }
- } catch (RuntimeException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- private Iterable<TreeNode> buildTreeIterable1() {
- return new TreeIterable<TreeNode>(this.buildTree()) {
- @Override
- public Iterator<TreeNode> children(TreeNode next) {
- return next.children();
- }
- };
- }
-
- private Iterable<TreeNode> buildTreeIterable2() {
- return new TreeIterable<TreeNode>(new TreeNode[] { this.buildTree() }) {
- @Override
- public Iterator<TreeNode> children(TreeNode next) {
- return next.children();
- }
- };
- }
-
- private TreeIterator.Midwife<TreeNode> buildMidwife() {
- return new TreeIterator.Midwife<TreeNode>() {
- public Iterator<TreeNode> children(TreeNode next) {
- return next.children();
- }
- };
- }
-
- private TreeNode buildTree() {
- TreeNode root = new TreeNode("root");
- TreeNode child1 = new TreeNode(root, "child 1");
- new TreeNode(child1, "grandchild 1A");
- TreeNode child2 = new TreeNode(root, "child 2");
- new TreeNode(child2, "grandchild 2A");
- TreeNode grandchild2B = new TreeNode(child2, "grandchild 2B");
- new TreeNode(grandchild2B, "great-grandchild 2B1");
- new TreeNode(grandchild2B, "great-grandchild 2B2");
- TreeNode grandchild2C = new TreeNode(child2, "grandchild 2C");
- new TreeNode(grandchild2C, "great-grandchild 2C1");
- new TreeNode(root, "child 3");
- return root;
- }
-
- public class TreeNode {
- private String name;
- private Collection<TreeNode> children = new ArrayList<TreeNode>();
-
- public TreeNode(String name) {
- super();
- TreeIterableTests.this.nodes.add(this); // log node
- this.name = name;
- }
-
- public TreeNode(TreeNode parent, String name) {
- this(name);
- parent.addChild(this);
- }
-
- public String getName() {
- return this.name;
- }
-
- private void addChild(TreeNode child) {
- this.children.add(child);
- }
-
- public Iterator<TreeNode> children() {
- return this.children.iterator();
- }
-
- public int childrenSize() {
- return this.children.size();
- }
-
- @Override
- public String toString() {
- return "TreeNode(" + this.name + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ArrayIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ArrayIteratorTests.java
deleted file mode 100644
index 8c8cda0ae7..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ArrayIteratorTests.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayIterator;
-
-@SuppressWarnings("nls")
-public class ArrayIteratorTests extends TestCase {
-
- public ArrayIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext(); ) {
- stream.next();
- i++;
- }
- assertEquals(this.buildArray().length, i);
- }
-
- public void testNext() {
- int i = 1;
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext(); ) {
- assertEquals("bogus element", i++, Integer.parseInt(stream.next()));
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext(); ) {
- if (stream.next().equals("3")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testIllegalArgumentException() {
- this.triggerIllegalArgumentException(-1, 1);
- this.triggerIllegalArgumentException(8, 1);
- this.triggerIllegalArgumentException(0, -1);
- this.triggerIllegalArgumentException(0, 9);
- }
-
- public void testGenerics() {
- Integer[] integers = new Integer[3];
- integers[0] = new Integer(0);
- integers[1] = new Integer(1);
- integers[2] = new Integer(2);
- int i = 0;
- for (Iterator<Number> stream = this.buildGenericIterator(integers); stream.hasNext();) {
- assertEquals(i++, stream.next().intValue());
- }
- assertEquals(integers.length, i);
- }
-
- Iterator<Number> buildGenericIterator(Integer[] integers) {
- return new ArrayIterator<Number>(integers);
- }
-
- public void testVarargs() {
- int i = 0;
- for (Iterator<Number> stream = this.buildVarArgIterator(); stream.hasNext();) {
- assertEquals(i++, stream.next().intValue());
- }
- assertEquals(3, i);
- }
-
- Iterator<Number> buildVarArgIterator() {
- return new ArrayIterator<Number>(new Integer(0), new Integer(1), new Integer(2));
- }
-
- void triggerIllegalArgumentException(int start, int length) {
- boolean exCaught = false;
- Iterator<String> stream = null;
- try {
- stream = this.buildIterator(start, length);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue("IllegalArgumentException not thrown: " + stream, exCaught);
- }
-
- Iterator<String> buildIterator() {
- return this.buildIterator(this.buildArray());
- }
-
- Iterator<String> buildIterator(String[] array) {
- return new ArrayIterator<String>(array);
- }
-
- Iterator<String> buildIterator(int start, int length) {
- return this.buildIterator(this.buildArray(), start, length);
- }
-
- Iterator<String> buildIterator(String[] array, int start, int length) {
- return new ArrayIterator<String>(array, start, length);
- }
-
- String[] buildArray() {
- return new String[] { "1", "2", "3", "4", "5", "6", "7", "8" };
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ArrayListIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ArrayListIteratorTests.java
deleted file mode 100644
index cae1762c27..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ArrayListIteratorTests.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.iterators.ArrayListIterator;
-
-@SuppressWarnings("nls")
-public class ArrayListIteratorTests extends ArrayIteratorTests {
-
- public ArrayListIteratorTests(String name) {
- super(name);
- }
-
- public void testHasPrevious() {
- ListIterator<String> stream = this.buildListIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- int i = 0;
- while (stream.hasPrevious()) {
- stream.previous();
- i++;
- }
- assertEquals(this.buildArray().length, i);
- }
-
- public void testPrevious() {
- ListIterator<String> stream = this.buildListIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- int i = this.buildArray().length;
- while (stream.hasPrevious()) {
- assertEquals("bogus element", i--, Integer.parseInt(stream.previous()));
- }
- }
-
- public void testNextIndex() {
- int i = 0;
- ListIterator<String> stream = this.buildListIterator();
- while (stream.hasNext()) {
- assertEquals(i, stream.nextIndex());
- stream.next();
- i++;
- }
- assertEquals(i, stream.nextIndex());
- }
-
- public void testPreviousIndex() {
- int i = 0;
- ListIterator<String> stream = this.buildListIterator();
- while (stream.hasNext()) {
- assertEquals(i - 1, stream.previousIndex());
- stream.next();
- i++;
- }
- assertEquals(i - 1, stream.previousIndex());
- }
-
- @Override
- public void testNoSuchElementException() {
- boolean exCaught = false;
- ListIterator<String> stream = this.buildListIterator();
- String string = null;
- try {
- string = stream.previous();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testUnsupportedOperationExceptionAdd() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildListIterator(); stream.hasNext();) {
- if (stream.next().equals("3")) {
- try {
- stream.add("3.5");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testUnsupportedOperationExceptionSet() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildListIterator(); stream.hasNext();) {
- if (stream.next().equals("3")) {
- try {
- stream.set("three");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- @Override
- Iterator<Number> buildGenericIterator(Integer[] integers) {
- return new ArrayListIterator<Number>(integers);
- }
-
- @Override
- Iterator<Number> buildVarArgIterator() {
- return new ArrayListIterator<Number>(new Integer(0), new Integer(1), new Integer(2));
- }
-
- private ListIterator<String> buildListIterator() {
- return this.buildListIterator(this.buildArray());
- }
-
- private ListIterator<String> buildListIterator(String[] array) {
- return new ArrayListIterator<String>(array);
- }
-
- @Override
- Iterator<String> buildIterator(String[] array) {
- return new ArrayListIterator<String>(array);
- }
-
- @Override
- Iterator<String> buildIterator(String[] array, int start, int length) {
- return new ArrayListIterator<String>(array, start, length);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ChainIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ChainIteratorTests.java
deleted file mode 100644
index b4cdcf1569..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ChainIteratorTests.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.AbstractCollection;
-import java.util.AbstractList;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Vector;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.ChainIterator;
-
-@SuppressWarnings("nls")
-public class ChainIteratorTests extends TestCase {
- private final static Class<?>[] VECTOR_HIERARCHY = { Vector.class, AbstractList.class, AbstractCollection.class, Object.class };
-
- public ChainIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<Class<?>> stream = this.buildIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(VECTOR_HIERARCHY.length, i);
- }
-
- public void testInnerHasNext() {
- int i = 0;
- for (Iterator<Class<?>> stream = this.buildInnerIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(VECTOR_HIERARCHY.length, i);
- }
-
- public void testNext() {
- int i = 0;
- for (Iterator<Class<?>> stream = this.buildIterator(); stream.hasNext(); i++) {
- assertEquals("bogus link", VECTOR_HIERARCHY[i], stream.next());
- }
- }
-
- public void testInnerNext() {
- int i = 0;
- for (Iterator<Class<?>> stream = this.buildInnerIterator(); stream.hasNext(); i++) {
- assertEquals("bogus link", VECTOR_HIERARCHY[i], stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<Class<?>> stream = this.buildIterator();
- Class<?> javaClass = null;
- while (stream.hasNext()) {
- javaClass = stream.next();
- }
- try {
- javaClass = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + javaClass, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<Class<?>> stream = this.buildIterator(); stream.hasNext();) {
- if (stream.next() == AbstractCollection.class) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- private Iterator<Class<?>> buildIterator() {
- return this.buildChainIterator(Vector.class, this.buildLinker());
- }
-
- private Iterator<Class<?>> buildInnerIterator() {
- return this.buildInnerChainIterator(Vector.class);
- }
-
- private Iterator<Class<?>> buildChainIterator(Class<?> startLink, ChainIterator.Linker<Class<?>> linker) {
- return new ChainIterator<Class<?>>(startLink, linker);
- }
-
- private ChainIterator.Linker<Class<?>> buildLinker() {
- // chain up the class's hierarchy
- return new ChainIterator.Linker<Class<?>>() {
- public Class<?> nextLink(Class<?> currentLink) {
- return currentLink.getSuperclass();
- }
- };
- }
-
- private Iterator<Class<?>> buildInnerChainIterator(Class<?> startLink) {
- // chain up the class's hierarchy
- return new ChainIterator<Class<?>>(startLink) {
- @Override
- protected Class<?> nextLink(Class<?> currentLink) {
- return currentLink.getSuperclass();
- }
- };
- }
-
- public void testInvalidChainIterator() {
- // missing method override
- Iterator<Class<?>> iterator = new ChainIterator<Class<?>>(Vector.class);
- boolean exCaught = false;
- try {
- Class<?> c = iterator.next();
- fail("invalid class: " + c.getName());
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CloneIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CloneIteratorTests.java
deleted file mode 100644
index 19c45dfd35..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CloneIteratorTests.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.common.utility.tests.internal.MultiThreadedTestCase;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class CloneIteratorTests
- extends MultiThreadedTestCase
-{
- Collection<String> originalCollection;
-
- private Collection<String> concurrentCollection;
-
- public CloneIteratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.originalCollection = this.buildCollection();
- }
-
- public void testHasNext() {
- int originalSize = this.originalCollection.size();
- int i = 0;
- for (Iterator<String> stream = this.buildCloneIterator(); stream.hasNext();) {
- stream.next();
- // should allow concurrent modification
- this.originalCollection.add("foo");
- i++;
- }
- assertTrue(originalSize != this.originalCollection.size());
- assertEquals(originalSize, i);
- }
-
- public void testNext() {
- Iterator<String> nestedIterator = this.originalCollection.iterator();
- for (Iterator<String> stream = this.buildCloneIterator(); stream.hasNext();) {
- assertEquals("bogus element", nestedIterator.next(), stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildCloneIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testRemoveDefault() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildCloneIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testRemoveEliminator() {
- CloneIterator.Remover<String> eliminator = new CloneIterator.Remover<String>() {
- public void remove(String element) {
- CloneIteratorTests.this.originalCollection.remove(element);
- }
- };
- this.verifyRemove(new CloneIterator<String>(this.originalCollection, eliminator));
- }
-
- public void testRemoveSubclass() {
- this.verifyRemove(new CloneIterator<String>(this.originalCollection) {
- @Override
- protected void remove(String current) {
- CloneIteratorTests.this.originalCollection.remove(current);
- }
- });
- }
-
- /**
- * Test concurrent access: First build a clone iterator in a separate thread
- * that hangs momentarily during its construction; then modify the shared
- * collection in this thread. This would cause a
- * ConcurrentModificationException in the other thread if the clone iterator
- * were not synchronized on the original collection.
- */
- public void testConcurrentAccess() throws Exception {
- SlowCollection<String> slow = new SlowCollection<String>();
- this.populateCollection(slow);
- // using the unsynchronized collection will cause the test to fail
- // this.originalCollection = slow;
- this.originalCollection = Collections.synchronizedCollection(slow);
-
- this.concurrentCollection = new ArrayList<String>();
- Thread thread = this.buildThread(this.buildRunnable());
- thread.start();
- while ( ! slow.hasStartedClone()) {
- // wait for the other thread to start the clone...
- Thread.yield();
- }
- // ...then sneak in an extra element
- this.originalCollection.add("seventeen");
- thread.join();
- Collection<String> expected = new ArrayList<String>();
- this.populateCollection(expected);
- assertEquals(expected, this.concurrentCollection);
- }
-
- private Runnable buildRunnable() {
- return new TestRunnable() {
- @Override
- protected void run_() throws Throwable {
- CloneIteratorTests.this.loopWithCloneIterator();
- }
- };
- }
-
- /**
- * use a clone iterator to loop over the "slow" collection and copy its
- * contents to the concurrent collection
- */
- void loopWithCloneIterator() {
- for (Iterator<String> stream = this.buildCloneIterator(); stream.hasNext();) {
- this.concurrentCollection.add(stream.next());
- }
- }
-
- private void verifyRemove(Iterator<String> iterator) {
- Object removed = "three";
- assertTrue(this.originalCollection.contains(removed));
- // try to remove before calling #next()
- boolean exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- while (iterator.hasNext()) {
- if (iterator.next().equals(removed)) {
- iterator.remove();
- // try to remove twice
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
- }
- assertFalse(this.originalCollection.contains(removed));
- }
-
- private Iterator<String> buildCloneIterator() {
- return this.buildCloneIterator(this.originalCollection);
- }
-
- private Iterator<String> buildCloneIterator(Collection<String> c) {
- return new CloneIterator<String>(c);
- }
-
- private Collection<String> buildCollection() {
- Collection<String> c = this.buildEmptyCollection();
- this.populateCollection(c);
- return c;
- }
-
- protected Collection<String> buildEmptyCollection() {
- return new ArrayList<String>();
- }
-
- private void populateCollection(Collection<String> c) {
- c.add("one");
- c.add("two");
- c.add("three");
- c.add("four");
- c.add("five");
- c.add("six");
- c.add("seven");
- c.add("eight");
- }
-
- // ********** custom collection **********
- static class SlowCollection<E> extends ArrayList<E> {
- private static final long serialVersionUID = 1L;
- private boolean hasStartedClone = false;
-
- public SlowCollection() {
- super();
- }
-
- @Override
- public Object[] toArray() {
- this.setHasStartedClone(true);
- // take a little snooze before returning the array
- TestTools.sleep(100);
- return super.toArray();
- }
-
- synchronized void setHasStartedClone(boolean hasStartedClone) {
- this.hasStartedClone = hasStartedClone;
- }
-
- synchronized boolean hasStartedClone() {
- return this.hasStartedClone;
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CloneListIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CloneListIteratorTests.java
deleted file mode 100644
index 0f3a841306..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CloneListIteratorTests.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.common.utility.tests.internal.MultiThreadedTestCase;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class CloneListIteratorTests
- extends MultiThreadedTestCase
-{
- List<String> originalList;
-
- private List<String> concurrentList;
-
- public CloneListIteratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.originalList = this.buildList();
- }
-
- public void testHasNext() {
- int originalSize = this.originalList.size();
- int i = 0;
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- stream.next();
- // should allow concurrent modification
- this.originalList.add("foo");
- i++;
- }
- assertTrue(originalSize != this.originalList.size());
- assertEquals(originalSize, i);
- }
-
- public void testNext() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- assertEquals("bogus element", nestedListIterator.next(), stream.next());
- }
- }
-
- public void testIndex() {
- ListIterator<String> cloneListIterator = this.buildCloneListIterator();
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- for (int i = 0; i < 7; i++) {
- nestedListIterator.next();
- cloneListIterator.next();
- assertEquals("bogus index", nestedListIterator.nextIndex(), cloneListIterator.nextIndex());
- assertEquals("bogus index", nestedListIterator.previousIndex(), cloneListIterator.previousIndex());
- }
-
- for (int i = 0; i < 3; i++) {
- nestedListIterator.previous();
- cloneListIterator.previous();
- assertEquals("bogus index", nestedListIterator.nextIndex(), cloneListIterator.nextIndex());
- assertEquals("bogus index", nestedListIterator.previousIndex(), cloneListIterator.previousIndex());
- }
-
- while (nestedListIterator.hasNext()) {
- nestedListIterator.next();
- cloneListIterator.next();
- assertEquals("bogus index", nestedListIterator.nextIndex(), cloneListIterator.nextIndex());
- assertEquals("bogus index", nestedListIterator.previousIndex(), cloneListIterator.previousIndex());
- }
- }
-
- public void testHasPrevious() {
- int originalSize = this.originalList.size();
- int i = 0;
- ListIterator<String> stream = this.buildCloneListIterator();
- while (stream.hasNext()) {
- stream.next();
- this.originalList.add("foo");
- i++;
- }
- assertTrue(originalSize != this.originalList.size());
- originalSize = this.originalList.size();
- while (stream.hasPrevious()) {
- stream.previous();
- // should allow concurrent modification
- this.originalList.add("bar");
- i--;
- }
- assertTrue(originalSize != this.originalList.size());
- assertEquals(0, i);
- }
-
- public void testPrevious() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- ListIterator<String> stream = this.buildCloneListIterator();
- while (stream.hasNext()) {
- nestedListIterator.next();
- stream.next();
- }
- while (stream.hasPrevious()) {
- assertEquals("bogus element", nestedListIterator.previous(), stream.previous());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- ListIterator<String> stream = this.buildCloneListIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
-
- exCaught = false;
- while (stream.hasPrevious()) {
- string = stream.previous();
- }
- try {
- string = stream.previous();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testModifyDefault() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
-
- exCaught = false;
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.add("three and a half");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
-
- exCaught = false;
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.set("another three");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testModifyMutatorNext() {
- this.verifyModifyNext(new CloneListIterator<String>(this.originalList, this.buildMutator()));
- }
-
- public void testModifyMutatorPrevious() {
- this.verifyModifyPrevious(new CloneListIterator<String>(this.originalList, this.buildMutator()));
- }
-
- private CloneListIterator.Mutator<String> buildMutator() {
- return new CloneListIterator.Mutator<String>() {
- public void add(int index, String o) {
- CloneListIteratorTests.this.originalList.add(index, o);
- }
-
- public void remove(int index) {
- CloneListIteratorTests.this.originalList.remove(index);
- }
-
- public void set(int index, String o) {
- CloneListIteratorTests.this.originalList.set(index, o);
- }
- };
- }
-
- public void testModifySubclassNext() {
- this.verifyModifyNext(this.buildSubclass());
- }
-
- public void testModifySubclassPrevious() {
- this.verifyModifyPrevious(this.buildSubclass());
- }
-
- private ListIterator<String> buildSubclass() {
- return new CloneListIterator<String>(this.originalList) {
- @Override
- protected void add(int currentIndex, String o) {
- CloneListIteratorTests.this.originalList.add(currentIndex, o);
- }
-
- @Override
- protected void remove(int currentIndex) {
- CloneListIteratorTests.this.originalList.remove(currentIndex);
- }
-
- @Override
- protected void set(int currentIndex, String o) {
- CloneListIteratorTests.this.originalList.set(currentIndex, o);
- }
- };
- }
-
- private void verifyModifyNext(ListIterator<String> iterator) {
- String removed = "three";
- String addedAfter = "five";
- String added = "five and a half";
- String replaced = "seven";
- String replacement = "another seven";
- assertTrue(this.originalList.contains(removed));
- assertTrue(this.originalList.contains(addedAfter));
- assertTrue(this.originalList.contains(replaced));
- // try to remove before calling #next()
- boolean exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- while (iterator.hasNext()) {
- String next = iterator.next();
- if (next.equals(addedAfter)) {
- iterator.add(added);
- }
- if (next.equals(removed)) {
- iterator.remove();
- // try to remove twice
- exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
- if (next.equals(replaced)) {
- iterator.set(replacement);
- }
- }
- assertTrue(this.originalList.contains(added));
- assertFalse(this.originalList.contains(removed));
- assertFalse(this.originalList.contains(replaced));
- assertTrue(this.originalList.contains(replacement));
- }
-
- private void verifyModifyPrevious(ListIterator<String> iterator) {
- String removed = "three";
- String addedBefore = "five";
- String added = "four and a half";
- String replaced = "seven";
- String replacement = "another seven";
- assertTrue(this.originalList.contains(removed));
- assertTrue(this.originalList.contains(addedBefore));
- assertTrue(this.originalList.contains(replaced));
- while (iterator.hasNext()) {
- iterator.next();
- }
- while (iterator.hasPrevious()) {
- Object previous = iterator.previous();
- if (previous.equals(addedBefore)) {
- iterator.add(added);
- }
- if (previous.equals(removed)) {
- iterator.remove();
- // try to remove twice
- boolean exCaught = false;
- try {
- iterator.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
- if (previous.equals(replaced)) {
- iterator.set(replacement);
- }
- }
- assertTrue(this.originalList.contains(added));
- assertFalse(this.originalList.contains(removed));
- assertFalse(this.originalList.contains(replaced));
- assertTrue(this.originalList.contains(replacement));
- }
-
- private ListIterator<String> buildCloneListIterator() {
- return this.buildCloneListIterator(this.originalList);
- }
-
- private ListIterator<String> buildCloneListIterator(List<String> list) {
- return new CloneListIterator<String>(list);
- }
-
- private ListIterator<String> buildNestedListIterator() {
- return this.originalList.listIterator();
- }
-
- private List<String> buildList() {
- List<String> list = this.buildEmptyList();
- this.populateList(list);
- return list;
- }
-
- private void populateList(List<String> list) {
- list.add("zero");
- list.add("one");
- list.add("two");
- list.add("three");
- list.add("four");
- list.add("five");
- list.add("six");
- list.add("seven");
- list.add("eight");
- list.add("nine");
- }
-
- protected List<String> buildEmptyList() {
- return new ArrayList<String>();
- }
-
- /**
- * Test concurrent access: First build a clone iterator in a separate thread
- * that hangs momentarily during its construction; then modify the shared
- * collection in this thread. This would cause a
- * ConcurrentModificationException in the other thread if the clone iterator
- * were not synchronized on the original collection.
- */
- public void testConcurrentAccess() throws Exception {
- CloneIteratorTests.SlowCollection<String> slow = new CloneIteratorTests.SlowCollection<String>();
- this.populateList(slow);
- // using the unsynchronized list will cause the test to fail
- // this.originalList = slow;
- this.originalList = Collections.synchronizedList(slow);
-
- this.concurrentList = new ArrayList<String>();
- Thread thread = this.buildThread(this.buildRunnable());
- thread.start();
- while ( ! slow.hasStartedClone()) {
- // wait for the other thread to start the clone...
- Thread.yield();
- }
- // ...then sneak in an extra element
- this.originalList.add("seventeen");
- thread.join();
- List<String> expected = new ArrayList<String>();
- this.populateList(expected);
- assertEquals(expected, this.concurrentList);
- }
-
- private Runnable buildRunnable() {
- return new TestRunnable() {
- @Override
- protected void run_() throws Throwable {
- CloneListIteratorTests.this.loopWithCloneListIterator();
- }
- };
- }
-
- /**
- * use a clone iterator to loop over the "slow" collection and copy its
- * contents to the concurrent collection
- */
- void loopWithCloneListIterator() {
- for (ListIterator<String> stream = this.buildCloneListIterator(); stream.hasNext();) {
- this.concurrentList.add(stream.next());
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CompositeIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CompositeIteratorTests.java
deleted file mode 100644
index 2a7dbd7c01..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CompositeIteratorTests.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-
-@SuppressWarnings("nls")
-public class CompositeIteratorTests extends TestCase {
-
- public CompositeIteratorTests(String name) {
- super(name);
- }
-
- public void testHasAnother() {
- this.verifyHasAnother(this.buildCompositeIterator());
- }
-
- public void testHasAnother2() {
- this.verifyHasAnother(this.buildCompositeIterator2());
- }
-
- public void testHasAnother3() {
- this.verifyHasAnother(this.buildCompositeIterator3());
- }
-
- void verifyHasAnother(Iterator<String> stream) {
- this.verifyHasAnother(8, stream);
- }
-
- void verifyHasAnother(int expected, Iterator<String> stream) {
- int i = 0;
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(expected, i);
- }
-
- public void testAnother() {
- this.verifyAnother(this.buildCompositeIterator());
- }
-
- public void testAnother2() {
- this.verifyAnother(this.buildCompositeIterator2());
- }
-
- public void testAnother3() {
- this.verifyAnother(this.buildCompositeIterator3());
- }
-
- void verifyAnother(Iterator<String> stream) {
- this.verifyAnother(1, stream);
- }
-
- void verifyAnother(int start, Iterator<String> stream) {
- int index = start;
- while (stream.hasNext()) {
- assertEquals("bogus element", String.valueOf(index++), stream.next().substring(0, 1));
- }
- }
-
- public void testRemove() {
- this.verifyRemove();
- }
-
- protected void verifyRemove() {
- List<String> list1 = this.buildList1();
- Object lastElement1 = list1.get(list1.size() - 1);
- List<String> list2 = this.buildList2();
- List<String> list3 = this.buildList3();
-
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(list1.listIterator());
- list.add(list2.listIterator());
- list.add(list3.listIterator());
-
- Iterator<String> stream = this.buildCompositeIterator(list.listIterator());
- while (stream.hasNext()) {
- Object next = stream.next();
- if (next.equals("333")) {
- stream.remove();
- }
- // test special case - where we are between iterators
- if (next.equals(lastElement1)) {
- // this will trigger the next iterator to be loaded
- stream.hasNext();
- // now try to remove from the previous iterator
- stream.remove();
- }
- }
- stream.remove();
-
- assertEquals("nothing removed from collection 1", this.buildList1().size() - 2, list1.size());
- assertFalse("element still in collection 1", list1.contains("333"));
- assertFalse("last element still in collection 1", list1.contains(lastElement1));
- assertTrue("wrong element removed from collection 1", list1.contains("22"));
-
- assertEquals("nothing removed from collection 3", this.buildList3().size() - 1, list3.size());
- assertFalse("element still in collection 3", list3.contains("88888888"));
- assertTrue("wrong element removed from collection 3", list3.contains("666666"));
- }
-
- public void testSingleElement() {
- String item = "0";
- this.verifyHasAnother(9, this.buildCompositeIterator(item, this.buildCompositeIterator()));
- this.verifyAnother(0, this.buildCompositeIterator(item, this.buildCompositeIterator()));
- }
-
- public void testNoSuchElementException() {
- this.verifyNoSuchElementException(this.buildCompositeIterator());
- }
-
- void verifyNoSuchElementException(Iterator<String> stream) {
- boolean exCaught = false;
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- this.verifyUnsupportedOperationException(this.buildUnmodifiableCompositeIterator());
- }
-
- void verifyUnsupportedOperationException(Iterator<String> stream) {
- boolean exCaught = false;
- while (stream.hasNext()) {
- Object string = stream.next();
- if (string.equals("333")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testIllegalStateException() {
- this.verifyIllegalStateException();
- }
-
- void verifyIllegalStateException() {
- this.verifyIllegalStateException(this.buildCompositeIterator());
- }
-
- void verifyIllegalStateException(Iterator<String> stream) {
- boolean exCaught = false;
- try {
- stream.remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
-
- public void testEmptyHasAnother1() {
- this.verifyEmptyHasAnother(this.buildEmptyCompositeIterator1());
- }
-
- void verifyEmptyHasAnother(Iterator<String> stream) {
- int i = 0;
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(0, i);
- }
-
- public void testEmptyNoSuchElementException1() {
- this.verifyNoSuchElementException(this.buildEmptyCompositeIterator1());
- }
-
- public void testEmptyIllegalStateException1() {
- this.verifyEmptyIllegalStateException1();
- }
-
- void verifyEmptyIllegalStateException1() {
- this.verifyIllegalStateException(this.buildEmptyCompositeIterator1());
- }
-
- public void testEmptyHasAnother2() {
- this.verifyEmptyHasAnother(this.buildEmptyCompositeIterator2());
- }
-
- public void testEmptyNoSuchElementException2() {
- this.verifyNoSuchElementException(this.buildEmptyCompositeIterator2());
- }
-
- public void testEmptyIllegalStateException2() {
- this.verifyEmptyIllegalStateException2();
- }
-
- void verifyEmptyIllegalStateException2() {
- this.verifyIllegalStateException(this.buildEmptyCompositeIterator2());
- }
-
- Iterator<String> buildCompositeIterator() {
- return this.buildCompositeIterator(this.buildIterators());
- }
-
- Iterator<String> buildEmptyCompositeIterator1() {
- return this.buildCompositeIterator(this.buildEmptyIterators1());
- }
-
- Iterator<String> buildEmptyCompositeIterator2() {
- return this.buildCompositeIterator(this.buildEmptyIterators2());
- }
-
- Iterator<String> buildUnmodifiableCompositeIterator() {
- return this.buildCompositeIterator(this.buildUnmodifiableIterators());
- }
-
- // leave unchecked so we can override in subclass
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator(Iterator iterators) {
- return new CompositeIterator<String>(iterators);
- }
-
- // use vararg constructor
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator2() {
- return new CompositeIterator<String>(this.buildIterator1(), this.buildIterator2(), this.buildIterator3());
- }
-
- // use vararg constructor
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator3() {
- return new CompositeIterator<String>(new Iterator[] { this.buildIterator1(), this.buildIterator2(), this.buildIterator3() });
- }
-
- Iterator<String> buildCompositeIterator(String string, Iterator<String> iterator) {
- return new CompositeIterator<String>(string, iterator);
- }
-
- ListIterator<Iterator<String>> buildIterators() {
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(this.buildIterator1());
- list.add(this.buildIterator2());
- list.add(this.buildIterator3());
- return list.listIterator();
- }
-
- ListIterator<Iterator<String>> buildEmptyIterators1() {
- return this.buildEmptyIteratorIterator();
- }
-
- ListIterator<Iterator<String>> buildEmptyIterators2() {
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(this.buildEmptyStringIterator());
- list.add(this.buildEmptyStringIterator());
- list.add(this.buildEmptyStringIterator());
- return list.listIterator();
- }
-
- ListIterator<Iterator<String>> buildUnmodifiableIterators() {
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(this.buildUnmodifiableIterator1());
- list.add(this.buildUnmodifiableIterator2());
- list.add(this.buildUnmodifiableIterator3());
- return list.listIterator();
- }
-
- ListIterator<String> buildIterator1() {
- return this.buildList1().listIterator();
- }
-
- ListIterator<String> buildIterator2() {
- return this.buildList2().listIterator();
- }
-
- ListIterator<String> buildIterator3() {
- return this.buildList3().listIterator();
- }
-
- ListIterator<String> buildUnmodifiableIterator1() {
- return this.buildUnmodifiableList1().listIterator();
- }
-
- ListIterator<String> buildUnmodifiableIterator2() {
- return this.buildUnmodifiableList2().listIterator();
- }
-
- ListIterator<String> buildUnmodifiableIterator3() {
- return this.buildUnmodifiableList3().listIterator();
- }
-
- ListIterator<Iterator<String>> buildEmptyIteratorIterator() {
- return (new ArrayList<Iterator<String>>()).listIterator();
- }
-
- ListIterator<String> buildEmptyStringIterator() {
- return (new ArrayList<String>()).listIterator();
- }
-
- List<String> buildList1() {
- List<String> list = new ArrayList<String>();
- list.add("1");
- list.add("22");
- list.add("333");
- list.add("4444");
- return list;
- }
-
- List<String> buildList2() {
- return new ArrayList<String>();
- }
-
- List<String> buildList3() {
- List<String> list = new ArrayList<String>();
- list.add("55555");
- list.add("666666");
- list.add("7777777");
- list.add("88888888");
- return list;
- }
-
- List<String> buildUnmodifiableList1() {
- return Collections.unmodifiableList(this.buildList1());
- }
-
- List<String> buildUnmodifiableList2() {
- return Collections.unmodifiableList(this.buildList2());
- }
-
- List<String> buildUnmodifiableList3() {
- return Collections.unmodifiableList(this.buildList3());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CompositeListIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CompositeListIteratorTests.java
deleted file mode 100644
index 5544e86355..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/CompositeListIteratorTests.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeListIterator;
-
-@SuppressWarnings("nls")
-public class CompositeListIteratorTests extends ReadOnlyCompositeListIteratorTests {
-
- public CompositeListIteratorTests(String name) {
- super(name);
- }
-
- @Override
- public void testRemove() {
- super.testRemove();
- List<String> list1 = this.buildList1();
- List<String> list2 = this.buildList2();
- List<String> list3 = this.buildList3();
- Object firstElement3 = list3.get(0);
-
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(list1.listIterator());
- list.add(list2.listIterator());
- list.add(list3.listIterator());
-
- ListIterator<String> stream = (ListIterator<String>) this.buildCompositeIterator(list.listIterator());
- // position to end of stream
- while (stream.hasNext()) {
- stream.next();
- }
- while (stream.hasPrevious()) {
- Object previous = stream.previous();
- if (previous.equals("333")) {
- stream.remove();
- }
- // test special case - where we are between iterators
- if (previous.equals(firstElement3)) {
- // this will trigger the next iterator to be loaded
- stream.hasPrevious();
- // now try to remove from the previous iterator
- stream.remove();
- }
- }
- stream.remove();
-
- assertEquals("nothing removed from collection 1", this.buildList1().size() - 2, list1.size());
- assertFalse("element still in collection 1", list1.contains("1"));
- assertFalse("element still in collection 1", list1.contains("333"));
-
- assertEquals("nothing removed from collection 3", this.buildList3().size() - 1, list3.size());
- assertFalse("first element still in collection 3", list3.contains(firstElement3));
- assertTrue("wrong element removed from collection 3", list3.contains("666666"));
- }
-
- public void testAdd() {
- List<String> list1 = this.buildList1();
- Object lastElement1 = list1.get(list1.size() - 1);
- List<String> list2 = this.buildList2();
- List<String> list3 = this.buildList3();
- Object firstElement3 = list3.get(0);
-
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(list1.listIterator());
- list.add(list2.listIterator());
- list.add(list3.listIterator());
-
- ListIterator<String> stream = (ListIterator<String>) this.buildCompositeIterator(list.listIterator());
- while (stream.hasNext()) {
- Object next = stream.next();
- if (next.equals("333")) {
- stream.add("3.5");
- }
- // test special case - where we are between iterators
- if (next.equals(lastElement1)) {
- // this will trigger the next iterator to be loaded
- stream.hasNext();
- // now try to add to the iterator
- stream.add("something in 3");
- }
- }
- stream.add("finale");
- boolean checkForFinale = true;
- while (stream.hasPrevious()) {
- Object previous = stream.previous();
- if (checkForFinale) {
- checkForFinale = false;
- assertEquals("added element dropped", "finale", previous);
- }
- if (previous.equals("333")) {
- stream.add("2.5");
- }
- // test special case - where we are between iterators
- if (previous.equals(firstElement3)) {
- // this will trigger the next iterator to be loaded
- stream.hasPrevious();
- // now try to remove from the previous iterator
- stream.add("old start of 3");
- }
- }
- stream.add("prelude");
- assertEquals("added element dropped", "prelude", stream.previous());
-
- assertEquals("elements not added to collection 1", this.buildList1().size() + 3, list1.size());
- assertEquals("element not added to collection 1", "prelude", list1.get(0));
- assertEquals("element not added to collection 1", "2.5", list1.get(3));
- assertEquals("element not added to collection 1", "3.5", list1.get(5));
-
- assertEquals("elements not added to collection 3", this.buildList3().size() + 3, list3.size());
- assertEquals("element not added to collection 3", "something in 3", list3.get(0));
- assertEquals("element not added to collection 3", "old start of 3", list3.get(1));
- assertEquals("element not added to collection 3", "finale", list3.get(list3.size() - 1));
-
- // add to the front
- stream = (ListIterator<String>) this.buildCompositeIterator();
- stream.add("blah");
- assertFalse("added element should be placed BEFORE the \"cursor\"", stream.next().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- stream.add("blah");
- assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- while (stream.hasPrevious()) {
- stream.previous();
- }
- stream.add("blah");
- assertFalse("added element should be placed BEFORE the \"cursor\"", stream.next().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- while (stream.hasPrevious()) {
- stream.previous();
- }
- stream.add("blah");
- assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah"));
-
- // add to the middle
- stream = (ListIterator<String>) this.buildCompositeIterator();
- stream.next();
- stream.add("blah");
- assertFalse("added element should be placed BEFORE the \"cursor\"", stream.next().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- stream.next();
- stream.add("blah");
- assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- stream.previous();
- stream.add("blah");
- assertFalse("added element should be placed BEFORE the \"cursor\"", stream.next().equals("blah"));
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- stream.previous();
- stream.add("blah");
- assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah"));
-
- // add to the end
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- stream.add("blah");
- assertFalse("added element should be placed BEFORE the \"cursor\"", stream.hasNext());
-
- stream = (ListIterator<String>) this.buildCompositeIterator();
- while (stream.hasNext()) {
- stream.next();
- }
- stream.add("blah");
- assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah"));
- }
-
- public void testSet() {
- List<String> list1 = this.buildList1();
- Object lastElement1 = list1.get(list1.size() - 1);
- List<String> list2 = this.buildList2();
- List<String> list3 = this.buildList3();
- Object firstElement3 = list3.get(0);
-
- List<Iterator<String>> list = new ArrayList<Iterator<String>>();
- list.add(list1.listIterator());
- list.add(list2.listIterator());
- list.add(list3.listIterator());
-
- ListIterator<String> stream = (ListIterator<String>) this.buildCompositeIterator(list.listIterator());
- // position to end of stream
- while (stream.hasNext()) {
- Object next = stream.next();
- if (next.equals("333")) {
- stream.set("333a");
- }
- // test special case - where we are between iterators
- if (next.equals(lastElement1)) {
- // this will trigger the next iterator to be loaded
- stream.hasNext();
- // now try to remove from the previous iterator
- stream.set("end of 1");
- }
- }
- while (stream.hasPrevious()) {
- Object previous = stream.previous();
- if (previous.equals("22")) {
- stream.set("22a");
- }
- // test special case - where we are between iterators
- if (previous.equals(firstElement3)) {
- // this will trigger the next iterator to be loaded
- stream.hasPrevious();
- // now try to remove from the previous iterator
- stream.set("start of 3");
- }
- }
-
- assertEquals("element(s) added to collection 1", this.buildList1().size(), list1.size());
- assertEquals("element not set in collection 1", "22a", list1.get(1));
- assertFalse("element not set in collection 1", list1.contains("22"));
- assertEquals("element not set in collection 1", "333a", list1.get(2));
- assertFalse("element not set in collection 1", list1.contains("333"));
- assertEquals("element not set in collection 1", "end of 1", list1.get(list1.size() - 1));
- assertFalse("element not set in collection 1", list1.contains(lastElement1));
-
- assertEquals("element(s) added to collection 3", this.buildList3().size(), list3.size());
- assertEquals("element not set in collection 3", "start of 3", list3.get(0));
- assertFalse("element not set in collection 3", list3.contains(firstElement3));
- }
-
- @Override
- public void testNextIndexPreviousIndex() {
- int i = 0;
- ListIterator<String> stream = (ListIterator<String>) this.buildCompositeIterator();
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- while (stream.hasNext()) {
- Object next = stream.next();
- i++;
- if (next.equals("333")) {
- stream.remove();
- i--;
- }
- if (next.equals("7777777")) {
- stream.add("7.5");
- i++;
- }
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- }
- assertEquals("index is corrupt", 8, i);
-
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- while (stream.hasPrevious()) {
- Object previous = stream.previous();
- i--;
- if (previous.equals("666666")) {
- stream.remove();
- // removing a previous element, does not change the cursor
- }
- if (previous.equals("22")) {
- stream.add("1.5");
- i++;
- }
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- }
- assertEquals("index is corrupt", 0, i);
- }
-
- @Override
- public void testIllegalStateException() {
- this.verifyIllegalStateException();
- }
-
- @Override
- public void testEmptyIllegalStateException1() {
- this.verifyEmptyIllegalStateException1();
- }
-
- @Override
- public void testEmptyIllegalStateException2() {
- this.verifyEmptyIllegalStateException2();
- }
-
- // unchecked so we can override the unchecked method in superclass
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator(Iterator iterators) {
- return new CompositeListIterator<String>((ListIterator<ListIterator<String>>) iterators);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator2() {
- return new CompositeListIterator<String>(this.buildIterator1(), this.buildIterator2(), this.buildIterator3());
- }
-
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator3() {
- return new CompositeListIterator<String>(new ListIterator[] { this.buildIterator1(), this.buildIterator2(), this.buildIterator3() });
- }
-
- @Override
- ListIterator<String> buildCompositeListIterator(String string, ListIterator<String> iterator) {
- return new CompositeListIterator<String>(string, iterator);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EmptyIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EmptyIteratorTests.java
deleted file mode 100644
index 511e484849..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EmptyIteratorTests.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-
-@SuppressWarnings("nls")
-public class EmptyIteratorTests extends TestCase {
-
- public EmptyIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<Object> stream = EmptyIterator.instance(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(0, i);
- }
-
- public void testNext() {
- for (Iterator<String> stream = EmptyIterator.instance(); stream.hasNext();) {
- fail("bogus element: " + stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<Number> stream = EmptyIterator.instance();
- Object element = null;
- while (stream.hasNext()) {
- element = stream.next();
- }
- try {
- element = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + element, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- try {
- EmptyIterator.instance().remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EmptyListIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EmptyListIteratorTests.java
deleted file mode 100644
index 1892415b13..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EmptyListIteratorTests.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
-
-@SuppressWarnings("nls")
-public class EmptyListIteratorTests extends TestCase {
-
- public EmptyListIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (ListIterator<Object> stream = EmptyListIterator.instance(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(0, i);
- }
-
- public void testNext() {
- for (ListIterator<Object> stream = EmptyListIterator.instance(); stream.hasNext();) {
- fail("bogus element: " + stream.next());
- }
- }
-
- public void testNextIndex() {
- ListIterator<Object> stream = EmptyListIterator.instance();
- assertEquals(0, stream.nextIndex());
- }
-
- public void testHasPrevious() {
- ListIterator<Object> stream = EmptyListIterator.instance();
- int i = 0;
- while (stream.hasPrevious()) {
- stream.previous();
- i++;
- }
- assertEquals(0, i);
-
- while (stream.hasNext()) {
- stream.next();
- }
- i = 0;
- while (stream.hasPrevious()) {
- stream.previous();
- i++;
- }
- assertEquals(0, i);
- }
-
- public void testPrevious() {
- ListIterator<Object> stream = EmptyListIterator.instance();
- while (stream.hasPrevious()) {
- fail("bogus element: " + stream.previous());
- }
- while (stream.hasNext()) {
- stream.next();
- }
- while (stream.hasPrevious()) {
- fail("bogus element: " + stream.previous());
- }
- }
-
- public void testPreviousIndex() {
- ListIterator<Object> stream = EmptyListIterator.instance();
- assertEquals(-1, stream.previousIndex());
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- ListIterator<Object> stream = EmptyListIterator.instance();
- Object element = null;
- while (stream.hasNext()) {
- element = stream.next();
- }
- try {
- element = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown (next): " + element, exCaught);
- while (stream.hasPrevious()) {
- element = stream.previous();
- }
- try {
- element = stream.previous();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown (previous): " + element, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- try {
- EmptyListIterator.instance().remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("UnsupportedOperationException not thrown (remove)", exCaught);
- try {
- EmptyListIterator.instance().set(new Object());
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("UnsupportedOperationException not thrown (set)", exCaught);
- try {
- EmptyListIterator.instance().add(new Object());
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("UnsupportedOperationException not thrown (add)", exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EnumerationIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EnumerationIteratorTests.java
deleted file mode 100644
index a7c7d289e6..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/EnumerationIteratorTests.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Vector;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.EnumerationIterator;
-
-@SuppressWarnings("nls")
-public class EnumerationIteratorTests extends TestCase {
-
- public EnumerationIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testHasNextUpcast() {
- int i = 0;
- for (Iterator<Object> stream = this.buildIteratorUpcast(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testNext() {
- Enumeration<String> enumeration = this.buildEnumeration();
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext();) {
- assertEquals("bogus element", enumeration.nextElement(), stream.next());
- }
- }
-
- public void testNextUpcast() {
- Enumeration<String> enumeration = this.buildEnumeration();
- for (Iterator<Object> stream = this.buildIteratorUpcast(); stream.hasNext();) {
- assertEquals("bogus element", enumeration.nextElement(), stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- private Iterator<String> buildIterator() {
- return this.buildIterator(this.buildEnumeration());
- }
-
- private Iterator<String> buildIterator(Enumeration<String> enumeration) {
- return new EnumerationIterator<String>(enumeration);
- }
-
- private Enumeration<String> buildEnumeration() {
- return this.buildVector().elements();
- }
-
- private Vector<String> buildVector() {
- Vector<String> v = new Vector<String>();
- v.addElement("one");
- v.addElement("two");
- v.addElement("three");
- v.addElement("four");
- v.addElement("five");
- v.addElement("six");
- v.addElement("seven");
- v.addElement("eight");
- return v;
- }
-
- private Iterator<Object> buildIteratorUpcast() {
- return this.buildIteratorUpcast(this.buildEnumeration());
- }
-
- private Iterator<Object> buildIteratorUpcast(Enumeration<String> enumeration) {
- return new EnumerationIterator<Object>(enumeration);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/FilteringIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/FilteringIteratorTests.java
deleted file mode 100644
index 6fe920b713..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/FilteringIteratorTests.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.SimpleFilter;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-
-@SuppressWarnings("nls")
-public class FilteringIteratorTests extends TestCase {
-
- private static final String PREFIX = "prefix";
-
- public FilteringIteratorTests(String name) {
- super(name);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildAcceptIterator(); stream.hasNext();) {
- String string = stream.next();
- if (string.equals(PREFIX + "3")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildAcceptIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testAcceptHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildAcceptIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testAcceptNext() {
- for (Iterator<String> stream = this.buildAcceptIterator(); stream.hasNext();) {
- assertTrue("bogus accept", stream.next().startsWith(PREFIX));
- }
- }
-
- public void testInnerHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildInnerIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testInnerNext() {
- for (Iterator<String> stream = this.buildInnerIterator(); stream.hasNext();) {
- assertTrue("bogus accept", stream.next().startsWith(PREFIX));
- }
- }
-
- public void testRejectHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildRejectIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(2, i);
- }
-
- public void testRejectNext() {
- for (Iterator<String> stream = this.buildRejectIterator(); stream.hasNext();) {
- assertFalse("bogus reject", stream.next().startsWith(PREFIX));
- }
- }
-
- public void testBothHasNext() {
- // if both accept() and reject() are overridden, accept() is used
- int i = 0;
- for (Iterator<String> stream = this.buildBothIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testLoadNext() {
- // loadNext() used to cause a NPE when executing during the
- // constructor because the "outer" class is not bound until completion
- // of the constructor
- for (Iterator<String> stream = this.buildInnerIterator2(); stream.hasNext();) {
- assertTrue("bogus accept", stream.next().startsWith(PREFIX));
- }
- }
-
- public void testFilterHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildFilterIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testFilterNext() {
- for (Iterator<String> stream = this.buildFilterIterator(); stream.hasNext();) {
- assertTrue("bogus accept", stream.next().startsWith(PREFIX));
- }
- }
-
- private Iterator<String> buildFilteredIterator(Iterator<String> nestedIterator, Filter<String> filter) {
- return new FilteringIterator<String>(nestedIterator, filter);
- }
-
- private Iterator<String> buildInnerFilteredIterator(Iterator<String> nestedIterator) {
- return new FilteringIterator<String>(nestedIterator) {
- @Override
- protected boolean accept(String s) {
- return s.startsWith(PREFIX);
- }
- };
- }
-
- String getPrefix() {
- return PREFIX;
- }
-
- // this inner iterator will call the "outer" object
- private Iterator<String> buildInnerFilteredIterator2(Iterator<String> nestedIterator) {
- return new FilteringIterator<String>(nestedIterator) {
- @Override
- protected boolean accept(String s) {
- return s.startsWith(FilteringIteratorTests.this.getPrefix());
- }
- };
- }
-
- private Iterator<String> buildNestedIterator() {
- Collection<String> c = new ArrayList<String>();
- c.add(PREFIX + "1");
- c.add(PREFIX + "2");
- c.add(PREFIX + "3");
- c.add("4");
- c.add(PREFIX + "5");
- c.add(PREFIX + "6");
- c.add(PREFIX + "7");
- c.add("8");
- return c.iterator();
- }
-
- private Iterator<String> buildAcceptIterator() {
- return this.buildFilteredIterator(this.buildNestedIterator(), this.buildAcceptFilter(PREFIX));
- }
-
- private Iterator<String> buildInnerIterator() {
- return this.buildInnerFilteredIterator(this.buildNestedIterator());
- }
-
- // this inner iterator will call the "outer" object
- private Iterator<String> buildInnerIterator2() {
- return this.buildInnerFilteredIterator2(this.buildNestedIterator());
- }
-
- private Iterator<String> buildFilterIterator() {
- return this.buildFilteredIterator(this.buildNestedIterator(), this.buildFilterFilter(PREFIX));
- }
-
- private Filter<String> buildAcceptFilter(String prefix) {
- return new SimpleFilter<String, String>(prefix) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public boolean accept(String s) {
- return s.startsWith(this.criterion);
- }
- };
- }
-
- private Iterator<String> buildRejectIterator() {
- return this.buildFilteredIterator(this.buildNestedIterator(), this.buildRejectFilter(PREFIX));
- }
-
- private Filter<String> buildRejectFilter(String prefix) {
- return new SimpleFilter<String, String>(prefix) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public boolean reject(String s) {
- return s.startsWith(this.criterion);
- }
- };
- }
-
- // use anonymous inner Filter
- private Filter<String> buildFilterFilter(final String prefix) {
- return new Filter<String>() {
- public boolean accept(String s) {
- return s.startsWith(prefix);
- }
- };
- }
-
- private Iterator<String> buildBothIterator() {
- return this.buildFilteredIterator(this.buildNestedIterator(), this.buildBothFilter(PREFIX));
- }
-
- private Filter<String> buildBothFilter(String prefix) {
- return new SimpleFilter<String, String>(prefix) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public boolean reject(String s) {
- return s.startsWith(this.criterion);
- }
-
- @Override
- public boolean accept(String s) {
- return s.startsWith(this.criterion);
- }
- };
- }
-
- public void testInvalidFilteringIterator() {
- boolean exCaught = false;
- try {
- // missing method override
- Iterator<String> iterator = new FilteringIterator<String>(this.buildNestedIterator());
- String s = iterator.next();
- fail("invalid string: " + s);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/GraphIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/GraphIteratorTests.java
deleted file mode 100644
index e320f28988..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/GraphIteratorTests.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.GraphIterator;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class GraphIteratorTests extends TestCase {
- /** this will be populated with all the nodes created for the test */
- Collection<GraphNode> nodes = new ArrayList<GraphNode>();
-
- public GraphIteratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testHasNext1() {
- this.verifyHasNext(this.buildGraphIterator1());
- }
-
- public void testHasNext2() {
- this.verifyHasNext(this.buildGraphIterator2());
- }
-
- private void verifyHasNext(Iterator<GraphNode> iterator) {
- int i = 0;
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(this.nodes.size(), i);
- }
-
- public void testNext1() {
- this.verifyNext(this.buildGraphIterator1());
- }
-
- public void testNext2() {
- this.verifyNext(this.buildGraphIterator2());
- }
-
- private void verifyNext(Iterator<GraphNode> iterator) {
- while (iterator.hasNext()) {
- assertTrue("bogus element", this.nodes.contains(iterator.next()));
- }
- }
-
- public void testNoSuchElementException1() {
- this.verifyNoSuchElementException(this.buildGraphIterator1());
- }
-
- public void testNoSuchElementException2() {
- this.verifyNoSuchElementException(this.buildGraphIterator2());
- }
-
- private void verifyNoSuchElementException(Iterator<GraphNode> iterator) {
- boolean exCaught = false;
- while (iterator.hasNext()) {
- iterator.next();
- }
- try {
- iterator.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
- public void testSize1() {
- this.verifySize(this.buildGraphIterator1());
- }
-
- public void testSize2() {
- this.verifySize(this.buildGraphIterator2());
- }
-
- private void verifySize(Iterator<GraphNode> iterator) {
- int iteratorSize = CollectionTools.size(iterator);
- int actualSize = this.nodes.size();
- assertTrue("Too few items in iterator.", iteratorSize >= actualSize);
- assertTrue("Too many items in iterator.", iteratorSize <= actualSize);
- }
-
- public void testInvalidGraphIterator() {
- boolean exCaught = false;
- try {
- // missing method override
- Iterator<GraphNode> iterator = new GraphIterator<GraphNode>(this.buildGraphRoot());
- GraphNode gn = iterator.next();
- fail("invalid graph node: " + gn);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
- /**
- * build a graph iterator with an explicit misterRogers
- */
- private Iterator<GraphNode> buildGraphIterator1() {
- return new GraphIterator<GraphNode>(this.buildGraphRoot(), this.buildMisterRogers());
- }
-
- private GraphIterator.MisterRogers<GraphNode> buildMisterRogers() {
- return new GraphIterator.MisterRogers<GraphNode>() {
- public Iterator<GraphNode> neighbors(GraphNode next) {
- return next.neighbors();
- }
- };
- }
-
- /**
- * build a graph iterator with an override
- */
- private Iterator<GraphNode> buildGraphIterator2() {
- return new GraphIterator<GraphNode>(this.buildGraphRoot()) {
- @Override
- public Iterator<GraphNode> neighbors(GraphNode next) {
- return next.neighbors();
- }
- };
- }
-
- private GraphNode buildGraphRoot() {
- GraphNode ncNode = new GraphNode("North Carolina");
- GraphNode vaNode = new GraphNode("Virginia");
- GraphNode scNode = new GraphNode("South Carolina");
- GraphNode gaNode = new GraphNode("Georgia");
- GraphNode flNode = new GraphNode("Florida");
- GraphNode alNode = new GraphNode("Alabama");
- GraphNode msNode = new GraphNode("Mississippi");
- GraphNode tnNode = new GraphNode("Tennessee");
-
- ncNode.setNeighbors(new GraphNode[] { vaNode, scNode, gaNode, tnNode });
- vaNode.setNeighbors(new GraphNode[] { ncNode, tnNode });
- scNode.setNeighbors(new GraphNode[] { ncNode, gaNode });
- gaNode.setNeighbors(new GraphNode[] { ncNode, scNode, flNode, alNode, tnNode });
- flNode.setNeighbors(new GraphNode[] { gaNode });
- alNode.setNeighbors(new GraphNode[] { gaNode, msNode, tnNode });
- msNode.setNeighbors(new GraphNode[] { alNode, tnNode });
- tnNode.setNeighbors(new GraphNode[] { vaNode, ncNode, gaNode, alNode, msNode });
-
- return ncNode;
- }
-
- public class GraphNode {
- private String name;
-
- private Collection<GraphNode> neighbors = new ArrayList<GraphNode>();
-
- public GraphNode(String name) {
- super();
- GraphIteratorTests.this.nodes.add(this); // log node
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- void setNeighbors(GraphNode[] neighbors) {
- this.neighbors = CollectionTools.list(neighbors);
- }
-
- public Iterator<GraphNode> neighbors() {
- return this.neighbors.iterator();
- }
-
- public int neighborsSize() {
- return this.neighbors.size();
- }
-
- @Override
- public String toString() {
- return "GraphNode(" + this.name + ")";
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/JptUtilityIteratorsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/JptUtilityIteratorsTests.java
deleted file mode 100644
index 54fb276ecb..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/JptUtilityIteratorsTests.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptUtilityIteratorsTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityIteratorsTests.class.getPackage().getName());
-
- suite.addTestSuite(ArrayIteratorTests.class);
- suite.addTestSuite(ArrayListIteratorTests.class);
- suite.addTestSuite(ChainIteratorTests.class);
- suite.addTestSuite(CloneIteratorTests.class);
- suite.addTestSuite(CloneListIteratorTests.class);
- suite.addTestSuite(CompositeIteratorTests.class);
- suite.addTestSuite(CompositeListIteratorTests.class);
- suite.addTestSuite(EmptyIteratorTests.class);
- suite.addTestSuite(EmptyListIteratorTests.class);
- suite.addTestSuite(EnumerationIteratorTests.class);
- suite.addTestSuite(FilteringIteratorTests.class);
- suite.addTestSuite(SuperIteratorWrapperTests.class);
- suite.addTestSuite(GraphIteratorTests.class);
- suite.addTestSuite(PeekableIteratorTests.class);
- suite.addTestSuite(ReadOnlyCompositeListIteratorTests.class);
- suite.addTestSuite(ReadOnlyIteratorTests.class);
- suite.addTestSuite(ReadOnlyListIteratorTests.class);
- suite.addTestSuite(SingleElementIteratorTests.class);
- suite.addTestSuite(SingleElementListIteratorTests.class);
- suite.addTestSuite(SynchronizedIteratorTests.class);
- suite.addTestSuite(SynchronizedListIteratorTests.class);
- suite.addTestSuite(TransformationIteratorTests.class);
- suite.addTestSuite(TransformationListIteratorTests.class);
- suite.addTestSuite(TreeIteratorTests.class);
-
- return suite;
- }
-
- private JptUtilityIteratorsTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/PeekableIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/PeekableIteratorTests.java
deleted file mode 100644
index 00a056f9a2..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/PeekableIteratorTests.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.PeekableIterator;
-
-@SuppressWarnings("nls")
-public class PeekableIteratorTests extends TestCase {
-
- public PeekableIteratorTests(String name) {
- super(name);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildPeekableIterator(); stream.hasNext();) {
- String string = stream.next();
- if (string.equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildPeekableIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildPeekableIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testHasNextUpcast() {
- int i = 0;
- for (Iterator<Object> stream = this.buildPeekableIteratorUpcast(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(6, i);
- }
-
- public void testNext() {
- Iterator<String> stream = this.buildPeekableIterator();
- assertEquals("zero", stream.next());
- assertEquals("one", stream.next());
- assertEquals("two", stream.next());
- assertEquals("three", stream.next());
- assertEquals("four", stream.next());
- assertEquals("five", stream.next());
- }
-
- public void testNextUpcast() {
- Iterator<Object> stream = this.buildPeekableIteratorUpcast();
- assertEquals("zero", stream.next());
- assertEquals("one", stream.next());
- assertEquals("two", stream.next());
- assertEquals("three", stream.next());
- assertEquals("four", stream.next());
- assertEquals("five", stream.next());
- }
-
- public void testPeek() {
- Object next = null;
- for (PeekableIterator<String> stream = this.buildPeekableIterator(); stream.hasNext();) {
- Object peek = stream.peek();
- assertTrue("peek and next are prematurely identical", peek != next);
- next = stream.next();
- assertTrue("peek and next are not identical", peek == next);
- }
- }
-
- public void testPeekUpcast() {
- Object next = null;
- for (PeekableIterator<Object> stream = this.buildPeekableIteratorUpcast(); stream.hasNext();) {
- Object peek = stream.peek();
- assertTrue("peek and next are prematurely identical", peek != next);
- next = stream.next();
- assertTrue("peek and next are not identical", peek == next);
- }
- }
-
- private PeekableIterator<String> buildPeekableIterator() {
- return this.buildPeekableIterator(this.buildNestedIterator());
- }
-
- private PeekableIterator<Object> buildPeekableIteratorUpcast() {
- return this.buildPeekableIteratorUpcast(this.buildNestedIterator());
- }
-
- private PeekableIterator<String> buildPeekableIterator(Iterator<String> nestedIterator) {
- return new PeekableIterator<String>(nestedIterator);
- }
-
- private PeekableIterator<Object> buildPeekableIteratorUpcast(Iterator<String> nestedIterator) {
- return new PeekableIterator<Object>(nestedIterator);
- }
-
- private Iterator<String> buildNestedIterator() {
- Collection<String> c = new ArrayList<String>();
- c.add("zero");
- c.add("one");
- c.add("two");
- c.add("three");
- c.add("four");
- c.add("five");
- return c.iterator();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyCompositeListIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyCompositeListIteratorTests.java
deleted file mode 100644
index dd1eea6db4..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyCompositeListIteratorTests.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyCompositeListIterator;
-
-@SuppressWarnings("nls")
-public class ReadOnlyCompositeListIteratorTests extends CompositeIteratorTests {
-
- public ReadOnlyCompositeListIteratorTests(String name) {
- super(name);
- }
-
- @Override
- void verifyHasAnother(Iterator<String> stream) {
- super.verifyHasAnother(stream);
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- int i = 0;
- while (stream2.hasPrevious()) {
- stream2.previous();
- i++;
- }
- assertEquals(8, i);
- }
-
- @Override
- void verifyAnother(Iterator<String> stream) {
- super.verifyAnother(stream);
- int i = 8;
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- while (stream2.hasPrevious()) {
- assertEquals("bogus element", String.valueOf(i--), stream2.previous().substring(0, 1));
- }
- }
-
- public void testNextIndexPreviousIndex() {
- int i = 0;
- ListIterator<String> stream = (ListIterator<String>) this.buildCompositeIterator();
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- while (stream.hasNext()) {
- stream.next();
- i++;
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- }
- assertEquals("index is corrupt", 8, i);
-
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- assertEquals(i, stream.nextIndex());
- assertEquals(i - 1, stream.previousIndex());
- }
- assertEquals("index is corrupt", 0, i);
- }
-
- public void testPreviousIndex() {
- // TODO
- }
-
- @Override
- public void testRemove() {
- // #remove() is not supported
- }
-
- @Override
- public void testIllegalStateException() {
- // #remove() is not supported
- }
-
- @Override
- public void testEmptyIllegalStateException1() {
- // #remove() is not supported
- }
-
- @Override
- public void testEmptyIllegalStateException2() {
- // #remove() is not supported
- }
-
- @Override
- void verifyNoSuchElementException(Iterator<String> stream) {
- super.verifyNoSuchElementException(stream);
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- boolean exCaught = false;
- String string = null;
- while (stream2.hasPrevious()) {
- string = stream2.previous();
- }
- try {
- string = stream2.previous();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- @Override
- void verifyUnsupportedOperationException(Iterator<String> stream) {
- super.verifyUnsupportedOperationException(stream);
- boolean exCaught = false;
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- while (stream2.hasPrevious()) {
- Object string = stream2.previous();
- if (string.equals("333")) {
- try {
- stream2.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- @Override
- void verifyIllegalStateException(Iterator<String> stream) {
- super.verifyIllegalStateException(stream);
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- boolean exCaught = false;
- try {
- stream2.set("junk");
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
-
- @Override
- void verifyEmptyHasAnother(Iterator<String> stream) {
- super.verifyEmptyHasAnother(stream);
- ListIterator<String> stream2 = (ListIterator<String>) stream;
- int i = 0;
- while (stream2.hasPrevious()) {
- stream2.previous();
- i++;
- }
- assertEquals(0, i);
- }
-
- // unchecked so we can override the unchecked method in superclass
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator(Iterator iterators) {
- return new ReadOnlyCompositeListIterator<String>((ListIterator<ListIterator<String>>) iterators);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator2() {
- return new ReadOnlyCompositeListIterator<String>(this.buildIterator1(), this.buildIterator2(), this.buildIterator3());
- }
-
- @Override
- @SuppressWarnings("unchecked")
- Iterator<String> buildCompositeIterator3() {
- return new ReadOnlyCompositeListIterator<String>(new ListIterator[] { this.buildIterator1(), this.buildIterator2(), this.buildIterator3() });
- }
-
- Iterator<String> buildCompositeIterator(String string, ListIterator<String> iterator) {
- return this.buildCompositeListIterator(string, iterator);
- }
-
- ListIterator<String> buildCompositeListIterator(String string, ListIterator<String> iterator) {
- return new ReadOnlyCompositeListIterator<String>(string, iterator);
- }
-
- public void testVariedNestedIterators() {
- List<Integer> integerList = new ArrayList<Integer>();
- integerList.add(new Integer(42));
- integerList.add(new Integer(42));
- integerList.add(new Integer(111));
- integerList.add(new Integer(77));
-
- List<Float> floatList = new ArrayList<Float>();
- floatList.add(new Float(42.42f));
- floatList.add(new Float(22.22f));
- floatList.add(new Float(111.111f));
- floatList.add(new Float(77.77f));
-
- List<List<? extends Number>> list = new ArrayList<List<? extends Number>>();
- list.add(integerList);
- list.add(floatList);
- ListIterator<Number> li = new ReadOnlyCompositeListIterator<Number>(list);
- while (li.hasNext()) {
- assertTrue(li.next().intValue() > 0);
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyIteratorTests.java
deleted file mode 100644
index f00417064d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyIteratorTests.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Vector;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyIterator;
-
-@SuppressWarnings("nls")
-public class ReadOnlyIteratorTests extends TestCase {
-
- public ReadOnlyIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildReadOnlyIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testHasNextUpcast() {
- int i = 0;
- for (Iterator<Object> stream = this.buildReadOnlyIteratorUpcast(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(this.buildVector().size(), i);
- }
-
- public void testNext() {
- Iterator<String> nestedIterator = this.buildNestedIterator();
- for (Iterator<String> stream = this.buildReadOnlyIterator(); stream.hasNext();) {
- assertEquals("bogus element", nestedIterator.next(), stream.next());
- }
- }
-
- public void testNextUpcast() {
- Iterator<String> nestedIterator = this.buildNestedIterator();
- for (Iterator<Object> stream = this.buildReadOnlyIteratorUpcast(); stream.hasNext();) {
- assertEquals("bogus element", nestedIterator.next(), stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildReadOnlyIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testRemove() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildReadOnlyIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- private Iterator<String> buildReadOnlyIterator() {
- return this.buildReadOnlyIterator(this.buildNestedIterator());
- }
-
- private Iterator<Object> buildReadOnlyIteratorUpcast() {
- return this.buildReadOnlyIteratorUpcast(this.buildNestedIterator());
- }
-
- private Iterator<String> buildReadOnlyIterator(Iterator<String> nestedIterator) {
- return new ReadOnlyIterator<String>(nestedIterator);
- }
-
- private Iterator<Object> buildReadOnlyIteratorUpcast(Iterator<String> nestedIterator) {
- return new ReadOnlyIterator<Object>(nestedIterator);
- }
-
- private Iterator<String> buildNestedIterator() {
- return this.buildVector().iterator();
- }
-
- private Vector<String> buildVector() {
- Vector<String> v = new Vector<String>();
- v.addElement("one");
- v.addElement("two");
- v.addElement("three");
- v.addElement("four");
- v.addElement("five");
- v.addElement("six");
- v.addElement("seven");
- v.addElement("eight");
- return v;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java
deleted file mode 100644
index 9d81a2ad37..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-
-@SuppressWarnings("nls")
-public class ReadOnlyListIteratorTests extends TestCase {
-
- public ReadOnlyListIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNextAndHasPrevious() {
- int i = 0;
- ListIterator<String> stream = this.buildReadOnlyListIterator();
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(this.buildList().size(), i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- }
- assertEquals(0, i);
- }
-
- public void testHasNextAndHasPreviousUpcast() {
- int i = 0;
- ListIterator<Object> stream = this.buildReadOnlyListIteratorUpcast();
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(this.buildList().size(), i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- }
- assertEquals(0, i);
- }
-
- public void testNextAndPrevious() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- ListIterator<String> stream = this.buildReadOnlyListIterator();
- while (stream.hasNext()) {
- assertEquals("bogus element", nestedListIterator.next(), stream.next());
- }
- while (stream.hasPrevious()) {
- assertEquals("bogus element", nestedListIterator.previous(), stream.previous());
- }
- }
-
- public void testNextAndPreviousUpcast() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- ListIterator<Object> stream = this.buildReadOnlyListIteratorUpcast();
- while (stream.hasNext()) {
- assertEquals("bogus element", nestedListIterator.next(), stream.next());
- }
- while (stream.hasPrevious()) {
- assertEquals("bogus element", nestedListIterator.previous(), stream.previous());
- }
- }
-
- public void testNextIndexAndPreviousIndex() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- ListIterator<String> stream = this.buildReadOnlyListIterator();
- while (stream.hasNext()) {
- assertEquals("bogus index", nestedListIterator.nextIndex(), stream.nextIndex());
- nestedListIterator.next();
- stream.next();
- }
- assertEquals("bogus index", this.buildList().size(), stream.nextIndex());
- while (stream.hasPrevious()) {
- assertEquals("bogus element", nestedListIterator.previousIndex(), stream.previousIndex());
- nestedListIterator.previous();
- stream.previous();
- }
- assertEquals("bogus index", -1, stream.previousIndex());
- }
-
- public void testNextIndexAndPreviousIndexUpcast() {
- ListIterator<String> nestedListIterator = this.buildNestedListIterator();
- ListIterator<Object> stream = this.buildReadOnlyListIteratorUpcast();
- while (stream.hasNext()) {
- assertEquals("bogus index", nestedListIterator.nextIndex(), stream.nextIndex());
- nestedListIterator.next();
- stream.next();
- }
- assertEquals("bogus index", this.buildList().size(), stream.nextIndex());
- while (stream.hasPrevious()) {
- assertEquals("bogus element", nestedListIterator.previousIndex(), stream.previousIndex());
- nestedListIterator.previous();
- stream.previous();
- }
- assertEquals("bogus index", -1, stream.previousIndex());
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- ListIterator<String> stream = this.buildReadOnlyListIterator();
- String string = null;
- while (stream.hasNext()) {
- string = stream.next();
- }
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testRemove() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildReadOnlyListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testSet() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildReadOnlyListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.set("bogus");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testAdd() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildReadOnlyListIterator(); stream.hasNext();) {
- if (stream.next().equals("three")) {
- try {
- stream.add("bogus");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- private ListIterator<String> buildReadOnlyListIterator() {
- return this.buildReadOnlyListIterator(this.buildNestedListIterator());
- }
-
- private ListIterator<Object> buildReadOnlyListIteratorUpcast() {
- return this.buildReadOnlyListIteratorUpcast(this.buildNestedListIterator());
- }
-
- private ListIterator<String> buildReadOnlyListIterator(ListIterator<String> nestedListIterator) {
- return new ReadOnlyListIterator<String>(nestedListIterator);
- }
-
- private ListIterator<Object> buildReadOnlyListIteratorUpcast(ListIterator<String> nestedListIterator) {
- return new ReadOnlyListIterator<Object>(nestedListIterator);
- }
-
- private ListIterator<String> buildNestedListIterator() {
- return this.buildList().listIterator();
- }
-
- private List<String> buildList() {
- List<String> l = new ArrayList<String>();
- l.add("one");
- l.add("two");
- l.add("three");
- l.add("four");
- l.add("five");
- l.add("six");
- l.add("seven");
- l.add("eight");
- return l;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SingleElementIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SingleElementIteratorTests.java
deleted file mode 100644
index 4fce5a6826..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SingleElementIteratorTests.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementIterator;
-
-@SuppressWarnings("nls")
-public class SingleElementIteratorTests extends TestCase {
-
- public SingleElementIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<String> stream = this.buildSingleElementIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(1, i);
- }
-
- public void testNext() {
- for (Iterator<String> stream = this.buildSingleElementIterator(); stream.hasNext();) {
- assertEquals("bogus element", this.singleElement(), stream.next());
- }
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<String> stream = this.buildSingleElementIterator();
- String string = stream.next();
- try {
- string = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + string, exCaught);
- }
-
- public void testRemove() {
- boolean exCaught = false;
- for (Iterator<String> stream = this.buildSingleElementIterator(); stream.hasNext();) {
- if (stream.next().equals(this.singleElement())) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- protected Iterator<String> buildSingleElementIterator() {
- return new SingleElementIterator<String>(this.singleElement());
- }
-
- protected String singleElement() {
- return "single element";
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SingleElementListIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SingleElementListIteratorTests.java
deleted file mode 100644
index d393a65201..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SingleElementListIteratorTests.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementListIterator;
-
-@SuppressWarnings("nls")
-public class SingleElementListIteratorTests extends SingleElementIteratorTests {
-
- public SingleElementListIteratorTests(String name) {
- super(name);
- }
-
- public void testNextIndex() {
- ListIterator<String> stream = this.buildSingleElementListIterator();
- while (stream.hasNext()) {
- assertEquals("bogus index", 0, stream.nextIndex());
- stream.next();
- }
- assertEquals("bogus index", 1, stream.nextIndex());
- }
-
- public void testHasPrevious() {
- int i = 0;
- ListIterator<String> stream = this.buildSingleElementListIterator();
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(1, i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i++;
- }
- assertEquals(2, i);
- }
-
- public void testPrevious() {
- ListIterator<String> stream = this.buildSingleElementListIterator();
-
- while (stream.hasNext()) {
- assertEquals("bogus element", this.singleElement(), stream.next());
- }
-
- while (stream.hasPrevious()) {
- assertEquals("bogus element", this.singleElement(), stream.previous());
- }
- }
-
- public void testPreviousIndex() {
- ListIterator<String> stream = this.buildSingleElementListIterator();
-
- while (stream.hasNext()) {
- assertEquals("bogus index", 0, stream.nextIndex());
- stream.next();
- }
-
- while (stream.hasPrevious()) {
- assertEquals("bogus index", 0, stream.previousIndex());
- stream.previous();
- }
-
- assertEquals("bogus index", -1, stream.previousIndex());
- }
-
- public void testAdd() {
- boolean exCaught = false;
- ListIterator<String> stream = this.buildSingleElementListIterator();
-
- try {
- stream.add("foo");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
-
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testSet() {
- boolean exCaught = false;
- for (ListIterator<String> stream = this.buildSingleElementListIterator(); stream.hasNext();) {
- if (stream.next().equals(this.singleElement())) {
- try {
- stream.set("foo");
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- @Override
- protected Iterator<String> buildSingleElementIterator() {
- return new SingleElementListIterator<String>(this.singleElement());
- }
-
- protected ListIterator<String> buildSingleElementListIterator() {
- return (ListIterator<String>) this.buildSingleElementIterator();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SuperIteratorWrapperTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SuperIteratorWrapperTests.java
deleted file mode 100644
index 4bb6dc626d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SuperIteratorWrapperTests.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.iterators.SuperIteratorWrapper;
-
-@SuppressWarnings("nls")
-public class SuperIteratorWrapperTests extends TestCase {
-
- public SuperIteratorWrapperTests(String name) {
- super(name);
- }
-
- public void testIterator() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- String concat = "";
- for (Iterator<String> stream = list.iterator(); stream.hasNext(); ) {
- concat += stream.next();
- }
- assertEquals("foobarbaz", concat);
-
- Iterator<Object> iterator = new SuperIteratorWrapper<Object>(list);
- concat = "";
- while (iterator.hasNext()) {
- Object next = iterator.next();
- if (next.equals("bar")) {
- iterator.remove();
- } else {
- concat += next;
- }
- }
- assertEquals("foobaz", concat);
- assertEquals(2, list.size());
- assertFalse(list.contains("bar"));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SynchronizedIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SynchronizedIteratorTests.java
deleted file mode 100644
index e30238fe74..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SynchronizedIteratorTests.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.SynchronizedIterator;
-import org.eclipse.jpt.common.utility.tests.internal.MultiThreadedTestCase;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class SynchronizedIteratorTests
- extends MultiThreadedTestCase
-{
- public SynchronizedIteratorTests(String name) {
- super(name);
- }
-
- /**
- * test that an unsynchronized iterator will produce corrupt output;
- * thread 1 will read the first element from the iterator
- * and then sleep for a bit, allowing thread 2 to sneak in and
- * read the same element from the iterator
- */
- public void testUnsynchronizedNext() throws Exception {
- TestIterator<String> iterator = this.buildTestIterator(TWO_TICKS);
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- NextTestRunnable<String> runnable2 = new NextTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- iterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // both threads should have read the same element from the iterator :-(
- assertEquals("foo", runnable1.next);
- assertEquals("foo", runnable2.next);
- }
-
- /**
- * test that a synchronized iterator will produce valid output;
- * thread 1 will read the first element from the iterator
- * and then sleep for a bit, but thread 2 will be locked out and
- * wait to read the second element from the iterator
- */
- public void testSynchronizedNext() throws Exception {
- TestIterator<String> nestedIterator = this.buildTestIterator(TWO_TICKS);
- Iterator<String> iterator = this.buildSynchronizedIterator(nestedIterator);
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- NextTestRunnable<String> runnable2 = new NextTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- nestedIterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // the threads should have read the correct elements from the iterator :-)
- assertEquals("foo", runnable1.next);
- assertEquals("bar", runnable2.next);
- }
-
- public void testUnsynchronizedHasNext() throws Exception {
- TestIterator<String> iterator = this.buildTestIterator(TWO_TICKS);
- iterator.next();
- iterator.next();
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- HasNextTestRunnable<String> runnable2 = new HasNextTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- iterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // thread 1 will have the last element,
- // but thread 2 will think there are more elements on the iterator :-(
- assertEquals("baz", runnable1.next);
- assertEquals(true, runnable2.hasNext);
- }
-
- public void testSynchronizedHasNext() throws Exception {
- TestIterator<String> nestedIterator = this.buildTestIterator(TWO_TICKS);
- Iterator<String> iterator = this.buildSynchronizedIterator(nestedIterator);
- iterator.next();
- iterator.next();
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- HasNextTestRunnable<String> runnable2 = new HasNextTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- nestedIterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // thread 1 will have the last element,
- // and thread 2 will think there are no more elements on the iterator :-)
- assertEquals("baz", runnable1.next);
- assertEquals(false, runnable2.hasNext);
- }
-
- public void testUnsynchronizedRemove() throws Exception {
- TestIterator<String> iterator = this.buildTestIterator(TWO_TICKS);
- iterator.next();
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- RemoveTestRunnable<String> runnable2 = new RemoveTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- iterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // the wrong element was removed :-(
- assertEquals("bar", runnable1.next);
- assertFalse(iterator.list.contains("foo"));
- assertTrue(iterator.list.contains("bar"));
- assertTrue(iterator.list.contains("baz"));
- }
-
- public void testSynchronizedRemove() throws Exception {
- TestIterator<String> nestedIterator = this.buildTestIterator(TWO_TICKS);
- Iterator<String> iterator = this.buildSynchronizedIterator(nestedIterator);
- iterator.next();
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- RemoveTestRunnable<String> runnable2 = new RemoveTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- nestedIterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // the correct element was removed :-)
- assertEquals("bar", runnable1.next);
- assertTrue(nestedIterator.list.contains("foo"));
- assertFalse(nestedIterator.list.contains("bar"));
- assertTrue(nestedIterator.list.contains("baz"));
- }
-
- TestIterator<String> buildTestIterator(long delay) {
- return new TestIterator<String>(delay, this.buildArray());
- }
-
- String[] buildArray() {
- return new String[] {"foo", "bar", "baz"};
- }
-
- Iterator<String> buildSynchronizedIterator(Iterator<String> nestedIterator) {
- return new SynchronizedIterator<String>(nestedIterator);
- }
-
-
- /**
- * next runnable
- */
- class NextTestRunnable<E> implements Runnable {
- final Iterator<E> iterator;
- E next;
-
- NextTestRunnable(Iterator<E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public void run() {
- this.next = this.iterator.next();
- }
-
- }
-
- /**
- * has next runnable
- */
- class HasNextTestRunnable<E> implements Runnable {
- final Iterator<E> iterator;
- boolean hasNext;
-
- HasNextTestRunnable(Iterator<E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public void run() {
- this.hasNext = this.iterator.hasNext();
- }
-
- }
-
- /**
- * remove runnable
- */
- class RemoveTestRunnable<E> implements Runnable {
- final Iterator<E> iterator;
-
- RemoveTestRunnable(Iterator<E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public void run() {
- this.iterator.remove();
- }
-
- }
-
- /**
- * Test iterator: If {@link #next()} is called while executing on the
- * {@link slowThread}, the iterator will delay for the configured time.
- */
- static class TestIterator<E> implements Iterator<E> {
- final long delay;
- final ArrayList<E> list = new ArrayList<E>();
- int nextIndex = 0;
- int lastIndex = -1;
- Thread slowThread;
-
- TestIterator(long delay, E... array) {
- super();
- this.delay = delay;
- CollectionTools.addAll(this.list, array);
- }
-
- public boolean hasNext() {
- return this.nextIndex != this.list.size();
- }
-
- public E next() {
- if (this.hasNext()) {
- E next = this.list.get(this.nextIndex);
- if (Thread.currentThread() == this.slowThread) {
- TestTools.sleep(this.delay);
- }
- this.lastIndex = this.nextIndex++;
- return next;
- }
- throw new NoSuchElementException();
- }
-
- public void remove() {
- if (this.lastIndex == -1) {
- throw new IllegalStateException();
- }
- this.list.remove(this.lastIndex);
- if (this.lastIndex < this.nextIndex) { // check necessary for ListIterator
- this.nextIndex--;
- }
- this.lastIndex = -1;
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SynchronizedListIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SynchronizedListIteratorTests.java
deleted file mode 100644
index dbf0ac5b57..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/SynchronizedListIteratorTests.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jpt.common.utility.internal.iterators.SynchronizedListIterator;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class SynchronizedListIteratorTests
- extends SynchronizedIteratorTests
-{
- public SynchronizedListIteratorTests(String name) {
- super(name);
- }
-
- public void testUnsynchronizedPrevious() throws Exception {
- TestListIterator<String> iterator = this.buildTestIterator(TWO_TICKS);
- iterator.next();
- iterator.next();
-
- PreviousTestRunnable<String> runnable1 = new PreviousTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- PreviousTestRunnable<String> runnable2 = new PreviousTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- iterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // both threads should have read the same element from the iterator :-(
- assertEquals("bar", runnable1.previous);
- assertEquals("bar", runnable2.previous);
- }
-
- public void testSynchronizedPrevious() throws Exception {
- TestListIterator<String> nestedIterator = this.buildTestIterator(TWO_TICKS);
- ListIterator<String> iterator = this.buildSynchronizedIterator(nestedIterator);
- iterator.next();
- iterator.next();
-
- PreviousTestRunnable<String> runnable1 = new PreviousTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- PreviousTestRunnable<String> runnable2 = new PreviousTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- nestedIterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // the threads should have read the correct elements from the iterator :-)
- assertEquals("bar", runnable1.previous);
- assertEquals("foo", runnable2.previous);
- }
-
- public void testUnsynchronizedHasPrevious() throws Exception {
- TestListIterator<String> iterator = this.buildTestIterator(TWO_TICKS);
- iterator.next();
-
- PreviousTestRunnable<String> runnable1 = new PreviousTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- HasPreviousTestRunnable<String> runnable2 = new HasPreviousTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- iterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // thread 1 will have the first element,
- // but thread 2 will think there are more "previous" elements on the iterator :-(
- assertEquals("foo", runnable1.previous);
- assertEquals(true, runnable2.hasPrevious);
- }
-
- public void testSynchronizedHasPrevious() throws Exception {
- TestListIterator<String> nestedIterator = this.buildTestIterator(TWO_TICKS);
- ListIterator<String> iterator = this.buildSynchronizedIterator(nestedIterator);
- iterator.next();
-
- PreviousTestRunnable<String> runnable1 = new PreviousTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- HasPreviousTestRunnable<String> runnable2 = new HasPreviousTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- nestedIterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // thread 1 will have the first element,
- // and thread 2 will think there are no more "previous" elements on the iterator :-)
- assertEquals("foo", runnable1.previous);
- assertEquals(false, runnable2.hasPrevious);
- }
-
- public void testUnsynchronizedNextIndex() throws Exception {
- TestListIterator<String> iterator = this.buildTestIterator(TWO_TICKS);
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- NextIndexTestRunnable<String> runnable2 = new NextIndexTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- iterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // thread 1 will have the first element,
- // but thread 2 will think the next index is still 0 :-(
- assertEquals("foo", runnable1.next);
- assertEquals(0, runnable2.nextIndex);
- }
-
- public void testSynchronizedNextIndex() throws Exception {
- TestListIterator<String> nestedIterator = this.buildTestIterator(TWO_TICKS);
- ListIterator<String> iterator = this.buildSynchronizedIterator(nestedIterator);
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- NextIndexTestRunnable<String> runnable2 = new NextIndexTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- nestedIterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // thread 1 will have the first element,
- // and thread 2 will think the next index is 1 :-)
- assertEquals("foo", runnable1.next);
- assertEquals(1, runnable2.nextIndex);
- }
-
- public void testUnsynchronizedPreviousIndex() throws Exception {
- TestListIterator<String> iterator = this.buildTestIterator(TWO_TICKS);
- iterator.next();
-
- PreviousTestRunnable<String> runnable1 = new PreviousTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- PreviousIndexTestRunnable<String> runnable2 = new PreviousIndexTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- iterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // thread 1 will have the first element,
- // but thread 2 will think the next index is still 0 :-(
- assertEquals("foo", runnable1.previous);
- assertEquals(0, runnable2.previousIndex);
- }
-
- public void testSynchronizedPreviousIndex() throws Exception {
- TestListIterator<String> nestedIterator = this.buildTestIterator(TWO_TICKS);
- ListIterator<String> iterator = this.buildSynchronizedIterator(nestedIterator);
- iterator.next();
-
- PreviousTestRunnable<String> runnable1 = new PreviousTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- PreviousIndexTestRunnable<String> runnable2 = new PreviousIndexTestRunnable<String>(iterator);
- Thread thread2 = this.buildThread(runnable2);
- nestedIterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // thread 1 will have the first element,
- // and thread 2 will think the next index is -1 :-)
- assertEquals("foo", runnable1.previous);
- assertEquals(-1, runnable2.previousIndex);
- }
-
- public void testUnsynchronizedSet() throws Exception {
- TestListIterator<String> iterator = this.buildTestIterator(TWO_TICKS);
- iterator.next();
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- SetTestRunnable<String> runnable2 = new SetTestRunnable<String>(iterator, "xxx");
- Thread thread2 = this.buildThread(runnable2);
- iterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // the wrong element was set :-(
- assertEquals("bar", runnable1.next);
- assertFalse(iterator.list.contains("foo"));
- assertTrue(iterator.list.contains("xxx"));
- assertTrue(iterator.list.contains("bar"));
- assertTrue(iterator.list.contains("baz"));
- }
-
- public void testSynchronizedSet() throws Exception {
- TestListIterator<String> nestedIterator = this.buildTestIterator(TWO_TICKS);
- ListIterator<String> iterator = this.buildSynchronizedIterator(nestedIterator);
- iterator.next();
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- SetTestRunnable<String> runnable2 = new SetTestRunnable<String>(iterator, "xxx");
- Thread thread2 = this.buildThread(runnable2);
- nestedIterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // the right element was set :-)
- assertEquals("bar", runnable1.next);
- assertTrue(nestedIterator.list.contains("foo"));
- assertFalse(nestedIterator.list.contains("bar"));
- assertTrue(nestedIterator.list.contains("xxx"));
- assertTrue(nestedIterator.list.contains("baz"));
- }
-
- public void testUnsynchronizedAdd() throws Exception {
- TestListIterator<String> iterator = this.buildTestIterator(TWO_TICKS);
- iterator.next();
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- AddTestRunnable<String> runnable2 = new AddTestRunnable<String>(iterator, "xxx");
- Thread thread2 = this.buildThread(runnable2);
- iterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // the element was added at the wrong index :-(
- assertEquals("bar", runnable1.next);
- assertTrue(iterator.list.contains("foo"));
- assertEquals(0, iterator.list.indexOf("xxx"));
- assertTrue(iterator.list.contains("xxx"));
- assertTrue(iterator.list.contains("bar"));
- assertTrue(iterator.list.contains("baz"));
- }
-
- public void testSynchronizedAdd() throws Exception {
- TestListIterator<String> nestedIterator = this.buildTestIterator(TWO_TICKS);
- ListIterator<String> iterator = this.buildSynchronizedIterator(nestedIterator);
- iterator.next();
-
- NextTestRunnable<String> runnable1 = new NextTestRunnable<String>(iterator);
- Thread thread1 = this.buildThread(runnable1);
- AddTestRunnable<String> runnable2 = new AddTestRunnable<String>(iterator, "xxx");
- Thread thread2 = this.buildThread(runnable2);
- nestedIterator.slowThread = thread1;
-
- thread1.start();
-
- // allow thread 1 to read the first element and get bogged down
- this.sleep(TICK);
- thread2.start();
-
- // wait for the threads to finish
- thread1.join();
- thread2.join();
-
- // the element was added at the correct index :-)
- assertEquals("bar", runnable1.next);
- assertTrue(nestedIterator.list.contains("foo"));
- assertEquals(1, nestedIterator.list.indexOf("xxx"));
- assertTrue(nestedIterator.list.contains("xxx"));
- assertTrue(nestedIterator.list.contains("bar"));
- assertTrue(nestedIterator.list.contains("baz"));
- }
-
- @Override
- ListIterator<String> buildSynchronizedIterator(Iterator<String> nestedIterator) {
- return new SynchronizedListIterator<String>((ListIterator<String>) nestedIterator);
- }
-
- @Override
- TestListIterator<String> buildTestIterator(long delay) {
- return new TestListIterator<String>(delay, this.buildArray());
- }
-
- /**
- * previous runnable
- */
- class PreviousTestRunnable<E> implements Runnable {
- final ListIterator<E> iterator;
- E previous;
-
- PreviousTestRunnable(ListIterator<E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public void run() {
- this.previous = this.iterator.previous();
- }
-
- }
-
- /**
- * has previous runnable
- */
- class HasPreviousTestRunnable<E> implements Runnable {
- final ListIterator<E> iterator;
- boolean hasPrevious;
-
- HasPreviousTestRunnable(ListIterator<E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public void run() {
- this.hasPrevious = this.iterator.hasPrevious();
- }
-
- }
-
- /**
- * next index runnable
- */
- class NextIndexTestRunnable<E> implements Runnable {
- final ListIterator<E> iterator;
- int nextIndex;
-
- NextIndexTestRunnable(ListIterator<E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public void run() {
- this.nextIndex = this.iterator.nextIndex();
- }
-
- }
-
- /**
- * previous index runnable
- */
- class PreviousIndexTestRunnable<E> implements Runnable {
- final ListIterator<E> iterator;
- int previousIndex;
-
- PreviousIndexTestRunnable(ListIterator<E> iterator) {
- super();
- this.iterator = iterator;
- }
-
- public void run() {
- this.previousIndex = this.iterator.previousIndex();
- }
-
- }
-
- /**
- * set runnable
- */
- class SetTestRunnable<E> implements Runnable {
- final ListIterator<E> iterator;
- final E element;
-
- SetTestRunnable(ListIterator<E> iterator, E element) {
- super();
- this.iterator = iterator;
- this.element = element;
- }
-
- public void run() {
- this.iterator.set(this.element);
- }
-
- }
-
- /**
- * add runnable
- */
- class AddTestRunnable<E> implements Runnable {
- final ListIterator<E> iterator;
- final E element;
-
- AddTestRunnable(ListIterator<E> iterator, E element) {
- super();
- this.iterator = iterator;
- this.element = element;
- }
-
- public void run() {
- this.iterator.add(this.element);
- }
-
- }
-
- /**
- * Test iterator: If {@link #next()} or {@link #previous()} is called
- * while executing on the {@link slowThread}, the iterator will delay
- * for the configured time.
- */
- static class TestListIterator<E> extends TestIterator<E> implements ListIterator<E> {
-
- TestListIterator(long delay, E... array) {
- super(delay, array);
- }
-
- public int nextIndex() {
- return this.nextIndex;
- }
-
- public boolean hasPrevious() {
- return this.nextIndex != 0;
- }
-
- public E previous() {
- if (this.hasPrevious()) {
- E previous = this.list.get(this.previousIndex());
- if (Thread.currentThread() == this.slowThread) {
- TestTools.sleep(this.delay);
- }
- this.nextIndex--;
- this.lastIndex = this.nextIndex;
- return previous;
- }
- throw new NoSuchElementException();
- }
-
- public int previousIndex() {
- return this.nextIndex - 1;
- }
-
- public void set(E e) {
- if (this.lastIndex == -1) {
- throw new IllegalStateException();
- }
- this.list.set(this.lastIndex, e);
- }
-
- public void add(E e) {
- this.list.add(this.lastIndex, e);
- this.lastIndex++;
- this.lastIndex = -1;
- }
-
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TransformationIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TransformationIteratorTests.java
deleted file mode 100644
index af7185a792..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TransformationIteratorTests.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-
-@SuppressWarnings("nls")
-public class TransformationIteratorTests extends TestCase {
-
- public TransformationIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNext() {
- int i = 0;
- for (Iterator<Integer> stream = this.buildIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
- }
-
- public void testHasNextUpcast() {
- int i = 0;
- for (Iterator<Object> stream = this.buildIteratorUpcast(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
- }
-
- public void testInnerHasNext() {
- int i = 0;
- for (Iterator<Integer> stream = this.buildInnerIterator(); stream.hasNext();) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
- }
-
- public void testNext() {
- int i = 0;
- for (Iterator<Integer> stream = this.buildIterator(); stream.hasNext();) {
- assertEquals("bogus transformation", ++i, stream.next().intValue());
- }
- }
-
- public void testNextUpcast() {
- int i = 0;
- for (Iterator<Object> stream = this.buildIteratorUpcast(); stream.hasNext();) {
- assertEquals("bogus transformation", ++i, ((Integer) stream.next()).intValue());
- }
- }
-
- public void testInnerNext() {
- int i = 0;
- for (Iterator<Integer> stream = this.buildInnerIterator(); stream.hasNext();) {
- assertEquals("bogus transformation", ++i, stream.next().intValue());
- }
- }
-
- public void testRemove() {
- Collection<String> c = this.buildCollection();
- for (Iterator<Integer> stream = this.buildInnerTransformationIterator(c.iterator()); stream.hasNext();) {
- if (stream.next().intValue() == 3) {
- stream.remove();
- }
- }
- assertEquals("nothing removed", this.buildCollection().size() - 1, c.size());
- assertFalse("element still in collection", c.contains("333"));
- assertTrue("wrong element removed", c.contains("22"));
- }
-
- public void testInnerRemove() {
- Collection<String> c = this.buildCollection();
- for (Iterator<Integer> stream = this.buildTransformationIterator(c.iterator(), this.buildTransformer()); stream.hasNext();) {
- if (stream.next().intValue() == 3) {
- stream.remove();
- }
- }
- assertEquals("nothing removed", this.buildCollection().size() - 1, c.size());
- assertFalse("element still in collection", c.contains("333"));
- assertTrue("wrong element removed", c.contains("22"));
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- Iterator<Integer> stream = this.buildIterator();
- Integer integer = null;
- while (stream.hasNext()) {
- integer = stream.next();
- }
- try {
- integer = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + integer, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<Integer> stream = this.buildUnmodifiableIterator(); stream.hasNext();) {
- int i = stream.next().intValue();
- if (i == 3) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testIllegalStateException() {
- boolean exCaught = false;
- try {
- this.buildIterator().remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
-
- private Iterator<Integer> buildIterator() {
- return this.buildTransformationIterator(this.buildNestedIterator(), this.buildTransformer());
- }
-
- private Iterator<Object> buildIteratorUpcast() {
- return this.buildTransformationIteratorUpcast(this.buildNestedIterator(), this.buildTransformerUpcast());
- }
-
- private Iterator<Integer> buildInnerIterator() {
- return this.buildInnerTransformationIterator(this.buildNestedIterator());
- }
-
- private Iterator<Integer> buildUnmodifiableIterator() {
- return this.buildTransformationIterator(this.buildUnmodifiableNestedIterator(), this.buildTransformer());
- }
-
- private Iterator<Integer> buildTransformationIterator(Iterator<String> nestedIterator, Transformer<String, Integer> transformer) {
- return new TransformationIterator<String, Integer>(nestedIterator, transformer);
- }
-
- private Iterator<Object> buildTransformationIteratorUpcast(Iterator<String> nestedIterator, Transformer<Object, Integer> transformer) {
- return new TransformationIterator<Object, Object>(nestedIterator, transformer);
- }
-
- private Transformer<String, Integer> buildTransformer() {
- // transform each string into an integer with a value of the string's length
- return new Transformer<String, Integer>() {
- public Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- private Transformer<Object, Integer> buildTransformerUpcast() {
- // transform each string into an integer with a value of the string's length
- return new Transformer<Object, Integer>() {
- public Integer transform(Object next) {
- return new Integer(((String) next).length());
- }
- };
- }
-
- private Iterator<Integer> buildInnerTransformationIterator(Iterator<String> nestedIterator) {
- // transform each string into an integer with a value of the string's length
- return new TransformationIterator<String, Integer>(nestedIterator) {
- @Override
- protected Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- private Iterator<String> buildNestedIterator() {
- return this.buildCollection().iterator();
- }
-
- private Iterator<String> buildUnmodifiableNestedIterator() {
- return this.buildUnmodifiableCollection().iterator();
- }
-
- private Collection<String> buildCollection() {
- Collection<String> c = new ArrayList<String>();
- c.add("1");
- c.add("22");
- c.add("333");
- c.add("4444");
- c.add("55555");
- c.add("666666");
- c.add("7777777");
- c.add("88888888");
- return c;
- }
-
- private Collection<String> buildUnmodifiableCollection() {
- return Collections.unmodifiableCollection(this.buildCollection());
- }
-
- public void testInvalidTransformationIterator() {
- // missing method override
- Iterator<Integer> iterator = new TransformationIterator<String, Integer>(this.buildCollection().iterator());
- boolean exCaught = false;
- try {
- Integer integer = iterator.next();
- fail("invalid integer: " + integer);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TransformationListIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TransformationListIteratorTests.java
deleted file mode 100644
index 9a438096ba..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TransformationListIteratorTests.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationListIterator;
-
-@SuppressWarnings("nls")
-public class TransformationListIteratorTests extends TestCase {
-
- public TransformationListIteratorTests(String name) {
- super(name);
- }
-
- public void testHasNextAndHasPrevious() {
- int i = 0;
- ListIterator<Integer> stream = this.buildIterator();
-
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- }
- assertEquals(0, i);
- }
-
- public void testHasNextAndHasPreviousUpcast() {
- int i = 0;
- ListIterator<Object> stream = this.buildIteratorUpcast();
-
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- }
- assertEquals(0, i);
- }
-
- public void testInnerHasNextAndHasPrevious() {
- int i = 0;
- ListIterator<Integer> stream = this.buildInnerIterator();
-
- while (stream.hasNext()) {
- stream.next();
- i++;
- }
- assertEquals(8, i);
-
- while (stream.hasPrevious()) {
- stream.previous();
- i--;
- }
- assertEquals(0, i);
- }
-
- public void testNextAndPrevious() {
- int i = 0;
- ListIterator<Integer> stream = this.buildIterator();
-
- while (stream.hasNext()) {
- assertEquals(++i, stream.next().intValue());
- }
-
- ++i;
-
- while (stream.hasPrevious()) {
- assertEquals(--i, stream.previous().intValue());
- }
- }
-
- public void testInnerNextAndPrevious() {
- int i = 0;
- ListIterator<Integer> stream = this.buildInnerIterator();
-
- while (stream.hasNext()) {
- assertEquals(++i, stream.next().intValue());
- }
-
- ++i;
-
- while (stream.hasPrevious()) {
- assertEquals(--i, stream.previous().intValue());
- }
- }
-
- public void testNextIndexAndPreviousIndex() {
- int i = -1;
- ListIterator<Integer> stream = this.buildIterator();
-
- while (stream.hasNext()) {
- assertEquals(++i, stream.nextIndex());
- stream.next();
- }
-
- ++i;
-
- while (stream.hasPrevious()) {
- assertEquals(--i, stream.previousIndex());
- stream.previous();
- }
- }
-
- public void testInnerNextIndexAndPreviousIndex() {
- int i = -1;
- ListIterator<Integer> stream = this.buildInnerIterator();
-
- while (stream.hasNext()) {
- assertEquals(++i, stream.nextIndex());
- stream.next();
- }
-
- ++i;
-
- while (stream.hasPrevious()) {
- assertEquals(--i, stream.previousIndex());
- stream.previous();
- }
- }
-
- public void testRemove() {
- List<String> l = this.buildList();
- for (ListIterator<Integer> stream = this.buildInnerTransformationListIterator(l.listIterator()); stream.hasNext();) {
- if (stream.next().intValue() == 3) {
- stream.remove();
- }
- }
- assertEquals("nothing removed", this.buildList().size() - 1, l.size());
- assertFalse("element still in list", l.contains("333"));
- assertTrue("wrong element removed", l.contains("22"));
- }
-
- public void testInnerRemove() {
- List<String> l = this.buildList();
- for (ListIterator<Integer> stream = this.buildTransformationListIterator(l.listIterator(), this.buildTransformer()); stream.hasNext();) {
- if (stream.next().intValue() == 3) {
- stream.remove();
- }
- }
- assertEquals("nothing removed", this.buildList().size() - 1, l.size());
- assertFalse("element still in list", l.contains("333"));
- assertTrue("wrong element removed", l.contains("22"));
- }
-
- public void testUnsupportedOperationExceptionOnAdd() {
- ListIterator<Integer> stream = this.buildIterator();
- boolean exCaught = false;
- try {
- stream.add(new Integer(0));
- fail("exception not thrown");
- } catch (UnsupportedOperationException e) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testUnsupportedOperationExceptionOnSet() {
- ListIterator<Integer> stream = this.buildIterator();
- boolean exCaught = false;
- try {
- stream.set(new Integer(0));
- fail("exception not thrown");
- } catch (UnsupportedOperationException e) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testNoSuchElementException() {
- boolean exCaught = false;
- ListIterator<Integer> stream = this.buildIterator();
- Integer integer = null;
- while (stream.hasNext()) {
- integer = stream.next();
- }
- try {
- integer = stream.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown: " + integer, exCaught);
- }
-
- public void testUnsupportedOperationException() {
- boolean exCaught = false;
- for (Iterator<Integer> stream = this.buildUnmodifiableIterator(); stream.hasNext();) {
- int i = stream.next().intValue();
- if (i == 3) {
- try {
- stream.remove();
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- }
- }
- assertTrue("UnsupportedOperationException not thrown", exCaught);
- }
-
- public void testIllegalStateException() {
- boolean exCaught = false;
- try {
- this.buildIterator().remove();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue("IllegalStateException not thrown", exCaught);
- }
-
- private ListIterator<Integer> buildIterator() {
- return this.buildTransformationListIterator(this.buildNestedIterator(), this.buildTransformer());
- }
-
- private ListIterator<Object> buildIteratorUpcast() {
- return this.buildTransformationListIteratorUpcast(this.buildNestedIterator(), this.buildTransformerUpcast());
- }
-
- private ListIterator<Integer> buildInnerIterator() {
- return this.buildInnerTransformationListIterator(this.buildNestedIterator());
- }
-
- private ListIterator<Integer> buildUnmodifiableIterator() {
- return this.buildTransformationListIterator(this.buildUnmodifiableNestedIterator(), this.buildTransformer());
- }
-
- private ListIterator<Integer> buildTransformationListIterator(ListIterator<String> nestedIterator, Transformer<String, Integer> transformer) {
- return new TransformationListIterator<String, Integer>(nestedIterator, transformer);
- }
-
- private ListIterator<Object> buildTransformationListIteratorUpcast(ListIterator<String> nestedIterator, Transformer<Object, Integer> transformer) {
- return new TransformationListIterator<Object, Object>(nestedIterator, transformer);
- }
-
- private Transformer<String, Integer> buildTransformer() {
- // transform each string into an integer with a value of the string's length
- return new Transformer<String, Integer>() {
- public Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- private Transformer<Object, Integer> buildTransformerUpcast() {
- // transform each string into an integer with a value of the string's length
- return new Transformer<Object, Integer>() {
- public Integer transform(Object next) {
- return new Integer(((String) next).length());
- }
- };
- }
-
- private ListIterator<Integer> buildInnerTransformationListIterator(ListIterator<String> nestedIterator) {
- // transform each string into an integer with a value of the string's length
- return new TransformationListIterator<String, Integer>(nestedIterator) {
- @Override
- protected Integer transform(String next) {
- return new Integer(next.length());
- }
- };
- }
-
- private ListIterator<String> buildNestedIterator() {
- return this.buildList().listIterator();
- }
-
- private ListIterator<String> buildUnmodifiableNestedIterator() {
- return this.buildUnmodifiableList().listIterator();
- }
-
- private List<String> buildList() {
- List<String> l = new ArrayList<String>();
- l.add("1");
- l.add("22");
- l.add("333");
- l.add("4444");
- l.add("55555");
- l.add("666666");
- l.add("7777777");
- l.add("88888888");
- return l;
- }
-
- private List<String> buildUnmodifiableList() {
- return Collections.unmodifiableList(this.buildList());
- }
-
- public void testInvalidTransformationListIterator() {
- // missing method override
- Iterator<Integer> iterator = new TransformationListIterator<String, Integer>(this.buildList().listIterator());
- boolean exCaught = false;
- try {
- Integer integer = iterator.next();
- fail("invalid integer: " + integer);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TreeIteratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TreeIteratorTests.java
deleted file mode 100644
index f800e12bde..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/iterators/TreeIteratorTests.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.iterators;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.TreeIterator;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class TreeIteratorTests extends TestCase {
- /** this will be populated with all the nodes created for the test */
- Collection<TreeNode> nodes = new ArrayList<TreeNode>();
-
- public TreeIteratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testHasNext1() {
- this.verifyHasNext(this.buildTreeIterator1());
- }
-
- public void testHasNext2() {
- this.verifyHasNext(this.buildTreeIterator2());
- }
-
- private void verifyHasNext(Iterator<TreeNode> iterator) {
- int i = 0;
- while (iterator.hasNext()) {
- iterator.next();
- i++;
- }
- assertEquals(this.nodes.size(), i);
- }
-
- public void testNext1() {
- this.verifyNext(this.buildTreeIterator1());
- }
-
- public void testNext2() {
- this.verifyNext(this.buildTreeIterator2());
- }
-
- private void verifyNext(Iterator<TreeNode> iterator) {
- while (iterator.hasNext()) {
- assertTrue("bogus element", this.nodes.contains(iterator.next()));
- }
- }
-
- public void testNoSuchElementException1() {
- this.verifyNoSuchElementException(this.buildTreeIterator1());
- }
-
- public void testNoSuchElementException2() {
- this.verifyNoSuchElementException(this.buildTreeIterator2());
- }
-
- private void verifyNoSuchElementException(Iterator<TreeNode> iterator) {
- boolean exCaught = false;
- while (iterator.hasNext()) {
- iterator.next();
- }
- try {
- iterator.next();
- } catch (NoSuchElementException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
- public void testRemove1() {
- this.verifyRemove(this.buildTreeIterator1());
- }
-
- public void testRemove2() {
- this.verifyRemove(this.buildTreeIterator2());
- }
-
- private void verifyRemove(Iterator<TreeNode> iterator) {
- String parentName = "child 2";
- String childName = "grandchild 2A";
- int startSize = this.childrenSize(parentName);
- while (iterator.hasNext()) {
- TreeNode node = iterator.next();
- if (node.getName().equals(childName)) {
- iterator.remove();
- }
- }
- int endSize = this.childrenSize(parentName);
- assertEquals(startSize - 1, endSize);
- }
-
- private int childrenSize(String nodeName) {
- for (Iterator<TreeNode> stream = this.nodes.iterator(); stream.hasNext();) {
- TreeNode node = stream.next();
- if (node.getName().equals(nodeName)) {
- return node.childrenSize();
- }
- }
- throw new IllegalArgumentException(nodeName);
- }
-
- /**
- * build a tree iterator with an explicit midwife
- */
- private Iterator<TreeNode> buildTreeIterator1() {
- return new TreeIterator<TreeNode>(this.buildTree(), this.buildMidwife());
- }
-
- private TreeIterator.Midwife<TreeNode> buildMidwife() {
- return new TreeIterator.Midwife<TreeNode>() {
- public Iterator<TreeNode> children(TreeNode next) {
- return next.children();
- }
- };
- }
-
- /**
- * build a tree iterator with an override
- */
- private Iterator<TreeNode> buildTreeIterator2() {
- return new TreeIterator<TreeNode>(this.buildTree()) {
- @Override
- public Iterator<TreeNode> children(TreeNode next) {
- return next.children();
- }
- };
- }
-
- public void testInvalidTreeIterator() {
- // missing method override
- Iterator<TreeNode> iterator = new TreeIterator<TreeNode>(this.buildTree());
- boolean exCaught = false;
- try {
- TreeNode tn = iterator.next();
- fail("invalid tree node: " + tn);
- } catch (UnsupportedOperationException ex) {
- exCaught = true;
- }
- assertTrue("NoSuchElementException not thrown", exCaught);
- }
-
- private TreeNode buildTree() {
- TreeNode root = new TreeNode("root");
- TreeNode child1 = new TreeNode(root, "child 1");
- new TreeNode(child1, "grandchild 1A");
- TreeNode child2 = new TreeNode(root, "child 2");
- new TreeNode(child2, "grandchild 2A");
- TreeNode grandchild2B = new TreeNode(child2, "grandchild 2B");
- new TreeNode(grandchild2B, "great-grandchild 2B1");
- new TreeNode(grandchild2B, "great-grandchild 2B2");
- TreeNode grandchild2C = new TreeNode(child2, "grandchild 2C");
- new TreeNode(grandchild2C, "great-grandchild 2C1");
- new TreeNode(root, "child 3");
- return root;
- }
-
- private class TreeNode {
- private String name;
- private Collection<TreeNode> children = new ArrayList<TreeNode>();
-
- public TreeNode(String name) {
- super();
- TreeIteratorTests.this.nodes.add(this); // log node
- this.name = name;
- }
-
- public TreeNode(TreeNode parent, String name) {
- this(name);
- parent.addChild(this);
- }
-
- public String getName() {
- return this.name;
- }
-
- private void addChild(TreeNode child) {
- this.children.add(child);
- }
-
- public Iterator<TreeNode> children() {
- return this.children.iterator();
- }
-
- public int childrenSize() {
- return this.children.size();
- }
-
- @Override
- public String toString() {
- return "TreeNode(" + this.name + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/ChangeSupportTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/ChangeSupportTests.java
deleted file mode 100644
index 2166827530..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/ChangeSupportTests.java
+++ /dev/null
@@ -1,4575 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EventListener;
-import java.util.HashSet;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.TreeChangeAdapter;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ChangeSupportTests
- extends TestCase
-{
- TestModel testModel;
- static final String TEST_TO_STRING = "this is a test";
-
- ChangeListener changeListener = new Adapter();
-
- StateChangeEvent stateChangeEvent;
- boolean stateChangedCalled = false;
-
- PropertyChangeEvent propertyChangeEvent;
- boolean propertyChangeCalled = false;
- static final String PROPERTY_NAME = "propertyName";
- static final Object OLD_OBJECT_VALUE = new Object();
- static final Object NEW_OBJECT_VALUE = new Object();
- static final Integer OLD_INT_VALUE = new Integer(27);
- static final Boolean OLD_BOOLEAN_VALUE = Boolean.TRUE;
- static final Integer NEW_INT_VALUE = new Integer(42);
- static final Boolean NEW_BOOLEAN_VALUE = Boolean.FALSE;
-
- CollectionEvent collectionEvent;
- boolean itemsAddedCollectionCalled = false;
- boolean itemsRemovedCollectionCalled = false;
- boolean collectionChangedCalled = false;
- boolean collectionClearedCalled = false;
- static final String COLLECTION_NAME = "collectionName";
- static final Object ADDED_OBJECT_VALUE = new Object();
- static final Object ADDED_OBJECT_VALUE_2 = new Object();
- static final Object REMOVED_OBJECT_VALUE = new Object();
- static final int TARGET_INDEX = 7;
- static final int SOURCE_INDEX = 22;
-
- ListEvent listEvent;
- boolean itemsAddedListCalled = false;
- boolean itemsRemovedListCalled = false;
- boolean itemsReplacedListCalled = false;
- boolean itemsMovedListCalled = false;
- boolean listChangedCalled = false;
- boolean listClearedCalled = false;
- static final String LIST_NAME = "listName";
- static final int ADD_INDEX = 3;
- static final int REMOVE_INDEX = 5;
- static final int REPLACE_INDEX = 2;
-
- TreeEvent treeEvent;
- boolean nodeAddedCalled = false;
- boolean nodeRemovedCalled = false;
- boolean treeChangedCalled = false;
- boolean treeClearedCalled = false;
- static final String TREE_NAME = "treeName";
- static final List<Object> OBJECT_PATH = Arrays.asList(new Object[] {new Object(), new Object(), new String()});
-
-
- public ChangeSupportTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.testModel = new TestModel();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
-
- // ********** general tests **********
-
- public void testNullSource() {
- boolean exCaught = false;
- try {
- ChangeSupport cs = new ChangeSupport(null);
- fail("bogus change support: " + cs);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- // ********** state change tests **********
-
- public void testFireStateChange() {
- this.stateChangeEvent = null;
- this.stateChangedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireStateChange();
- assertNotNull(this.stateChangeEvent);
- assertEquals(this.testModel, this.stateChangeEvent.getSource());
- assertTrue(this.stateChangedCalled);
- }
-
- public void testHasAnyStateChangeListeners() {
- assertTrue(this.testModel.hasNoStateChangeListeners());
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.hasAnyStateChangeListeners());
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.hasNoStateChangeListeners());
- }
-
- public void testHasAnyStateChangeListenersDuplicate() {
- assertTrue(this.testModel.hasNoStateChangeListeners());
- this.testModel.addChangeListener(this.changeListener);
- boolean exCaught = false;
- try {
- this.testModel.addChangeListener(this.changeListener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- assertTrue(this.testModel.hasAnyStateChangeListeners());
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.hasNoStateChangeListeners());
-
- exCaught = false;
- try {
- this.testModel.removeChangeListener(this.changeListener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(this.testModel.hasNoStateChangeListeners());
- }
-
- public void testAddNullStateListener() {
- boolean exCaught = false;
- try {
- this.testModel.addStateChangeListener(null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusStateListener() {
- boolean exCaught = false;
- try {
- this.testModel.removeChangeListener(this.changeListener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener("foo", this.changeListener);
- exCaught = false;
- try {
- this.testModel.removeChangeListener(this.changeListener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addChangeListener(this.changeListener);
- exCaught = false;
- try {
- this.testModel.removeStateChangeListener(new Adapter());
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- this.testModel.removeStateChangeListener(new StateChangeAdapter());
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- // ********** property change tests **********
-
- public void testFirePropertyChangedEvent() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedEvent();
- this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedEvent();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedEvent();
- this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedEvent();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangedEventNoChange() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedEventNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedEventNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedEventNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedEventNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangedObjectObject() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedObjectObject();
- this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedObjectObject();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedObjectObject();
- this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedObjectObject();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangedObjectObjectNoChange() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedObjectObjectNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedObjectObjectNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedObjectObjectNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedObjectObjectNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangedObject() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedObject();
- this.verifyPropertyChangeEvent(null, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedObject();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedObject();
- this.verifyPropertyChangeEvent(null, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedObject();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangedObjectNoChange() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedObjectNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedObjectNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedObjectNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedObjectNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangedIntInt() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedIntInt();
- this.verifyPropertyChangeEvent(OLD_INT_VALUE, NEW_INT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedIntInt();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedIntInt();
- this.verifyPropertyChangeEvent(OLD_INT_VALUE, NEW_INT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedIntInt();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangedIntIntNoChange() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedIntIntNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedIntIntNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedIntIntNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedIntIntNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangedBooleanBoolean() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedBooleanBoolean();
- this.verifyPropertyChangeEvent(OLD_BOOLEAN_VALUE, NEW_BOOLEAN_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedBooleanBoolean();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedBooleanBoolean();
- this.verifyPropertyChangeEvent(OLD_BOOLEAN_VALUE, NEW_BOOLEAN_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedBooleanBoolean();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testFirePropertyChangedBooleanBooleanNoChange() {
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedBooleanBooleanNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFirePropertyChangedBooleanBooleanNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedBooleanBooleanNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
-
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this.changeListener);
- this.testModel.testFirePropertyChangedBooleanBooleanNoChange();
- assertNull(this.propertyChangeEvent);
- assertFalse(this.propertyChangeCalled);
- }
-
- public void testHasAnyPropertyChangeListeners() {
- assertTrue(this.testModel.hasNoPropertyChangeListeners(PROPERTY_NAME));
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.hasNoPropertyChangeListeners(PROPERTY_NAME));
-
- assertTrue(this.testModel.hasNoPropertyChangeListeners(PROPERTY_NAME));
- this.testModel.addPropertyChangeListener(PROPERTY_NAME, this.changeListener);
- assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- this.testModel.removePropertyChangeListener(PROPERTY_NAME, this.changeListener);
- assertTrue(this.testModel.hasNoPropertyChangeListeners(PROPERTY_NAME));
- }
-
- public void testAddNullPropertyListener() {
- boolean exCaught = false;
- try {
- this.testModel.addChangeListener(null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddNullPropertyListenerName() {
- boolean exCaught = false;
- try {
- this.testModel.addPropertyChangeListener("foo", null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusPropertyListener() {
- boolean exCaught = false;
- try {
- this.testModel.removePropertyChangeListener("foo", new PropertyChangeAdapter());
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addCollectionChangeListener("foo", this.changeListener);
- exCaught = false;
- try {
- this.testModel.removePropertyChangeListener("foo", this.changeListener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener("foo", this.changeListener);
- exCaught = false;
- try {
- this.testModel.removePropertyChangeListener("foo", new PropertyChangeAdapter());
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- this.testModel.removePropertyChangeListener("foo", new PropertyChangeAdapter());
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- private void verifyPropertyChangeEvent(Object oldValue, Object newValue) {
- this.verifyPropertyChangeEvent(this.testModel, oldValue, newValue);
- }
-
- private void verifyPropertyChangeEvent(Object source, Object oldValue, Object newValue) {
- assertNotNull(this.propertyChangeEvent);
- assertEquals(source, this.propertyChangeEvent.getSource());
- assertEquals(PROPERTY_NAME, this.propertyChangeEvent.getPropertyName());
- assertEquals(oldValue, this.propertyChangeEvent.getOldValue());
- assertEquals(newValue, this.propertyChangeEvent.getNewValue());
- }
-
-
- // ********** collection change tests **********
-
- public void testFireItemsAddedCollectionEvent() {
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedCollectionEvent();
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedCollectionEvent();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsAddedCollectionEvent();
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsAddedCollectionEvent();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
- }
-
- public void testFireItemsAddedCollectionEventNoChange() {
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedCollectionEventNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedCollectionEventNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsAddedCollectionEventNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsAddedCollectionEventNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
- }
-
- public void testFireItemsAddedCollection() {
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedCollection();
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedCollection();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsAddedCollection();
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsAddedCollection();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
- }
-
- public void testFireItemsAddedCollectionNoChange() {
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedCollectionNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedCollectionNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsAddedCollectionNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsAddedCollectionNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
- }
-
- public void testFireItemAddedCollection() {
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemAddedCollection();
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemAddedCollection();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemAddedCollection();
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemAddedCollection();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
- }
-
- public void testFireItemsRemovedCollectionEvent() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedCollectionEvent();
- this.verifyCollectionEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedCollectionEvent();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedCollectionEvent();
- this.verifyCollectionEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedCollectionEvent();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testFireItemsRemovedCollectionEventNoChange() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedCollectionEventNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedCollectionEventNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedCollectionEventNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedCollectionEventNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testFireItemsRemovedCollection() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedCollection();
- this.verifyCollectionEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedCollection();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedCollection();
- this.verifyCollectionEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedCollection();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testFireItemsRemovedCollectionNoChange() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedCollectionNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedCollectionNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedCollectionNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedCollectionNoChange();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testFireItemRemovedCollection() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemRemovedCollection();
- this.verifyCollectionEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemRemovedCollection();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemRemovedCollection();
- this.verifyCollectionEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireItemRemovedCollection();
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testFireCollectionCleared() {
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireCollectionCleared();
- this.verifyCollectionEvent(null);
- assertTrue(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireCollectionCleared();
- assertNull(this.collectionEvent);
- assertFalse(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireCollectionCleared();
- this.verifyCollectionEvent(null);
- assertTrue(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireCollectionCleared();
- assertNull(this.collectionEvent);
- assertFalse(this.collectionClearedCalled);
- }
-
- public void testFireCollectionChangedEvent() {
- this.collectionEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireCollectionChangedEvent();
- this.verifyCollectionEvent(null);
- assertTrue(this.collectionChangedCalled);
-
- this.collectionEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireCollectionChangedEvent();
- assertNull(this.collectionEvent);
- assertFalse(this.collectionChangedCalled);
-
- this.collectionEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireCollectionChangedEvent();
- this.verifyCollectionEvent(null);
- assertTrue(this.collectionChangedCalled);
-
- this.collectionEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireCollectionChangedEvent();
- assertNull(this.collectionEvent);
- assertFalse(this.collectionChangedCalled);
- }
-
- public void testFireCollectionChanged() {
- this.collectionEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireCollectionChanged();
- this.verifyCollectionEvent(null);
- assertTrue(this.collectionChangedCalled);
-
- this.collectionEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireCollectionChanged();
- assertNull(this.collectionEvent);
- assertFalse(this.collectionChangedCalled);
-
- this.collectionEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireCollectionChanged();
- this.verifyCollectionEvent(null);
- assertTrue(this.collectionChangedCalled);
-
- this.collectionEvent = null;
- this.collectionChangedCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- this.testModel.testFireCollectionChanged();
- assertNull(this.collectionEvent);
- assertFalse(this.collectionChangedCalled);
- }
-
- public void testAddItemToCollection() {
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.testAddItemToCollection());
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.testAddItemToCollection());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testAddItemToCollection());
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testAddItemToCollection());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
- }
-
- public void testAddItemToCollectionNoChange() {
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertFalse(this.testModel.testAddItemToCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertFalse(this.testModel.testAddItemToCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testAddItemToCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testAddItemToCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
- }
-
- public void testAddItemsToCollection() {
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.testAddItemsToCollection());
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.testAddItemsToCollection());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testAddItemsToCollection());
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testAddItemsToCollection());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
- }
-
- public void testAddItemsToCollectionNoChange() {
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertFalse(this.testModel.testAddItemsToCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertFalse(this.testModel.testAddItemsToCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testAddItemsToCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testAddItemsToCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
- }
-
- public void testAddItemsToCollectionMixed() {
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.testAddItemsToCollectionMixed());
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE_2);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.testAddItemsToCollectionMixed());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testAddItemsToCollectionMixed());
- this.verifyCollectionEvent(ADDED_OBJECT_VALUE_2);
- assertTrue(this.itemsAddedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsAddedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testAddItemsToCollectionMixed());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsAddedCollectionCalled);
- }
-
- public void testRemoveItemFromCollection() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.testRemoveItemFromCollection());
- this.verifyCollectionEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.testRemoveItemFromCollection());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testRemoveItemFromCollection());
- this.verifyCollectionEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testRemoveItemFromCollection());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testRemoveItemFromCollectionNoChange() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertFalse(this.testModel.testRemoveItemFromCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertFalse(this.testModel.testRemoveItemFromCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRemoveItemFromCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRemoveItemFromCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testRemoveItemsFromCollection() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.testRemoveItemsFromCollection());
- this.verifyCollectionChangeEvent2(REMOVED_OBJECT_VALUE, "foo", "bar");
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.testRemoveItemsFromCollection());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testRemoveItemsFromCollection());
- this.verifyCollectionChangeEvent2(REMOVED_OBJECT_VALUE, "foo", "bar");
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testRemoveItemsFromCollection());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testRemoveItemsFromCollectionNoChange1() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange1());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange1());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange1());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange1());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testRemoveItemsFromCollectionNoChange2() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange2());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange2());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange2());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange2());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testRemoveItemsFromCollectionNoChange3() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange3());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange3());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange3());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRemoveItemsFromCollectionNoChange3());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testRetainItemsInCollection1() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.testRetainItemsInCollection1());
- this.verifyCollectionEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.testRetainItemsInCollection1());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testRetainItemsInCollection1());
- this.verifyCollectionEvent(REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testRetainItemsInCollection1());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- // collection cleared...
- public void testRetainItemsInCollection2() {
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.testRetainItemsInCollection2());
- this.verifyCollectionEvent(null);
- assertTrue(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.testRetainItemsInCollection2());
- assertNull(this.collectionEvent);
- assertFalse(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testRetainItemsInCollection2());
- this.verifyCollectionEvent(null);
- assertTrue(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testRetainItemsInCollection2());
- assertNull(this.collectionEvent);
- assertFalse(this.collectionClearedCalled);
- }
-
- public void testRetainItemsInCollectionNoChange1() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertFalse(this.testModel.testRetainItemsInCollectionNoChange1());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertFalse(this.testModel.testRetainItemsInCollectionNoChange1());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRetainItemsInCollectionNoChange1());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRetainItemsInCollectionNoChange1());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testRetainItemsInCollectionNoChange2() {
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertFalse(this.testModel.testRetainItemsInCollectionNoChange2());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertFalse(this.testModel.testRetainItemsInCollectionNoChange2());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRetainItemsInCollectionNoChange2());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
-
- this.collectionEvent = null;
- this.itemsRemovedCollectionCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testRetainItemsInCollectionNoChange2());
- assertNull(this.collectionEvent);
- assertFalse(this.itemsRemovedCollectionCalled);
- }
-
- public void testClearCollection() {
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.testClearCollection());
- this.verifyCollectionEvent(null);
- assertTrue(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.testClearCollection());
- assertNull(this.collectionEvent);
- assertFalse(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testClearCollection());
- this.verifyCollectionEvent(null);
- assertTrue(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.testClearCollection());
- assertNull(this.collectionEvent);
- assertFalse(this.collectionClearedCalled);
- }
-
- public void testClearCollectionNoChange() {
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- assertFalse(this.testModel.testClearCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- assertFalse(this.testModel.testClearCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testClearCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.collectionClearedCalled);
-
- this.collectionEvent = null;
- this.collectionClearedCalled = false;
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertFalse(this.testModel.testClearCollectionNoChange());
- assertNull(this.collectionEvent);
- assertFalse(this.collectionClearedCalled);
- }
-
- public void testSynchronizeCollection1() {
- CollectionSynchListener csl = new CollectionSynchListener();
- this.testModel.addChangeListener(csl);
- assertTrue(this.testModel.testSynchronizeCollection1());
- assertTrue(csl.itemsAdded);
- assertTrue(csl.itemsRemoved);
- assertFalse(csl.collectionChanged);
- assertFalse(csl.collectionCleared);
- assertEquals(2, csl.addedItems.size());
- assertTrue(CollectionTools.containsAll(csl.addedItems, new Object[] {"joo", "jar"}));
- assertEquals(2, csl.removedItems.size());
- assertTrue(CollectionTools.containsAll(csl.removedItems, new Object[] {"foo", "bar"}));
- }
-
- public void testSynchronizeCollection2() {
- CollectionSynchListener csl = new CollectionSynchListener();
- this.testModel.addChangeListener(csl);
- assertTrue(this.testModel.testSynchronizeCollection2());
- assertFalse(csl.itemsAdded);
- assertFalse(csl.itemsRemoved);
- assertFalse(csl.collectionChanged);
- assertTrue(csl.collectionCleared);
- assertTrue(csl.addedItems.isEmpty());
- assertTrue(csl.removedItems.isEmpty());
- }
-
- public void testSynchronizeCollection3() {
- CollectionSynchListener csl = new CollectionSynchListener();
- this.testModel.addChangeListener(csl);
- assertTrue(this.testModel.testSynchronizeCollection3());
- assertTrue(csl.itemsAdded);
- assertFalse(csl.itemsRemoved);
- assertFalse(csl.collectionChanged);
- assertFalse(csl.collectionCleared);
- assertEquals(3, csl.addedItems.size());
- assertTrue(CollectionTools.containsAll(csl.addedItems, new Object[] {"joo", "jar", "baz"}));
- assertTrue(csl.removedItems.isEmpty());
- }
-
- class CollectionSynchListener extends ChangeAdapter {
- boolean itemsAdded = false;
- boolean itemsRemoved = false;
- boolean collectionChanged = false;
- boolean collectionCleared = false;
- Collection<Object> addedItems = new ArrayList<Object>();
- Collection<Object> removedItems = new ArrayList<Object>();
- @Override
- public void collectionChanged(CollectionChangeEvent event) {
- this.collectionChanged = true;
- }
- @Override
- public void collectionCleared(CollectionClearEvent event) {
- this.collectionCleared = true;
- }
- @Override
- public void itemsAdded(CollectionAddEvent event) {
- this.itemsAdded = true;
- CollectionTools.addAll(this.addedItems, event.getItems());
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent event) {
- this.itemsRemoved = true;
- CollectionTools.addAll(this.removedItems, event.getItems());
- }
- }
-
- public void testHasAnyCollectionChangeListeners() {
- assertTrue(this.testModel.hasNoCollectionChangeListeners(COLLECTION_NAME));
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME));
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.hasNoCollectionChangeListeners(COLLECTION_NAME));
-
- assertTrue(this.testModel.hasNoCollectionChangeListeners(COLLECTION_NAME));
- this.testModel.addCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.hasAnyCollectionChangeListeners(COLLECTION_NAME));
- this.testModel.removeCollectionChangeListener(COLLECTION_NAME, this.changeListener);
- assertTrue(this.testModel.hasNoCollectionChangeListeners(COLLECTION_NAME));
- }
-
- public void testAddNullCollectionListener() {
- boolean exCaught = false;
- try {
- this.testModel.addCollectionChangeListener("foo", null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusCollectionListener() {
- boolean exCaught = false;
- try {
- this.testModel.removeCollectionChangeListener("foo", this.changeListener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener("foo", this.changeListener);
- exCaught = false;
- try {
- this.testModel.removeCollectionChangeListener("foo", this.changeListener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addCollectionChangeListener("foo", this.changeListener);
- exCaught = false;
- try {
- this.testModel.removeCollectionChangeListener("foo", new CollectionChangeAdapter());
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- this.testModel.removeCollectionChangeListener("foo", new CollectionChangeAdapter());
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- private void verifyCollectionEvent(Object item) {
- assertNotNull(this.collectionEvent);
- assertEquals(this.testModel, this.collectionEvent.getSource());
- assertEquals(COLLECTION_NAME, this.collectionEvent.getCollectionName());
- if (item != null) {
- assertEquals(item, this.getCollectionEventItems().iterator().next());
- }
- }
-
- private Iterable<?> getCollectionEventItems() {
- if (this.collectionEvent instanceof CollectionAddEvent) {
- return ((CollectionAddEvent) this.collectionEvent).getItems();
- } else if (this.collectionEvent instanceof CollectionRemoveEvent) {
- return ((CollectionRemoveEvent) this.collectionEvent).getItems();
- }
- throw new IllegalStateException();
- }
-
- private void verifyCollectionChangeEvent2(Object... items) {
- assertNotNull(this.collectionEvent);
- assertEquals(this.testModel, this.collectionEvent.getSource());
- assertEquals(COLLECTION_NAME, this.collectionEvent.getCollectionName());
- assertEquals(items.length, this.getCollectionEventItemsSize());
- for (Object item : items) {
- assertTrue(CollectionTools.contains(this.getCollectionEventItems(), item));
- }
- }
-
- private int getCollectionEventItemsSize() {
- if (this.collectionEvent instanceof CollectionAddEvent) {
- return ((CollectionAddEvent) this.collectionEvent).getItemsSize();
- } else if (this.collectionEvent instanceof CollectionRemoveEvent) {
- return ((CollectionRemoveEvent) this.collectionEvent).getItemsSize();
- }
- throw new IllegalStateException();
- }
-
-
- // ********** list change tests **********
-
- public void testFireItemsAddedListEvent() {
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedListEvent();
- this.verifyListAddEvent(ADD_INDEX, ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedListEvent();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsAddedListEvent();
- this.verifyListAddEvent(ADD_INDEX, ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsAddedListEvent();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testFireItemsAddedListEventNoChange() {
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsAddedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsAddedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testFireItemsAddedList() {
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedList();
- this.verifyListAddEvent(ADD_INDEX, ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsAddedList();
- this.verifyListAddEvent(ADD_INDEX, ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsAddedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testFireItemsAddedListNoChange() {
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsAddedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsAddedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsAddedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testFireItemAddedList() {
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemAddedList();
- this.verifyListAddEvent(ADD_INDEX, ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemAddedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemAddedList();
- this.verifyListAddEvent(ADD_INDEX, ADDED_OBJECT_VALUE);
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemAddedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testFireItemsRemovedListEvent() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedListEvent();
- this.verifyListRemoveEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedListEvent();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedListEvent();
- this.verifyListRemoveEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedListEvent();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testFireItemsRemovedListEventNoChange() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testFireItemsRemovedList() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedList();
- this.verifyListRemoveEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedList();
- this.verifyListRemoveEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testFireItemsRemovedListNoChange() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsRemovedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsRemovedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testFireItemRemovedList() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemRemovedList();
- this.verifyListRemoveEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemRemovedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemRemovedList();
- this.verifyListRemoveEvent(REMOVE_INDEX, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemRemovedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testFireItemsReplacedListEvent() {
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsReplacedListEvent();
- this.verifyListReplaceEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsReplacedListEvent();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsReplacedListEvent();
- this.verifyListReplaceEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsReplacedListEvent();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
- }
-
- public void testFireItemsReplacedListEventNoChange() {
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsReplacedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsReplacedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsReplacedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsReplacedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
- }
-
- public void testFireItemsReplacedList() {
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsReplacedList();
- this.verifyListReplaceEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsReplacedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsReplacedList();
- this.verifyListReplaceEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsReplacedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
- }
-
- public void testFireItemsReplacedListNoChange() {
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsReplacedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsReplacedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsReplacedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsReplacedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
- }
-
- public void testFireItemReplacedList() {
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemReplacedList();
- this.verifyListReplaceEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemReplacedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemReplacedList();
- this.verifyListReplaceEvent(REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE);
- assertTrue(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemReplacedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
- }
-
- public void testFireItemsMovedListEvent() {
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsMovedListEvent();
- this.verifyListMoveEvent(TARGET_INDEX, SOURCE_INDEX);
- assertTrue(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsMovedListEvent();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsMovedListEvent();
- this.verifyListMoveEvent(TARGET_INDEX, SOURCE_INDEX);
- assertTrue(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsMovedListEvent();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
- }
-
- public void testFireItemsMovedListEventNoChange() {
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsMovedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsMovedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsMovedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsMovedListEventNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
- }
-
- public void testFireItemsMovedList() {
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsMovedList();
- this.verifyListMoveEvent(TARGET_INDEX, SOURCE_INDEX);
- assertTrue(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsMovedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsMovedList();
- this.verifyListMoveEvent(TARGET_INDEX, SOURCE_INDEX);
- assertTrue(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsMovedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
- }
-
- public void testFireItemsMovedListNoChange() {
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemsMovedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemsMovedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsMovedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemsMovedListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
- }
-
- public void testFireItemMovedList() {
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireItemMovedList();
- this.verifyListMoveEvent(TARGET_INDEX, SOURCE_INDEX);
- assertTrue(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireItemMovedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemMovedList();
- this.verifyListMoveEvent(TARGET_INDEX, SOURCE_INDEX);
- assertTrue(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireItemMovedList();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
- }
-
- public void testFireListClearedEvent() {
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireListClearedEvent();
- this.verifyListClearEvent();
- assertTrue(this.listClearedCalled);
-
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireListClearedEvent();
- assertNull(this.listEvent);
- assertFalse(this.listClearedCalled);
-
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireListClearedEvent();
- this.verifyListClearEvent();
- assertTrue(this.listClearedCalled);
-
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireListClearedEvent();
- assertNull(this.listEvent);
- assertFalse(this.listClearedCalled);
- }
-
- public void testFireListCleared() {
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireListCleared();
- this.verifyListClearEvent();
- assertTrue(this.listClearedCalled);
-
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireListCleared();
- assertNull(this.listEvent);
- assertFalse(this.listClearedCalled);
-
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireListCleared();
- this.verifyListClearEvent();
- assertTrue(this.listClearedCalled);
-
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireListCleared();
- assertNull(this.listEvent);
- assertFalse(this.listClearedCalled);
- }
-
- public void testFireListChangedEvent() {
- this.listEvent = null;
- this.listChangedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireListChangedEvent();
- this.verifyListChangeEvent();
- assertTrue(this.listChangedCalled);
-
- this.listEvent = null;
- this.listChangedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireListChangedEvent();
- assertNull(this.listEvent);
- assertFalse(this.listChangedCalled);
-
- this.listEvent = null;
- this.listChangedCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireListChangedEvent();
- this.verifyListChangeEvent();
- assertTrue(this.listChangedCalled);
-
- this.listEvent = null;
- this.listChangedCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireListChangedEvent();
- assertNull(this.listEvent);
- assertFalse(this.listChangedCalled);
- }
-
- public void testFireListChanged() {
- this.listEvent = null;
- this.listChangedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireListChanged();
- this.verifyListChangeEvent();
- assertTrue(this.listChangedCalled);
-
- this.listEvent = null;
- this.listChangedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireListChanged();
- assertNull(this.listEvent);
- assertFalse(this.listChangedCalled);
-
- this.listEvent = null;
- this.listChangedCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireListChanged();
- this.verifyListChangeEvent();
- assertTrue(this.listChangedCalled);
-
- this.listEvent = null;
- this.listChangedCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testFireListChanged();
- assertNull(this.listEvent);
- assertFalse(this.listChangedCalled);
- }
-
- public void testAddItemToListIndex() {
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testAddItemToListIndex();
- this.verifyListAddEvent(2, "joo");
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testAddItemToListIndex();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemToListIndex();
- this.verifyListAddEvent(2, "joo");
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemToListIndex();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testAddItemToList() {
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testAddItemToList();
- this.verifyListAddEvent(3, "joo");
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testAddItemToList();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemToList();
- this.verifyListAddEvent(3, "joo");
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemToList();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testAddItemsToListIndex() {
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testAddItemsToListIndex();
- this.verifyListAddEvent(2, "joo");
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testAddItemsToListIndex();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemsToListIndex();
- this.verifyListAddEvent(2, "joo");
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemsToListIndex();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testAddItemsToListIndexNoChange() {
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testAddItemsToListIndexNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testAddItemsToListIndexNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemsToListIndexNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemsToListIndexNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testAddItemsToList() {
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testAddItemsToList();
- this.verifyListAddEvent(3, "joo");
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testAddItemsToList();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemsToList();
- this.verifyListAddEvent(3, "joo");
- assertTrue(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemsToList();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testAddItemsToListNoChange() {
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testAddItemsToListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testAddItemsToListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemsToListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
-
- this.listEvent = null;
- this.itemsAddedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testAddItemsToListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsAddedListCalled);
- }
-
- public void testRemoveItemFromListIndex() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testRemoveItemFromListIndex();
- this.verifyListRemoveEvent(1, "bar");
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testRemoveItemFromListIndex();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemFromListIndex();
- this.verifyListRemoveEvent(1, "bar");
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemFromListIndex();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testRemoveItemFromList() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testRemoveItemFromList();
- this.verifyListRemoveEvent(1, "bar");
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testRemoveItemFromList();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemFromList();
- this.verifyListRemoveEvent(1, "bar");
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemFromList();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testRemoveItemsFromListIndex() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testRemoveItemsFromListIndex();
- this.verifyListRemoveEvent(1, "bar");
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testRemoveItemsFromListIndex();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemsFromListIndex();
- this.verifyListRemoveEvent(1, "bar");
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemsFromListIndex();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testRemoveItemsFromListIndexNoChange() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testRemoveItemsFromListIndexNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testRemoveItemsFromListIndexNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemsFromListIndexNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemsFromListIndexNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testRemoveItemsFromList() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testRemoveItemsFromList();
- this.verifyListRemoveEvent(1, "bar");
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testRemoveItemsFromList();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemsFromList();
- this.verifyListRemoveEvent(1, "bar");
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemsFromList();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testRemoveItemsFromListNoChange() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testRemoveItemsFromListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testRemoveItemsFromListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemsFromListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRemoveItemsFromListNoChange();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testRetainItemsInList() {
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testRetainItemsInList();
- this.verifyListRemoveEvent(0, "foo");
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testRetainItemsInList();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRetainItemsInList();
- this.verifyListRemoveEvent(0, "foo");
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testRetainItemsInList();
- assertNull(this.listEvent);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testReplaceItemInList() {
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testReplaceItemInList();
- this.verifyListReplaceEvent(1, "xxx", "bar");
- assertTrue(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testReplaceItemInList();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testReplaceItemInList();
- this.verifyListReplaceEvent(1, "xxx", "bar");
- assertTrue(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testReplaceItemInList();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
- }
-
- public void testSetItemsInList() {
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testSetItemsInList();
- this.verifyListReplaceEvent(1, "xxx", "bar");
- assertTrue(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testSetItemsInList();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testSetItemsInList();
- this.verifyListReplaceEvent(1, "xxx", "bar");
- assertTrue(this.itemsReplacedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testSetItemsInList();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
- }
-
- public void testMoveItemsInList() {
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testMoveItemsInList();
- this.verifyListMoveEvent(2, 4, 2);
- assertTrue(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testMoveItemsInList();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testMoveItemsInList();
- this.verifyListMoveEvent(2, 4, 2);
- assertTrue(this.itemsMovedListCalled);
-
- this.listEvent = null;
- this.itemsMovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testMoveItemsInList();
- assertNull(this.listEvent);
- assertFalse(this.itemsMovedListCalled);
- }
-
- public void testClearList() {
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testClearList();
- this.verifyListClearEvent();
- assertTrue(this.listClearedCalled);
-
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testClearList();
- assertNull(this.listEvent);
- assertFalse(this.listClearedCalled);
-
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testClearList();
- this.verifyListClearEvent();
- assertTrue(this.listClearedCalled);
-
- this.listEvent = null;
- this.listClearedCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testClearList();
- assertNull(this.listEvent);
- assertFalse(this.listClearedCalled);
- }
-
- public void testSynchronizeList() {
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.itemsRemovedListCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testSynchronizeList();
- assertNotNull(this.listEvent);
- assertTrue(this.itemsReplacedListCalled);
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.itemsRemovedListCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testSynchronizeList();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
- assertFalse(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.itemsRemovedListCalled = false;
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testSynchronizeList();
- assertNotNull(this.listEvent);
- assertTrue(this.itemsReplacedListCalled);
- assertTrue(this.itemsRemovedListCalled);
-
- this.listEvent = null;
- this.itemsReplacedListCalled = false;
- this.itemsRemovedListCalled = false;
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- this.testModel.testSynchronizeList();
- assertNull(this.listEvent);
- assertFalse(this.itemsReplacedListCalled);
- assertFalse(this.itemsRemovedListCalled);
- }
-
- public void testHasAnyListChangeListeners() {
- assertTrue(this.testModel.hasNoListChangeListeners(LIST_NAME));
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.hasAnyListChangeListeners(LIST_NAME));
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.hasNoListChangeListeners(LIST_NAME));
-
- assertTrue(this.testModel.hasNoListChangeListeners(LIST_NAME));
- this.testModel.addListChangeListener(LIST_NAME, this.changeListener);
- assertTrue(this.testModel.hasAnyListChangeListeners(LIST_NAME));
- this.testModel.removeListChangeListener(LIST_NAME, this.changeListener);
- assertTrue(this.testModel.hasNoListChangeListeners(LIST_NAME));
- }
-
- public void testAddNullListListener() {
- boolean exCaught = false;
- try {
- this.testModel.addListChangeListener("foo", null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusListListener() {
- boolean exCaught = false;
- try {
- this.testModel.removeListChangeListener("foo", this.changeListener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener("foo", this.changeListener);
- exCaught = false;
- try {
- this.testModel.removeListChangeListener("foo", this.changeListener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addListChangeListener("foo", this.changeListener);
- exCaught = false;
- try {
- this.testModel.removeListChangeListener("foo", new ListChangeAdapter());
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- this.testModel.removeListChangeListener("foo", new ListChangeAdapter());
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- private void verifyListAddEvent(int index, Object item) {
- assertNotNull(this.listEvent);
- assertEquals(this.testModel, this.listEvent.getSource());
- assertEquals(LIST_NAME, this.listEvent.getListName());
- assertEquals(index, ((ListAddEvent) this.listEvent).getIndex());
- assertEquals(item, ((ListAddEvent) this.listEvent).getItems().iterator().next());
- }
-
- private void verifyListRemoveEvent(int index, Object item) {
- assertNotNull(this.listEvent);
- assertEquals(this.testModel, this.listEvent.getSource());
- assertEquals(LIST_NAME, this.listEvent.getListName());
- assertEquals(index, ((ListRemoveEvent) this.listEvent).getIndex());
- assertEquals(item, ((ListRemoveEvent) this.listEvent).getItems().iterator().next());
- }
-
- private void verifyListReplaceEvent(int index, Object newItem, Object oldItem) {
- assertNotNull(this.listEvent);
- assertEquals(this.testModel, this.listEvent.getSource());
- assertEquals(LIST_NAME, this.listEvent.getListName());
- assertEquals(index, ((ListReplaceEvent) this.listEvent).getIndex());
- assertEquals(newItem, ((ListReplaceEvent) this.listEvent).getNewItems().iterator().next());
- assertEquals(oldItem, ((ListReplaceEvent) this.listEvent).getOldItems().iterator().next());
- }
-
- private void verifyListMoveEvent(int targetIndex, int sourceIndex) {
- this.verifyListMoveEvent(targetIndex, sourceIndex, 1);
- }
-
- private void verifyListMoveEvent(int targetIndex, int sourceIndex, int length) {
- assertNotNull(this.listEvent);
- assertEquals(this.testModel, this.listEvent.getSource());
- assertEquals(LIST_NAME, this.listEvent.getListName());
- assertEquals(targetIndex, ((ListMoveEvent) this.listEvent).getTargetIndex());
- assertEquals(sourceIndex, ((ListMoveEvent) this.listEvent).getSourceIndex());
- assertEquals(length, ((ListMoveEvent) this.listEvent).getLength());
- }
-
- private void verifyListClearEvent() {
- assertNotNull(this.listEvent);
- assertEquals(this.testModel, this.listEvent.getSource());
- assertEquals(LIST_NAME, this.listEvent.getListName());
- assertEquals(ListClearEvent.class, this.listEvent.getClass());
- }
-
- private void verifyListChangeEvent() {
- assertNotNull(this.listEvent);
- assertEquals(this.testModel, this.listEvent.getSource());
- assertEquals(LIST_NAME, this.listEvent.getListName());
- assertEquals(ListChangeEvent.class, this.listEvent.getClass());
- }
-
-
- // ********** tree change tests **********
-
- public void testFireNodeAddedTree() {
- this.treeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireNodeAddedTree();
- this.verifyTreeEvent(OBJECT_PATH);
- assertTrue(this.nodeAddedCalled);
-
- this.treeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireNodeAddedTree();
- assertNull(this.treeEvent);
- assertFalse(this.nodeAddedCalled);
-
- this.treeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireNodeAddedTree();
- this.verifyTreeEvent(OBJECT_PATH);
- assertTrue(this.nodeAddedCalled);
-
- this.treeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireNodeAddedTree();
- assertNull(this.treeEvent);
- assertFalse(this.nodeAddedCalled);
- }
-
- public void testFireNodeAddedTreeEvent() {
- this.treeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireNodeAddedTreeEvent();
- this.verifyTreeEvent(OBJECT_PATH);
- assertTrue(this.nodeAddedCalled);
-
- this.treeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireNodeAddedTreeEvent();
- assertNull(this.treeEvent);
- assertFalse(this.nodeAddedCalled);
-
- this.treeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireNodeAddedTreeEvent();
- this.verifyTreeEvent(OBJECT_PATH);
- assertTrue(this.nodeAddedCalled);
-
- this.treeEvent = null;
- this.nodeAddedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireNodeAddedTreeEvent();
- assertNull(this.treeEvent);
- assertFalse(this.nodeAddedCalled);
- }
-
- public void testFireNodeRemovedTreeEvent() {
- this.treeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireNodeRemovedTreeEvent();
- this.verifyTreeEvent(OBJECT_PATH);
- assertTrue(this.nodeRemovedCalled);
-
- this.treeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireNodeRemovedTreeEvent();
- assertNull(this.treeEvent);
- assertFalse(this.nodeRemovedCalled);
-
- this.treeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireNodeRemovedTreeEvent();
- this.verifyTreeEvent(OBJECT_PATH);
- assertTrue(this.nodeRemovedCalled);
-
- this.treeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireNodeRemovedTreeEvent();
- assertNull(this.treeEvent);
- assertFalse(this.nodeRemovedCalled);
- }
-
- public void testFireNodeRemovedTree() {
- this.treeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireNodeRemovedTree();
- this.verifyTreeEvent(OBJECT_PATH);
- assertTrue(this.nodeRemovedCalled);
-
- this.treeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireNodeRemovedTree();
- assertNull(this.treeEvent);
- assertFalse(this.nodeRemovedCalled);
-
- this.treeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireNodeRemovedTree();
- this.verifyTreeEvent(OBJECT_PATH);
- assertTrue(this.nodeRemovedCalled);
-
- this.treeEvent = null;
- this.nodeRemovedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireNodeRemovedTree();
- assertNull(this.treeEvent);
- assertFalse(this.nodeRemovedCalled);
- }
-
- public void testFireTreeClearedEvent() {
- this.treeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireTreeClearedEvent();
- this.verifyTreeEvent(null);
- assertTrue(this.treeClearedCalled);
-
- this.treeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireTreeClearedEvent();
- assertNull(this.treeEvent);
- assertFalse(this.treeClearedCalled);
-
- this.treeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireTreeClearedEvent();
- this.verifyTreeEvent(null);
- assertTrue(this.treeClearedCalled);
-
- this.treeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireTreeClearedEvent();
- assertNull(this.treeEvent);
- assertFalse(this.treeClearedCalled);
- }
-
- public void testFireTreeCleared() {
- this.treeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireTreeCleared();
- this.verifyTreeEvent(null);
- assertTrue(this.treeClearedCalled);
-
- this.treeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireTreeCleared();
- assertNull(this.treeEvent);
- assertFalse(this.treeClearedCalled);
-
- this.treeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireTreeCleared();
- this.verifyTreeEvent(null);
- assertTrue(this.treeClearedCalled);
-
- this.treeEvent = null;
- this.treeClearedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireTreeCleared();
- assertNull(this.treeEvent);
- assertFalse(this.treeClearedCalled);
- }
-
- public void testFireTreeChangedEvent() {
- this.treeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireTreeChangedEvent();
- this.verifyTreeEvent(null);
- assertTrue(this.treeChangedCalled);
-
- this.treeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireTreeChangedEvent();
- assertNull(this.treeEvent);
- assertFalse(this.treeChangedCalled);
-
- this.treeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireTreeChangedEvent();
- this.verifyTreeEvent(null);
- assertTrue(this.treeChangedCalled);
-
- this.treeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireTreeChangedEvent();
- assertNull(this.treeEvent);
- assertFalse(this.treeChangedCalled);
- }
-
- public void testFireTreeChanged() {
- this.treeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.addChangeListener(this.changeListener);
- this.testModel.testFireTreeChanged();
- this.verifyTreeEvent(null);
- assertTrue(this.treeChangedCalled);
-
- this.treeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.removeChangeListener(this.changeListener);
- this.testModel.testFireTreeChanged();
- assertNull(this.treeEvent);
- assertFalse(this.treeChangedCalled);
-
- this.treeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.addTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireTreeChanged();
- this.verifyTreeEvent(null);
- assertTrue(this.treeChangedCalled);
-
- this.treeEvent = null;
- this.treeChangedCalled = false;
- this.testModel.removeTreeChangeListener(TREE_NAME, this.changeListener);
- this.testModel.testFireTreeChanged();
- assertNull(this.treeEvent);
- assertFalse(this.treeChangedCalled);
- }
-
- public void testHasAnyTreeChangeListeners() {
- assertTrue(this.testModel.hasNoTreeChangeListeners(TREE_NAME));
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.hasAnyTreeChangeListeners(TREE_NAME));
- this.testModel.removeChangeListener(this.changeListener);
- assertTrue(this.testModel.hasNoTreeChangeListeners(TREE_NAME));
-
- assertTrue(this.testModel.hasNoTreeChangeListeners(TREE_NAME));
- this.testModel.addTreeChangeListener(TREE_NAME, this.changeListener);
- assertTrue(this.testModel.hasAnyTreeChangeListeners(TREE_NAME));
- this.testModel.removeTreeChangeListener(TREE_NAME, this.changeListener);
- assertTrue(this.testModel.hasNoTreeChangeListeners(TREE_NAME));
- }
-
- public void testAddNullTreeListener() {
- boolean exCaught = false;
- try {
- this.testModel.addTreeChangeListener("foo", null);
- } catch (NullPointerException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testRemoveBogusTreeListener() {
- boolean exCaught = false;
- try {
- this.testModel.removeTreeChangeListener("foo", this.changeListener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addPropertyChangeListener("foo", this.changeListener);
- exCaught = false;
- try {
- this.testModel.removeTreeChangeListener("foo", this.changeListener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- this.testModel.addTreeChangeListener("foo", this.changeListener);
- exCaught = false;
- try {
- this.testModel.removeTreeChangeListener("foo", new TreeChangeAdapter());
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
-
- exCaught = false;
- try {
- this.testModel.removeTreeChangeListener("foo", new TreeChangeAdapter());
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- private void verifyTreeEvent(List<?> path) {
- assertNotNull(this.treeEvent);
- assertEquals(this.testModel, this.treeEvent.getSource());
- assertEquals(TREE_NAME, this.treeEvent.getTreeName());
- assertEquals(path, this.getListPath());
- }
-
- private List<?> getListPath() {
- Iterable<?> iterable = this.getPath();
- return (iterable == null) ? null : CollectionTools.list(iterable);
- }
-
- private Iterable<?> getPath() {
- if (this.treeEvent instanceof TreeAddEvent) {
- return ((TreeAddEvent) this.treeEvent).getPath();
- }
- if (this.treeEvent instanceof TreeRemoveEvent) {
- return ((TreeRemoveEvent) this.treeEvent).getPath();
- }
- return null;
- }
-
-
-
- // ********** convenience method tests **********
-
- public void testElementsAreEqual() {
- Collection<String> c1 = new ArrayList<String>();
- c1.add("foo");
- c1.add("bar");
- c1.add("baz");
- Collection<String> c2 = new ArrayList<String>();
- c2.add("foo");
- c2.add("bar");
- c2.add("baz");
- assertTrue(this.testModel.testElementsAreEqual(c1, c2));
- }
-
- public void testElementsAreDifferent() {
- Collection<String> c1 = new ArrayList<String>();
- c1.add("foo");
- c1.add("bar");
- c1.add("baz");
- Collection<String> c2 = new ArrayList<String>();
- c2.add("baz");
- c2.add("bar");
- c2.add("foo");
- assertTrue(this.testModel.testElementsAreDifferent(c1, c2));
- }
-
-
- // ********** AbstractModel tests **********
-
- public void testAbstractModelValuesAreEqual1() {
- assertTrue(this.testModel.testValuesAreEqual(null, null));
- }
-
- public void testAbstractModelValuesAreEqual2() {
- assertTrue(this.testModel.testValuesAreEqual("foo", "foo"));
- }
-
- public void testAbstractModelValuesAreEqual3() {
- assertFalse(this.testModel.testValuesAreEqual("foo", null));
- }
-
- public void testAbstractModelValuesAreEqual4() {
- assertFalse(this.testModel.testValuesAreEqual(null, "foo"));
- }
-
- public void testAbstractModelValuesAreEqual5() {
- assertFalse(this.testModel.testValuesAreEqual("bar", "foo"));
- }
-
- public void testAbstractModelValuesAreDifferent1() {
- assertFalse(this.testModel.testValuesAreDifferent(null, null));
- }
-
- public void testAbstractModelValuesAreDifferent2() {
- assertFalse(this.testModel.testValuesAreDifferent("foo", "foo"));
- }
-
- public void testAbstractModelValuesAreDifferent3() {
- assertTrue(this.testModel.testValuesAreDifferent("foo", null));
- }
-
- public void testAbstractModelValuesAreDifferent4() {
- assertTrue(this.testModel.testValuesAreDifferent(null, "foo"));
- }
-
- public void testAbstractModelValuesAreDifferent5() {
- assertTrue(this.testModel.testValuesAreDifferent("bar", "foo"));
- }
-
- public void testAbstractModelAttributeValueHasChanged1() {
- assertFalse(this.testModel.testAttributeValueHasChanged(null, null));
- }
-
- public void testAbstractModelAttributeValueHasChanged2() {
- assertFalse(this.testModel.testAttributeValueHasChanged("foo", "foo"));
- }
-
- public void testAbstractModelAttributeValueHasChanged3() {
- assertTrue(this.testModel.testAttributeValueHasChanged("foo", null));
- }
-
- public void testAbstractModelAttributeValueHasChanged4() {
- assertTrue(this.testModel.testAttributeValueHasChanged(null, "foo"));
- }
-
- public void testAbstractModelAttributeValueHasChanged5() {
- assertTrue(this.testModel.testAttributeValueHasChanged("bar", "foo"));
- }
-
- public void testAbstractModelAttributeValueHasNotChanged1() {
- assertTrue(this.testModel.testAttributeValueHasNotChanged(null, null));
- }
-
- public void testAbstractModelAttributeValueHasNotChanged2() {
- assertTrue(this.testModel.testAttributeValueHasNotChanged("foo", "foo"));
- }
-
- public void testAbstractModelAttributeValueHasNotChanged3() {
- assertFalse(this.testModel.testAttributeValueHasNotChanged("foo", null));
- }
-
- public void testAbstractModelAttributeValueHasNotChanged4() {
- assertFalse(this.testModel.testAttributeValueHasNotChanged(null, "foo"));
- }
-
- public void testAbstractModelAttributeValueHasNotChanged5() {
- assertFalse(this.testModel.testAttributeValueHasNotChanged("bar", "foo"));
- }
-
- public void testAbstractModelClone() {
- assertFalse(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- this.testModel.addChangeListener(this.changeListener);
- assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
-
- // verify that the clone does not have any listeners
- TestModel clone = this.testModel.clone();
- assertFalse(clone.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- clone.addChangeListener(this.changeListener);
- assertTrue(clone.hasAnyPropertyChangeListeners(PROPERTY_NAME));
- // check original
- assertTrue(this.testModel.hasAnyPropertyChangeListeners(PROPERTY_NAME));
-
- // now test events fired by original
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- this.testModel.testFirePropertyChangedObjectObject();
- this.verifyPropertyChangeEvent(OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
-
- // now test events fired by clone
- this.propertyChangeEvent = null;
- this.propertyChangeCalled = false;
- clone.testFirePropertyChangedObjectObject();
- this.verifyPropertyChangeEvent(clone, OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- assertTrue(this.propertyChangeCalled);
- }
-
- public void testAbstractModelToString() {
- assertTrue(this.testModel.toString().contains('(' + TEST_TO_STRING + ')'));
- }
-
-
- // ********** listener implementations **********
-
- class Adapter implements ChangeListener {
- public void stateChanged(StateChangeEvent e) {
- ChangeSupportTests.this.stateChangedCalled = true;
- ChangeSupportTests.this.stateChangeEvent = e;
- }
-
- public void propertyChanged(PropertyChangeEvent e) {
- ChangeSupportTests.this.propertyChangeCalled = true;
- ChangeSupportTests.this.propertyChangeEvent = e;
- }
-
-
- public void itemsAdded(CollectionAddEvent e) {
- ChangeSupportTests.this.itemsAddedCollectionCalled = true;
- ChangeSupportTests.this.collectionEvent = e;
- }
- public void itemsRemoved(CollectionRemoveEvent e) {
- ChangeSupportTests.this.itemsRemovedCollectionCalled = true;
- ChangeSupportTests.this.collectionEvent = e;
- }
- public void collectionCleared(CollectionClearEvent e) {
- ChangeSupportTests.this.collectionClearedCalled = true;
- ChangeSupportTests.this.collectionEvent = e;
- }
- public void collectionChanged(CollectionChangeEvent e) {
- ChangeSupportTests.this.collectionChangedCalled = true;
- ChangeSupportTests.this.collectionEvent = e;
- }
-
- public void itemsAdded(ListAddEvent e) {
- ChangeSupportTests.this.itemsAddedListCalled = true;
- ChangeSupportTests.this.listEvent = e;
- }
- public void itemsRemoved(ListRemoveEvent e) {
- ChangeSupportTests.this.itemsRemovedListCalled = true;
- ChangeSupportTests.this.listEvent = e;
- }
- public void itemsReplaced(ListReplaceEvent e) {
- ChangeSupportTests.this.itemsReplacedListCalled = true;
- ChangeSupportTests.this.listEvent = e;
- }
- public void itemsMoved(ListMoveEvent e) {
- ChangeSupportTests.this.itemsMovedListCalled = true;
- ChangeSupportTests.this.listEvent = e;
- }
- public void listCleared(ListClearEvent e) {
- ChangeSupportTests.this.listClearedCalled = true;
- ChangeSupportTests.this.listEvent = e;
- }
- public void listChanged(ListChangeEvent e) {
- ChangeSupportTests.this.listChangedCalled = true;
- ChangeSupportTests.this.listEvent = e;
- }
-
- public void nodeAdded(TreeAddEvent e) {
- ChangeSupportTests.this.nodeAddedCalled = true;
- ChangeSupportTests.this.treeEvent = e;
- }
- public void nodeRemoved(TreeRemoveEvent e) {
- ChangeSupportTests.this.nodeRemovedCalled = true;
- ChangeSupportTests.this.treeEvent = e;
- }
- public void treeCleared(TreeClearEvent e) {
- ChangeSupportTests.this.treeClearedCalled = true;
- ChangeSupportTests.this.treeEvent = e;
- }
- public void treeChanged(TreeChangeEvent e) {
- ChangeSupportTests.this.treeChangedCalled = true;
- ChangeSupportTests.this.treeEvent = e;
- }
- }
-
-
- // ********** inner class **********
-
- private static class TestModel extends AbstractModel implements Cloneable {
- TestModel() {
- super();
- }
-
- // ***** state
- public void testFireStateChange() {
- this.fireStateChanged();
- }
-
- // ***** property
- public void testFirePropertyChangedEvent() {
- this.firePropertyChanged(new PropertyChangeEvent(this, PROPERTY_NAME, OLD_OBJECT_VALUE, NEW_OBJECT_VALUE));
- }
-
- public void testFirePropertyChangedEventNoChange() {
- this.firePropertyChanged(new PropertyChangeEvent(this, PROPERTY_NAME, OLD_OBJECT_VALUE, OLD_OBJECT_VALUE));
- }
-
- public void testFirePropertyChangedObjectObject() {
- this.firePropertyChanged(PROPERTY_NAME, OLD_OBJECT_VALUE, NEW_OBJECT_VALUE);
- }
-
- public void testFirePropertyChangedObjectObjectNoChange() {
- this.firePropertyChanged(PROPERTY_NAME, OLD_OBJECT_VALUE, OLD_OBJECT_VALUE);
- }
-
- public void testFirePropertyChangedObject() {
- this.firePropertyChanged(PROPERTY_NAME, NEW_OBJECT_VALUE);
- }
-
- public void testFirePropertyChangedObjectNoChange() {
- this.firePropertyChanged(PROPERTY_NAME, null);
- }
-
- public void testFirePropertyChangedIntInt() {
- this.firePropertyChanged(PROPERTY_NAME, OLD_INT_VALUE.intValue(), NEW_INT_VALUE.intValue());
- }
-
- public void testFirePropertyChangedIntIntNoChange() {
- this.firePropertyChanged(PROPERTY_NAME, OLD_INT_VALUE.intValue(), OLD_INT_VALUE.intValue());
- }
-
- public void testFirePropertyChangedBooleanBoolean() {
- this.firePropertyChanged(PROPERTY_NAME, OLD_BOOLEAN_VALUE.booleanValue(), NEW_BOOLEAN_VALUE.booleanValue());
- }
-
- public void testFirePropertyChangedBooleanBooleanNoChange() {
- this.firePropertyChanged(PROPERTY_NAME, OLD_BOOLEAN_VALUE.booleanValue(), OLD_BOOLEAN_VALUE.booleanValue());
- }
-
- // ***** collection
- public void testFireItemsAddedCollectionEvent() {
- this.fireItemsAdded(new CollectionAddEvent(this, COLLECTION_NAME, ADDED_OBJECT_VALUE));
- }
-
- public void testFireItemsAddedCollectionEventNoChange() {
- this.fireItemsAdded(new CollectionAddEvent(this, COLLECTION_NAME, Collections.emptySet()));
- }
-
- public void testFireItemsAddedCollection() {
- this.fireItemsAdded(COLLECTION_NAME, Collections.singleton(ADDED_OBJECT_VALUE));
- }
-
- public void testFireItemsAddedCollectionNoChange() {
- this.fireItemsAdded(COLLECTION_NAME, Collections.emptySet());
- }
-
- public void testFireItemAddedCollection() {
- this.fireItemAdded(COLLECTION_NAME, ADDED_OBJECT_VALUE);
- }
-
- public void testFireItemsRemovedCollectionEvent() {
- this.fireItemsRemoved(new CollectionRemoveEvent(this, COLLECTION_NAME, REMOVED_OBJECT_VALUE));
- }
-
- public void testFireItemsRemovedCollectionEventNoChange() {
- this.fireItemsRemoved(new CollectionRemoveEvent(this, COLLECTION_NAME, Collections.emptySet()));
- }
-
- public void testFireItemsRemovedCollection() {
- this.fireItemsRemoved(COLLECTION_NAME, Collections.singleton(REMOVED_OBJECT_VALUE));
- }
-
- public void testFireItemsRemovedCollectionNoChange() {
- this.fireItemsRemoved(COLLECTION_NAME, Collections.emptySet());
- }
-
- public void testFireItemRemovedCollection() {
- this.fireItemRemoved(COLLECTION_NAME, REMOVED_OBJECT_VALUE);
- }
-
- public void testFireCollectionCleared() {
- this.fireCollectionCleared(COLLECTION_NAME);
- }
-
- public void testFireCollectionChangedEvent() {
- this.fireCollectionChanged(new CollectionChangeEvent(this, COLLECTION_NAME, Collections.emptySet()));
- }
-
- public void testFireCollectionChanged() {
- this.fireCollectionChanged(COLLECTION_NAME, Collections.emptySet());
- }
-
- public boolean testAddItemToCollection() {
- return this.addItemToCollection(ADDED_OBJECT_VALUE, new ArrayList<Object>(), COLLECTION_NAME);
- }
-
- public boolean testAddItemToCollectionNoChange() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(ADDED_OBJECT_VALUE);
- return this.addItemToCollection(ADDED_OBJECT_VALUE, collection, COLLECTION_NAME);
- }
-
- public boolean testAddItemsToCollection() {
- return this.addItemsToCollection(Collections.singleton(ADDED_OBJECT_VALUE), new ArrayList<Object>(), COLLECTION_NAME);
- }
-
- public boolean testAddItemsToCollectionNoChange() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(ADDED_OBJECT_VALUE);
- return this.addItemsToCollection(Collections.singleton(ADDED_OBJECT_VALUE), collection, COLLECTION_NAME);
- }
-
- public boolean testAddItemsToCollectionMixed() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(ADDED_OBJECT_VALUE);
- return this.addItemsToCollection(new Object[] {ADDED_OBJECT_VALUE, ADDED_OBJECT_VALUE_2}, collection, COLLECTION_NAME);
- }
-
- public boolean testRemoveItemFromCollection() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(REMOVED_OBJECT_VALUE);
- return this.removeItemFromCollection(REMOVED_OBJECT_VALUE, collection, COLLECTION_NAME);
- }
-
- public boolean testRemoveItemFromCollectionNoChange() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(REMOVED_OBJECT_VALUE);
- return this.removeItemFromCollection("foo", collection, COLLECTION_NAME);
- }
-
- public boolean testRemoveItemsFromCollection() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(REMOVED_OBJECT_VALUE);
- collection.add("foo");
- collection.add("bar");
- return this.removeItemsFromCollection(new Object[] {"foo", "bar", REMOVED_OBJECT_VALUE}, collection, COLLECTION_NAME);
- }
-
- public boolean testRemoveItemsFromCollectionNoChange1() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(REMOVED_OBJECT_VALUE);
- return this.removeItemsFromCollection(Collections.emptySet(), collection, COLLECTION_NAME);
- }
-
- public boolean testRemoveItemsFromCollectionNoChange2() {
- Collection<Object> collection = new HashSet<Object>();
- return this.removeItemsFromCollection(Collections.singleton("foo"), collection, COLLECTION_NAME);
- }
-
- public boolean testRemoveItemsFromCollectionNoChange3() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(REMOVED_OBJECT_VALUE);
- return this.removeItemsFromCollection(Collections.singleton("foo"), collection, COLLECTION_NAME);
- }
-
- public boolean testRetainItemsInCollection1() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(REMOVED_OBJECT_VALUE);
- collection.add("foo");
- collection.add("bar");
- return this.retainItemsInCollection(new Object[] {"foo", "bar"}, collection, COLLECTION_NAME);
- }
-
- public boolean testRetainItemsInCollection2() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(REMOVED_OBJECT_VALUE);
- collection.add("foo");
- collection.add("bar");
- return this.retainItemsInCollection(Collections.emptySet(), collection, COLLECTION_NAME);
- }
-
- public boolean testRetainItemsInCollectionNoChange1() {
- Collection<Object> collection = new HashSet<Object>();
- return this.retainItemsInCollection(new Object[] {"foo", "bar"}, collection, COLLECTION_NAME);
- }
-
- public boolean testRetainItemsInCollectionNoChange2() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(REMOVED_OBJECT_VALUE);
- collection.add("foo");
- collection.add("bar");
- return this.retainItemsInCollection(new Object[] {"foo", "bar", REMOVED_OBJECT_VALUE}, collection, COLLECTION_NAME);
- }
-
- public boolean testClearCollection() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add(REMOVED_OBJECT_VALUE);
- collection.add("foo");
- collection.add("bar");
- return this.clearCollection(collection, COLLECTION_NAME);
- }
-
- public boolean testClearCollectionNoChange() {
- Collection<Object> collection = new HashSet<Object>();
- return this.clearCollection(collection, COLLECTION_NAME);
- }
-
- public boolean testSynchronizeCollection1() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add("foo");
- collection.add("bar");
- collection.add("baz");
- Collection<Object> newCollection = new HashSet<Object>();
- newCollection.add("joo");
- newCollection.add("jar");
- newCollection.add("baz");
- boolean result = this.synchronizeCollection(newCollection, collection, COLLECTION_NAME);
- assertEquals(newCollection, collection);
- return result;
- }
-
- public boolean testSynchronizeCollection2() {
- Collection<Object> collection = new HashSet<Object>();
- collection.add("foo");
- collection.add("bar");
- collection.add("baz");
- Collection<Object> newCollection = new HashSet<Object>();
- boolean result = this.synchronizeCollection(newCollection, collection, COLLECTION_NAME);
- assertEquals(newCollection, collection);
- return result;
- }
-
- public boolean testSynchronizeCollection3() {
- Collection<Object> collection = new HashSet<Object>();
- Collection<Object> newCollection = new HashSet<Object>();
- newCollection.add("joo");
- newCollection.add("jar");
- newCollection.add("baz");
- boolean result = this.synchronizeCollection(newCollection, collection, COLLECTION_NAME);
- assertEquals(newCollection, collection);
- return result;
- }
-
- // ***** list
- public void testFireItemsAddedListEvent() {
- this.fireItemsAdded(new ListAddEvent(this, LIST_NAME, ADD_INDEX, ADDED_OBJECT_VALUE));
- }
-
- public void testFireItemsAddedListEventNoChange() {
- this.fireItemsAdded(new ListAddEvent(this, LIST_NAME, ADD_INDEX, Collections.emptyList()));
- }
-
- public void testFireItemsAddedList() {
- this.fireItemsAdded(LIST_NAME, ADD_INDEX, Collections.singletonList(ADDED_OBJECT_VALUE));
- }
-
- public void testFireItemsAddedListNoChange() {
- this.fireItemsAdded(LIST_NAME, ADD_INDEX, Collections.emptyList());
- }
-
- public void testFireItemAddedList() {
- this.fireItemAdded(LIST_NAME, ADD_INDEX, ADDED_OBJECT_VALUE);
- }
-
- public void testFireItemsRemovedListEvent() {
- this.fireItemsRemoved(new ListRemoveEvent(this, LIST_NAME, REMOVE_INDEX, REMOVED_OBJECT_VALUE));
- }
-
- public void testFireItemsRemovedListEventNoChange() {
- this.fireItemsRemoved(new ListRemoveEvent(this, LIST_NAME, REMOVE_INDEX, Collections.emptyList()));
- }
-
- public void testFireItemsRemovedList() {
- this.fireItemsRemoved(LIST_NAME, REMOVE_INDEX, Collections.singletonList(REMOVED_OBJECT_VALUE));
- }
-
- public void testFireItemsRemovedListNoChange() {
- this.fireItemsRemoved(LIST_NAME, REMOVE_INDEX, Collections.emptyList());
- }
-
- public void testFireItemRemovedList() {
- this.fireItemRemoved(LIST_NAME, REMOVE_INDEX, REMOVED_OBJECT_VALUE);
- }
-
- public void testFireItemsReplacedListEvent() {
- this.fireItemsReplaced(new ListReplaceEvent(this, LIST_NAME, REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE));
- }
-
- public void testFireItemsReplacedListEventNoChange() {
- this.fireItemsReplaced(new ListReplaceEvent(this, LIST_NAME, REPLACE_INDEX, Collections.emptyList(), Collections.emptyList()));
- }
-
- public void testFireItemsReplacedList() {
- this.fireItemsReplaced(LIST_NAME, REPLACE_INDEX, Collections.singletonList(ADDED_OBJECT_VALUE), Collections.singletonList(REMOVED_OBJECT_VALUE));
- }
-
- public void testFireItemsReplacedListNoChange() {
- this.fireItemsReplaced(LIST_NAME, REPLACE_INDEX, Collections.emptyList(), Collections.emptyList());
- }
-
- public void testFireItemReplacedList() {
- this.fireItemReplaced(LIST_NAME, REPLACE_INDEX, ADDED_OBJECT_VALUE, REMOVED_OBJECT_VALUE);
- }
-
- public void testFireItemsMovedListEvent() {
- this.fireItemsMoved(new ListMoveEvent(this, LIST_NAME, TARGET_INDEX, SOURCE_INDEX, 1));
- }
-
- public void testFireItemsMovedListEventNoChange() {
- this.fireItemsMoved(new ListMoveEvent(this, LIST_NAME, SOURCE_INDEX, SOURCE_INDEX, 1));
- }
-
- public void testFireItemsMovedList() {
- this.fireItemsMoved(LIST_NAME, TARGET_INDEX, SOURCE_INDEX, 1);
- }
-
- public void testFireItemsMovedListNoChange() {
- this.fireItemsMoved(LIST_NAME, SOURCE_INDEX, SOURCE_INDEX, 1);
- }
-
- public void testFireItemMovedList() {
- this.fireItemMoved(LIST_NAME, TARGET_INDEX, SOURCE_INDEX);
- }
-
- public void testFireListClearedEvent() {
- this.fireListCleared(new ListClearEvent(this, LIST_NAME));
- }
-
- public void testFireListCleared() {
- this.fireListCleared(LIST_NAME);
- }
-
- public void testFireListChangedEvent() {
- this.fireListChanged(new ListChangeEvent(this, LIST_NAME, Collections.emptyList()));
- }
-
- public void testFireListChanged() {
- this.fireListChanged(LIST_NAME, Collections.emptyList());
- }
-
- public void testAddItemToListIndex() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.addItemToList(2, "joo", list, LIST_NAME);
- }
-
- public void testAddItemToList() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.addItemToList("joo", list, LIST_NAME);
- }
-
- public void testAddItemsToListIndex() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.addItemsToList(2, Collections.singletonList("joo"), list, LIST_NAME);
- }
-
- public void testAddItemsToListIndexNoChange() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.addItemsToList(2, Collections.<String>emptyList(), list, LIST_NAME);
- }
-
- public void testAddItemsToList() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.addItemsToList(Collections.singletonList("joo"), list, LIST_NAME);
- }
-
- public void testAddItemsToListNoChange() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.addItemsToList(Collections.<String>emptyList(), list, LIST_NAME);
- }
-
- public void testRemoveItemFromListIndex() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.removeItemFromList(1, list, LIST_NAME);
- }
-
- public void testRemoveItemFromList() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.removeItemFromList("bar", list, LIST_NAME);
- }
-
- public void testRemoveItemsFromListIndex() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.removeItemsFromList(1, 1, list, LIST_NAME);
- }
-
- public void testRemoveItemsFromListIndexNoChange() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.removeItemsFromList(2, 0, list, LIST_NAME);
- }
-
- public void testRemoveItemsFromList() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.removeItemsFromList(Collections.singletonList("bar"), list, LIST_NAME);
- }
-
- public void testRemoveItemsFromListNoChange() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.addItemsToList(Collections.<String>emptyList(), list, LIST_NAME);
- }
-
- public void testRetainItemsInList() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.retainItemsInList(new String[] {"bar", "baz"}, list, LIST_NAME);
- }
-
- public void testReplaceItemInList() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.replaceItemInList("bar", "xxx", list, LIST_NAME);
- }
-
- public void testSetItemsInList() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.setItemsInList(1, new String[] {"xxx"}, list, LIST_NAME);
- }
-
- public void testMoveItemsInList() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- list.add("xxx");
- list.add("yyy");
- list.add("zzz");
- this.moveItemsInList(2, 4, 2, list, LIST_NAME);
- }
-
- public void testClearList() {
- List<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- list.add("baz");
- this.clearList(list, LIST_NAME);
- }
-
- public void testSynchronizeList() {
- List<String> oldList = new ArrayList<String>();
- oldList.add("foo");
- oldList.add("bar");
- oldList.add("baz");
- oldList.add("xxx");
- oldList.add("yyy");
- oldList.add("zzz");
- List<String> newList = new ArrayList<String>();
- newList.add("foo");
- newList.add("ppp");
- newList.add("baz");
- newList.add("xxx");
- newList.add("qqq");
- this.synchronizeList(newList, oldList, LIST_NAME);
- assertEquals(newList, oldList);
- }
-
- // ***** tree
- public void testFireNodeAddedTreeEvent() {
- this.fireNodeAdded(new TreeAddEvent(this, TREE_NAME, OBJECT_PATH));
- }
-
- public void testFireNodeAddedTree() {
- this.fireNodeAdded(TREE_NAME, OBJECT_PATH);
- }
-
- public void testFireNodeRemovedTreeEvent() {
- this.fireNodeRemoved(new TreeRemoveEvent(this, TREE_NAME, OBJECT_PATH));
- }
-
- public void testFireNodeRemovedTree() {
- this.fireNodeRemoved(TREE_NAME, OBJECT_PATH);
- }
-
- public void testFireTreeClearedEvent() {
- this.fireTreeCleared(new TreeClearEvent(this, TREE_NAME));
- }
-
- public void testFireTreeCleared() {
- this.fireTreeCleared(TREE_NAME);
- }
-
- public void testFireTreeChangedEvent() {
- this.fireTreeChanged(new TreeChangeEvent(this, TREE_NAME, OBJECT_PATH));
- }
-
- public void testFireTreeChanged() {
- this.fireTreeChanged(TREE_NAME, OBJECT_PATH);
- }
-
- public boolean testAttributeValueHasChanged(Object value1, Object value2) {
- return this.attributeValueHasChanged(value1, value2);
- }
-
- public boolean testAttributeValueHasNotChanged(Object value1, Object value2) {
- return this.attributeValueHasNotChanged(value1, value2);
- }
-
- // ***** misc
- @Override
- public TestModel clone() {
- try {
- return (TestModel) super.clone();
- } catch (CloneNotSupportedException ex) {
- throw new InternalError();
- }
- }
-
- public boolean testValuesAreDifferent(Object value1, Object value2) {
- return this.valuesAreDifferent(value1, value2);
- }
-
- public boolean testValuesAreEqual(Object value1, Object value2) {
- return this.valuesAreEqual(value1, value2);
- }
-
- public boolean testElementsAreDifferent(Iterable<?> iterable1, Iterable<?> iterable2) {
- return this.getChangeSupport().elementsAreDifferent(iterable1, iterable2);
- }
-
- public boolean testElementsAreEqual(Iterable<?> iterable1, Iterable<?> iterable2) {
- return this.getChangeSupport().elementsAreEqual(iterable1, iterable2);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(TEST_TO_STRING);
- }
-
- }
-
-
- // ********** serialization test **********
- public void testSerialization() throws java.io.IOException, ClassNotFoundException {
- if (Tools.jvmIsSun()) {
- // This test doesn't pass in the Eclipse build environment (Linux/IBM JVM) for some reason
- this.verifySerialization();
- }
- }
-
- private void verifySerialization() throws java.io.IOException, ClassNotFoundException {
- LocalModel model1 = new LocalModel();
- Foo foo1 = new Foo();
- Bar bar1 = new Bar();
- Joo joo1 = new Joo();
- Jar jar1 = new Jar();
- model1.addStateChangeListener(foo1);
- model1.addStateChangeListener(bar1);
- model1.addListChangeListener("foo", joo1);
- model1.addListChangeListener("foo", jar1);
-
- Iterable<EventListener> listeners1 = this.getListeners(model1, StateChangeListener.class, null);
- Object[] listenersArray1 = ArrayTools.array(listeners1);
- assertEquals(2, listenersArray1.length);
- // the order of these could change...
- assertEquals(Foo.class, listenersArray1[0].getClass());
- assertEquals(Bar.class, listenersArray1[1].getClass());
-
- listeners1 = this.getListeners(model1, ListChangeListener.class, "foo");
- listenersArray1 = ArrayTools.array(listeners1);
- assertEquals(2, listenersArray1.length);
- // the order of these could change...
- assertEquals(Joo.class, listenersArray1[0].getClass());
- assertEquals(Jar.class, listenersArray1[1].getClass());
-
- LocalModel model2 = TestTools.serialize(model1);
-
- Iterable<EventListener> listeners2 = this.getListeners(model2, StateChangeListener.class, null);
- Object[] listenersArray2 = ArrayTools.array(listeners2);
- assertEquals(1, listenersArray2.length);
- assertEquals(Foo.class, listenersArray2[0].getClass());
-
- listeners2 = this.getListeners(model2, ListChangeListener.class, "foo");
- listenersArray2 = ArrayTools.array(listeners2);
- assertEquals(1, listenersArray2.length);
- assertEquals(Joo.class, listenersArray2[0].getClass());
- }
-
- private Iterable<EventListener> getListeners(LocalModel model, Class<? extends EventListener> listenerClass, String aspectName) {
- return this.getListenerList(model, listenerClass, aspectName).getListeners();
- }
-
- @SuppressWarnings("unchecked")
- private ListenerList<EventListener> getListenerList(LocalModel model, Class<? extends EventListener> listenerClass, String aspectName) {
- ChangeSupport changeSupport = (ChangeSupport) ReflectionTools.getFieldValue(model, "changeSupport");
- return (ListenerList<EventListener>) ReflectionTools.executeMethod(changeSupport, "getListenerList_", new Class<?>[] {Class.class, String.class}, new Object[] {listenerClass, aspectName});
- }
-
- // we have to manually handle 'changeSupport' since AbstractModel is not Serializable
- private static class LocalModel extends AbstractModel implements Serializable {
- LocalModel() {
- super();
- }
- private synchronized void writeObject(ObjectOutputStream s) throws IOException {
- s.defaultWriteObject();
- s.writeObject(this.changeSupport);
- }
- private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {
- s.defaultReadObject();
- this.changeSupport = (ChangeSupport) s.readObject();
- }
- }
-
- private static class Foo implements Serializable, StateChangeListener {
- Foo() {
- super();
- }
- public void stateChanged(StateChangeEvent event) {
- // do nothing
- }
- }
-
- private static class Bar implements StateChangeListener {
- Bar() {
- super();
- }
- public void stateChanged(StateChangeEvent event) {
- // do nothing
- }
- }
-
- private static class Joo extends ListChangeAdapter implements Serializable {
- Joo() {
- super();
- }
- }
-
- private static class Jar extends ListChangeAdapter {
- Jar() {
- super();
- }
- }
-
-
- // ********** bug(?) test **********
-
- private static final String ISE_MESSAGE = "this object is no longer listening to localA";
-
- /**
- * Test the following situation:
- * - both B and C are listening to A
- * - C is also listening to B
- * - when B receives an event from A, it will fire an event to C
- * - when C receives an event from B, it will STOP listening to A
- * - the event from B to C may be preceded or followed (depending on
- * the hash positions of listeners) by an event from A to C:
- * - if the A to C event comes first, no problem
- * - but if the A to B event comes first, the A to C event should NOT happen
- */
- public void testIndirectRemoveStateListener() {
- this.verifyIndirectRemoveListener(
- new NotifyCommand() {
- public void notifyListeners(LocalA localA) {
- localA.notifyStateListeners();
- }
- }
- );
- }
-
- public void testIndirectRemovePropertyListener() {
- this.verifyIndirectRemoveListener(
- new NotifyCommand() {
- public void notifyListeners(LocalA localA) {
- localA.notifyPropertyListeners();
- }
- }
- );
- }
-
- public void testIndirectRemoveCollectionListener() {
- this.verifyIndirectRemoveListener(
- new NotifyCommand() {
- public void notifyListeners(LocalA localA) {
- localA.notifyCollectionListeners();
- }
- }
- );
- }
-
- public void testIndirectRemoveListListener() {
- this.verifyIndirectRemoveListener(
- new NotifyCommand() {
- public void notifyListeners(LocalA localA) {
- localA.notifyListListeners();
- }
- }
- );
- }
-
- public void testIndirectRemoveTreeListener() {
- this.verifyIndirectRemoveListener(
- new NotifyCommand() {
- public void notifyListeners(LocalA localA) {
- localA.notifyTreeListeners();
- }
- }
- );
- }
-
- public void verifyIndirectRemoveListener(NotifyCommand command) {
- LocalA localA = new LocalA();
- LocalB localB = new LocalB(localA);
-
- // build a bunch of LocalCs so at least one of them is notified AFTER the LocalB;
- // using 1000 seemed to fail very consistently before ChangeSupport was fixed
- LocalC[] localCs = new LocalC[1000];
- for (int i = localCs.length; i-- > 0; ) {
- localCs[i] = new LocalC(localA, localB);
- }
-
- boolean exCaught = false;
- try {
- command.notifyListeners(localA);
- } catch (IllegalStateException ex) {
- if (ex.getMessage() == ISE_MESSAGE) {
- exCaught = true;
- } else {
- throw ex;
- }
- }
- assertFalse(exCaught);
-
- for (int i = localCs.length; i-- > 0; ) {
- assertFalse(localCs[i].isListeningToLocalA());
- }
- }
-
- private interface NotifyCommand {
- void notifyListeners(LocalA localA);
- }
-
- /**
- * This object simply fires a state change event. Both LocalB and LocalC
- * will be listeners.
- */
- private static class LocalA extends AbstractModel {
- LocalA() {
- super();
- }
- void notifyStateListeners() {
- this.fireStateChanged();
- }
- void notifyPropertyListeners() {
- this.firePropertyChanged("foo", 1, 2);
- }
- void notifyCollectionListeners() {
- this.fireCollectionChanged("foo", Collections.emptySet());
- }
- void notifyListListeners() {
- this.fireListChanged("foo", Collections.emptyList());
- }
- void notifyTreeListeners() {
- this.fireTreeChanged("foo", Collections.emptySet());
- }
- }
-
- /**
- * This object will fire state change events whenever it receives
- * a state change event from localA.
- */
- private static class LocalB
- extends AbstractModel
- implements ChangeListener
- {
- LocalB(LocalA localA) {
- super();
- localA.addChangeListener(this);
- }
-
- public void stateChanged(StateChangeEvent e) {
- this.fireStateChanged();
- }
-
- public void propertyChanged(PropertyChangeEvent evt) {
- this.firePropertyChanged("bar", 1, 2);
- }
-
- public void collectionChanged(CollectionChangeEvent e) {
- this.fireCollectionChanged("bar", Collections.emptySet());
- }
- public void collectionCleared(CollectionClearEvent e) {/*ignore*/}
- public void itemsAdded(CollectionAddEvent e) {/*ignore*/}
- public void itemsRemoved(CollectionRemoveEvent e) {/*ignore*/}
-
- public void listChanged(ListChangeEvent e) {
- this.fireListChanged("bar", Collections.emptyList());
- }
- public void listCleared(ListClearEvent e) {/*ignore*/}
- public void itemsAdded(ListAddEvent e) {/*ignore*/}
- public void itemsRemoved(ListRemoveEvent e) {/*ignore*/}
- public void itemsReplaced(ListReplaceEvent e) {/*ignore*/}
- public void itemsMoved(ListMoveEvent e) {/*ignore*/}
-
- public void treeChanged(TreeChangeEvent e) {
- this.fireTreeChanged("bar", Collections.emptySet());
- }
- public void treeCleared(TreeClearEvent e) {/*ignore*/}
- public void nodeAdded(TreeAddEvent e) {/*ignore*/}
- public void nodeRemoved(TreeRemoveEvent e) {/*ignore*/}
-
- }
-
- /**
- * This object will listen to two other objects, localA and localB.
- * If this object receives notification from localB, it will stop listening to
- * localA. If this object receives notification from localA, it will check to
- * see whether it still listening to localA. If this object is no longer
- * listening to localA, it will complain about receiving the event and
- * throw an exception.
- */
- private static class LocalC
- extends AbstractModel
- implements ChangeListener
- {
- private LocalA localA;
- private LocalB localB;
- private boolean listeningToLocalA;
-
- LocalC(LocalA localA, LocalB localB) {
- super();
- this.localA = localA;
- this.localB = localB;
-
- localA.addChangeListener(this);
- this.listeningToLocalA = true;
-
- localB.addChangeListener(this);
- }
- boolean isListeningToLocalA() {
- return this.listeningToLocalA;
- }
-
- public void stateChanged(StateChangeEvent e) {
- Object source = e.getSource();
- if (source == this.localA) {
- if ( ! this.listeningToLocalA) {
- throw new IllegalStateException(ISE_MESSAGE);
- }
- } else if (source == this.localB) {
- this.localA.removeChangeListener(this);
- this.listeningToLocalA = false;
- } else {
- throw new IllegalStateException("bogus event source: " + source);
- }
- }
-
- public void propertyChanged(PropertyChangeEvent e) {
- Object source = e.getSource();
- if (source == this.localA) {
- if ( ! this.listeningToLocalA) {
- throw new IllegalStateException(ISE_MESSAGE);
- }
- } else if (source == this.localB) {
- this.localA.removeChangeListener(this);
- this.listeningToLocalA = false;
- } else {
- throw new IllegalStateException("bogus event source: " + source);
- }
- }
-
- public void collectionChanged(CollectionChangeEvent e) {
- Object source = e.getSource();
- if (source == this.localA) {
- if ( ! this.listeningToLocalA) {
- throw new IllegalStateException(ISE_MESSAGE);
- }
- } else if (source == this.localB) {
- this.localA.removeChangeListener(this);
- this.listeningToLocalA = false;
- } else {
- throw new IllegalStateException("bogus event source: " + source);
- }
- }
- public void collectionCleared(CollectionClearEvent e) {/*ignore*/}
- public void itemsAdded(CollectionAddEvent e) {/*ignore*/}
- public void itemsRemoved(CollectionRemoveEvent e) {/*ignore*/}
-
- public void listChanged(ListChangeEvent e) {
- Object source = e.getSource();
- if (source == this.localA) {
- if ( ! this.listeningToLocalA) {
- throw new IllegalStateException(ISE_MESSAGE);
- }
- } else if (source == this.localB) {
- this.localA.removeChangeListener(this);
- this.listeningToLocalA = false;
- } else {
- throw new IllegalStateException("bogus event source: " + source);
- }
- }
- public void listCleared(ListClearEvent e) {/*ignore*/}
- public void itemsAdded(ListAddEvent e) {/*ignore*/}
- public void itemsRemoved(ListRemoveEvent e) {/*ignore*/}
- public void itemsReplaced(ListReplaceEvent e) {/*ignore*/}
- public void itemsMoved(ListMoveEvent e) {/*ignore*/}
-
- public void treeChanged(TreeChangeEvent e) {
- Object source = e.getSource();
- if (source == this.localA) {
- if ( ! this.listeningToLocalA) {
- throw new IllegalStateException(ISE_MESSAGE);
- }
- } else if (source == this.localB) {
- this.localA.removeChangeListener(this);
- this.listeningToLocalA = false;
- } else {
- throw new IllegalStateException("bogus event source: " + source);
- }
- }
- public void treeCleared(TreeClearEvent e) {/*ignore*/}
- public void nodeAdded(TreeAddEvent e) {/*ignore*/}
- public void nodeRemoved(TreeRemoveEvent e) {/*ignore*/}
-
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/JptUtilityModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/JptUtilityModelTests.java
deleted file mode 100644
index f4f64ef801..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/JptUtilityModelTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.common.utility.tests.internal.model.listener.JptUtilityModelListenerTests;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.JptUtilityModelValueTests;
-
-public class JptUtilityModelTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityModelTests.class.getPackage().getName());
-
- suite.addTest(JptUtilityModelListenerTests.suite());
- suite.addTest(JptUtilityModelValueTests.suite());
-
- suite.addTestSuite(ChangeSupportTests.class);
- suite.addTestSuite(NewEventTests.class);
- suite.addTestSuite(SingleAspectChangeSupportTests.class);
-
- return suite;
- }
-
- private JptUtilityModelTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/NewEventTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/NewEventTests.java
deleted file mode 100644
index 2ce4ac0c49..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/NewEventTests.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model;
-
-import java.util.EventListener;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.ListenerList;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.ChangeEvent;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-/**
- * test what it takes to add a new type of event to
- * model and change support
- */
-public class NewEventTests extends TestCase {
- private Foo foo;
-
- public NewEventTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.foo = new Foo();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testHasNoFooChangeListeners() {
- assertTrue(this.foo.hasNoFooChangeListeners());
- LocalListener listener = new LocalListener();
- this.foo.addFooChangeListener(listener);
- assertFalse(this.foo.hasNoFooChangeListeners());
- this.foo.removeFooChangeListener(listener);
- assertTrue(this.foo.hasNoFooChangeListeners());
- }
-
- public void testHasAnyFooChangeListeners() {
- assertFalse(this.foo.hasAnyFooChangeListeners());
- LocalListener listener = new LocalListener();
- this.foo.addFooChangeListener(listener);
- assertTrue(this.foo.hasAnyFooChangeListeners());
- this.foo.removeFooChangeListener(listener);
- assertFalse(this.foo.hasAnyFooChangeListeners());
- }
-
- public void testFireFooChangeEvent() {
- LocalListener listener = new LocalListener();
- assertFalse(listener.receivedFooEvent);
- this.foo.addFooChangeListener(listener);
- this.foo.foo();
- assertTrue(listener.receivedFooEvent);
- }
-
-
- // ********** harness classes **********
-
- class Foo extends AbstractFooModel {
- Foo() {
- super();
- }
- void foo() {
- this.fireFooChangeEvent();
- }
- }
-
- class LocalListener implements FooChangeListener {
- boolean receivedFooEvent = false;
- LocalListener() {
- super();
- }
- public void fooChanged(FooChangeEvent event) {
- this.receivedFooEvent = true;
- }
- }
-
- interface FooModel extends Model {
- void addFooChangeListener(FooChangeListener listener);
- void removeFooChangeListener(FooChangeListener listener);
- }
-
- interface FooChangeListener extends EventListener {
- void fooChanged(FooChangeEvent event);
- }
-
- static class FooChangeEvent extends ChangeEvent {
- private static final long serialVersionUID = 1L;
- public FooChangeEvent(FooModel source) {
- super(source);
- }
- public FooChangeEvent clone(Model newSource) {
- return new FooChangeEvent((FooModel) newSource);
- }
- }
-
- static class AbstractFooModel extends AbstractModel implements FooModel {
- @Override
- protected synchronized FooChangeSupport getChangeSupport() {
- return (FooChangeSupport) super.getChangeSupport();
- }
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new FooChangeSupport(this);
- }
- public void addFooChangeListener(FooChangeListener listener) {
- this.getChangeSupport().addFooChangeListener(listener);
- }
- public void removeFooChangeListener(FooChangeListener listener) {
- this.getChangeSupport().removeFooChangeListener(listener);
- }
- protected void fireFooChangeEvent() {
- this.getChangeSupport().fireFooChanged();
- }
- public boolean hasAnyFooChangeListeners() {
- return this.getChangeSupport().hasAnyFooChangeListeners();
- }
- public boolean hasNoFooChangeListeners() {
- return ! this.hasAnyFooChangeListeners();
- }
- }
-
- static class FooChangeSupport extends ChangeSupport {
- FooChangeSupport(FooModel source) {
- super(source);
- }
- protected static final Class<FooChangeListener> FOO_CHANGE_LISTENER_CLASS = FooChangeListener.class;
- void addFooChangeListener(FooChangeListener listener) {
- this.addListener(FOO_CHANGE_LISTENER_CLASS, listener);
- }
- void removeFooChangeListener(FooChangeListener listener) {
- this.removeListener(FOO_CHANGE_LISTENER_CLASS, listener);
- }
- public boolean hasAnyFooChangeListeners() {
- return this.hasAnyListeners(FOO_CHANGE_LISTENER_CLASS);
- }
- private ListenerList<FooChangeListener> getFooChangeListenerList() {
- return this.getListenerList(FOO_CHANGE_LISTENER_CLASS);
- }
- private Iterable<FooChangeListener> getFooChangeListeners() {
- ListenerList<FooChangeListener> listenerList = this.getFooChangeListenerList();
- return (listenerList == null) ? null : listenerList.getListeners();
- }
- private boolean hasFooChangeListener(FooChangeListener listener) {
- return CollectionTools.contains(this.getFooChangeListeners(), listener);
- }
- public void fireFooChanged() {
- Iterable<FooChangeListener> listeners = this.getFooChangeListeners();
- if (listeners != null) {
- FooChangeEvent event = null;
- for (FooChangeListener listener : listeners) {
- if (this.hasFooChangeListener(listener)) {
- if (event == null) {
- // here's the reason for the duplicate code...
- event = new FooChangeEvent((FooModel) this.source);
- }
- listener.fooChanged(event);
- }
- }
- }
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/SingleAspectChangeSupportTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/SingleAspectChangeSupportTests.java
deleted file mode 100644
index a0dae05267..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/SingleAspectChangeSupportTests.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.ChangeSupport;
-import org.eclipse.jpt.common.utility.internal.model.SingleAspectChangeSupport;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.TreeChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.TreeChangeListener;
-
-@SuppressWarnings("nls")
-public class SingleAspectChangeSupportTests extends TestCase {
-
- public SingleAspectChangeSupportTests(String name) {
- super(name);
- }
-
- public void testAddPropertyChangeListenerInvalidClass() {
- Model model = new StateTestModel();
- boolean exCaught = false;
- PropertyChangeListener listener = new PropertyChangeAdapter();
- try {
- model.addPropertyChangeListener("foo", listener);
- fail("bogus listener: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddPropertyChangeListenerInvalidAspect() {
- Model model = new PropertyTestModel();
- boolean exCaught = false;
- PropertyChangeListener listener = new PropertyChangeAdapter();
- try {
- model.addPropertyChangeListener("bar", listener);
- fail("bogus listener: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddCollectionChangeListenerInvalidClass() {
- Model model = new StateTestModel();
- boolean exCaught = false;
- CollectionChangeListener listener = new CollectionChangeAdapter();
- try {
- model.addCollectionChangeListener("foo", listener);
- fail("bogus listener: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddCollectionChangeListenerInvalidAspect() {
- Model model = new CollectionTestModel();
- boolean exCaught = false;
- CollectionChangeListener listener = new CollectionChangeAdapter();
- try {
- model.addCollectionChangeListener("bar", listener);
- fail("bogus listener: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddListChangeListenerInvalidClass() {
- Model model = new StateTestModel();
- boolean exCaught = false;
- ListChangeListener listener = new ListChangeAdapter();
- try {
- model.addListChangeListener("foo", listener);
- fail("bogus listener: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddListChangeListenerInvalidAspect() {
- Model model = new ListTestModel();
- boolean exCaught = false;
- ListChangeListener listener = new ListChangeAdapter();
- try {
- model.addListChangeListener("bar", listener);
- fail("bogus listener: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddTreeChangeListenerInvalidClass() {
- Model model = new StateTestModel();
- boolean exCaught = false;
- TreeChangeListener listener = new TreeChangeAdapter();
- try {
- model.addTreeChangeListener("foo", listener);
- fail("bogus listener: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testAddTreeChangeListenerInvalidAspect() {
- Model model = new TreeTestModel();
- boolean exCaught = false;
- TreeChangeListener listener = new TreeChangeAdapter();
- try {
- model.addTreeChangeListener("bar", listener);
- fail("bogus listener: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- // ********** test models **********
-
- static class StateTestModel extends AbstractModel {
- StateTestModel() {
- super();
- }
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, StateChangeListener.class, null);
- }
- }
-
- static class PropertyTestModel extends AbstractModel {
- PropertyTestModel() {
- super();
- }
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, PropertyChangeListener.class, "foo");
- }
- }
-
- static class CollectionTestModel extends AbstractModel {
- CollectionTestModel() {
- super();
- }
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, CollectionChangeListener.class, "foo");
- }
- }
-
- static class ListTestModel extends AbstractModel {
- ListTestModel() {
- super();
- }
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, ListChangeListener.class, "foo");
- }
- }
-
- static class TreeTestModel extends AbstractModel {
- TreeTestModel() {
- super();
- }
- @Override
- protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, TreeChangeListener.class, "foo");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/JptUtilityModelListenerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/JptUtilityModelListenerTests.java
deleted file mode 100644
index 1de3f75c49..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/JptUtilityModelListenerTests.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.listener;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptUtilityModelListenerTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityModelListenerTests.class.getPackage().getName());
-
- suite.addTestSuite(ReflectiveCollectionChangeListenerTests.class);
- suite.addTestSuite(ReflectiveListChangeListenerTests.class);
- suite.addTestSuite(ReflectivePropertyChangeListenerTests.class);
- suite.addTestSuite(ReflectiveStateChangeListenerTests.class);
- suite.addTestSuite(ReflectiveTreeChangeListenerTests.class);
-
- return suite;
- }
-
- private JptUtilityModelListenerTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java
deleted file mode 100644
index 96ae5c351a..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveCollectionChangeListenerTests.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.listener;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ReflectiveChangeListener;
-
-@SuppressWarnings("nls")
-public class ReflectiveCollectionChangeListenerTests extends TestCase {
-
- public ReflectiveCollectionChangeListenerTests(String name) {
- super(name);
- }
-
- private CollectionChangeListener buildZeroArgumentListener(Object target) {
- return ReflectiveChangeListener.buildCollectionChangeListener(target, "itemAddedZeroArgument", "itemRemovedZeroArgument", "collectionClearedZeroArgument", "collectionChangedZeroArgument");
- }
-
- private CollectionChangeListener buildSingleArgumentListener(Object target) {
- return ReflectiveChangeListener.buildCollectionChangeListener(target, "itemAddedSingleArgument", "itemRemovedSingleArgument", "collectionClearedSingleArgument", "collectionChangedSingleArgument");
- }
-
- public void testItemAddedZeroArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildZeroArgumentListener(target));
- testModel.addString(string);
- assertTrue(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testItemAddedSingleArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildSingleArgumentListener(target));
- testModel.addString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertTrue(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedZeroArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildZeroArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertTrue(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedSingleArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildSingleArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertTrue(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionClearedZeroArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildZeroArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertTrue(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionClearedSingleArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildSingleArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertTrue(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionChangedZeroArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildZeroArgumentListener(target));
- testModel.replaceStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertTrue(target.collectionChangedZeroArgumentFlag);
- assertFalse(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testCollectionChangedSingleArgumentNamedCollection() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- testModel.addCollectionChangeListener(TestModel.STRINGS_COLLECTION, this.buildSingleArgumentListener(target));
- testModel.replaceStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.collectionClearedZeroArgumentFlag);
- assertFalse(target.collectionClearedSingleArgumentFlag);
- assertFalse(target.collectionChangedZeroArgumentFlag);
- assertTrue(target.collectionChangedSingleArgumentFlag);
- }
-
- public void testBogusDoubleArgument1() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- boolean exCaught = false;
- try {
- CollectionChangeListener listener = ReflectiveChangeListener.buildCollectionChangeListener(target, "collectionChangedDoubleArgument");
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getCause().getClass() == NoSuchMethodException.class) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument2() throws Exception {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- Method method = ReflectionTools.getMethod(target, "collectionChangedDoubleArgument", new Class[] {CollectionChangeEvent.class, Object.class});
- boolean exCaught = false;
- try {
- CollectionChangeListener listener = ReflectiveChangeListener.buildCollectionChangeListener(target, method);
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getMessage().equals(method.toString())) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testListenerMismatch() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_COLLECTION, string);
- // build a COLLECTION change listener and hack it so we
- // can add it as a LIST change listener
- Object listener = ReflectiveChangeListener.buildCollectionChangeListener(target, "collectionEventSingleArgument");
- testModel.addListChangeListener("bogus list", (ListChangeListener) listener);
-
- boolean exCaught = false;
- try {
- testModel.changeList();
- fail("listener mismatch: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- class TestModel extends AbstractModel {
- private Collection<String> strings = new ArrayList<String>();
- public static final String STRINGS_COLLECTION = "strings";
- TestModel() {
- super();
- }
- Iterator<String> strings() {
- return new CloneIterator<String>(this.strings) {
- @Override
- protected void remove(String s) {
- TestModel.this.removeString(s);
- }
- };
- }
- void addString(String string) {
- this.addItemToCollection(string, this.strings, STRINGS_COLLECTION);
- }
- void removeString(String string) {
- this.removeItemFromCollection(string, this.strings, STRINGS_COLLECTION);
- }
- void clearStrings() {
- this.clearCollection(this.strings, STRINGS_COLLECTION);
- }
- void replaceStrings(String[] newStrings) {
- this.strings.clear();
- CollectionTools.addAll(this.strings, newStrings);
- this.fireCollectionChanged(STRINGS_COLLECTION, this.strings);
- }
- void changeList() {
- this.fireListChanged("bogus list", Collections.emptyList());
- }
- }
-
- class Target {
- TestModel testModel;
- String collectionName;
- String string;
- boolean itemAddedZeroArgumentFlag = false;
- boolean itemAddedSingleArgumentFlag = false;
- boolean itemRemovedZeroArgumentFlag = false;
- boolean itemRemovedSingleArgumentFlag = false;
- boolean collectionClearedZeroArgumentFlag = false;
- boolean collectionClearedSingleArgumentFlag = false;
- boolean collectionChangedZeroArgumentFlag = false;
- boolean collectionChangedSingleArgumentFlag = false;
- boolean collectionEventSingleArgumentFlag = false;
- Target(TestModel testModel, String collectionName, String string) {
- super();
- this.testModel = testModel;
- this.collectionName = collectionName;
- this.string = string;
- }
- void itemAddedZeroArgument() {
- this.itemAddedZeroArgumentFlag = true;
- }
- void itemAddedSingleArgument(CollectionAddEvent e) {
- this.itemAddedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.collectionName, e.getCollectionName());
- assertEquals(this.string, e.getItems().iterator().next());
- }
- void itemRemovedZeroArgument() {
- this.itemRemovedZeroArgumentFlag = true;
- }
- void itemRemovedSingleArgument(CollectionRemoveEvent e) {
- this.itemRemovedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.collectionName, e.getCollectionName());
- assertEquals(this.string, e.getItems().iterator().next());
- }
- void collectionClearedZeroArgument() {
- this.collectionClearedZeroArgumentFlag = true;
- }
- void collectionClearedSingleArgument(CollectionClearEvent e) {
- this.collectionClearedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.collectionName, e.getCollectionName());
- }
- void collectionChangedZeroArgument() {
- this.collectionChangedZeroArgumentFlag = true;
- }
- void collectionChangedSingleArgument(CollectionChangeEvent e) {
- this.collectionChangedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.collectionName, e.getCollectionName());
- }
- void collectionEventSingleArgument(CollectionEvent e) {
- this.collectionEventSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.collectionName, e.getCollectionName());
- }
- void collectionChangedDoubleArgument(CollectionChangeEvent e, Object o) {
- fail("bogus event: " + e + " object: " + o);
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java
deleted file mode 100644
index 34f6c9b49f..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveListChangeListenerTests.java
+++ /dev/null
@@ -1,498 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.listener;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.ListIterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ReflectiveChangeListener;
-
-@SuppressWarnings("nls")
-public class ReflectiveListChangeListenerTests extends TestCase {
-
- public ReflectiveListChangeListenerTests(String name) {
- super(name);
- }
-
- private ListChangeListener buildZeroArgumentListener(Object target) {
- return ReflectiveChangeListener.buildListChangeListener(target, "itemAddedZeroArgument", "itemRemovedZeroArgument", "itemReplacedZeroArgument", "itemMovedZeroArgument", "listClearedZeroArgument", "listChangedZeroArgument");
- }
-
- private ListChangeListener buildSingleArgumentListener(Object target) {
- return ReflectiveChangeListener.buildListChangeListener(target, "itemAddedSingleArgument", "itemRemovedSingleArgument", "itemReplacedSingleArgument", "itemMovedSingleArgument", "listClearedSingleArgument", "listChangedSingleArgument");
- }
-
- public void testItemAddedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.addString(string);
- assertTrue(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemAddedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.addString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertTrue(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertTrue(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemRemovedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.removeString(string);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertTrue(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemReplacedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- String oldString = "foo";
- String newString = "bar";
- testModel.addString(oldString);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, newString, 0, oldString);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.replaceString(oldString, newString);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertTrue(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemReplacedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- String oldString = "foo";
- String newString = "bar";
- testModel.addString(oldString);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, newString, 0, oldString);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.replaceString(oldString, newString);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertTrue(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemMovedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- testModel.addString("zero");
- testModel.addString("one");
- testModel.addString("two");
- testModel.addString("three");
- Target target = new Target(testModel, TestModel.STRINGS_LIST, 0, 2);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.moveString(0, 2);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertTrue(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testItemMovedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- testModel.addString("zero");
- testModel.addString("one");
- testModel.addString("two");
- testModel.addString("three");
- Target target = new Target(testModel, TestModel.STRINGS_LIST, 0, 2);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.moveString(0, 2);
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertTrue(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testListClearedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertTrue(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testListClearedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.clearStrings();
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertTrue(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testListChangedZeroArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildZeroArgumentListener(target));
- testModel.replaceAllStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertTrue(target.listChangedZeroArgumentFlag);
- assertFalse(target.listChangedSingleArgumentFlag);
- }
-
- public void testListChangedSingleArgumentNamedList() {
- TestModel testModel = new TestModel();
- String string = "foo";
- testModel.addString(string);
- Target target = new Target(testModel, TestModel.STRINGS_LIST, null, -1);
- testModel.addListChangeListener(TestModel.STRINGS_LIST, this.buildSingleArgumentListener(target));
- testModel.replaceAllStrings(new String[] {"bar", "baz"});
- assertFalse(target.itemAddedZeroArgumentFlag);
- assertFalse(target.itemAddedSingleArgumentFlag);
- assertFalse(target.itemRemovedZeroArgumentFlag);
- assertFalse(target.itemRemovedSingleArgumentFlag);
- assertFalse(target.itemReplacedZeroArgumentFlag);
- assertFalse(target.itemReplacedSingleArgumentFlag);
- assertFalse(target.itemMovedZeroArgumentFlag);
- assertFalse(target.itemMovedSingleArgumentFlag);
- assertFalse(target.listClearedZeroArgumentFlag);
- assertFalse(target.listClearedSingleArgumentFlag);
- assertFalse(target.listChangedZeroArgumentFlag);
- assertTrue(target.listChangedSingleArgumentFlag);
- }
-
- public void testBogusDoubleArgument1() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- boolean exCaught = false;
- try {
- ListChangeListener listener = ReflectiveChangeListener.buildListChangeListener(target, "listChangedDoubleArgument");
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getCause().getClass() == NoSuchMethodException.class) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument2() throws Exception {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- Method method = ReflectionTools.getMethod(target, "listChangedDoubleArgument", new Class[] {ListChangeEvent.class, Object.class});
- boolean exCaught = false;
- try {
- ListChangeListener listener = ReflectiveChangeListener.buildListChangeListener(target, method);
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getMessage().equals(method.toString())) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testListenerMismatch() {
- TestModel testModel = new TestModel();
- String string = "foo";
- Target target = new Target(testModel, TestModel.STRINGS_LIST, string, 0);
- // build a LIST change listener and hack it so we
- // can add it as a COLLECTION change listener
- Object listener = ReflectiveChangeListener.buildListChangeListener(target, "listEventSingleArgument");
- testModel.addCollectionChangeListener("bogus collection", (CollectionChangeListener) listener);
-
- boolean exCaught = false;
- try {
- testModel.changeCollection();
- fail("listener mismatch: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- class TestModel extends AbstractModel {
- private List<String> strings = new ArrayList<String>();
- public static final String STRINGS_LIST = "strings";
- TestModel() {
- super();
- }
- ListIterator<String> strings() {
- return new CloneListIterator<String>(this.strings);
- }
- void addString(String string) {
- this.addItemToList(string, this.strings, STRINGS_LIST);
- }
- void removeString(String string) {
- this.removeItemFromList(this.strings.indexOf(string), this.strings, STRINGS_LIST);
- }
- void replaceString(String oldString, String newString) {
- this.setItemInList(this.strings.indexOf(oldString), newString, this.strings, STRINGS_LIST);
- }
- void moveString(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.strings, STRINGS_LIST);
- }
- void clearStrings() {
- this.clearList(this.strings, STRINGS_LIST);
- }
- void replaceAllStrings(String[] newStrings) {
- this.strings.clear();
- CollectionTools.addAll(this.strings, newStrings);
- this.fireListChanged(STRINGS_LIST, this.strings);
- }
- void changeCollection() {
- this.fireCollectionChanged("bogus collection", Collections.emptySet());
- }
- }
-
- class Target {
- TestModel testModel;
- String listName;
- String string;
- int index;
- String replacedString;
- int sourceIndex;
- boolean itemAddedZeroArgumentFlag = false;
- boolean itemAddedSingleArgumentFlag = false;
- boolean itemRemovedZeroArgumentFlag = false;
- boolean itemRemovedSingleArgumentFlag = false;
- boolean itemReplacedZeroArgumentFlag = false;
- boolean itemReplacedSingleArgumentFlag = false;
- boolean itemMovedZeroArgumentFlag = false;
- boolean itemMovedSingleArgumentFlag = false;
- boolean listClearedZeroArgumentFlag = false;
- boolean listClearedSingleArgumentFlag = false;
- boolean listChangedZeroArgumentFlag = false;
- boolean listChangedSingleArgumentFlag = false;
- boolean listEventSingleArgumentFlag = false;
- Target(TestModel testModel, String listName, String string, int index) {
- super();
- this.testModel = testModel;
- this.listName = listName;
- this.string = string;
- this.index = index;
- }
- Target(TestModel testModel, String listName, String string, int index, String replacedString) {
- this(testModel, listName, string, index);
- this.replacedString = replacedString;
- }
- Target(TestModel testModel, String listName, int targetIndex, int sourceIndex) {
- super();
- this.testModel = testModel;
- this.listName = listName;
- this.index = targetIndex;
- this.sourceIndex = sourceIndex;
- }
- void itemAddedZeroArgument() {
- this.itemAddedZeroArgumentFlag = true;
- }
- void itemAddedSingleArgument(ListAddEvent e) {
- this.itemAddedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- assertEquals(this.string, e.getItems().iterator().next());
- assertEquals(this.index, e.getIndex());
- }
- void itemRemovedZeroArgument() {
- this.itemRemovedZeroArgumentFlag = true;
- }
- void itemRemovedSingleArgument(ListRemoveEvent e) {
- this.itemRemovedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- assertEquals(this.string, e.getItems().iterator().next());
- assertEquals(this.index, e.getIndex());
- }
- void itemReplacedZeroArgument() {
- this.itemReplacedZeroArgumentFlag = true;
- }
- void itemReplacedSingleArgument(ListReplaceEvent e) {
- this.itemReplacedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- assertEquals(this.string, e.getNewItems().iterator().next());
- assertEquals(this.replacedString, e.getOldItems().iterator().next());
- assertEquals(this.index, e.getIndex());
- }
- void itemMovedZeroArgument() {
- this.itemMovedZeroArgumentFlag = true;
- }
- void itemMovedSingleArgument(ListMoveEvent e) {
- this.itemMovedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- assertEquals(this.index, e.getTargetIndex());
- assertEquals(this.sourceIndex, e.getSourceIndex());
- }
- void listChangedZeroArgument() {
- this.listChangedZeroArgumentFlag = true;
- }
- void listClearedSingleArgument(ListClearEvent e) {
- this.listClearedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- }
- void listClearedZeroArgument() {
- this.listClearedZeroArgumentFlag = true;
- }
- void listChangedSingleArgument(ListChangeEvent e) {
- this.listChangedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- }
- void listChangedDoubleArgument(ListChangeEvent e, Object o) {
- fail("bogus event: " + e + " - object: " + o);
- }
- void listEventSingleArgument(ListEvent e) {
- this.listEventSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.listName, e.getListName());
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java
deleted file mode 100644
index 9b27d57fcb..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectivePropertyChangeListenerTests.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.listener;
-
-import java.lang.reflect.Method;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ReflectiveChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-
-@SuppressWarnings("nls")
-public class ReflectivePropertyChangeListenerTests extends TestCase {
-
- public ReflectivePropertyChangeListenerTests(String name) {
- super(name);
- }
-
- public void testZeroArgumentNamedProperty() {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- testModel.addPropertyChangeListener(TestModel.VALUE_PROPERTY, ReflectiveChangeListener.buildPropertyChangeListener(target, "propertyChangedZeroArgument"));
- testModel.setValue(99);
- assertTrue(target.zeroArgumentFlag);
- assertFalse(target.singleArgumentFlag);
- }
-
- /**
- * test method that has more general method parameter type
- */
- public void testSingleArgument2() throws Exception {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- Method method = ReflectionTools.getMethod(target, "propertyChangedSingleArgument2", new Class[] {Object.class});
- testModel.addPropertyChangeListener(TestModel.VALUE_PROPERTY, ReflectiveChangeListener.buildPropertyChangeListener(target, method));
- testModel.setValue(99);
- assertFalse(target.zeroArgumentFlag);
- assertTrue(target.singleArgumentFlag);
- }
-
- public void testSingleArgumentNamedProperty() {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- testModel.addPropertyChangeListener(TestModel.VALUE_PROPERTY, ReflectiveChangeListener.buildPropertyChangeListener(target, "propertyChangedSingleArgument"));
- testModel.setValue(99);
- assertFalse(target.zeroArgumentFlag);
- assertTrue(target.singleArgumentFlag);
- }
-
- /**
- * test method that has more general method parameter type
- */
- public void testSingleArgumentNamedProperty2() throws Exception {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- Method method = ReflectionTools.getMethod(target, "propertyChangedSingleArgument2", new Class[] {Object.class});
- testModel.addPropertyChangeListener(TestModel.VALUE_PROPERTY, ReflectiveChangeListener.buildPropertyChangeListener(target, method));
- testModel.setValue(99);
- assertFalse(target.zeroArgumentFlag);
- assertTrue(target.singleArgumentFlag);
- }
-
- public void testListenerMismatch() {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- // build a PROPERTY change listener and hack it so we
- // can add it as a STATE change listener
- Object listener = ReflectiveChangeListener.buildPropertyChangeListener(target, "propertyChangedSingleArgument");
- testModel.addStateChangeListener((StateChangeListener) listener);
-
- boolean exCaught = false;
- try {
- testModel.setValue(99);
- fail("listener mismatch: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument1() {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- boolean exCaught = false;
- try {
- PropertyChangeListener listener = ReflectiveChangeListener.buildPropertyChangeListener(target, "stateChangedDoubleArgument");
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getCause().getClass() == NoSuchMethodException.class) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument2() throws Exception {
- TestModel testModel = new TestModel(7);
- Target target = new Target(testModel, TestModel.VALUE_PROPERTY, 7, 99);
- Method method = ReflectionTools.getMethod(target, "propertyChangedDoubleArgument", new Class[] {PropertyChangeEvent.class, Object.class});
- boolean exCaught = false;
- try {
- PropertyChangeListener listener = ReflectiveChangeListener.buildPropertyChangeListener(target, method);
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getMessage().equals(method.toString())) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
-
- class TestModel extends AbstractModel {
- private int value = 0;
- public static final String VALUE_PROPERTY = "value";
- TestModel(int value) {
- super();
- this.value = value;
- }
- void setValue(int value) {
- int old = this.value;
- this.value = value;
- this.firePropertyChanged(VALUE_PROPERTY, old, value);
- if (old != value) {
- this.fireStateChanged();
- }
- }
- }
-
- class Target {
- TestModel testModel;
- String propertyName;
- Object oldValue;
- Object newValue;
- boolean zeroArgumentFlag = false;
- boolean singleArgumentFlag = false;
- Target(TestModel testModel, String propertyName, int oldValue, int newValue) {
- super();
- this.testModel = testModel;
- this.propertyName = propertyName;
- this.oldValue = new Integer(oldValue);
- this.newValue = new Integer(newValue);
- }
- void propertyChangedZeroArgument() {
- this.zeroArgumentFlag = true;
- }
- void propertyChangedSingleArgument(PropertyChangeEvent e) {
- this.singleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.propertyName, e.getPropertyName());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- }
- void propertyChangedSingleArgument2(Object o) {
- PropertyChangeEvent e = (PropertyChangeEvent) o;
- this.singleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.propertyName, e.getPropertyName());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- }
- void propertyChangedDoubleArgument(PropertyChangeEvent e, Object o) {
- fail("bogus event: " + e + " - object: " + o);
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java
deleted file mode 100644
index 9a799e37db..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveStateChangeListenerTests.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.listener;
-
-import java.lang.reflect.Method;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ReflectiveChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-
-@SuppressWarnings("nls")
-public class ReflectiveStateChangeListenerTests extends TestCase {
-
- public ReflectiveStateChangeListenerTests(String name) {
- super(name);
- }
-
- public void testZeroArgument() {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- testModel.addStateChangeListener(ReflectiveChangeListener.buildStateChangeListener(target, "stateChangedZeroArgument"));
- testModel.changeState();
- assertTrue(target.zeroArgumentFlag);
- assertFalse(target.singleArgumentFlag);
- }
-
- public void testSingleArgument() {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- testModel.addStateChangeListener(ReflectiveChangeListener.buildStateChangeListener(target, "stateChangedSingleArgument"));
- testModel.changeState();
- assertFalse(target.zeroArgumentFlag);
- assertTrue(target.singleArgumentFlag);
- }
-
- /**
- * test method that has more general method parameter type
- */
- public void testSingleArgument2() throws Exception {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- Method method = ReflectionTools.getMethod(target, "stateChangedSingleArgument2", new Class[] {Object.class});
- testModel.addStateChangeListener(ReflectiveChangeListener.buildStateChangeListener(target, method));
- testModel.changeState();
- assertFalse(target.zeroArgumentFlag);
- assertTrue(target.singleArgumentFlag);
- }
-
- public void testListenerMismatch() {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- // build a STATE change listener and hack it so we
- // can add it as a PROPERTY change listener
- Object listener = ReflectiveChangeListener.buildStateChangeListener(target, "stateChangedSingleArgument");
- testModel.addPropertyChangeListener("value", (PropertyChangeListener) listener);
-
- boolean exCaught = false;
- try {
- testModel.changeProperty();
- fail("listener mismatch: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument1() {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- boolean exCaught = false;
- try {
- StateChangeListener listener = ReflectiveChangeListener.buildStateChangeListener(target, "stateChangedDoubleArgument");
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getCause().getClass() == NoSuchMethodException.class) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
- public void testBogusDoubleArgument2() throws Exception {
- TestModel testModel = new TestModel();
- Target target = new Target(testModel);
- Method method = ReflectionTools.getMethod(target, "stateChangedDoubleArgument", new Class[] {StateChangeEvent.class, Object.class});
- boolean exCaught = false;
- try {
- StateChangeListener listener = ReflectiveChangeListener.buildStateChangeListener(target, method);
- fail("bogus listener: " + listener);
- } catch (RuntimeException ex) {
- if (ex.getMessage().equals(method.toString())) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- }
-
-
- class TestModel extends AbstractModel {
- TestModel() {
- super();
- }
- void changeState() {
- this.fireStateChanged();
- }
- void changeProperty() {
- this.firePropertyChanged("value", 55, 42);
- }
- }
-
- class Target {
- TestModel testModel;
- boolean zeroArgumentFlag = false;
- boolean singleArgumentFlag = false;
- Target(TestModel testModel) {
- super();
- this.testModel = testModel;
- }
- void stateChangedZeroArgument() {
- this.zeroArgumentFlag = true;
- }
- void stateChangedSingleArgument(StateChangeEvent e) {
- this.singleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- }
- void stateChangedSingleArgument2(Object e) {
- this.singleArgumentFlag = true;
- assertSame(this.testModel, ((StateChangeEvent) e).getSource());
- }
- void stateChangedDoubleArgument(StateChangeEvent e, Object o) {
- fail("bogus event: " + e + " - object: " + o);
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveTreeChangeListenerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveTreeChangeListenerTests.java
deleted file mode 100644
index e6dbfe7253..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/listener/ReflectiveTreeChangeListenerTests.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.listener;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.model.event.TreeAddEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeClearEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeEvent;
-import org.eclipse.jpt.common.utility.model.event.TreeRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ReflectiveChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.TreeChangeListener;
-
-@SuppressWarnings("nls")
-public class ReflectiveTreeChangeListenerTests extends TestCase {
-
- public ReflectiveTreeChangeListenerTests(String name) {
- super(name);
- }
-
- private TreeChangeListener buildZeroArgumentListener(Object target) {
- return ReflectiveChangeListener.buildTreeChangeListener(target, "nodeAddedZeroArgument", "nodeRemovedZeroArgument", "treeClearedZeroArgument", "treeChangedZeroArgument");
- }
-
- private TreeChangeListener buildSingleArgumentListener(Object target) {
- return ReflectiveChangeListener.buildTreeChangeListener(target, "nodeAddedSingleArgument", "nodeRemovedSingleArgument", "treeClearedSingleArgument", "treeChangedSingleArgument");
- }
-
- public void testNodeAddedZeroArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildZeroArgumentListener(target));
- testModel.addNode("root", "child");
- assertTrue(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testNodeAddedSingleArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildSingleArgumentListener(target));
- testModel.addNode("root", "child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertTrue(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testNodeRemovedZeroArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildZeroArgumentListener(target));
- testModel.removeNode("child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertTrue(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testNodeRemovedSingleArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildSingleArgumentListener(target));
- testModel.removeNode("child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertTrue(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeClearedZeroArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- testModel.addNode("child", "grandchild");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[0]);
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildZeroArgumentListener(target));
- testModel.clearTree();
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertTrue(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeClearedSingleArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- testModel.addNode("child", "grandchild");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[0]);
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildSingleArgumentListener(target));
- testModel.clearTree();
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertTrue(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeChangedZeroArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "another child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildZeroArgumentListener(target));
- testModel.replaceNode("child", "another child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertTrue(target.treeChangedZeroArgumentFlag);
- assertFalse(target.treeChangedSingleArgumentFlag);
- }
-
- public void testTreeChangedSingleArgumentNamedTree() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "another child"});
- testModel.addTreeChangeListener(TestModel.STRINGS_TREE, this.buildSingleArgumentListener(target));
- testModel.replaceNode("child", "another child");
- assertFalse(target.nodeAddedZeroArgumentFlag);
- assertFalse(target.nodeAddedSingleArgumentFlag);
- assertFalse(target.nodeRemovedZeroArgumentFlag);
- assertFalse(target.nodeRemovedSingleArgumentFlag);
- assertFalse(target.treeClearedZeroArgumentFlag);
- assertFalse(target.treeClearedSingleArgumentFlag);
- assertFalse(target.treeChangedZeroArgumentFlag);
- assertTrue(target.treeChangedSingleArgumentFlag);
- }
-
- public void testListenerMismatch() {
- TestModel testModel = new TestModel("root");
- testModel.addNode("root", "child");
- Target target = new Target(testModel, TestModel.STRINGS_TREE, new String[]{"root", "child"});
- // build a TREE change listener and hack it so we
- // can add it as a COLLECTION change listener
- Object listener = ReflectiveChangeListener.buildTreeChangeListener(target, "treeEventSingleArgument");
- testModel.addCollectionChangeListener("bogus collection", (CollectionChangeListener) listener);
-
- boolean exCaught = false;
- try {
- testModel.changeCollection();
- fail("listener mismatch: " + listener);
- } catch (IllegalArgumentException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
-
- class TestModel extends AbstractModel {
- private final String root;
- private Map<String, Collection<String>> childrenLists = new HashMap<String, Collection<String>>();
- private Map<String, String> parents = new HashMap<String, String>();
- public static final String STRINGS_TREE = "strings";
- TestModel(String root) {
- super();
- if (root == null) {
- throw new NullPointerException();
- }
- this.root = root;
- this.childrenLists.put(root, new ArrayList<String>());
- this.parents.put(root, null);
- }
- String getRoot() {
- return this.root;
- }
- private List<String> path(String node) {
- String temp = node;
- List<String> reversePath = new ArrayList<String>();
- do {
- reversePath.add(temp);
- temp = this.parents.get(temp);
- } while (temp != null);
- return CollectionTools.reverse(reversePath);
- }
- Iterator<String> strings() {
- return new CloneIterator<String>(this.childrenLists.keySet()) {
- @Override
- protected void remove(String s) {
- TestModel.this.removeNode(s);
- }
- };
- }
- void addNode(String parent, String child) {
- if ((parent == null) || (child == null)) {
- throw new NullPointerException();
- }
-
- Collection<String> children = this.childrenLists.get(parent);
- if (children == null) {
- throw new IllegalStateException("cannot add a child to a non-existent parent");
- }
-
- if (this.childrenLists.get(child) != null) {
- throw new IllegalStateException("cannot add a child that is already in the tree");
- }
-
- children.add(child);
- this.childrenLists.put(child, new ArrayList<String>());
- this.parents.put(child, parent);
- this.fireNodeAdded(STRINGS_TREE, this.path(child));
- }
- void removeNode(String node) {
- if (node == null) {
- throw new NullPointerException();
- }
-
- Collection<String> children = this.childrenLists.get(node);
- if (children == null) {
- throw new IllegalStateException("node is not in tree");
- }
- List<String> path = this.path(node);
- for (String s : children) {
- this.removeNode(s);
- }
- this.childrenLists.remove(node);
- this.parents.remove(node);
- this.fireNodeRemoved(STRINGS_TREE, path);
- }
- void replaceNode(String oldNode, String newNode) {
- if ((oldNode == null) || (newNode == null)) {
- throw new NullPointerException();
- }
-
- Collection<String> children = this.childrenLists.remove(oldNode);
- if (children == null) {
- throw new IllegalStateException("old node is not in tree");
- }
- this.childrenLists.put(newNode, children);
- for (String child : children) {
- this.parents.put(child, newNode);
- }
-
- String parent = this.parents.remove(oldNode);
- this.parents.put(newNode, parent);
-
- this.fireTreeChanged(STRINGS_TREE, this.path(newNode));
- }
- void clearTree() {
- this.childrenLists.clear();
- this.childrenLists.put(root, new ArrayList<String>());
- this.parents.clear();
- this.parents.put(root, null);
- this.fireTreeCleared(STRINGS_TREE);
- }
- void changeCollection() {
- this.fireCollectionChanged("bogus collection", Collections.emptySet());
- }
- }
-
- class Target {
- TestModel testModel;
- String treeName;
- List<String> path;
- boolean nodeAddedZeroArgumentFlag = false;
- boolean nodeAddedSingleArgumentFlag = false;
- boolean nodeRemovedZeroArgumentFlag = false;
- boolean nodeRemovedSingleArgumentFlag = false;
- boolean treeClearedZeroArgumentFlag = false;
- boolean treeClearedSingleArgumentFlag = false;
- boolean treeChangedZeroArgumentFlag = false;
- boolean treeChangedSingleArgumentFlag = false;
- boolean treeEventSingleArgumentFlag = false;
- Target(TestModel testModel, String treeName, String[] path) {
- super();
- this.testModel = testModel;
- this.treeName = treeName;
- this.path = Arrays.asList(path);
- }
- void nodeAddedZeroArgument() {
- this.nodeAddedZeroArgumentFlag = true;
- }
- void nodeAddedSingleArgument(TreeAddEvent e) {
- this.nodeAddedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.treeName, e.getTreeName());
- assertEquals(this.path, CollectionTools.list(e.getPath()));
- }
- void nodeRemovedZeroArgument() {
- this.nodeRemovedZeroArgumentFlag = true;
- }
- void nodeRemovedSingleArgument(TreeRemoveEvent e) {
- this.nodeRemovedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.treeName, e.getTreeName());
- assertEquals(this.path, CollectionTools.list(e.getPath()));
- }
- void treeClearedZeroArgument() {
- this.treeClearedZeroArgumentFlag = true;
- }
- void treeClearedSingleArgument(TreeClearEvent e) {
- this.treeClearedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.treeName, e.getTreeName());
- }
- void treeChangedZeroArgument() {
- this.treeChangedZeroArgumentFlag = true;
- }
- void treeChangedSingleArgument(TreeChangeEvent e) {
- this.treeChangedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.treeName, e.getTreeName());
- }
- void treeEventSingleArgument(TreeEvent e) {
- this.treeChangedSingleArgumentFlag = true;
- assertSame(this.testModel, e.getSource());
- assertEquals(this.treeName, e.getTreeName());
- }
- void collectionChangedDoubleArgument(TreeChangeEvent e, Object o) {
- fail("bogus event: " + e + " - object: " + o);
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/BufferedWritablePropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/BufferedWritablePropertyValueModelTests.java
deleted file mode 100644
index 9e38380992..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/BufferedWritablePropertyValueModelTests.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.BufferedWritablePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class BufferedWritablePropertyValueModelTests extends TestCase {
- private Employee employee;
- private ModifiablePropertyValueModel<Employee> employeeHolder;
- PropertyChangeEvent employeeEvent;
-
- private ModifiablePropertyValueModel<Integer> idAdapter;
- private ModifiablePropertyValueModel<String> nameAdapter;
- private ModifiablePropertyValueModel<Date> hireDateAdapter;
- PropertyChangeEvent adapterEvent;
-
- private BufferedWritablePropertyValueModel.Trigger trigger;
- private BufferedWritablePropertyValueModel<Integer> bufferedIDHolder;
- private BufferedWritablePropertyValueModel<String> bufferedNameHolder;
- private BufferedWritablePropertyValueModel<Date> bufferedHireDateHolder;
- PropertyChangeEvent bufferedEvent;
-
- public BufferedWritablePropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- this.employee = new Employee(17, "Freddy", new Date());
- this.employeeHolder = new SimplePropertyValueModel<Employee>(this.employee);
-
- this.trigger = new BufferedWritablePropertyValueModel.Trigger();
-
- this.idAdapter = this.buildIDAdapter(this.employeeHolder);
- this.bufferedIDHolder = new BufferedWritablePropertyValueModel<Integer>(this.idAdapter, this.trigger);
-
- this.nameAdapter = this.buildNameAdapter(this.employeeHolder);
- this.bufferedNameHolder = new BufferedWritablePropertyValueModel<String>(this.nameAdapter, this.trigger);
-
- this.hireDateAdapter = this.buildHireDateAdapter(this.employeeHolder);
- this.bufferedHireDateHolder = new BufferedWritablePropertyValueModel<Date>(this.hireDateAdapter, this.trigger);
- }
-
- private ModifiablePropertyValueModel<Integer> buildIDAdapter(PropertyValueModel<Employee> eHolder) {
- return new PropertyAspectAdapter<Employee, Integer>(eHolder, Employee.ID_PROPERTY) {
- @Override
- protected Integer buildValue_() {
- return new Integer(this.subject.getID());
- }
- @Override
- protected void setValue_(Integer value) {
- this.subject.setID(value.intValue());
- }
- };
- }
-
- private ModifiablePropertyValueModel<String> buildNameAdapter(PropertyValueModel<Employee> eHolder) {
- return new PropertyAspectAdapter<Employee, String>(eHolder, Employee.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
- @Override
- protected void setValue_(String value) {
- this.subject.setName(value);
- }
- };
- }
-
- private ModifiablePropertyValueModel<Date> buildHireDateAdapter(PropertyValueModel<Employee> eHolder) {
- return new PropertyAspectAdapter<Employee, Date>(eHolder, Employee.HIRE_DATE_PROPERTY) {
- @Override
- protected Date buildValue_() {
- return this.subject.getHireDate();
- }
- @Override
- protected void setValue_(Date value) {
- this.subject.setHireDate(value);
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGetValue() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedIDHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedHireDateHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- assertEquals(new Integer(17), this.idAdapter.getValue());
- assertEquals(new Integer(17), this.bufferedIDHolder.getValue());
-
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Freddy", this.bufferedNameHolder.getValue());
-
- Date temp = this.employee.getHireDate();
- assertEquals(temp, this.employee.getHireDate());
- assertEquals(temp, this.hireDateAdapter.getValue());
- assertEquals(temp, this.bufferedHireDateHolder.getValue());
-
- this.bufferedIDHolder.setValue(new Integer(323));
- assertEquals(17, this.employee.getID());
- assertEquals(new Integer(17), this.idAdapter.getValue());
- assertEquals(new Integer(323), this.bufferedIDHolder.getValue());
-
- this.bufferedNameHolder.setValue("Ripley");
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
-
- this.bufferedHireDateHolder.setValue(null);
- assertEquals(temp, this.employee.getHireDate());
- assertEquals(temp, this.hireDateAdapter.getValue());
- assertEquals(null, this.bufferedHireDateHolder.getValue());
- }
-
- public void testTriggerAccept() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedIDHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedHireDateHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- this.bufferedIDHolder.setValue(new Integer(323));
- assertEquals(17, this.employee.getID());
- assertEquals(new Integer(17), this.idAdapter.getValue());
- assertEquals(new Integer(323), this.bufferedIDHolder.getValue());
-
- this.bufferedNameHolder.setValue("Ripley");
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
-
- Date temp = this.employee.getHireDate();
- this.bufferedHireDateHolder.setValue(null);
- assertEquals(temp, this.employee.getHireDate());
- assertEquals(temp, this.hireDateAdapter.getValue());
- assertEquals(null, this.bufferedHireDateHolder.getValue());
-
- this.trigger.accept();
-
- assertEquals(323, this.employee.getID());
- assertEquals(new Integer(323), this.idAdapter.getValue());
- assertEquals(new Integer(323), this.bufferedIDHolder.getValue());
-
- assertEquals("Ripley", this.employee.getName());
- assertEquals("Ripley", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
-
- assertEquals(null, this.employee.getHireDate());
- assertEquals(null, this.hireDateAdapter.getValue());
- assertEquals(null, this.bufferedHireDateHolder.getValue());
- }
-
- public void testTriggerReset() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedIDHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedHireDateHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- this.bufferedIDHolder.setValue(new Integer(323));
- assertEquals(17, this.employee.getID());
- assertEquals(new Integer(17), this.idAdapter.getValue());
- assertEquals(new Integer(323), this.bufferedIDHolder.getValue());
-
- this.bufferedNameHolder.setValue("Ripley");
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
-
- Date temp = this.employee.getHireDate();
- this.bufferedHireDateHolder.setValue(null);
- assertEquals(temp, this.employee.getHireDate());
- assertEquals(temp, this.hireDateAdapter.getValue());
- assertEquals(null, this.bufferedHireDateHolder.getValue());
-
- this.trigger.reset();
-
- assertEquals(17, this.employee.getID());
- assertEquals(new Integer(17), this.idAdapter.getValue());
- assertEquals(new Integer(17), this.bufferedIDHolder.getValue());
-
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Freddy", this.bufferedNameHolder.getValue());
-
- assertEquals(temp, this.employee.getHireDate());
- assertEquals(temp, this.hireDateAdapter.getValue());
- assertEquals(temp, this.bufferedHireDateHolder.getValue());
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.bufferedIDHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedNameHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedHireDateHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(((AbstractModel) this.idAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.nameAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.hireDateAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.ID_PROPERTY));
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.NAME_PROPERTY));
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.HIRE_DATE_PROPERTY));
-
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedIDHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedHireDateHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- assertTrue(((AbstractModel) this.bufferedIDHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedNameHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedHireDateHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(((AbstractModel) this.idAdapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.nameAdapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.hireDateAdapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(this.employee.hasAnyPropertyChangeListeners(Employee.ID_PROPERTY));
- assertTrue(this.employee.hasAnyPropertyChangeListeners(Employee.NAME_PROPERTY));
- assertTrue(this.employee.hasAnyPropertyChangeListeners(Employee.HIRE_DATE_PROPERTY));
-
- this.bufferedIDHolder.removePropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedNameHolder.removePropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
- this.bufferedHireDateHolder.removePropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- assertTrue(((AbstractModel) this.bufferedIDHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedNameHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.bufferedHireDateHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(((AbstractModel) this.idAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.nameAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.hireDateAdapter).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.ID_PROPERTY));
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.NAME_PROPERTY));
- assertTrue(this.employee.hasNoPropertyChangeListeners(Employee.HIRE_DATE_PROPERTY));
- }
-
- public void testPropertyChange1() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- PropertyChangeListener adapterListener = this.buildAdapterListener();
- this.nameAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, adapterListener);
-
- PropertyChangeListener employeeListener = this.buildEmployeeListener();
- this.employee.addPropertyChangeListener(Employee.NAME_PROPERTY, employeeListener);
-
- this.verifyPropertyChanges();
- }
-
- public void testPropertyChange2() {
- ChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedNameHolder.addChangeListener(bufferedListener);
-
- ChangeListener adapterListener = this.buildAdapterListener();
- this.nameAdapter.addChangeListener(adapterListener);
-
- ChangeListener employeeListener = this.buildEmployeeListener();
- this.employee.addChangeListener(employeeListener);
-
- this.verifyPropertyChanges();
- }
-
- private void verifyPropertyChanges() {
- this.bufferedEvent = null;
- this.adapterEvent = null;
- this.employeeEvent = null;
- this.bufferedNameHolder.setValue("Ripley");
- this.verifyEvent(this.bufferedEvent, this.bufferedNameHolder, PropertyValueModel.VALUE, "Freddy", "Ripley");
- assertNull(this.adapterEvent);
- assertNull(this.employeeEvent);
-
- this.bufferedEvent = null;
- this.adapterEvent = null;
- this.employeeEvent = null;
- this.bufferedNameHolder.setValue("Charlie");
- this.verifyEvent(this.bufferedEvent, this.bufferedNameHolder, PropertyValueModel.VALUE, "Ripley", "Charlie");
- assertNull(this.adapterEvent);
- assertNull(this.employeeEvent);
-
- this.bufferedEvent = null;
- this.adapterEvent = null;
- this.employeeEvent = null;
- this.trigger.accept();
- assertNull(this.bufferedEvent);
- this.verifyEvent(this.adapterEvent, this.nameAdapter, PropertyValueModel.VALUE, "Freddy", "Charlie");
- this.verifyEvent(this.employeeEvent, this.employee, Employee.NAME_PROPERTY, "Freddy", "Charlie");
-
- this.bufferedEvent = null;
- this.adapterEvent = null;
- this.employeeEvent = null;
- this.bufferedNameHolder.setValue("Jason");
- this.verifyEvent(this.bufferedEvent, this.bufferedNameHolder, PropertyValueModel.VALUE, "Charlie", "Jason");
- assertNull(this.adapterEvent);
- assertNull(this.employeeEvent);
-
- this.bufferedEvent = null;
- this.adapterEvent = null;
- this.employeeEvent = null;
- this.trigger.reset();
- this.verifyEvent(this.bufferedEvent, this.bufferedNameHolder, PropertyValueModel.VALUE, "Jason", "Charlie");
- assertNull(this.adapterEvent);
- assertNull(this.employeeEvent);
- }
-
- /**
- * changing the value should trigger buffering
- */
- public void testBuffering1() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- this.bufferedNameHolder.setValue("Ripley");
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
- assertTrue(this.bufferedNameHolder.isBuffering());
- }
-
- /**
- * setting to the same value should not trigger buffering (?)
- */
- public void testBuffering2() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- this.bufferedNameHolder.setValue("Freddy");
- assertEquals("Freddy", this.bufferedNameHolder.getValue());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertFalse(this.bufferedNameHolder.isBuffering());
- }
-
- /**
- * setting to the original value should not trigger buffering (?)
- */
- public void testBuffering3() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- this.bufferedNameHolder.setValue("Ripley");
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
- assertTrue(this.bufferedNameHolder.isBuffering());
-
- this.bufferedNameHolder.setValue("Freddy");
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Freddy", this.bufferedNameHolder.getValue());
- assertFalse(this.bufferedNameHolder.isBuffering());
- }
-
- /**
- * back-door changes are ignored - "Last One In Wins"
- */
- public void testChangeConflict1() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- this.bufferedNameHolder.setValue("Ripley");
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
-
- this.nameAdapter.setValue("Jason");
- assertEquals("Jason", this.employee.getName());
- assertEquals("Jason", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
-
- this.trigger.accept();
- // "Jason" is dropped on the floor...
- assertEquals("Ripley", this.employee.getName());
- assertEquals("Ripley", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
- }
-
- /**
- * back-door changes can de-activate buffering (?)
- */
- public void testChangeConflict2() {
- PropertyChangeListener bufferedListener = this.buildBufferedListener();
- this.bufferedNameHolder.addPropertyChangeListener(PropertyValueModel.VALUE, bufferedListener);
-
- this.bufferedNameHolder.setValue("Ripley");
- assertEquals("Freddy", this.employee.getName());
- assertEquals("Freddy", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
- assertTrue(this.bufferedNameHolder.isBuffering());
-
- this.nameAdapter.setValue("Ripley");
- assertEquals("Ripley", this.employee.getName());
- assertEquals("Ripley", this.nameAdapter.getValue());
- assertEquals("Ripley", this.bufferedNameHolder.getValue());
- assertFalse(this.bufferedNameHolder.isBuffering());
- }
-
- private ChangeListener buildBufferedListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- BufferedWritablePropertyValueModelTests.this.bufferedEvent = e;
- }
- };
- }
-
- private ChangeListener buildAdapterListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- BufferedWritablePropertyValueModelTests.this.adapterEvent = e;
- }
- };
- }
-
- private ChangeListener buildEmployeeListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- BufferedWritablePropertyValueModelTests.this.employeeEvent = e;
- }
- };
- }
-
- private void verifyEvent(PropertyChangeEvent event, Object source, String propertyName, Object oldValue, Object newValue) {
- assertEquals(source, event.getSource());
- assertEquals(propertyName, event.getPropertyName());
- assertEquals(oldValue, event.getOldValue());
- assertEquals(newValue, event.getNewValue());
- }
-
-
- // ********** inner class **********
-
- class Employee extends AbstractModel {
- private int id;
- public static final String ID_PROPERTY = "id";
- private String name;
- public static final String NAME_PROPERTY = "name";
- private Date hireDate;
- public static final String HIRE_DATE_PROPERTY = "hireDate";
-
- Employee(int id, String name, Date hireDate) {
- super();
- this.id = id;
- this.name = name;
- this.hireDate = hireDate;
- }
- int getID() {
- return this.id;
- }
- void setID(int id) {
- int old = this.id;
- this.id = id;
- this.firePropertyChanged(ID_PROPERTY, old, id);
- }
- String getName() {
- return this.name;
- }
- void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
- Date getHireDate() {
- return this.hireDate;
- }
- void setHireDate(Date hireDate) {
- Object old = this.hireDate;
- this.hireDate = hireDate;
- this.firePropertyChanged(HIRE_DATE_PROPERTY, old, hireDate);
- }
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationPropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationPropertyValueModelTests.java
deleted file mode 100644
index 63fc3f2bfb..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationPropertyValueModelTests.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.BidiTransformer;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class CachingTransformationPropertyValueModelTests extends TestCase {
- private ModifiablePropertyValueModel<Person> objectHolder;
- PropertyChangeEvent event;
-
- private PropertyValueModel<Person> transformationObjectHolder;
- PropertyChangeEvent transformationEvent;
-
- public CachingTransformationPropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.objectHolder = new SimplePropertyValueModel<Person>(new Person("Karen", "Peggy", null));
- this.transformationObjectHolder = new TransformationPropertyValueModel<Person, Person>(this.objectHolder, this.buildTransformer());
- }
-
- private BidiTransformer<Person, Person> buildTransformer() {
- return new BidiTransformer<Person, Person>() {
- public Person transform(Person p) {
- return (p == null) ? null : p.getParent();
- }
- public Person reverseTransform(Person p) {
- return (p == null) ? null : p.getChild();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- ChangeListener listener = this.buildTransformationChangeListener();
- this.transformationObjectHolder.addChangeListener(listener);
-
- Person person = this.objectHolder.getValue();
- assertEquals("Karen", person.getName());
- Person parent = this.transformationObjectHolder.getValue();
- assertEquals(person.getParent().getName(), parent.getName());
- assertNotSame(person.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent, this.transformationObjectHolder.getValue());
-
- Person person1 = new Person("Matt", "Mitch", null);
- this.objectHolder.setValue(person1);
- Person parent2 = this.transformationObjectHolder.getValue();
- assertEquals(person1.getParent().getName(), parent2.getName());
- assertNotSame(person1.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent2, this.transformationObjectHolder.getValue());
-
-
- this.objectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
-
- Person person3 = new Person("Karen", "Peggy", null);
- this.objectHolder.setValue(person3);
- assertEquals("Karen", person3.getName());
- Person parent3 = this.transformationObjectHolder.getValue();
- assertEquals(person3.getParent().getName(), parent3.getName());
- assertNotSame(person3.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent3, this.transformationObjectHolder.getValue());
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- ChangeListener listener = this.buildTransformationChangeListener();
- this.transformationObjectHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removeChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testPropertyChange1() {
- this.objectHolder.addChangeListener(this.buildChangeListener());
- this.transformationObjectHolder.addChangeListener(this.buildTransformationChangeListener());
- this.verifyPropertyChanges();
- }
-
- public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildTransformationListener());
- this.verifyPropertyChanges();
- }
-
- private void verifyPropertyChanges() {
- this.event = null;
- this.transformationEvent = null;
- Person karen = this.objectHolder.getValue();
- Person peggyParent = this.transformationObjectHolder.getValue();
- Person peggy = new Person("Peggy", "Marian", null);
- this.objectHolder.setValue(peggy);
- Person marianParent = this.transformationObjectHolder.getValue();
- this.verifyEvent(this.event, this.objectHolder, karen, peggy);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, peggyParent, marianParent);
-
- this.event = null;
- this.transformationEvent = null;
- Person matt = new Person("Matt", "Mitch", null);
- this.objectHolder.setValue(matt);
- Person mitchParent = this.transformationObjectHolder.getValue();
- this.verifyEvent(this.event, this.objectHolder, peggy, matt);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, marianParent, mitchParent);
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue(null);
- this.verifyEvent(this.event, this.objectHolder, matt, null);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, mitchParent, null);
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue(matt);
- mitchParent = this.transformationObjectHolder.getValue();
- this.verifyEvent(this.event, this.objectHolder, null, matt);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, null, mitchParent);
- }
-
- private PropertyChangeListener buildListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CachingTransformationPropertyValueModelTests.this.event = e;
- }
- };
- }
-
- private PropertyChangeListener buildTransformationListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CachingTransformationPropertyValueModelTests.this.transformationEvent = e;
- }
- };
- }
-
- private ChangeListener buildChangeListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- CachingTransformationPropertyValueModelTests.this.event = e;
- }
- };
- }
-
- private ChangeListener buildTransformationChangeListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- CachingTransformationPropertyValueModelTests.this.transformationEvent = e;
- }
- };
- }
-
- private void verifyEvent(PropertyChangeEvent e, Object source, Object oldValue, Object newValue) {
- assertEquals(source, e.getSource());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- assertEquals(oldValue, e.getOldValue());
- assertEquals(newValue, e.getNewValue());
- }
-
-
- class Person
- extends AbstractModel
- {
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- private String parentName;
- public static final String PARENT_NAME_PROPERTY = "parentName";
-
- private Person child;
-
- public Person(String name, String parentName, Person child) {
- this.name = name;
- this.parentName = parentName;
- this.child = child;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String newName) {
- String oldName = this.name;
- this.name = newName;
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- public Person getParent() {
- return new Person(this.parentName, null, this);
- }
-
- public String getParentName() {
- return this.parentName;
- }
-
- public void setParentName(String newParentName) {
- String oldParentName = this.parentName;
- this.parentName = newParentName;
- firePropertyChanged(PARENT_NAME_PROPERTY, oldParentName, newParentName);
- }
-
- public Person getChild() {
- return this.child;
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationWritablePropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationWritablePropertyValueModelTests.java
deleted file mode 100644
index 7c711a316e..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CachingTransformationWritablePropertyValueModelTests.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationWritablePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class CachingTransformationWritablePropertyValueModelTests
- extends TestCase
-{
- private ModifiablePropertyValueModel<Person> objectHolder;
- PropertyChangeEvent event;
-
- private ModifiablePropertyValueModel<Person> transformationObjectHolder;
- PropertyChangeEvent transformationEvent;
-
- public CachingTransformationWritablePropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.objectHolder = new SimplePropertyValueModel<Person>(new Person("Karen", "Peggy", null));
- this.transformationObjectHolder = new TransformationWritablePropertyValueModel<Person, Person>(this.objectHolder, this.buildTransformer(), this.buildReverseTransformer());
- }
-
- private Transformer<Person, Person> buildTransformer() {
- return new Transformer<Person, Person>() {
- public Person transform(Person p) {
- return (p == null) ? null : p.getParent();
- }
- };
- }
-
- private Transformer<Person, Person> buildReverseTransformer() {
- return new Transformer<Person, Person>() {
- public Person transform(Person p) {
- return (p == null) ? null : p.getChild();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
-
-
- Person person = this.objectHolder.getValue();
- assertEquals("Karen", person.getName());
- Person parent = this.transformationObjectHolder.getValue();
- assertEquals(person.getParent().getName(), parent.getName());
- assertNotSame(person.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent, this.transformationObjectHolder.getValue());
-
- Person person1 = new Person("Matt", "Mitch", null);
- this.objectHolder.setValue(person1);
- Person parent2 = this.transformationObjectHolder.getValue();
- assertEquals(person1.getParent().getName(), parent2.getName());
- assertNotSame(person1.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent2, this.transformationObjectHolder.getValue());
-
-
- this.objectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
-
- Person person3 = new Person("Karen", "Peggy", null);
- this.objectHolder.setValue(person3);
- assertEquals("Karen", person3.getName());
- Person parent3 = this.transformationObjectHolder.getValue();
- assertEquals(person3.getParent().getName(), parent3.getName());
- assertNotSame(person3.getParent(), this.transformationObjectHolder.getValue());
- assertEquals(parent3, this.transformationObjectHolder.getValue());
- }
-
- public void testSetValue() {
- ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
-
- Person person = new Person("Chris", "Noel", null);
- this.transformationObjectHolder.setValue(person.getParent());
- assertEquals(person, this.objectHolder.getValue());
- assertEquals(person.getParent().getName(), this.transformationObjectHolder.getValue().getName());
- assertNotSame(person.getParent(), this.transformationObjectHolder.getValue());
-
- Person person2 = new Person("Jon", "Elizabeth", null);
- this.transformationObjectHolder.setValue(person2.getParent());
- assertEquals(person2, this.objectHolder.getValue());
- assertEquals(person2.getParent().getName(), this.transformationObjectHolder.getValue().getName());
- assertNotSame(person2.getParent(), this.transformationObjectHolder.getValue());
-
- this.transformationObjectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
-
- this.transformationObjectHolder.setValue(person.getParent());
- assertEquals(person, this.objectHolder.getValue());
- assertEquals(person.getParent().getName(), this.transformationObjectHolder.getValue().getName());
- assertNotSame(person.getParent(), this.transformationObjectHolder.getValue());
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removeChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testPropertyChange1() {
- this.objectHolder.addChangeListener(this.buildListener());
- this.transformationObjectHolder.addChangeListener(this.buildTransformationListener());
- this.verifyPropertyChanges();
- }
-
- public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildTransformationListener());
- this.verifyPropertyChanges();
- }
-
- private void verifyPropertyChanges() {
- this.event = null;
- this.transformationEvent = null;
- Person oldPerson = this.objectHolder.getValue();
- Person oldParent = this.transformationObjectHolder.getValue();
- Person newPerson = new Person("Karen" , "Peggy", null);
- this.objectHolder.setValue(newPerson);
- Person newParent = this.transformationObjectHolder.getValue();
- this.verifyEvent(this.event, this.objectHolder, oldPerson, newPerson);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, oldParent, newParent);
-
-//
-// this.event = null;
-// this.transformationEvent = null;
-// this.objectHolder.setValue("Foo");
-// this.verifyEvent(this.event, this.objectHolder, "baz", "Foo");
-// this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "BAZ", "FOO");
-//
-// this.event = null;
-// this.transformationEvent = null;
-// this.objectHolder.setValue("FOO");
-// this.verifyEvent(this.event, this.objectHolder, "Foo", "FOO");
-// assertNull(this.transformationEvent);
-//
-// this.event = null;
-// this.transformationEvent = null;
-// this.objectHolder.setValue(null);
-// this.verifyEvent(this.event, this.objectHolder, "FOO", null);
-// this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "FOO", null);
-//
-// this.event = null;
-// this.transformationEvent = null;
-// this.objectHolder.setValue("bar");
-// this.verifyEvent(this.event, this.objectHolder, null, "bar");
-// this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, null, "BAR");
- }
-
- private ChangeListener buildListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- CachingTransformationWritablePropertyValueModelTests.this.event = e;
- }
- };
- }
-
- private ChangeListener buildTransformationListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- CachingTransformationWritablePropertyValueModelTests.this.transformationEvent = e;
- }
- };
- }
-
- private void verifyEvent(PropertyChangeEvent e, Object source, Object oldValue, Object newValue) {
- assertEquals(source, e.getSource());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- assertEquals(oldValue, e.getOldValue());
- assertEquals(newValue, e.getNewValue());
- }
-
-
- class Person extends AbstractModel {
-
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- private String parentName;
- public static final String PARENT_NAME_PROPERTY = "parentName";
-
- private Person child;
-
- public Person(String name, String parentName, Person child) {
- this.name = name;
- this.parentName = parentName;
- this.child = child;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String newName) {
- String oldName = this.name;
- this.name = newName;
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- public Person getParent() {
- return new Person(this.parentName, null, this);
- }
-
- public String getParentName() {
- return this.parentName;
- }
-
- public void setParentName(String newParentName) {
- String oldParentName = this.parentName;
- this.parentName = newParentName;
- firePropertyChanged(PARENT_NAME_PROPERTY, oldParentName, newParentName);
- }
-
- public Person getChild() {
- return this.child;
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionAspectAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionAspectAdapterTests.java
deleted file mode 100644
index eadcc93bff..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionAspectAdapterTests.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class CollectionAspectAdapterTests extends TestCase {
- private TestSubject subject1;
- private ModifiablePropertyValueModel<TestSubject> subjectHolder1;
- private LocalCollectionAspectAdapter aa1;
- private CollectionEvent event1;
- private CollectionChangeListener listener1;
- private String event1Type;
-
- private static final String ADD = "add";
- private static final String REMOVE = "remove";
- private static final String CHANGE = "change";
- private static final String CLEAR = "clear";
-
- private TestSubject subject2;
-
- public CollectionAspectAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject1 = new TestSubject();
- this.subject1.addNames(this.subject1Names());
- this.subject1.addDescriptions(this.subject1Descriptions());
- this.subjectHolder1 = new SimplePropertyValueModel<TestSubject>(this.subject1);
- this.aa1 = this.buildAspectAdapter(this.subjectHolder1);
- this.listener1 = this.buildValueChangeListener1();
- this.aa1.addCollectionChangeListener(CollectionValueModel.VALUES, this.listener1);
- this.event1 = null;
- this.event1Type = null;
-
- this.subject2 = new TestSubject();
- this.subject2.addNames(this.subject2Names());
- this.subject2.addDescriptions(this.subject2Descriptions());
- }
-
- private Collection<String> subject1Names() {
- Collection<String> result = new HashBag<String>();
- result.add("foo");
- result.add("bar");
- return result;
- }
-
- private Collection<String> subject1Descriptions() {
- Collection<String> result = new HashBag<String>();
- result.add("this.subject1 description1");
- result.add("this.subject1 description2");
- return result;
- }
-
- private Collection<String> subject2Names() {
- Collection<String> result = new HashBag<String>();
- result.add("baz");
- result.add("bam");
- return result;
- }
-
- private Collection<String> subject2Descriptions() {
- Collection<String> result = new HashBag<String>();
- result.add("this.subject2 description1");
- result.add("this.subject2 description2");
- return result;
- }
-
- private LocalCollectionAspectAdapter buildAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- return new LocalCollectionAspectAdapter(subjectHolder);
- }
-
- private CollectionChangeListener buildValueChangeListener1() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent e) {
- CollectionAspectAdapterTests.this.value1Changed(e, ADD);
- }
- public void itemsRemoved(CollectionRemoveEvent e) {
- CollectionAspectAdapterTests.this.value1Changed(e, REMOVE);
- }
- public void collectionCleared(CollectionClearEvent e) {
- CollectionAspectAdapterTests.this.value1Changed(e, CLEAR);
- }
- public void collectionChanged(CollectionChangeEvent e) {
- CollectionAspectAdapterTests.this.value1Changed(e, CHANGE);
- }
- };
- }
-
- void value1Changed(CollectionEvent e, String eventType) {
- this.event1 = e;
- this.event1Type = eventType;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSubjectHolder() {
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- assertNull(this.event1);
-
- this.subjectHolder1.setValue(this.subject2);
- assertNotNull(this.event1);
- assertEquals(this.event1Type, CHANGE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertEquals(this.subject2Names(), CollectionTools.bag(this.aa1.iterator()));
-
- this.event1 = null;
- this.event1Type = null;
- this.subjectHolder1.setValue(null);
- assertNotNull(this.event1);
- assertEquals(this.event1Type, CHANGE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertFalse(this.aa1.iterator().hasNext());
-
- this.event1 = null;
- this.event1Type = null;
- this.subjectHolder1.setValue(this.subject1);
- assertNotNull(this.event1);
- assertEquals(this.event1Type, CHANGE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- }
-
- public void testAdd() {
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- assertNull(this.event1);
-
- this.subject1.addName("jam");
- assertNotNull(this.event1);
- assertEquals(this.event1Type, ADD);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertEquals("jam", ((CollectionAddEvent) this.event1).getItems().iterator().next());
- Collection<String> namesPlus = this.subject1Names();
- namesPlus.add("jam");
- assertEquals(namesPlus, CollectionTools.bag(this.aa1.iterator()));
-
- this.event1 = null;
- this.event1Type = null;
- this.aa1.addAll(Collections.singleton("jaz"));
- assertNotNull(this.event1);
- assertEquals(this.event1Type, ADD);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertEquals("jaz", ((CollectionAddEvent) this.event1).getItems().iterator().next());
- namesPlus.add("jaz");
- assertEquals(namesPlus, CollectionTools.bag(this.aa1.iterator()));
- }
-
- public void testRemove() {
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- assertNull(this.event1);
-
- this.subject1.removeName("foo");
- assertNotNull(this.event1);
- assertEquals(this.event1Type, REMOVE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertEquals("foo", ((CollectionRemoveEvent) this.event1).getItems().iterator().next());
- Collection<String> namesMinus = this.subject1Names();
- namesMinus.remove("foo");
- assertEquals(namesMinus, CollectionTools.bag(this.aa1.iterator()));
-
- this.event1 = null;
- this.event1Type = null;
- this.aa1.removeAll(Collections.singleton("bar"));
- assertNotNull(this.event1);
- assertEquals(this.event1Type, REMOVE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- assertEquals("bar", ((CollectionRemoveEvent) this.event1).getItems().iterator().next());
- namesMinus.remove("bar");
- assertEquals(namesMinus, CollectionTools.bag(this.aa1.iterator()));
- }
-
- public void testCollectionChange() {
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- assertNull(this.event1);
-
- this.subject1.addTwoNames("jam", "jaz");
- assertNotNull(this.event1);
- assertEquals(this.event1Type, CHANGE);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event1.getCollectionName());
- Collection<String> namesPlus2 = this.subject1Names();
- namesPlus2.add("jam");
- namesPlus2.add("jaz");
- assertEquals(namesPlus2, CollectionTools.bag(this.aa1.iterator()));
- }
-
- public void testIterator() {
- assertEquals(this.subject1Names(), CollectionTools.bag(this.subject1.names()));
- assertEquals(this.subject1Names(), CollectionTools.bag(this.aa1.iterator()));
- }
-
- public void testSize() {
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.subject1.names()));
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.aa1.iterator()));
- }
-
- public void testHasListeners() {
- assertTrue(this.aa1.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(this.subject1.hasAnyCollectionChangeListeners(TestSubject.NAMES_COLLECTION));
- this.aa1.removeCollectionChangeListener(CollectionValueModel.VALUES, this.listener1);
- assertFalse(this.subject1.hasAnyCollectionChangeListeners(TestSubject.NAMES_COLLECTION));
- assertFalse(this.aa1.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- ChangeListener listener2 = new ChangeAdapter();
- this.aa1.addChangeListener(listener2);
- assertTrue(this.aa1.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(this.subject1.hasAnyCollectionChangeListeners(TestSubject.NAMES_COLLECTION));
- this.aa1.removeChangeListener(listener2);
- assertFalse(this.subject1.hasAnyCollectionChangeListeners(TestSubject.NAMES_COLLECTION));
- assertFalse(this.aa1.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
-
- // ********** inner class **********
-
- private class TestSubject extends AbstractModel {
- private Collection<String> names;
- public static final String NAMES_COLLECTION = "names";
- private Collection<String> descriptions;
- public static final String DESCRIPTIONS_COLLECTION = "descriptions";
-
- public TestSubject() {
- this.names = new HashBag<String>();
- this.descriptions = new HashBag<String>();
- }
- public Iterator<String> names() {
- return new ReadOnlyIterator<String>(this.names);
- }
- public void addName(String name) {
- if (this.names.add(name)) {
- this.fireItemAdded(NAMES_COLLECTION, name);
- }
- }
- public void addNames(Iterator<String> newNames) {
- while (newNames.hasNext()) {
- this.addName(newNames.next());
- }
- }
- public void addNames(Collection<String> newNames) {
- this.addNames(newNames.iterator());
- }
- public void addTwoNames(String name1, String name2) {
- if (this.names.add(name1) | this.names.add(name2)) {
- this.fireCollectionChanged(NAMES_COLLECTION, this.names);
- }
- }
- public void removeName(String name) {
- if (this.names.remove(name)) {
- this.fireItemRemoved(NAMES_COLLECTION, name);
- }
- }
- public Iterator<String> descriptions() {
- return new ReadOnlyIterator<String>(this.descriptions);
- }
- public void addDescription(String description) {
- if (this.descriptions.add(description)) {
- this.fireItemAdded(DESCRIPTIONS_COLLECTION, description);
- }
- }
- public void addDescriptions(Iterator<String> newDescriptions) {
- while (newDescriptions.hasNext()) {
- this.addDescription(newDescriptions.next());
- }
- }
- public void addDescriptions(Collection<String> newDescriptions) {
- this.addDescriptions(newDescriptions.iterator());
- }
- public void removeDescription(String description) {
- if (this.descriptions.remove(description)) {
- this.fireItemRemoved(DESCRIPTIONS_COLLECTION, description);
- }
- }
- }
-
- // this is not a typical aspect adapter - the value is determined by the aspect name
- private class LocalCollectionAspectAdapter extends CollectionAspectAdapter<TestSubject, String> {
-
- LocalCollectionAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- super(subjectHolder, TestSubject.NAMES_COLLECTION);
- }
-
- @Override
- protected Iterator<String> iterator_() {
- if (this.aspectNames[0] == TestSubject.NAMES_COLLECTION) {
- return this.subject.names();
- }
- if (this.aspectNames[0] == TestSubject.DESCRIPTIONS_COLLECTION) {
- return this.subject.descriptions();
- }
- throw new IllegalStateException("invalid aspect name: " + this.aspectNames[0]);
- }
-
- public void add(String item) {
- if (this.aspectNames[0] == TestSubject.NAMES_COLLECTION) {
- this.subject.addName(item);
- } else if (this.aspectNames[0] == TestSubject.DESCRIPTIONS_COLLECTION) {
- this.subject.addDescription(item);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.aspectNames[0]);
- }
- }
-
- public void addAll(Collection<String> items) {
- for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
- this.add(stream.next());
- }
- }
-
- public void remove(Object item) {
- if (this.aspectNames[0] == TestSubject.NAMES_COLLECTION) {
- this.subject.removeName((String) item);
- } else if (this.aspectNames[0] == TestSubject.DESCRIPTIONS_COLLECTION) {
- this.subject.removeDescription((String) item);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.aspectNames[0]);
- }
- }
-
- public void removeAll(Collection<String> items) {
- for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
- this.remove(stream.next());
- }
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java
deleted file mode 100644
index 7c0a154f5b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionListValueModelAdapterTests.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.JList;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class CollectionListValueModelAdapterTests extends TestCase {
- private ListValueModel<String> adapter;
- private SimpleCollectionValueModel<String> wrappedCollectionHolder;
- private Collection<String> wrappedCollection;
-
- public CollectionListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedCollection = new HashBag<String>();
- this.wrappedCollectionHolder = new SimpleCollectionValueModel<String>(this.wrappedCollection);
- this.adapter = new CollectionListValueModelAdapter<String>(this.wrappedCollectionHolder);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListAddEvent e) {/* OK */}
- });
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- Collection<String> adapterCollection = this.adapterCollection();
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection, adapterCollection);
- }
-
- private Collection<String> adapterCollection() {
- return CollectionTools.collection(this.adapter.iterator());
- }
-
- public void testStaleValue() {
- ListChangeListener listener = new TestListChangeListener() {
- @Override
- public void itemsAdded(ListAddEvent e) {/* OK */}
- };
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- Collection<String> adapterCollection = this.adapterCollection();
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection, adapterCollection);
-
- this.adapter.removeListChangeListener(ListValueModel.LIST_VALUES, listener);
- adapterCollection = this.adapterCollection();
- assertEquals(0, adapterCollection.size());
- assertEquals(new HashBag<String>(), adapterCollection);
-
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- adapterCollection = this.adapterCollection();
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection, adapterCollection);
- }
-
- public void testAdd() {
- List<String> synchList = new CoordinatedList<String>(this.adapter);
- Bag<String> synchCollection = new CoordinatedBag<String>(this.wrappedCollectionHolder);
- this.wrappedCollectionHolder.add("foo");
- assertTrue(this.wrappedCollection.contains("foo"));
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- assertEquals(6, this.wrappedCollection.size());
-
- Collection<String> adapterCollection = this.adapterCollection();
- assertEquals(this.wrappedCollection, adapterCollection);
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
- }
-
- public void testRemove() {
- List<String> synchList = new CoordinatedList<String>(this.adapter);
- Bag<String> synchCollection = new CoordinatedBag<String>(this.wrappedCollectionHolder);
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- assertTrue(this.wrappedCollection.contains("jaz"));
- this.wrappedCollectionHolder.remove("jaz");
- assertFalse(this.wrappedCollection.contains("jaz"));
- this.wrappedCollectionHolder.remove("foo");
- assertFalse(this.wrappedCollection.contains("foo"));
- assertEquals(4, this.wrappedCollection.size());
-
- Collection<String> adapterCollection = this.adapterCollection();
- assertEquals(this.wrappedCollection, adapterCollection);
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
- }
-
- public void testListSynch() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListAddEvent e) {/* OK */}
- @Override
- public void itemsRemoved(ListRemoveEvent e) {/* OK */}
- });
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- this.wrappedCollectionHolder.remove("jaz");
- assertFalse(this.wrappedCollection.contains("jaz"));
- this.wrappedCollectionHolder.remove("foo");
- assertFalse(this.wrappedCollection.contains("foo"));
- assertEquals(4, this.wrappedCollection.size());
-
- Collection<String> adapterCollection = this.adapterCollection();
- assertEquals(this.wrappedCollection, adapterCollection);
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- CoordinatedList<String> synchList = new CoordinatedList<String>(this.adapter);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ChangeListener cl = new ChangeAdapter();
- this.adapter.addChangeListener(cl);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeChangeListener(cl);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- public void testCollectionChangedToEmpty() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void listCleared(ListClearEvent e) {/* OK */}
- @Override
- public void itemsAdded(ListAddEvent e) {/* OK */}
- });
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- JList jList = new JList(new ListModelAdapter(this.adapter));
- this.wrappedCollectionHolder.setValues(new HashBag<String>());
- assertEquals(0, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmpty() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListAddEvent e) {/* OK */}
- @Override
- public void itemsRemoved(ListRemoveEvent e) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- HashBag<String> bag = new HashBag<String>();
- bag.add("foo");
- bag.add("bar");
- this.wrappedCollectionHolder.setValues(bag);
- assertEquals(2, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmptyToEmpty() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListAddEvent e) {/* OK */}
- @Override
- public void itemsRemoved(ListRemoveEvent e) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- HashBag<String> bag = new HashBag<String>();
- this.wrappedCollectionHolder.setValues(bag);
- assertEquals(0, jList.getModel().getSize());
- }
-
-
- class TestListChangeListener implements ListChangeListener {
- public void itemsAdded(ListAddEvent e) {
- fail("unexpected event");
- }
- public void itemsRemoved(ListRemoveEvent e) {
- fail("unexpected event");
- }
- public void itemsReplaced(ListReplaceEvent e) {
- fail("unexpected event");
- }
- public void itemsMoved(ListMoveEvent e) {
- fail("unexpected event");
- }
- public void listCleared(ListClearEvent e) {
- fail("unexpected event");
- }
- public void listChanged(ListChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java
deleted file mode 100644
index 9b9343ce75..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CollectionPropertyValueModelAdapterTests.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionPropertyValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class CollectionPropertyValueModelAdapterTests extends TestCase {
- private ModifiablePropertyValueModel<Boolean> adapter;
- private SimpleCollectionValueModel<String> wrappedCollectionHolder;
- PropertyChangeEvent event;
-
- public CollectionPropertyValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedCollectionHolder = new SimpleCollectionValueModel<String>();
- this.adapter = new LocalAdapter(this.wrappedCollectionHolder, "666");
- this.event = null;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- private boolean booleanValue() {
- return this.adapter.getValue().booleanValue();
- }
-
- private Collection<String> wrappedCollection() {
- return CollectionTools.collection(this.wrappedCollectionHolder.iterator());
- }
-
- public void testValue() {
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {/* OK */}
- });
- assertFalse(this.booleanValue());
- assertFalse(this.wrappedCollection().contains("666"));
-
- this.wrappedCollectionHolder.add("111");
- assertFalse(this.booleanValue());
-
- this.wrappedCollectionHolder.add("222");
- assertFalse(this.booleanValue());
-
- this.wrappedCollectionHolder.add("666");
- assertTrue(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
-
- this.wrappedCollectionHolder.remove("666");
- assertFalse(this.booleanValue());
- assertFalse(this.wrappedCollection().contains("666"));
-
- this.wrappedCollectionHolder.add("666");
- assertTrue(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
-
- this.wrappedCollectionHolder.clear();
- assertFalse(this.booleanValue());
- assertFalse(this.wrappedCollection().contains("666"));
- }
-
- public void testSetValue() {
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {/* OK */}
- });
- assertFalse(this.booleanValue());
- assertFalse(this.wrappedCollection().contains("666"));
-
- this.adapter.setValue(Boolean.TRUE);
- assertTrue(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
-
- this.adapter.setValue(Boolean.FALSE);
- assertFalse(this.booleanValue());
- assertFalse(this.wrappedCollection().contains("666"));
- }
-
- public void testEventFiring() {
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- CollectionPropertyValueModelAdapterTests.this.event = e;
- }
- });
- assertNull(this.event);
-
- this.wrappedCollectionHolder.add("111");
- assertNull(this.event);
-
- this.wrappedCollectionHolder.add("222");
- assertNull(this.event);
-
- this.wrappedCollectionHolder.add("666");
- this.verifyEvent(false, true);
-
- this.wrappedCollectionHolder.remove("666");
- this.verifyEvent(true, false);
-
- this.wrappedCollectionHolder.add("666");
- this.verifyEvent(false, true);
-
- this.wrappedCollectionHolder.clear();
- this.verifyEvent(true, false);
- }
-
- private void verifyEvent(boolean oldValue, boolean newValue) {
- assertEquals(this.adapter, this.event.getSource());
- assertEquals(Boolean.valueOf(oldValue), this.event.getOldValue());
- assertEquals(Boolean.valueOf(newValue), this.event.getNewValue());
- this.event = null;
- }
-
- public void testStaleValue() {
- PropertyChangeListener listener = new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {/* OK */}
- };
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- this.wrappedCollectionHolder.add("666");
- assertTrue(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
-
- this.adapter.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertFalse(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
-
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(this.booleanValue());
- assertTrue(this.wrappedCollection().contains("666"));
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(((AbstractModel) this.wrappedCollectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- ChangeListener listener = new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {/* OK */}
- };
- this.adapter.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.adapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.wrappedCollectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- this.adapter.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertFalse(((AbstractModel) this.adapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(((AbstractModel) this.wrappedCollectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- this.adapter.addChangeListener(listener);
- assertTrue(((AbstractModel) this.adapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.wrappedCollectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- this.adapter.removeChangeListener(listener);
- assertFalse(((AbstractModel) this.adapter).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(((AbstractModel) this.wrappedCollectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
-
- // ********** member class **********
-
- /**
- * the value is true if the wrapped collection contains the specified item,
- * otherwise the value is false
- */
- static class LocalAdapter
- extends CollectionPropertyValueModelAdapter<Boolean, String>
- implements ModifiablePropertyValueModel<Boolean>
- {
- private String item;
-
- LocalAdapter(CollectionValueModel<String> collectionHolder, String item) {
- super(collectionHolder);
- this.item = item;
- }
-
- // ********** CollectionPropertyValueModelAdapter implementation **********
- /**
- * always return a Boolean
- */
- @Override
- public Boolean getValue() {
- Boolean result = super.getValue();
- return (result == null) ? Boolean.FALSE : result;
- }
- @SuppressWarnings("unchecked")
- public void setValue(Boolean value) {
- if (this.booleanValue()) {
- if ( ! this.booleanValueOf(value)) {
- // the value is changing from true to false
- ((SimpleCollectionValueModel<String>) this.collectionModel).remove(this.item);
- }
- } else {
- if (this.booleanValueOf(value)) {
- // the value is changing from false to true
- ((SimpleCollectionValueModel<String>) this.collectionModel).add(this.item);
- }
- }
- }
- @Override
- protected Boolean buildValue() {
- return Boolean.valueOf(CollectionTools.contains(this.collectionModel.iterator(), this.item));
- }
-
- // ********** internal methods **********
- private boolean booleanValue() {
- return this.booleanValueOf(this.value);
- }
- private boolean booleanValueOf(Object b) {
- return (b == null) ? false : ((Boolean) b).booleanValue();
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeBooleanPropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeBooleanPropertyValueModelTests.java
deleted file mode 100644
index 5f27baf3f1..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeBooleanPropertyValueModelTests.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.model.value.CompositeBooleanPropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-public class CompositeBooleanPropertyValueModelTests extends TestCase {
- private SimplePropertyValueModel<Boolean> pvm1;
- private ModifiablePropertyValueModel<Boolean> pvm2;
- private ModifiablePropertyValueModel<Boolean> pvm3;
- private ModifiablePropertyValueModel<Boolean> pvm4;
- private Collection<ModifiablePropertyValueModel<Boolean>> collection;
- private SimpleCollectionValueModel<ModifiablePropertyValueModel<Boolean>> cvm;
- private PropertyValueModel<Boolean> compositePVM;
- PropertyChangeEvent event;
-
-
- public CompositeBooleanPropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.pvm1 = new SimplePropertyValueModel<Boolean>(Boolean.TRUE);
- this.pvm2 = new SimplePropertyValueModel<Boolean>(Boolean.TRUE);
- this.pvm3 = new SimplePropertyValueModel<Boolean>(Boolean.TRUE);
- this.pvm4 = new SimplePropertyValueModel<Boolean>(Boolean.TRUE);
- this.collection = new ArrayList<ModifiablePropertyValueModel<Boolean>>();
- this.collection.add(this.pvm1);
- this.collection.add(this.pvm2);
- this.collection.add(this.pvm3);
- this.collection.add(this.pvm4);
- this.cvm = new SimpleCollectionValueModel<ModifiablePropertyValueModel<Boolean>>(this.collection);
-
- this.compositePVM = this.buildCompositePVM(cvm);
- }
-
- private PropertyValueModel<Boolean> buildCompositePVM(CollectionValueModel<ModifiablePropertyValueModel<Boolean>> pvms) {
- return CompositeBooleanPropertyValueModel.and(pvms);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGetValue() {
- assertNull(this.compositePVM.getValue());
- ChangeListener listener = this.buildListener();
- this.compositePVM.addChangeListener(listener);
- assertTrue(this.compositePVM.getValue().booleanValue());
- }
-
- public void testValueAndListeners1() {
- assertNull(this.compositePVM.getValue());
- ChangeListener listener = this.buildListener();
- this.compositePVM.addChangeListener(listener);
- assertTrue(this.compositePVM.getValue().booleanValue());
- this.compositePVM.removeChangeListener(listener);
- assertNull(this.compositePVM.getValue());
- }
-
- public void testValueAndListeners2() {
- assertNull(this.compositePVM.getValue());
- ChangeListener listener = this.buildListener();
- this.compositePVM.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(this.compositePVM.getValue().booleanValue());
- this.compositePVM.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertNull(this.compositePVM.getValue());
- }
-
- public void testPropertyChange1() {
- this.compositePVM.addChangeListener(this.buildListener());
- this.verifyPropertyChange();
- }
-
- public void testPropertyChange2() {
- this.compositePVM.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.verifyPropertyChange();
- }
-
- private void verifyPropertyChange() {
- this.event = null;
- this.pvm1.setValue(Boolean.FALSE);
- this.verifyEvent(true, false);
-
- this.event = null;
- this.pvm2.setValue(Boolean.FALSE);
- assertNull(this.event); // no change
-
- this.event = null;
- this.pvm2.setValue(Boolean.TRUE);
- assertNull(this.event); // no change
-
- this.event = null;
- this.pvm1.setValue(Boolean.TRUE);
- this.verifyEvent(false, true);
-
- this.event = null;
- this.pvm4.setValue(Boolean.FALSE);
- this.verifyEvent(true, false);
- }
-
- public void testCollectionChange1() {
- this.compositePVM.addChangeListener(this.buildListener());
- this.verifyCollectionChange();
- }
-
- public void testCollectionChange2() {
- this.compositePVM.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.verifyCollectionChange();
- }
-
- private void verifyCollectionChange() {
- this.event = null;
- ModifiablePropertyValueModel<Boolean> pvm = new SimplePropertyValueModel<Boolean>(Boolean.FALSE);
- this.cvm.add(pvm);
- this.verifyEvent(true, false);
-
- this.event = null;
- this.cvm.remove(pvm);
- this.verifyEvent(false, true);
-
- this.event = null;
- this.cvm.clear();
- this.verifyEvent(Boolean.TRUE, null);
-
- Collection<ModifiablePropertyValueModel<Boolean>> c2 = new ArrayList<ModifiablePropertyValueModel<Boolean>>();
- c2.add(this.pvm1);
- c2.add(this.pvm2);
- this.event = null;
- this.cvm.setValues(c2);
- this.verifyEvent(null, Boolean.TRUE);
- }
-
- public void testLazyListening1() {
- assertFalse(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- ChangeListener listener = this.buildListener();
-
- this.compositePVM.addChangeListener(listener);
- assertTrue(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.compositePVM.removeChangeListener(listener);
- assertFalse(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testLazyListening2() {
- assertFalse(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- ChangeListener listener = this.buildListener();
-
- this.compositePVM.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.compositePVM.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertFalse(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- private ChangeListener buildListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- CompositeBooleanPropertyValueModelTests.this.event = e;
- }
- };
- }
-
- private void verifyEvent(boolean oldValue, boolean newValue) {
- this.verifyEvent(Boolean.valueOf(oldValue), Boolean.valueOf(newValue));
- }
-
- private void verifyEvent(Boolean oldValue, Boolean newValue) {
- assertEquals(this.compositePVM, this.event.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event.getPropertyName());
- assertEquals(oldValue, this.event.getOldValue());
- assertEquals(newValue, this.event.getNewValue());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java
deleted file mode 100644
index 6e8e9346f1..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeCollectionValueModelTests.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.CompositeCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class CompositeCollectionValueModelTests extends TestCase {
- private Neighborhood neighborhood;
- private ModifiablePropertyValueModel<Neighborhood> neighborhoodHolder;
-
- public CompositeCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.neighborhood = new Neighborhood("Hanna-Barbera");
- this.neighborhoodHolder = new SimplePropertyValueModel<Neighborhood>(this.neighborhood);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSynch1() {
- this.verifySynch(this.buildAllMembersComposite(this.neighborhoodHolder));
- }
-
- public void testSynch2() {
- this.verifySynch(this.buildAllMembersComposite2(this.neighborhoodHolder));
- }
-
- private void verifySynch(CollectionValueModel<Member> compositeCVM) {
- assertEquals(0, CollectionTools.size(compositeCVM.iterator()));
- Bag<Family> familiesSynch = new CoordinatedBag<Family>(this.buildFamiliesAspectAdapter(this.neighborhoodHolder));
- Bag<Member> membersSynch = new CoordinatedBag<Member>(compositeCVM);
- this.populateNeighborhood(this.neighborhood);
-
- Family jetsons = this.neighborhood.familyNamed("Jetson");
-
- assertEquals(3, familiesSynch.size());
- assertEquals(12, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(12, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- jetsons.removeMember(jetsons.memberNamed("Astro"));
- assertEquals(3, familiesSynch.size());
- assertEquals(11, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(11, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- jetsons.removeMember(jetsons.memberNamed("Judy"));
- assertEquals(3, familiesSynch.size());
- assertEquals(10, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(10, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- jetsons.addMember("Fido");
- assertEquals(3, familiesSynch.size());
- assertEquals(11, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(11, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- this.neighborhood.removeFamily(jetsons);
- assertEquals(2, familiesSynch.size());
- assertEquals(7, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(7, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- Family bears = this.neighborhood.addFamily("Bear");
- bears.addMember("Yogi");
- assertEquals(3, familiesSynch.size());
- assertEquals(8, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(8, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- bears.addMember("Boo-Boo");
- assertEquals(3, familiesSynch.size());
- assertEquals(9, CollectionTools.size(this.neighborhood.allMembers()));
- assertEquals(9, membersSynch.size());
- assertEquals(CollectionTools.bag(this.neighborhood.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
-
- Neighborhood n2 = new Neighborhood("Hanna-Barbera 2");
- this.neighborhoodHolder.setValue(n2);
- this.populateNeighborhood(n2);
- assertEquals(3, familiesSynch.size());
- assertEquals(12, CollectionTools.size(n2.allMembers()));
- assertEquals(12, membersSynch.size());
- assertEquals(CollectionTools.bag(n2.allMembers()), membersSynch);
- assertEquals(membersSynch, CollectionTools.bag(compositeCVM.iterator()));
- }
-
- public void testNoTransformer() {
- SimpleCollectionValueModel<String> subCVM1 = new SimpleCollectionValueModel<String>();
- SimpleCollectionValueModel<String> subCVM2 = new SimpleCollectionValueModel<String>();
- Collection<CollectionValueModel<String>> collection = new ArrayList<CollectionValueModel<String>>();
- collection.add(subCVM1);
- collection.add(subCVM2);
- Bag<String> synchBag = new CoordinatedBag<String>(new CompositeCollectionValueModel<CollectionValueModel<String>, String>(collection));
-
- assertEquals(0, synchBag.size());
-
- subCVM1.add("foo");
- subCVM1.add("bar");
- subCVM1.add("baz");
- assertEquals(3, synchBag.size());
- assertTrue(synchBag.contains("foo"));
-
- subCVM2.add("joo");
- subCVM2.add("jar");
- subCVM2.add("jaz");
- assertEquals(6, synchBag.size());
- assertTrue(synchBag.contains("foo"));
- assertTrue(synchBag.contains("jaz"));
-
- subCVM1.remove("baz");
- assertEquals(5, synchBag.size());
- assertFalse(synchBag.contains("baz"));
- }
-
- public void testDuplicateItem() {
- Bag<Member> synchBag = new CoordinatedBag<Member>(this.buildAllMembersComposite(this.neighborhoodHolder));
- this.populateNeighborhood(this.neighborhood);
- boolean exCaught = false;
- try {
- this.neighborhood.addFamily(this.neighborhood.familyNamed("Jetson"));
- } catch (IllegalStateException ex) {
- if (ex.getMessage().indexOf("duplicate component") != -1) {
- exCaught = true;
- }
- }
- assertTrue(exCaught);
- assertEquals(12, synchBag.size());
- }
-
- public void testHasListeners() {
- CompositeCollectionValueModel<Family, Member> compositeCVM = this.buildAllMembersComposite(this.neighborhoodHolder);
- CoordinatedBag<Member> synchBag = new CoordinatedBag<Member>(compositeCVM);
- this.populateNeighborhood(this.neighborhood);
- Family jetsons = this.neighborhood.familyNamed("Jetson");
-
- assertTrue(compositeCVM.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(jetsons.hasAnyCollectionChangeListeners(Family.MEMBERS_COLLECTION));
-
- compositeCVM.removeCollectionChangeListener(CollectionValueModel.VALUES, synchBag);
- assertFalse(compositeCVM.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertFalse(jetsons.hasAnyCollectionChangeListeners(Family.MEMBERS_COLLECTION));
-
- compositeCVM.addCollectionChangeListener(CollectionValueModel.VALUES, synchBag);
- assertTrue(compositeCVM.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(jetsons.hasAnyCollectionChangeListeners(Family.MEMBERS_COLLECTION));
- }
-
- private void populateNeighborhood(Neighborhood n) {
- Family family1 = n.addFamily("Flintstone");
- family1.addMember("Fred");
- family1.addMember("Wilma");
- family1.addMember("Pebbles");
- family1.addMember("Dino");
- Family family2 = n.addFamily("Rubble");
- family2.addMember("Barney");
- family2.addMember("Betty");
- family2.addMember("Bamm-Bamm");
- Family family3 = n.addFamily("Jetson");
- family3.addMember("George");
- family3.addMember("Jane");
- family3.addMember("Judy");
- family3.addMember("Elroy");
- family3.addMember("Astro");
- }
-
- private CollectionValueModel<Family> buildFamiliesAspectAdapter(PropertyValueModel<Neighborhood> communeHolder) {
- return new CollectionAspectAdapter<Neighborhood, Family>(communeHolder, Neighborhood.FAMILIES_COLLECTION) {
- @Override
- protected Iterator<Family> iterator_() {
- return this.subject.families();
- }
- };
- }
-
- CollectionValueModel<Member> buildMembersAdapter(Family family) {
- return new CollectionAspectAdapter<Family, Member>(Family.MEMBERS_COLLECTION, family) {
- @Override
- protected Iterator<Member> iterator_() {
- return this.subject.members();
- }
- };
- }
-
- private CompositeCollectionValueModel<Family, Member> buildAllMembersComposite(PropertyValueModel<Neighborhood> communeHolder) {
- // override #transform(Object)
- return new CompositeCollectionValueModel<Family, Member>(this.buildFamiliesAspectAdapter(communeHolder)) {
- @Override
- protected CollectionValueModel<Member> transform(Family family) {
- return CompositeCollectionValueModelTests.this.buildMembersAdapter(family);
- }
- };
- }
-
- private CollectionValueModel<Member> buildAllMembersComposite2(PropertyValueModel<Neighborhood> communeHolder) {
- // build a custom Transformer
- return new CompositeCollectionValueModel<Family, Member>(this.buildFamiliesAspectAdapter(communeHolder), this.buildTransformer());
- }
-
- private Transformer<Family, CollectionValueModel<Member>> buildTransformer() {
- return new Transformer<Family, CollectionValueModel<Member>>() {
- public CollectionValueModel<Member> transform(Family family) {
- return CompositeCollectionValueModelTests.this.buildMembersAdapter(family);
- }
- @Override
- public String toString() {
- return "Local Transformer";
- }
- };
- }
-
-
-// ********** inner classes **********
-
- /**
- * inner class
- */
- public class Neighborhood extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
- private Collection<Family> families = new ArrayList<Family>();
- public static final String FAMILIES_COLLECTION = "families";
-
- public Neighborhood(String name) {
- super();
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- public Iterator<Family> families() {
- return this.families.iterator();
- }
-
- public Family addFamily(String familyName) {
- return this.addFamily(new Family(familyName));
- }
-
- // backdoor to allow duplicates
- public Family addFamily(Family family) {
- this.addItemToCollection(family, this.families, FAMILIES_COLLECTION);
- return family;
- }
-
- public void removeFamily(Family family) {
- this.removeItemFromCollection(family, this.families, FAMILIES_COLLECTION);
- }
-
- public Family familyNamed(String familyName) {
- for (Family family : this.families) {
- if (family.getName().equals(familyName)) {
- return family;
- }
- }
- throw new IllegalArgumentException(familyName);
- }
-
- public Iterator<Member> allMembers() {
- return new CompositeIterator<Member>(this.membersIterators());
- }
-
- private Iterator<Iterator<Member>> membersIterators() {
- return new TransformationIterator<Family, Iterator<Member>>(this.families()) {
- @Override
- protected Iterator<Member> transform(Family family) {
- return family.members();
- }
- };
- }
-
- public Member memberNamed(String familyName, String memberName) {
- return this.familyNamed(familyName).memberNamed(memberName);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- }
-
-
- /**
- * inner class
- */
- public class Family extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
- private Collection<Member> members = new ArrayList<Member>();
- public static final String MEMBERS_COLLECTION = "members";
-
- public Family(String name) {
- super();
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- public Iterator<Member> members() {
- return this.members.iterator();
- }
-
- public Member addMember(String memberName) {
- Member member = new Member(memberName);
- this.addItemToCollection(member, this.members, MEMBERS_COLLECTION);
- return member;
- }
-
- public void removeMember(Member member) {
- this.removeItemFromCollection(member, this.members, MEMBERS_COLLECTION);
- }
-
- public Member memberNamed(String memberName) {
- for (Member member : this.members) {
- if (member.getName().equals(memberName)) {
- return member;
- }
- }
- throw new IllegalArgumentException(memberName);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- }
-
-
- /**
- * inner class
- */
- public class Member extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- public Member(String name) {
- super();
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeListValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeListValueModelTests.java
deleted file mode 100644
index 82cf531454..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositeListValueModelTests.java
+++ /dev/null
@@ -1,1248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.CompositeListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class CompositeListValueModelTests extends TestCase {
- private LocalListValueModel<String> lvm0;
- private LocalListValueModel<String> lvm1;
- private LocalListValueModel<String> lvm2;
- private LocalListValueModel<String> lvm3;
- private LocalListValueModel<LocalListValueModel<String>> uberLVM;
- private CompositeListValueModel<LocalListValueModel<String>, String> compositeLVM;
-
- public CompositeListValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- this.lvm0 = new LocalListValueModel<String>();
- this.lvm0.add("aaa");
- this.lvm0.add("bbb");
- this.lvm0.add("ccc");
-
- this.lvm1 = new LocalListValueModel<String>();
- this.lvm1.add("ddd");
- this.lvm1.add("eee");
-
- this.lvm2 = new LocalListValueModel<String>();
- this.lvm2.add("fff");
-
- this.lvm3 = new LocalListValueModel<String>();
- this.lvm3.add("ggg");
- this.lvm3.add("hhh");
- this.lvm3.add("iii");
- this.lvm3.add("jjj");
- this.lvm3.add("kkk");
-
- this.uberLVM = new LocalListValueModel<LocalListValueModel<String>>();
- this.uberLVM.add(this.lvm0);
- this.uberLVM.add(this.lvm1);
- this.uberLVM.add(this.lvm2);
- this.uberLVM.add(this.lvm3);
-
- this.compositeLVM = new CompositeListValueModel<LocalListValueModel<String>, String>((ListValueModel<LocalListValueModel<String>>) this.uberLVM);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGetInt() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
- assertEquals("aaa", this.compositeLVM.get(0));
- assertEquals("aaa", coordList.get(0));
- assertEquals("bbb", this.compositeLVM.get(1));
- assertEquals("bbb", coordList.get(1));
- assertEquals("ccc", this.compositeLVM.get(2));
- assertEquals("ccc", coordList.get(2));
-
- assertEquals("ddd", this.compositeLVM.get(3));
- assertEquals("ddd", coordList.get(3));
- assertEquals("eee", this.compositeLVM.get(4));
- assertEquals("eee", coordList.get(4));
-
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
-
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testIterator() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
- assertEquals("aaa", this.compositeLVM.iterator().next());
- assertEquals("aaa", coordList.iterator().next());
- Iterator<String> stream1 = coordList.iterator();
- for (Iterator<String> stream2 = this.compositeLVM.iterator(); stream2.hasNext(); ) {
- assertEquals(stream1.next(), stream2.next());
- }
- assertFalse(stream1.hasNext());
- }
-
- public void testSize() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
- assertEquals(11, this.compositeLVM.size());
- assertEquals(11, coordList.size());
- }
-
- public void testToArray() {
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- }
-
- public void testHasListeners() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- assertTrue(this.compositeLVM.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.lvm0.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.compositeLVM.removeListChangeListener(ListValueModel.LIST_VALUES, coordList);
- assertFalse(this.compositeLVM.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.lvm0.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, coordList);
- assertTrue(this.compositeLVM.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.lvm0.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- public void testAddSource_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- LocalListValueModel<String> lvm = new LocalListValueModel<String>();
- lvm.add("xxx");
- lvm.add("yyy");
- lvm.add("zzz");
- this.uberLVM.add(0, lvm);
-
- Object[] expected = new Object[] { "xxx", "yyy", "zzz", "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testAddSource_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- LocalListValueModel<String> lvm = new LocalListValueModel<String>();
- lvm.add("xxx");
- lvm.add("yyy");
- lvm.add("zzz");
- this.uberLVM.add(2, lvm);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "xxx", "yyy", "zzz", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testAddSource_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- LocalListValueModel<String> lvm = new LocalListValueModel<String>();
- lvm.add("xxx");
- lvm.add("yyy");
- lvm.add("zzz");
- this.uberLVM.add(lvm);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk", "xxx", "yyy", "zzz" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testAddSources() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- LocalListValueModel<String> lvmA = new LocalListValueModel<String>();
- lvmA.add("xxx");
- lvmA.add("yyy");
- lvmA.add("zzz");
- LocalListValueModel<String> lvmB = new LocalListValueModel<String>();
- lvmB.add("ppp");
- lvmB.add("qqq");
- lvmB.add("rrr");
- Collection<LocalListValueModel<String>> c = new ArrayList<LocalListValueModel<String>>();
- c.add(lvmA);
- c.add(lvmB);
- this.uberLVM.addAll(2, c);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "xxx", "yyy", "zzz", "ppp", "qqq", "rrr", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(12));
- assertEquals("ggg", coordList.get(12));
- }
-
- public void testRemoveSource_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.remove(0);
-
- Object[] expected = new Object[] { "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(3));
- assertEquals("ggg", coordList.get(3));
- }
-
- public void testRemoveSource_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.remove(2);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(5));
- assertEquals("ggg", coordList.get(5));
- }
-
- public void testRemoveSource_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.remove(3);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
- }
-
- public void testRemoveSources() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.remove(2, 2);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("eee", this.compositeLVM.get(4));
- assertEquals("eee", coordList.get(4));
- }
-
- public void testReplaceSources() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- LocalListValueModel<String> lvmA = new LocalListValueModel<String>();
- lvmA.add("xxx");
- lvmA.add("yyy");
- lvmA.add("zzz");
- LocalListValueModel<String> lvmB = new LocalListValueModel<String>();
- lvmB.add("ppp");
- lvmB.add("qqq");
- lvmB.add("rrr");
- List<LocalListValueModel<String>> list = new ArrayList<LocalListValueModel<String>>();
- list.add(lvmA);
- list.add(lvmB);
- this.uberLVM.set(2, list);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "xxx", "yyy", "zzz", "ppp", "qqq", "rrr" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("qqq", this.compositeLVM.get(9));
- assertEquals("qqq", coordList.get(9));
- }
-
- public void testMoveSources_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.move(0, 2, 2);
-
- Object[] expected = new Object[] { "fff", "ggg", "hhh", "iii", "jjj", "kkk", "aaa", "bbb", "ccc", "ddd", "eee" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(1));
- assertEquals("ggg", coordList.get(1));
- }
-
- public void testMoveSources_Middle() {
- LocalListValueModel<String> lvm4 = new LocalListValueModel<String>();
- lvm4.add("lll");
- lvm4.add("mmm");
- this.uberLVM.add(lvm4);
-
- LocalListValueModel<String> lvm5 = new LocalListValueModel<String>();
- lvm5.add("nnn");
- lvm5.add("ooo");
- lvm5.add("ppp");
- lvm5.add("qqq");
- this.uberLVM.add(lvm5);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.move(1, 3, 2);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ggg", "hhh", "iii", "jjj", "kkk", "lll", "mmm", "ddd", "eee", "fff", "nnn", "ooo", "ppp", "qqq" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(3));
- assertEquals("ggg", coordList.get(3));
- }
-
- public void testMoveSources_End() {
- LocalListValueModel<String> lvm4 = new LocalListValueModel<String>();
- lvm4.add("lll");
- lvm4.add("mmm");
- this.uberLVM.add(lvm4);
-
- LocalListValueModel<String> lvm5 = new LocalListValueModel<String>();
- lvm5.add("nnn");
- lvm5.add("ooo");
- lvm5.add("ppp");
- lvm5.add("qqq");
- this.uberLVM.add(lvm5);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.move(3, 0, 3);
-
- Object[] expected = new Object[] { "ggg", "hhh", "iii", "jjj", "kkk", "lll", "mmm", "nnn", "ooo", "ppp", "qqq", "aaa", "bbb", "ccc", "ddd", "eee", "fff" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(0));
- assertEquals("ggg", coordList.get(0));
- }
-
- public void testMoveSource() {
- LocalListValueModel<String> lvm4 = new LocalListValueModel<String>();
- lvm4.add("lll");
- lvm4.add("mmm");
- this.uberLVM.add(lvm4);
-
- LocalListValueModel<String> lvm5 = new LocalListValueModel<String>();
- lvm5.add("nnn");
- lvm5.add("ooo");
- lvm5.add("ppp");
- lvm5.add("qqq");
- this.uberLVM.add(lvm5);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.move(3, 1);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "fff", "ggg", "hhh", "iii", "jjj", "kkk", "ddd", "eee", "lll", "mmm", "nnn", "ooo", "ppp", "qqq" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ooo", this.compositeLVM.get(14));
- assertEquals("ooo", coordList.get(14));
- }
-
- public void testClearSources() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.clear();
-
- Object[] expected = new Object[0];
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- }
-
- public void testChangeSources1() {
- List<LocalListValueModel<String>> newList = new ArrayList<LocalListValueModel<String>>();
- LocalListValueModel<String> lvm4 = new LocalListValueModel<String>();
- lvm4.add("lll");
- lvm4.add("mmm");
- newList.add(lvm4);
-
- LocalListValueModel<String> lvm5 = new LocalListValueModel<String>();
- lvm5.add("nnn");
- lvm5.add("ooo");
- lvm5.add("ppp");
- lvm5.add("qqq");
- newList.add(lvm5);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.setListValues(newList);
-
- Object[] expected = new Object[] { "lll", "mmm", "nnn", "ooo", "ppp", "qqq" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ooo", this.compositeLVM.get(3));
- assertEquals("ooo", coordList.get(3));
- }
-
- public void testChangeSources2() {
- List<LocalListValueModel<String>> newList = new ArrayList<LocalListValueModel<String>>();
- LocalListValueModel<String> lvm4 = new LocalListValueModel<String>();
- lvm4.add("lll");
- lvm4.add("mmm");
- newList.add(lvm4);
-
- LocalListValueModel<String> lvm5 = new LocalListValueModel<String>();
- lvm5.add("nnn");
- lvm5.add("ooo");
- lvm5.add("ppp");
- lvm5.add("qqq");
- newList.add(lvm5);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.changeListValues(newList);
-
- Object[] expected = new Object[] { "lll", "mmm", "nnn", "ooo", "ppp", "qqq" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ooo", this.compositeLVM.get(3));
- assertEquals("ooo", coordList.get(3));
- }
-
- public void testChangeSources3() {
- ListChangeListener listener = new ErrorListener();
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
-
- List<LocalListValueModel<String>> newList = new ArrayList<LocalListValueModel<String>>();
- newList.add(this.lvm0);
- newList.add(this.lvm1);
- newList.add(this.lvm2);
- newList.add(this.lvm3);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.changeListValues(newList);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ddd", this.compositeLVM.get(3));
- assertEquals("ddd", coordList.get(3));
- }
-
- public void testChangeSources4() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsAdded(ListAddEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
-
- List<LocalListValueModel<String>> newList = new ArrayList<LocalListValueModel<String>>();
- newList.add(this.lvm0);
- newList.add(this.lvm1);
- newList.add(this.lvm2);
- newList.add(this.lvm3);
- LocalListValueModel<String> lvm4 = new LocalListValueModel<String>();
- lvm4.add("lll");
- lvm4.add("mmm");
- newList.add(lvm4);
-
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.changeListValues(newList);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk", "lll", "mmm" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ddd", this.compositeLVM.get(3));
- assertEquals("ddd", coordList.get(3));
- }
-
- public void testChangeSources5() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsRemoved(ListRemoveEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
-
- List<LocalListValueModel<String>> newList = new ArrayList<LocalListValueModel<String>>();
- newList.add(this.lvm0);
- newList.add(this.lvm1);
- newList.add(this.lvm2);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.changeListValues(newList);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ddd", this.compositeLVM.get(3));
- assertEquals("ddd", coordList.get(3));
- }
-
- public void testChangeSources6() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsAdded(ListAddEvent event) { /* OK */ }
- @Override
- public void itemsRemoved(ListRemoveEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
-
- List<LocalListValueModel<String>> newList = new ArrayList<LocalListValueModel<String>>();
- newList.add(this.lvm0);
- newList.add(this.lvm1);
-
- LocalListValueModel<String> lvm4 = new LocalListValueModel<String>();
- lvm4.add("lll");
- lvm4.add("mmm");
- newList.add(lvm4);
-
- newList.add(this.lvm3);
-
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.uberLVM.changeListValues(newList);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "lll", "mmm", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ddd", this.compositeLVM.get(3));
- assertEquals("ddd", coordList.get(3));
- }
-
- public void testAddItem_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.add(0, "xxx");
-
- Object[] expected = new Object[] { "xxx", "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(7));
- assertEquals("ggg", coordList.get(7));
- }
-
- public void testAddItem_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm2.add(1, "xxx");
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "xxx", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(7));
- assertEquals("ggg", coordList.get(7));
- }
-
- public void testAddItem_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.add(5, "xxx");
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk", "xxx" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testAddItems_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.addAll(0, Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "xxx", "yyy", "zzz", "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testAddItems_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm2.addAll(1, Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "xxx", "yyy", "zzz", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testAddItems_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.addAll(5, Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk", "xxx", "yyy", "zzz" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testRemoveItem_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.remove(0);
-
- Object[] expected = new Object[] { "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(5));
- assertEquals("ggg", coordList.get(5));
- }
-
- public void testRemoveItem_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm2.remove(0);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(5));
- assertEquals("ggg", coordList.get(5));
- }
-
- public void testRemoveItem_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.remove(4);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testRemoveItems_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.remove(0, 3);
-
- Object[] expected = new Object[] { "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(3));
- assertEquals("ggg", coordList.get(3));
- }
-
- public void testRemoveItems_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.remove(1, 3);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("kkk", this.compositeLVM.get(7));
- assertEquals("kkk", coordList.get(7));
- }
-
- public void testRemoveItems_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.remove(3, 2);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testReplaceItem_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.set(0, "xxx");
-
- Object[] expected = new Object[] { "xxx", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testReplaceItem_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm2.set(0, "xxx");
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "xxx", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testReplaceItem_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.set(4, "xxx");
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "xxx" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testReplaceItems_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.set(0, Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "xxx", "yyy", "zzz", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testReplaceItems_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.set(1, Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "xxx", "yyy", "zzz", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("kkk", this.compositeLVM.get(10));
- assertEquals("kkk", coordList.get(10));
- }
-
- public void testReplaceItems_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.set(3, Arrays.asList(new String[] { "xxx", "yyy" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "xxx", "yyy" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testMoveItem_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.move(2, 0);
-
- Object[] expected = new Object[] { "bbb", "ccc", "aaa", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testMoveItem_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.move(0, 1);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "eee", "ddd", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testMoveItem_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.move(0, 4);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "kkk", "ggg", "hhh", "iii", "jjj" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(7));
- assertEquals("ggg", coordList.get(7));
- }
-
- public void testMoveItems_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.move(1, 0, 2);
-
- Object[] expected = new Object[] { "ccc", "aaa", "bbb", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testMoveItems_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.add("eee.1");
- this.lvm1.add("eee.2");
- this.lvm1.add("eee.3");
- this.lvm1.move(1, 2, 3);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee.1", "eee.2", "eee.3", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testMoveItems_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.move(0, 2, 3);
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "iii", "jjj", "kkk", "ggg", "hhh" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(9));
- assertEquals("ggg", coordList.get(9));
- }
-
- public void testClearItems_Begin() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.clear();
-
- Object[] expected = new Object[] { "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(3));
- assertEquals("ggg", coordList.get(3));
- }
-
- public void testClearItems_Middle() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.clear();
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(4));
- assertEquals("ggg", coordList.get(4));
- }
-
- public void testClearItems_End() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.clear();
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
- }
-
- public void testChangeItems_Begin1() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.setListValues(Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "xxx", "yyy", "zzz", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testChangeItems_Middle1() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.setListValues(Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "xxx", "yyy", "zzz", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(7));
- assertEquals("ggg", coordList.get(7));
- }
-
- public void testChangeItems_End1() {
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.setListValues(Arrays.asList(new String[] { "xxx", "yyy", "zzz" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "xxx", "yyy", "zzz" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
- }
-
- public void testChangeItems_Begin2() {
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, new ErrorListener());
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.changeListValues(Arrays.asList(new String[] { "aaa", "bbb", "ccc" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testChangeItems_Middle2() {
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, new ErrorListener());
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.changeListValues(Arrays.asList(new String[] { "ddd", "eee" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("hhh", this.compositeLVM.get(7));
- assertEquals("hhh", coordList.get(7));
- }
-
- public void testChangeItems_End2() {
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, new ErrorListener());
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.changeListValues(Arrays.asList(new String[] { "ggg", "hhh", "iii", "jjj", "kkk" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
- }
-
- public void testChangeItems_Begin3() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsReplaced(ListReplaceEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.changeListValues(Arrays.asList(new String[] { "aaa", "bbb", "xxx" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "xxx", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(6));
- assertEquals("ggg", coordList.get(6));
- }
-
- public void testChangeItems_Middle3() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsReplaced(ListReplaceEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.changeListValues(Arrays.asList(new String[] { "ddd", "xxx" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "xxx", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("hhh", this.compositeLVM.get(7));
- assertEquals("hhh", coordList.get(7));
- }
-
- public void testChangeItems_End3() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsReplaced(ListReplaceEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.changeListValues(Arrays.asList(new String[] { "ggg", "hhh", "iii", "xxx", "kkk" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "xxx", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
- }
-
- public void testChangeItems_Begin4() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsAdded(ListAddEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.changeListValues(Arrays.asList(new String[] { "aaa", "bbb", "ccc", "xxx" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "xxx", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("fff", this.compositeLVM.get(6));
- assertEquals("fff", coordList.get(6));
- }
-
- public void testChangeItems_Middle4() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsAdded(ListAddEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.changeListValues(Arrays.asList(new String[] { "ddd", "eee", "xxx" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "xxx", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("ggg", this.compositeLVM.get(7));
- assertEquals("ggg", coordList.get(7));
- }
-
- public void testChangeItems_End4() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsAdded(ListAddEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.changeListValues(Arrays.asList(new String[] { "ggg", "hhh", "iii", "jjj", "kkk", "xxx" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk", "xxx" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
- }
-
- public void testChangeItems_Begin5() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsRemoved(ListRemoveEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm0.changeListValues(Arrays.asList(new String[] { "aaa" }));
-
- Object[] expected = new Object[] { "aaa", "ddd", "eee", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("iii", this.compositeLVM.get(6));
- assertEquals("iii", coordList.get(6));
- }
-
- public void testChangeItems_Middle5() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsRemoved(ListRemoveEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm1.changeListValues(Arrays.asList(new String[] { "ddd" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "fff", "ggg", "hhh", "iii", "jjj", "kkk" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("iii", this.compositeLVM.get(7));
- assertEquals("iii", coordList.get(7));
- }
-
- public void testChangeItems_End5() {
- ListChangeListener listener = new ErrorListener() {
- @Override
- public void itemsRemoved(ListRemoveEvent event) { /* OK */ }
- };
- this.compositeLVM.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- CoordinatedList<String> coordList = new CoordinatedList<String>(this.compositeLVM);
-
- this.lvm3.changeListValues(Arrays.asList(new String[] { "ggg", "hhh", "iii" }));
-
- Object[] expected = new Object[] { "aaa", "bbb", "ccc", "ddd", "eee", "fff", "ggg", "hhh", "iii" };
- assertEquals(expected.length, this.compositeLVM.size());
- assertEquals(expected.length, coordList.size());
- assertTrue(Arrays.equals(expected, this.compositeLVM.toArray()));
- assertTrue(Arrays.equals(expected, coordList.toArray()));
- assertEquals("fff", this.compositeLVM.get(5));
- assertEquals("fff", coordList.get(5));
- }
-
- class ErrorListener implements ListChangeListener {
- public void itemsAdded(ListAddEvent event) {
- fail();
- }
- public void itemsRemoved(ListRemoveEvent event) {
- fail();
- }
- public void itemsMoved(ListMoveEvent event) {
- fail();
- }
- public void itemsReplaced(ListReplaceEvent event) {
- fail();
- }
- public void listCleared(ListClearEvent event) {
- fail();
- }
- public void listChanged(ListChangeEvent event) {
- fail();
- }
- }
-
- class LocalListValueModel<E> extends SimpleListValueModel<E> {
- LocalListValueModel() {
- super();
- }
- void changeListValues(Iterable<E> listValues) {
- if (listValues == null) {
- throw new NullPointerException();
- }
- this.list.clear();
- CollectionTools.addAll(this.list, listValues);
- this.fireListChanged(LIST_VALUES, this.list);
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositePropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositePropertyValueModelTests.java
deleted file mode 100644
index 229cbfede5..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CompositePropertyValueModelTests.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.model.value.CompositePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-public class CompositePropertyValueModelTests extends TestCase {
- private SimplePropertyValueModel<Integer> pvm1;
- private ModifiablePropertyValueModel<Integer> pvm2;
- private ModifiablePropertyValueModel<Integer> pvm3;
- private ModifiablePropertyValueModel<Integer> pvm4;
- private Collection<ModifiablePropertyValueModel<Integer>> collection;
- private SimpleCollectionValueModel<ModifiablePropertyValueModel<Integer>> cvm;
- private PropertyValueModel<Integer> compositePVM;
- PropertyChangeEvent event;
-
-
- public CompositePropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.pvm1 = new SimplePropertyValueModel<Integer>(Integer.valueOf(1));
- this.pvm2 = new SimplePropertyValueModel<Integer>(Integer.valueOf(2));
- this.pvm3 = new SimplePropertyValueModel<Integer>(Integer.valueOf(3));
- this.pvm4 = new SimplePropertyValueModel<Integer>(Integer.valueOf(4));
- this.collection = new ArrayList<ModifiablePropertyValueModel<Integer>>();
- this.collection.add(this.pvm1);
- this.collection.add(this.pvm2);
- this.collection.add(this.pvm3);
- this.collection.add(this.pvm4);
- this.cvm = new SimpleCollectionValueModel<ModifiablePropertyValueModel<Integer>>(this.collection);
-
- this.compositePVM = this.buildCompositePVM(cvm);
- }
-
- private <T extends PropertyValueModel<Integer>> PropertyValueModel<Integer> buildCompositePVM(CollectionValueModel<T> pvms) {
- return new CompositePropertyValueModel<Integer, Integer>(pvms) {
- @Override
- protected Integer buildValue() {
- int sum = 0;
- for (PropertyValueModel<? extends Integer> each : this.collectionModel) {
- sum += each.getValue().intValue();
- }
- return Integer.valueOf(sum);
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGetValue() {
- assertNull(this.compositePVM.getValue());
- ChangeListener listener = this.buildListener();
- this.compositePVM.addChangeListener(listener);
- assertEquals(10, this.compositePVM.getValue().intValue());
- }
-
- public void testValueAndListeners1() {
- assertNull(this.compositePVM.getValue());
- ChangeListener listener = this.buildListener();
- this.compositePVM.addChangeListener(listener);
- assertEquals(10, this.compositePVM.getValue().intValue());
- this.compositePVM.removeChangeListener(listener);
- assertNull(this.compositePVM.getValue());
- }
-
- public void testValueAndListeners2() {
- assertNull(this.compositePVM.getValue());
- ChangeListener listener = this.buildListener();
- this.compositePVM.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertEquals(10, this.compositePVM.getValue().intValue());
- this.compositePVM.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertNull(this.compositePVM.getValue());
- }
-
- public void testPropertyChange1() {
- this.compositePVM.addChangeListener(this.buildListener());
- this.verifyPropertyChange();
- }
-
- public void testPropertyChange2() {
- this.compositePVM.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.verifyPropertyChange();
- }
-
- private void verifyPropertyChange() {
- this.event = null;
- this.pvm1.setValue(Integer.valueOf(5));
- this.verifyEvent(10, 14);
-
- this.event = null;
- this.pvm4.setValue(Integer.valueOf(0));
- this.verifyEvent(14, 10);
- }
-
- public void testCollectionChange1() {
- this.compositePVM.addChangeListener(this.buildListener());
- this.verifyCollectionChange();
- }
-
- public void testCollectionChange2() {
- this.compositePVM.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.verifyCollectionChange();
- }
-
- private void verifyCollectionChange() {
- this.event = null;
- ModifiablePropertyValueModel<Integer> pvm = new SimplePropertyValueModel<Integer>(Integer.valueOf(77));
- this.cvm.add(pvm);
- this.verifyEvent(10, 87);
-
- this.event = null;
- this.cvm.remove(pvm);
- this.verifyEvent(87, 10);
-
- this.event = null;
- this.cvm.clear();
- this.verifyEvent(10, 0);
-
- Collection<ModifiablePropertyValueModel<Integer>> c2 = new ArrayList<ModifiablePropertyValueModel<Integer>>();
- c2.add(this.pvm1);
- c2.add(this.pvm2);
- this.event = null;
- this.cvm.setValues(c2);
- this.verifyEvent(0, 3);
- }
-
- public void testLazyListening1() {
- assertFalse(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- ChangeListener listener = this.buildListener();
-
- this.compositePVM.addChangeListener(listener);
- assertTrue(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.compositePVM.removeChangeListener(listener);
- assertFalse(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testLazyListening2() {
- assertFalse(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- ChangeListener listener = this.buildListener();
-
- this.compositePVM.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.compositePVM.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertFalse(this.pvm1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- private ChangeListener buildListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- CompositePropertyValueModelTests.this.event = e;
- }
- };
- }
-
- private void verifyEvent(int oldValue, int newValue) {
- assertEquals(this.compositePVM, this.event.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event.getPropertyName());
- assertEquals(Integer.valueOf(oldValue), this.event.getOldValue());
- assertEquals(Integer.valueOf(newValue), this.event.getNewValue());
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CoordinatedBag.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CoordinatedBag.java
deleted file mode 100644
index 508a4d62f4..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CoordinatedBag.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-
-/**
- * Helper class that keeps an internal collection in synch with the
- * collection held by a collection value model.
- */
-class CoordinatedBag<E> implements Bag<E>, CollectionChangeListener {
-
- private Bag<E> bag = new HashBag<E>();
-
- CoordinatedBag(CollectionValueModel<E> cvm) {
- cvm.addCollectionChangeListener(CollectionValueModel.VALUES, this);
- }
-
-
- // ********** Collection implementation **********
-
- public boolean add(E o) {
- return this.bag.add(o);
- }
-
- public boolean addAll(Collection<? extends E> c) {
- return this.bag.addAll(c);
- }
-
- public void clear() {
- this.bag.clear();
- }
-
- public boolean contains(Object o) {
- return this.bag.contains(o);
- }
-
- public boolean containsAll(Collection<?> c) {
- return this.bag.containsAll(c);
- }
-
- public boolean isEmpty() {
- return this.bag.isEmpty();
- }
-
- public Iterator<E> iterator() {
- return this.bag.iterator();
- }
-
- public boolean remove(Object o) {
- return this.bag.remove(o);
- }
-
- public boolean removeAll(Collection<?> c) {
- return this.bag.removeAll(c);
- }
-
- public boolean retainAll(Collection<?> c) {
- return this.bag.retainAll(c);
- }
-
- public int size() {
- return this.bag.size();
- }
-
- public Object[] toArray() {
- return this.bag.toArray();
- }
-
- public <T> T[] toArray(T[] a) {
- return this.bag.toArray(a);
- }
-
-
- // ********** Bag implementation **********
-
- public int count(Object o) {
- return this.bag.count(o);
- }
-
- public boolean add(E o, int count) {
- return this.bag.add(o, count);
- }
-
- public boolean remove(Object o, int count) {
- return this.bag.remove(o, count);
- }
-
- public Iterator<E> uniqueIterator() {
- return this.bag.uniqueIterator();
- }
-
- public int uniqueCount() {
- return this.bag.uniqueCount();
- }
-
- public Iterator<Bag.Entry<E>> entries() {
- return this.bag.entries();
- }
-
- // ********** CollectionChangeListener implementation **********
-
- @SuppressWarnings("unchecked")
- public void itemsAdded(CollectionAddEvent event) {
- for (E item : (Iterable<E>) event.getItems()) {
- this.bag.add(item);
- }
- }
-
- @SuppressWarnings("unchecked")
- public void itemsRemoved(CollectionRemoveEvent event) {
- for (E item : (Iterable<E>) event.getItems()) {
- this.bag.remove(item);
- }
- }
-
- public void collectionCleared(CollectionClearEvent event) {
- this.bag.clear();
- }
-
- @SuppressWarnings("unchecked")
- public void collectionChanged(CollectionChangeEvent event) {
- this.bag.clear();
- CollectionTools.addAll(this.bag, ((CollectionValueModel<E>) event.getSource()).iterator());
- }
-
-
- // ********** standard methods **********
-
- @Override
- public boolean equals(Object o) {
- return this.bag.equals(o);
- }
-
- @Override
- public int hashCode() {
- return this.bag.hashCode();
- }
-
- @Override
- public String toString() {
- return this.bag.toString();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CoordinatedList.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CoordinatedList.java
deleted file mode 100644
index 95cf02457b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/CoordinatedList.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import javax.swing.ListModel;
-import javax.swing.event.ListDataEvent;
-import javax.swing.event.ListDataListener;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- * Helper class that keeps an internal list in synch with the
- * list held by a list value model.
- */
-public class CoordinatedList<E> implements List<E>, ListChangeListener, ListDataListener {
- private List<E> list = new ArrayList<E>();
-
- public CoordinatedList(ListValueModel<E> listValueModel) {
- listValueModel.addListChangeListener(ListValueModel.LIST_VALUES, this);
- for (Iterator<E> stream = listValueModel.iterator(); stream.hasNext(); ) {
- this.add(stream.next());
- }
- }
-
- public CoordinatedList(ListModel listModel) {
- listModel.addListDataListener(this);
- for (int i = 0; i < listModel.getSize(); i++) {
- this.add(i, this.getElementAt(listModel, i));
- }
- }
-
-
- // ********** List implementation **********
-
- public void add(int index, E element) {
- this.list.add(index, element);
- }
-
- public boolean add(E o) {
- return this.list.add(o);
- }
-
- public boolean addAll(Collection<? extends E> c) {
- return this.list.addAll(c);
- }
-
- public boolean addAll(int index, Collection<? extends E> c) {
- return this.list.addAll(index, c);
- }
-
- public void clear() {
- this.list.clear();
- }
-
- public boolean contains(Object o) {
- return this.list.contains(o);
- }
-
- public boolean containsAll(Collection<?> c) {
- return this.list.containsAll(c);
- }
-
- public E get(int index) {
- return this.list.get(index);
- }
-
- public int indexOf(Object o) {
- return this.list.indexOf(o);
- }
-
- public boolean isEmpty() {
- return this.list.isEmpty();
- }
-
- public Iterator<E> iterator() {
- return this.list.iterator();
- }
-
- public int lastIndexOf(Object o) {
- return this.list.lastIndexOf(o);
- }
-
- public ListIterator<E> listIterator() {
- return this.list.listIterator();
- }
-
- public ListIterator<E> listIterator(int index) {
- return this.list.listIterator(index);
- }
-
- public E remove(int index) {
- return this.list.remove(index);
- }
-
- public boolean remove(Object o) {
- return this.list.remove(o);
- }
-
- public boolean removeAll(Collection<?> c) {
- return this.list.removeAll(c);
- }
-
- public boolean retainAll(Collection<?> c) {
- return this.list.retainAll(c);
- }
-
- public E set(int index, E element) {
- return this.list.set(index, element);
- }
-
- public int size() {
- return this.list.size();
- }
-
- public List<E> subList(int fromIndex, int toIndex) {
- return this.list.subList(fromIndex, toIndex);
- }
-
- public Object[] toArray() {
- return this.list.toArray();
- }
-
- public <T> T[] toArray(T[] a) {
- return this.list.toArray(a);
- }
-
-
- // ********** ListChangeListener implementation **********
-
- public void itemsAdded(ListAddEvent e) {
- int i = e.getIndex();
- for (E item : this.getItems(e)) {
- this.list.add(i++, item);
- }
- }
-
- public void itemsRemoved(ListRemoveEvent e) {
- int base = e.getIndex();
- for (int i = e.getItemsSize(); i-- > 0; ) {
- this.list.remove(base + i); // remove from end
- }
- }
-
- public void itemsReplaced(ListReplaceEvent e) {
- int i = e.getIndex();
- for (E item : this.getNewItems(e)) {
- this.list.set(i++, item);
- }
- }
-
- public void itemsMoved(ListMoveEvent e) {
- CollectionTools.move(this.list, e.getTargetIndex(), e.getSourceIndex(), e.getLength());
- }
-
- public void listCleared(ListClearEvent e) {
- this.list.clear();
- }
-
- public void listChanged(ListChangeEvent e) {
- this.list.clear();
- CollectionTools.addAll(this.list, this.getSource(e).iterator());
- }
-
-
- // ********** ListDataListener implementation **********
-
- public void contentsChanged(ListDataEvent e) {
- this.list.clear();
- ListModel lm = (ListModel) e.getSource();
- int size = lm.getSize();
- for (int i = 0; i < size; i++) {
- this.list.add(i, this.getElementAt(lm, i));
- }
- }
-
- public void intervalAdded(ListDataEvent e) {
- ListModel lm = (ListModel) e.getSource();
- int start = Math.min(e.getIndex0(), e.getIndex1());
- int end = Math.max(e.getIndex0(), e.getIndex1());
- for (int i = start; i <= end; i++) {
- this.list.add(i, this.getElementAt(lm, i));
- }
- }
-
- public void intervalRemoved(ListDataEvent e) {
- int start = Math.min(e.getIndex0(), e.getIndex1());
- int end = Math.max(e.getIndex0(), e.getIndex1());
- int length = end - start + 1;
- for (int i = 1; i <= length; i++) {
- this.list.remove(start);
- }
- }
-
-
- // ********** standard methods **********
-
- @Override
- public boolean equals(Object o) {
- return this.list.equals(o);
- }
-
- @Override
- public int hashCode() {
- return this.list.hashCode();
- }
-
- @Override
- public String toString() {
- return this.list.toString();
- }
-
-
- // ********** internal methods **********
-
- /**
- * minimize the scope of the suppressed warnings.=
- */
- @SuppressWarnings("unchecked")
- private E getElementAt(ListModel listModel, int index) {
- return (E) listModel.getElementAt(index);
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private Iterable<E> getItems(ListAddEvent event) {
- return (Iterable<E>) event.getItems();
- }
-
- // minimized scope of suppressed warnings
- @SuppressWarnings("unchecked")
- private Iterable<E> getNewItems(ListReplaceEvent event) {
- return (Iterable<E>) event.getNewItems();
- }
-
- /**
- * minimize the scope of the suppressed warnings.=
- */
- @SuppressWarnings("unchecked")
- private ListValueModel<E> getSource(ListChangeEvent event) {
- return (ListValueModel<E>) event.getSource();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoubleModifiablePropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoubleModifiablePropertyValueModelTests.java
deleted file mode 100644
index d12aae8f8c..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoubleModifiablePropertyValueModelTests.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import org.eclipse.jpt.common.utility.internal.model.value.DoubleModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-@SuppressWarnings("nls")
-public class DoubleModifiablePropertyValueModelTests
- extends DoublePropertyValueModelTests
-{
- public DoubleModifiablePropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected PropertyValueModel<String> buildDoubleModel() {
- return new DoubleModifiablePropertyValueModel<String>(this.stringModelModel);
- }
-
- protected ModifiablePropertyValueModel<String> getDoubleModel() {
- return (ModifiablePropertyValueModel<String>) this.doubleModel;
- }
-
- public void testSetValue() {
- assertEquals("foo", this.stringModel.getValue());
- assertEquals(this.stringModel, this.stringModelModel.getValue());
- assertNull(this.doubleModel.getValue());
- this.doubleModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.doubleModelListener);
- assertEquals("foo", this.doubleModel.getValue());
-
- this.getDoubleModel().setValue("bar");
- assertEquals("bar", this.stringModel.getValue());
- assertEquals("bar", this.doubleModel.getValue());
-
- this.stringModelModel.setValue(null);
- assertNull(this.doubleModel.getValue());
- this.getDoubleModel().setValue("TTT"); // NOP?
- assertEquals("bar", this.stringModel.getValue());
- assertNull(this.doubleModel.getValue());
- }
-
- public void testPropertyChange3() {
- this.stringModel.addChangeListener(this.stringModelListener);
- this.stringModelModel.addChangeListener(this.stringModelModelListener);
- this.doubleModel.addChangeListener(this.doubleModelListener);
- this.verifyPropertyChanges2();
- }
-
- public void testPropertyChange4() {
- this.stringModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.stringModelListener);
- this.stringModelModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.stringModelModelListener);
- this.doubleModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.doubleModelListener);
- this.verifyPropertyChanges2();
- }
-
- protected void verifyPropertyChanges2() {
- this.stringModelEvent = null;
- this.stringModelModelEvent = null;
- this.doubleModelEvent = null;
- this.getDoubleModel().setValue("bar");
- this.verifyEvent(this.stringModelEvent, this.stringModel, "foo", "bar");
- assertNull(this.stringModelModelEvent);
- this.verifyEvent(this.doubleModelEvent, this.doubleModel, "foo", "bar");
-
- this.stringModelEvent = null;
- this.stringModelModelEvent = null;
- this.doubleModelEvent = null;
- this.getDoubleModel().setValue(null);
- this.verifyEvent(this.stringModelEvent, this.stringModel, "bar", null);
- assertNull(this.stringModelModelEvent);
- this.verifyEvent(this.doubleModelEvent, this.doubleModel, "bar", null);
-
- this.stringModelEvent = null;
- this.stringModelModelEvent = null;
- this.doubleModelEvent = null;
- this.getDoubleModel().setValue("foo");
- this.verifyEvent(this.stringModelEvent, this.stringModel, null, "foo");
- assertNull(this.stringModelModelEvent);
- this.verifyEvent(this.doubleModelEvent, this.doubleModel, null, "foo");
-
- this.stringModelEvent = null;
- this.stringModelModelEvent = null;
- this.doubleModelEvent = null;
- ModifiablePropertyValueModel<String> stringModel2 = new SimplePropertyValueModel<String>("TTT");
- this.stringModelModel.setValue(stringModel2);
- assertNull(this.stringModelEvent);
- this.verifyEvent(this.stringModelModelEvent, this.stringModelModel, this.stringModel, stringModel2);
- this.verifyEvent(this.doubleModelEvent, this.doubleModel, "foo", "TTT");
-
- this.stringModelEvent = null;
- this.stringModelModelEvent = null;
- this.doubleModelEvent = null;
- this.getDoubleModel().setValue("XXX");
- assertNull(this.stringModelEvent);
- assertNull(this.stringModelModelEvent);
- this.verifyEvent(this.doubleModelEvent, this.doubleModel, "TTT", "XXX");
- assertEquals("foo", this.stringModel.getValue());
- assertEquals("XXX", stringModel2.getValue());
-
- this.stringModelEvent = null;
- this.stringModelModelEvent = null;
- this.doubleModelEvent = null;
- this.stringModelModel.setValue(this.stringModel);
- assertNull(this.stringModelEvent);
- this.verifyEvent(this.stringModelModelEvent, this.stringModelModel, stringModel2, this.stringModel);
- this.verifyEvent(this.doubleModelEvent, this.doubleModel, "XXX", "foo");
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoublePropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoublePropertyValueModelTests.java
deleted file mode 100644
index e9cf6ae65b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/DoublePropertyValueModelTests.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.DoublePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class DoublePropertyValueModelTests
- extends TestCase
-{
- protected ModifiablePropertyValueModel<String> stringModel;
- protected ChangeListener stringModelListener;
- protected PropertyChangeEvent stringModelEvent;
-
- protected ModifiablePropertyValueModel<ModifiablePropertyValueModel<String>> stringModelModel;
- protected ChangeListener stringModelModelListener;
- protected PropertyChangeEvent stringModelModelEvent;
-
- protected PropertyValueModel<String> doubleModel;
- protected ChangeListener doubleModelListener;
- protected PropertyChangeEvent doubleModelEvent;
-
- public DoublePropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.stringModel = new SimplePropertyValueModel<String>("foo");
- this.stringModelListener = new StringModelListener();
-
- this.stringModelModel = new SimplePropertyValueModel<ModifiablePropertyValueModel<String>>(stringModel);
- this.stringModelModelListener = new StringModelModelListener();
-
- this.doubleModel = this.buildDoubleModel();
- this.doubleModelListener = new DoubleModelListener();
- }
-
- protected PropertyValueModel<String> buildDoubleModel() {
- return new DoublePropertyValueModel<String>(this.stringModelModel);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGetValue1() {
- assertEquals("foo", this.stringModel.getValue());
- assertEquals(this.stringModel, this.stringModelModel.getValue());
- assertNull(this.doubleModel.getValue());
- this.doubleModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.doubleModelListener);
- assertEquals("foo", this.doubleModel.getValue());
-
- this.stringModel.setValue("bar");
- assertEquals("bar", this.stringModel.getValue());
- assertEquals("bar", this.doubleModel.getValue());
-
- this.stringModel.setValue("baz");
- assertEquals("baz", this.stringModel.getValue());
- assertEquals("baz", this.doubleModel.getValue());
-
- this.stringModel.setValue(null);
- assertNull(this.stringModel.getValue());
- assertNull(this.doubleModel.getValue());
-
- this.stringModel.setValue("foo");
- assertEquals("foo", this.stringModel.getValue());
- assertEquals("foo", this.doubleModel.getValue());
- }
-
- public void testGetValue2() {
- assertNull(this.doubleModel.getValue());
- this.doubleModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.doubleModelListener);
- assertEquals("foo", this.doubleModel.getValue());
-
- this.stringModelModel.setValue(null);
- assertNull(this.doubleModel.getValue());
-
- ModifiablePropertyValueModel<String> stringModel2 = new SimplePropertyValueModel<String>("TTT");
- this.stringModelModel.setValue(stringModel2);
- assertEquals("TTT", this.doubleModel.getValue());
-
- this.stringModelModel.setValue(this.stringModel);
- assertEquals("foo", this.doubleModel.getValue());
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.stringModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.stringModelModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- this.doubleModel.addChangeListener(this.doubleModelListener);
- assertTrue(((AbstractModel) this.stringModel).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.stringModelModel).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.doubleModel.removeChangeListener(this.doubleModelListener);
- assertTrue(((AbstractModel) this.stringModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) this.stringModelModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.doubleModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.doubleModelListener);
- assertTrue(((AbstractModel) this.stringModel).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.doubleModel.removePropertyChangeListener(PropertyValueModel.VALUE, this.doubleModelListener);
- assertTrue(((AbstractModel) this.stringModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.doubleModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.doubleModelListener);
- ModifiablePropertyValueModel<String> stringModel2 = new SimplePropertyValueModel<String>("TTT");
- assertTrue(((AbstractModel) this.stringModel).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) stringModel2).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- this.stringModelModel.setValue(stringModel2);
- assertTrue(((AbstractModel) this.stringModel).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) stringModel2).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.stringModelModel.setValue(this.stringModel);
- assertTrue(((AbstractModel) this.stringModel).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(((AbstractModel) stringModel2).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testPropertyChange1() {
- this.stringModel.addChangeListener(this.stringModelListener);
- this.stringModelModel.addChangeListener(this.stringModelModelListener);
- this.doubleModel.addChangeListener(this.doubleModelListener);
- this.verifyPropertyChanges1();
- }
-
- public void testPropertyChange2() {
- this.stringModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.stringModelListener);
- this.stringModelModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.stringModelModelListener);
- this.doubleModel.addPropertyChangeListener(PropertyValueModel.VALUE, this.doubleModelListener);
- this.verifyPropertyChanges1();
- }
-
- protected void verifyPropertyChanges1() {
- this.stringModelEvent = null;
- this.stringModelModelEvent = null;
- this.doubleModelEvent = null;
- this.stringModel.setValue("bar");
- this.verifyEvent(this.stringModelEvent, this.stringModel, "foo", "bar");
- assertNull(this.stringModelModelEvent);
- this.verifyEvent(this.doubleModelEvent, this.doubleModel, "foo", "bar");
-
- this.stringModelEvent = null;
- this.stringModelModelEvent = null;
- this.doubleModelEvent = null;
- this.stringModel.setValue(null);
- this.verifyEvent(this.stringModelEvent, this.stringModel, "bar", null);
- assertNull(this.stringModelModelEvent);
- this.verifyEvent(this.doubleModelEvent, this.doubleModel, "bar", null);
-
- this.stringModelEvent = null;
- this.stringModelModelEvent = null;
- this.doubleModelEvent = null;
- this.stringModel.setValue("foo");
- this.verifyEvent(this.stringModelEvent, this.stringModel, null, "foo");
- assertNull(this.stringModelModelEvent);
- this.verifyEvent(this.doubleModelEvent, this.doubleModel, null, "foo");
-
- this.stringModelEvent = null;
- this.stringModelModelEvent = null;
- this.doubleModelEvent = null;
- ModifiablePropertyValueModel<String> stringModel2 = new SimplePropertyValueModel<String>("TTT");
- this.stringModelModel.setValue(stringModel2);
- assertNull(this.stringModelEvent);
- this.verifyEvent(this.stringModelModelEvent, this.stringModelModel, this.stringModel, stringModel2);
- this.verifyEvent(this.doubleModelEvent, this.doubleModel, "foo", "TTT");
-
- this.stringModelEvent = null;
- this.stringModelModelEvent = null;
- this.doubleModelEvent = null;
- this.stringModelModel.setValue(this.stringModel);
- assertNull(this.stringModelEvent);
- this.verifyEvent(this.stringModelModelEvent, this.stringModelModel, stringModel2, this.stringModel);
- this.verifyEvent(this.doubleModelEvent, this.doubleModel, "TTT", "foo");
- }
-
- protected void verifyEvent(PropertyChangeEvent event, Object source, Object oldValue, Object newValue) {
- assertEquals(source, event.getSource());
- assertEquals(PropertyValueModel.VALUE, event.getPropertyName());
- assertEquals(oldValue, event.getOldValue());
- assertEquals(newValue, event.getNewValue());
- }
-
- protected class StringModelListener
- extends ChangeAdapter
- {
- @Override
- public void propertyChanged(PropertyChangeEvent event) {
- DoublePropertyValueModelTests.this.stringModelEvent = event;
- }
- }
-
- protected class StringModelModelListener
- extends ChangeAdapter
- {
- @Override
- public void propertyChanged(PropertyChangeEvent event) {
- DoublePropertyValueModelTests.this.stringModelModelEvent = event;
- }
- }
-
- protected class DoubleModelListener
- extends ChangeAdapter
- {
- @Override
- public void propertyChanged(PropertyChangeEvent event) {
- DoublePropertyValueModelTests.this.doubleModelEvent = event;
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ExtendedListValueModelWrapperTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ExtendedListValueModelWrapperTests.java
deleted file mode 100644
index 56e1a25d14..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ExtendedListValueModelWrapperTests.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ExtendedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ExtendedListValueModelWrapperTests extends TestCase {
- private SimpleListValueModel<String> listHolder;
- private ListValueModel<String> extendedListHolder;
- ListEvent event;
- String eventType;
-
- private static final String ADD = "add";
- private static final String REMOVE = "remove";
- private static final String REPLACE = "replace";
- private static final String MOVE = "move";
- private static final String CLEAR = "clear";
- private static final String CHANGE = "change";
-
- public ExtendedListValueModelWrapperTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listHolder = new SimpleListValueModel<String>(this.buildList());
- this.extendedListHolder = this.buildExtendedListHolder(this.listHolder);
- }
-
- private List<String> buildList() {
- List<String> result = new ArrayList<String>();
- result.add("A");
- result.add("B");
- result.add("C");
- result.add("D");
- return result;
- }
-
- private List<String> buildExtendedList() {
- List<String> extendedList = new ArrayList<String>();
- extendedList.addAll(this.buildPrefix());
- extendedList.addAll(this.buildList());
- extendedList.addAll(this.buildSuffix());
- return extendedList;
- }
-
- private List<String> buildPrefix() {
- List<String> prefix = new ArrayList<String>();
- prefix.add("x");
- prefix.add("y");
- prefix.add("z");
- return prefix;
- }
-
- private List<String> buildSuffix() {
- List<String> suffix = new ArrayList<String>();
- suffix.add("i");
- suffix.add("j");
- return suffix;
- }
-
- private ListValueModel<String> buildExtendedListHolder(ListValueModel<String> lvm) {
- return new ExtendedListValueModelWrapper<String>(this.buildPrefix(), lvm, this.buildSuffix());
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- assertEquals(this.buildExtendedList(), CollectionTools.list(this.extendedListHolder.iterator()));
- }
-
- public void testSize() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- assertEquals(this.buildExtendedList().size(), CollectionTools.size(this.extendedListHolder.iterator()));
- assertEquals(this.buildExtendedList().size(), this.extendedListHolder.size());
- }
-
- private boolean extendedListContains(Object item) {
- return CollectionTools.contains(this.extendedListHolder.iterator(), item);
- }
-
- private boolean extendedListContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.extendedListHolder.iterator(), items);
- }
-
- private boolean extendedListContainsAny(Collection<String> items) {
- List<String> extendedList = CollectionTools.list(this.extendedListHolder.iterator());
- for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
- if (extendedList.contains(stream.next())) {
- return true;
- }
- }
- return false;
- }
-
- private boolean listContains(Object item) {
- return CollectionTools.contains(this.listHolder.iterator(), item);
- }
-
- private boolean listContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.listHolder.iterator(), items);
- }
-
-// private boolean listContainsAny(Collection<String> items) {
-// List<String> extendedList = CollectionTools.list(this.listHolder.iterator());
-// for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
-// if (extendedList.contains(stream.next())) {
-// return true;
-// }
-// }
-// return false;
-// }
-//
- public void testAdd1() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertFalse(this.extendedListContains("E"));
- this.listHolder.add(4, "E");
- assertTrue(this.extendedListContains("E"));
- assertTrue(this.listContains("E"));
- }
-
- public void testAdd2() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertFalse(this.extendedListContains(null));
- this.listHolder.add(4, null);
- assertTrue(this.extendedListContains(null));
- assertTrue(this.listContains(null));
- }
-
- private List<String> buildAddList() {
- List<String> addList = new ArrayList<String>();
- addList.add("E");
- addList.add("F");
- return addList;
- }
-
- public void testAddAll1() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertFalse(this.extendedListContainsAny(this.buildAddList()));
- this.listHolder.addAll(4, this.buildAddList());
- assertTrue(this.extendedListContainsAll(this.buildAddList()));
- assertTrue(this.listContainsAll(this.buildAddList()));
- }
-
- public void testRemove1() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertTrue(this.extendedListContains("B"));
- this.listHolder.remove(this.buildList().indexOf("B"));
- assertFalse(this.extendedListContains("B"));
- assertFalse(this.listContains("B"));
- }
-
- public void testListChangeGeneric() {
- this.extendedListHolder.addChangeListener(this.buildListener());
- this.verifyListChange();
- }
-
- public void testListChangeNamed() {
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- this.verifyListChange();
- }
-
- private void verifyListChange() {
- this.event = null;
- this.eventType = null;
- this.listHolder.add(4, "E");
- this.verifyEvent(ADD, 7, "E");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.add(5, null);
- this.verifyEvent(ADD, 8, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(5);
- this.verifyEvent(REMOVE, 8, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(4);
- this.verifyEvent(REMOVE, 7, "E");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.addAll(0, this.buildList());
- this.verifyEvent(ADD);
- assertEquals(this.buildList(), CollectionTools.list(((ListAddEvent) this.event).getItems()));
-
- this.event = null;
- this.eventType = null;
- this.listHolder.set(0, "AA");
- this.verifyEvent(REPLACE);
- assertFalse(CollectionTools.contains(((ListReplaceEvent) this.event).getNewItems(), "A"));
- assertTrue(CollectionTools.contains(((ListReplaceEvent) this.event).getNewItems(), "AA"));
- }
-
- private ChangeListener buildListener() {
- return new ChangeAdapter() {
- @Override
- public void itemsAdded(ListAddEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = ADD;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- @Override
- public void itemsRemoved(ListRemoveEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = REMOVE;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- @Override
- public void itemsReplaced(ListReplaceEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = REPLACE;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- @Override
- public void itemsMoved(ListMoveEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = MOVE;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- @Override
- public void listCleared(ListClearEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = CLEAR;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- @Override
- public void listChanged(ListChangeEvent e) {
- ExtendedListValueModelWrapperTests.this.eventType = CHANGE;
- ExtendedListValueModelWrapperTests.this.event = e;
- }
- };
- }
-
- private void verifyEvent(String type) {
- assertEquals(type, this.eventType);
- assertEquals(this.extendedListHolder, this.event.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event.getListName());
- }
-
- private void verifyEvent(String type, int index, Object item) {
- this.verifyEvent(type);
- if (type == ADD) {
- assertEquals(index, ((ListAddEvent) this.event).getIndex());
- assertEquals(item, ((ListAddEvent) this.event).getItems().iterator().next());
- } else if (type == REMOVE) {
- assertEquals(index, ((ListRemoveEvent) this.event).getIndex());
- assertEquals(item, ((ListRemoveEvent) this.event).getItems().iterator().next());
- }
- }
-
- public void testHasListeners() {
- /*
- * adding listeners to the extended list will cause listeners
- * to be added to the wrapped list;
- * likewise, removing listeners from the extended list will
- * cause listeners to be removed from the wrapped list
- */
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ChangeListener listener = this.buildListener();
-
- this.extendedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertTrue(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.extendedListHolder.removeListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.extendedListHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.extendedListHolder.removeChangeListener(listener);
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java
deleted file mode 100644
index df0787fe93..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/FilteringCollectionValueModelTests.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Vector;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.FilteringCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class FilteringCollectionValueModelTests extends TestCase {
- private SimpleCollectionValueModel<String> collectionHolder;
- CollectionAddEvent addEvent;
- CollectionRemoveEvent removeEvent;
- CollectionClearEvent collectionClearedEvent;
- CollectionChangeEvent collectionChangedEvent;
-
- private CollectionValueModel<String> filteredCollectionHolder;
- CollectionAddEvent filteredAddEvent;
- CollectionRemoveEvent filteredRemoveEvent;
- CollectionClearEvent filteredCollectionClearedEvent;
- CollectionChangeEvent filteredCollectionChangedEvent;
-
- public FilteringCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.collectionHolder = new SimpleCollectionValueModel<String>(buildCollection());
- this.filteredCollectionHolder = new FilteringCollectionValueModel<String>(this.collectionHolder, this.buildFilter());
- }
-
- private Collection<String> buildCollection() {
- Collection<String> collection = new Vector<String>();
- collection.add("foo");
- return collection;
- }
-
- private Filter<String> buildFilter() {
- return new Filter<String>() {
- public boolean accept(String s) {
- return s.startsWith("b");
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- // add a listener to "activate" the wrapper
- this.filteredCollectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildFilteredListener());
-
- assertEquals("foo", this.collectionHolder.iterator().next());
- assertFalse(this.filteredCollectionHolder.iterator().hasNext());
-
- this.collectionHolder.add("bar");
- Iterator<String> collectionHolderValue = this.collectionHolder.iterator();
- assertEquals("foo", collectionHolderValue.next());
- assertEquals("bar", collectionHolderValue.next());
- assertTrue(this.filteredCollectionHolder.iterator().hasNext());
- assertEquals("bar", this.filteredCollectionHolder.iterator().next());
-
- this.collectionHolder.remove("bar");
- assertEquals("foo", this.collectionHolder.iterator().next());
- assertFalse(this.filteredCollectionHolder.iterator().hasNext());
-
- this.collectionHolder.remove("foo");
- assertFalse(this.collectionHolder.iterator().hasNext());
- assertFalse(this.filteredCollectionHolder.iterator().hasNext());
-
- this.collectionHolder.add("foo");
- assertEquals("foo", this.collectionHolder.iterator().next());
- assertFalse(this.filteredCollectionHolder.iterator().hasNext());
- }
-
- public void testSetValue() {
- // add a listener to "activate" the wrapper
- this.filteredCollectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildFilteredListener());
-
- Collection<String> newCollection = new Vector<String>();
- newCollection.add("fox");
- newCollection.add("baz");
-
- this.collectionHolder.setValues(newCollection);
-
- Iterator<String> collectionValues = this.collectionHolder.iterator();
- assertEquals("fox", collectionValues.next());
- assertEquals("baz", collectionValues.next());
- Iterator<String> filteredCollectionValues = this.filteredCollectionHolder.iterator();
- assertEquals("baz", filteredCollectionValues.next());
- assertFalse(filteredCollectionValues.hasNext());
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.collectionHolder).hasNoCollectionChangeListeners(CollectionValueModel.VALUES));
- ChangeListener listener = this.buildFilteredChangeListener();
- this.filteredCollectionHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.filteredCollectionHolder.removeChangeListener(listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasNoCollectionChangeListeners(CollectionValueModel.VALUES));
-
- this.filteredCollectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.filteredCollectionHolder.removeCollectionChangeListener(CollectionValueModel.VALUES, listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasNoCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
- public void testCollectionChange1() {
- this.collectionHolder.addChangeListener(this.buildChangeListener());
- this.filteredCollectionHolder.addChangeListener(this.buildFilteredChangeListener());
- this.verifyCollectionChanges();
- }
-
- public void testCollectionChange2() {
- this.collectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildListener());
- this.filteredCollectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildFilteredListener());
- this.verifyCollectionChanges();
- }
-
- private void clearEvents() {
- this.addEvent = null;
- this.removeEvent = null;
- this.collectionClearedEvent = null;
- this.collectionChangedEvent = null;
- this.filteredAddEvent = null;
- this.filteredRemoveEvent = null;
- this.filteredCollectionClearedEvent = null;
- this.filteredCollectionChangedEvent = null;
- }
-
- private void verifyCollectionChanges() {
- clearEvents();
- this.collectionHolder.add("bar");
- Collection<String> tempCollection = new Vector<String>();
- tempCollection.add("bar");
- this.verifyEvent(this.addEvent, this.collectionHolder, tempCollection);
- this.verifyEvent(this.filteredAddEvent, this.filteredCollectionHolder, tempCollection);
-
- clearEvents();
- this.collectionHolder.remove("foo");
- tempCollection.remove("bar");
- tempCollection.add("foo");
- this.verifyEvent(this.removeEvent, this.collectionHolder, tempCollection);
- assertNull(this.filteredRemoveEvent);
-
-
- clearEvents();
- this.collectionHolder.remove("bar");
- tempCollection.add("bar");
- tempCollection.remove("foo");
- this.verifyEvent(this.removeEvent, this.collectionHolder, tempCollection);
- this.verifyEvent(this.filteredRemoveEvent, this.filteredCollectionHolder, tempCollection);
-
-
- clearEvents();
- this.collectionHolder.add("foo");
- tempCollection.remove("bar");
- tempCollection.add("foo");
- this.verifyEvent(this.addEvent, this.collectionHolder, tempCollection);
- assertNull(this.filteredAddEvent);
-
-
- clearEvents();
- Collection<String> newCollection = new Vector<String>();
- newCollection.add("fox");
- newCollection.add("baz");
-
- this.collectionHolder.setValues(newCollection);
-
- this.verifyEvent(this.collectionChangedEvent, this.collectionHolder);
-
- tempCollection.remove("foo");
- tempCollection.add("baz");
- this.verifyEvent(this.filteredCollectionChangedEvent, this.filteredCollectionHolder);
-
- }
-
- private CollectionChangeListener buildListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent e) {
- FilteringCollectionValueModelTests.this.addEvent = e;
- }
- public void itemsRemoved(CollectionRemoveEvent e) {
- FilteringCollectionValueModelTests.this.removeEvent = e;
- }
- public void collectionCleared(CollectionClearEvent e) {
- FilteringCollectionValueModelTests.this.collectionClearedEvent = e;
- }
- public void collectionChanged(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.collectionChangedEvent = e;
- }
- };
- }
-
- private ChangeListener buildChangeListener() {
- return new ChangeAdapter() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {
- FilteringCollectionValueModelTests.this.addEvent = e;
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent e) {
- FilteringCollectionValueModelTests.this.removeEvent = e;
- }
- @Override
- public void collectionCleared(CollectionClearEvent e) {
- FilteringCollectionValueModelTests.this.collectionClearedEvent = e;
- }
- @Override
- public void collectionChanged(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.collectionChangedEvent = e;
- }
- };
- }
-
- private CollectionChangeListener buildFilteredListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent e) {
- FilteringCollectionValueModelTests.this.filteredAddEvent = e;
- }
- public void itemsRemoved(CollectionRemoveEvent e) {
- FilteringCollectionValueModelTests.this.filteredRemoveEvent = e;
- }
- public void collectionCleared(CollectionClearEvent e) {
- FilteringCollectionValueModelTests.this.filteredCollectionClearedEvent = e;
- }
- public void collectionChanged(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.filteredCollectionChangedEvent = e;
- }
- };
- }
-
- private ChangeListener buildFilteredChangeListener() {
- return new ChangeAdapter() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {
- FilteringCollectionValueModelTests.this.filteredAddEvent = e;
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent e) {
- FilteringCollectionValueModelTests.this.filteredRemoveEvent = e;
- }
- @Override
- public void collectionCleared(CollectionClearEvent e) {
- FilteringCollectionValueModelTests.this.filteredCollectionClearedEvent = e;
- }
- @Override
- public void collectionChanged(CollectionChangeEvent e) {
- FilteringCollectionValueModelTests.this.filteredCollectionChangedEvent = e;
- }
- };
- }
-
- private void verifyEvent(CollectionChangeEvent event, Object source) {
- assertEquals(source, event.getSource());
- assertEquals(CollectionValueModel.VALUES, event.getCollectionName());
- }
-
- private void verifyEvent(CollectionAddEvent event, Object source, Object items) {
- assertEquals(source, event.getSource());
- assertEquals(CollectionValueModel.VALUES, event.getCollectionName());
- assertEquals(items, CollectionTools.vector(event.getItems()));
- }
-
- private void verifyEvent(CollectionRemoveEvent event, Object source, Object items) {
- assertEquals(source, event.getSource());
- assertEquals(CollectionValueModel.VALUES, event.getCollectionName());
- assertEquals(items, CollectionTools.vector(event.getItems()));
- }
-
- public void testRemoveFilteredItem() {
- // build collection with TestItems
- SimpleCollectionValueModel<TestItem> tiHolder = new SimpleCollectionValueModel<TestItem>(this.buildCollection2());
- CollectionValueModel<TestItem> filteredTIHolder = new FilteringCollectionValueModel<TestItem>(tiHolder, this.buildFilter2());
- // add a listener to "activate" the wrapper
- filteredTIHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildFilteredListener());
-
- assertEquals(0, filteredTIHolder.size());
-
- tiHolder.add(new TestItem("bar"));
- assertEquals(1, filteredTIHolder.size());
-
- TestItem baz = new TestItem("baz");
- tiHolder.add(baz);
- assertEquals(2, filteredTIHolder.size());
- // before removing it, change the item so that it is filtered
- baz.name = "jaz";
- tiHolder.remove(baz);
- // this would fail because the item was not removed from
- // the filtered collection cache... but we've fixed it now
- assertEquals(1, filteredTIHolder.size());
- }
-
- private Collection<TestItem> buildCollection2() {
- Collection<TestItem> collection = new Vector<TestItem>();
- collection.add(new TestItem("foo"));
- return collection;
- }
-
- private Filter<TestItem> buildFilter2() {
- return new Filter<TestItem>() {
- public boolean accept(TestItem ti) {
- return ti.name.startsWith("b");
- }
- };
- }
-
-
- // ********** TestItem inner class **********
-
- private class TestItem {
- String name;
- TestItem(String name) {
- super();
- this.name = name;
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/FilteringPropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/FilteringPropertyValueModelTests.java
deleted file mode 100644
index 8b2f4f0f86..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/FilteringPropertyValueModelTests.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.FilteringWritablePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class FilteringPropertyValueModelTests extends TestCase {
- private ModifiablePropertyValueModel<String> objectHolder;
- PropertyChangeEvent event;
-
- private ModifiablePropertyValueModel<String> filteredObjectHolder;
- PropertyChangeEvent filteredEvent;
-
- public FilteringPropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.objectHolder = new SimplePropertyValueModel<String>("foo");
- this.filteredObjectHolder = new FilteringWritablePropertyValueModel<String>(this.objectHolder, this.buildFilter(), this.buildSetFilter());
- }
-
- private Filter<String> buildFilter() {
- return new Filter<String>() {
- public boolean accept(String s) {
- return (s != null) && s.startsWith("b");
- }
- };
- }
-
- private Filter<String> buildSetFilter() {
- return new Filter<String>() {
- public boolean accept(String s) {
- return (s != null) && s.startsWith("b");
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- assertEquals("foo", this.objectHolder.getValue());
- assertNull(this.filteredObjectHolder.getValue());
-
- this.objectHolder.setValue("bar");
- assertEquals("bar", this.objectHolder.getValue());
- assertNotNull(this.filteredObjectHolder.getValue());
- assertEquals("bar", this.filteredObjectHolder.getValue());
-
- this.objectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- assertNotNull(this.filteredObjectHolder.getValue());
- assertEquals("baz", this.filteredObjectHolder.getValue());
-
- this.objectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.filteredObjectHolder.getValue());
-
- this.objectHolder.setValue("foo");
- assertEquals("foo", this.objectHolder.getValue());
- assertNull(this.filteredObjectHolder.getValue());
- }
-
- public void testSetValue() {
- this.filteredObjectHolder.setValue("bar");
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("bar", this.filteredObjectHolder.getValue());
-
- this.filteredObjectHolder.setValue("foo");
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("bar", this.filteredObjectHolder.getValue());
-
- this.filteredObjectHolder.setValue(null);
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("bar", this.filteredObjectHolder.getValue());
-
- this.filteredObjectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- assertEquals("baz", this.filteredObjectHolder.getValue());
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- ChangeListener listener = this.buildFilteredListener();
- this.filteredObjectHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.filteredObjectHolder.removeChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.filteredObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.filteredObjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testPropertyChange1() {
- this.objectHolder.addChangeListener(this.buildListener());
- this.filteredObjectHolder.addChangeListener(this.buildFilteredListener());
- this.verifyPropertyChanges();
- }
-
- public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.filteredObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildFilteredListener());
- this.verifyPropertyChanges();
- }
-
- private void verifyPropertyChanges() {
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent(this.event, this.objectHolder, "foo", "bar");
- this.verifyEvent(this.filteredEvent, this.filteredObjectHolder, null, "bar");
-
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue("baz");
- this.verifyEvent(this.event, this.objectHolder, "bar", "baz");
- this.verifyEvent(this.filteredEvent, this.filteredObjectHolder, "bar", "baz");
-
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue("foo");
- this.verifyEvent(this.event, this.objectHolder, "baz", "foo");
- this.verifyEvent(this.filteredEvent, this.filteredObjectHolder, "baz", null);
-
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue("fop");
- this.verifyEvent(this.event, this.objectHolder, "foo", "fop");
- assertNull(this.filteredEvent);
-
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue(null);
- this.verifyEvent(this.event, this.objectHolder, "fop", null);
- assertNull(this.filteredEvent);
-
- this.event = null;
- this.filteredEvent = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent(this.event, this.objectHolder, null, "bar");
- this.verifyEvent(this.filteredEvent, this.filteredObjectHolder, null, "bar");
- }
-
- private ChangeListener buildListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- FilteringPropertyValueModelTests.this.event = e;
- }
- };
- }
-
- private ChangeListener buildFilteredListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- FilteringPropertyValueModelTests.this.filteredEvent = e;
- }
- };
- }
-
- private void verifyEvent(PropertyChangeEvent e, Object source, Object oldValue, Object newValue) {
- assertEquals(source, e.getSource());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- assertEquals(oldValue, e.getOldValue());
- assertEquals(newValue, e.getNewValue());
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java
deleted file mode 100644
index 7ede9fcd6a..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemCollectionListValueModelAdapterTests.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.Icon;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ItemCollectionListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.internal.swing.Displayable;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ItemCollectionListValueModelAdapterTests extends TestCase {
- private Junk foo;
- private Junk bar;
- private Junk baz;
- private Junk joo;
- private Junk jar;
- private Junk jaz;
-
- private Junk tom;
- private Junk dick;
- private Junk harry;
-
- public ItemCollectionListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.foo = new Junk("foo");
- this.bar = new Junk("bar");
- this.baz = new Junk("baz");
- this.joo = new Junk("joo");
- this.jar = new Junk("jar");
- this.jaz = new Junk("jaz");
-
- this.tom = new Junk("tom");
- this.dick = new Junk("dick");
- this.harry = new Junk("harry");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testCollectionSynchronization() {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemCollectionListValueModelAdapter<Junk>(collectionHolder, Junk.STUFF_COLLECTION);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- public void testListSynchronization() {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemCollectionListValueModelAdapter<Junk>(listHolder, Junk.STUFF_COLLECTION);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.add(6, this.tom);
- listHolder.add(7, this.dick);
- listHolder.add(8, this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.remove(8);
- listHolder.remove(0);
- listHolder.remove(4);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- private void compare(ListValueModel<Junk> listValueModel, List<Junk> list) {
- assertEquals(listValueModel.size(), list.size());
- for (int i = 0; i < listValueModel.size(); i++) {
- assertEquals(listValueModel.get(i), list.get(i));
- }
- }
-
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyListChangeListeners(Junk.STUFF_COLLECTION));
- assertFalse(this.jaz.hasAnyListChangeListeners(Junk.STUFF_COLLECTION));
-
- ListValueModel<Junk> listValueModel = new ItemCollectionListValueModelAdapter<Junk>(listHolder, Junk.STUFF_COLLECTION);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertFalse(this.jaz.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- this.verifyHasNoListeners(listValueModel);
-
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.foo.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertTrue(this.jaz.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- this.verifyHasListeners(listValueModel);
-
- listValueModel.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertFalse(this.jaz.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- this.verifyHasNoListeners(listValueModel);
- }
-
- public void testGetSize() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemCollectionListValueModelAdapter<Junk>(listHolder, Junk.STUFF_COLLECTION);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(6, listValueModel.size());
- assertEquals(6, synchList.size());
- }
-
- public void testGet() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new SortedListValueModelWrapper<Junk>(new ItemCollectionListValueModelAdapter<Junk>(listHolder, Junk.STUFF_COLLECTION));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(this.bar, listValueModel.get(0));
- assertEquals(this.bar, synchList.get(0));
- this.bar.removeStuff("bar");
- this.bar.addStuff("zzz");
- this.bar.addStuff("bar");
- assertEquals(this.bar, listValueModel.get(5));
- assertEquals(this.bar, synchList.get(5));
- this.bar.removeStuff("zzz");
- }
-
- private void verifyHasNoListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private void verifyHasListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private SimpleCollectionValueModel<Junk> buildCollectionHolder() {
- return new SimpleCollectionValueModel<Junk>(this.buildCollection());
- }
-
- private Collection<Junk> buildCollection() {
- Bag<Junk> bag = new HashBag<Junk>();
- this.populateCollection(bag);
- return bag;
- }
-
- private SimpleListValueModel<Junk> buildListHolder() {
- return new SimpleListValueModel<Junk>(this.buildList());
- }
-
- private List<Junk> buildList() {
- List<Junk> list = new ArrayList<Junk>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<Junk> c) {
- c.add(this.foo);
- c.add(this.bar);
- c.add(this.baz);
- c.add(this.joo);
- c.add(this.jar);
- c.add(this.jaz);
- }
-
-
- // ********** Junk class **********
-
- private class Junk extends AbstractModel implements Displayable, Comparable<Junk> {
- private Collection<String> stuff;
- public static final String STUFF_COLLECTION = "stuff";
-
-
- public Junk(String stuffItem) {
- this.stuff = new ArrayList<String>();
- this.stuff.add(stuffItem);
- }
-
- public void addStuff(String stuffItem) {
- this.addItemToCollection(stuffItem, this.stuff, STUFF_COLLECTION);
- }
-
- public void removeStuff(String stuffItem) {
- this.removeItemFromCollection(stuffItem, this.stuff, STUFF_COLLECTION);
- }
-
- public String displayString() {
- return toString();
- }
-
- public Icon icon() {
- return null;
- }
-
- public int compareTo(Junk o) {
- return this.displayString().compareTo(o.displayString());
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.stuff + ")";
- }
-
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java
deleted file mode 100644
index d566ece7d8..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemListListValueModelAdapterTests.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.Icon;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ItemListListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.internal.swing.Displayable;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ItemListListValueModelAdapterTests extends TestCase {
- private Junk foo;
- private Junk bar;
- private Junk baz;
- private Junk joo;
- private Junk jar;
- private Junk jaz;
-
- private Junk tom;
- private Junk dick;
- private Junk harry;
-
- public ItemListListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.foo = new Junk("foo");
- this.bar = new Junk("bar");
- this.baz = new Junk("baz");
- this.joo = new Junk("joo");
- this.jar = new Junk("jar");
- this.jaz = new Junk("jaz");
-
- this.tom = new Junk("tom");
- this.dick = new Junk("dick");
- this.harry = new Junk("harry");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testCollectionSynchronization() {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemListListValueModelAdapter<Junk>(collectionHolder, Junk.STUFF_LIST);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- public void testListSynchronization() {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemListListValueModelAdapter<Junk>(listHolder, Junk.STUFF_LIST);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.add(6, this.tom);
- listHolder.add(7, this.dick);
- listHolder.add(8, this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.remove(8);
- listHolder.remove(0);
- listHolder.remove(4);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- private void compare(ListValueModel<Junk> listValueModel, List<Junk> list) {
- assertEquals(listValueModel.size(), list.size());
- for (int i = 0; i < listValueModel.size(); i++) {
- assertEquals(listValueModel.get(i), list.get(i));
- }
- }
-
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertFalse(this.jaz.hasAnyListChangeListeners(Junk.STUFF_LIST));
-
- ListValueModel<Junk> listValueModel = new ItemListListValueModelAdapter<Junk>(listHolder, Junk.STUFF_LIST);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertFalse(this.jaz.hasAnyListChangeListeners(Junk.STUFF_LIST));
- this.verifyHasNoListeners(listValueModel);
-
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.foo.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertTrue(this.jaz.hasAnyListChangeListeners(Junk.STUFF_LIST));
- this.verifyHasListeners(listValueModel);
-
- listValueModel.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertFalse(this.jaz.hasAnyListChangeListeners(Junk.STUFF_LIST));
- this.verifyHasNoListeners(listValueModel);
- }
-
- public void testGetSize() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemListListValueModelAdapter<Junk>(listHolder, Junk.STUFF_LIST);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(6, listValueModel.size());
- assertEquals(6, synchList.size());
- }
-
- public void testGet() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new SortedListValueModelWrapper<Junk>(new ItemListListValueModelAdapter<Junk>(listHolder, Junk.STUFF_LIST));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(this.bar, listValueModel.get(0));
- assertEquals(this.bar, synchList.get(0));
- this.bar.removeStuff("bar");
- this.bar.addStuff("zzz");
- this.bar.addStuff("bar");
- assertEquals(this.bar, listValueModel.get(5));
- assertEquals(this.bar, synchList.get(5));
- this.bar.removeStuff("zzz");
- }
-
- private void verifyHasNoListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private void verifyHasListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private SimpleCollectionValueModel<Junk> buildCollectionHolder() {
- return new SimpleCollectionValueModel<Junk>(this.buildCollection());
- }
-
- private Collection<Junk> buildCollection() {
- Bag<Junk> bag = new HashBag<Junk>();
- this.populateCollection(bag);
- return bag;
- }
-
- private SimpleListValueModel<Junk> buildListHolder() {
- return new SimpleListValueModel<Junk>(this.buildList());
- }
-
- private List<Junk> buildList() {
- List<Junk> list = new ArrayList<Junk>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<Junk> c) {
- c.add(this.foo);
- c.add(this.bar);
- c.add(this.baz);
- c.add(this.joo);
- c.add(this.jar);
- c.add(this.jaz);
- }
-
-
- // ********** Junk class **********
-
- private class Junk extends AbstractModel implements Displayable, Comparable<Junk> {
- private List<String> stuff;
- public static final String STUFF_LIST = "stuff";
-
-
- public Junk(String stuffItem) {
- this.stuff = new ArrayList<String>();
- this.stuff.add(stuffItem);
- }
- public void addStuff(String stuffItem) {
- this.stuff.add(stuffItem);
- fireItemAdded(STUFF_LIST, this.stuff.indexOf(stuffItem), stuffItem);
- }
-
- public void removeStuff(String stuffItem) {
- int index = this.stuff.indexOf(stuffItem);
- this.stuff.remove(stuffItem);
- fireItemRemoved(STUFF_LIST, index, stuffItem);
- }
-
- public String displayString() {
- return toString();
- }
-
- public Icon icon() {
- return null;
- }
-
- public int compareTo(Junk o) {
- return this.displayString().compareTo(o.displayString());
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.stuff + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java
deleted file mode 100644
index 35fce2a3e9..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemPropertyListValueModelAdapterTests.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.swing.Icon;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.internal.swing.Displayable;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ItemPropertyListValueModelAdapterTests extends TestCase {
- private Junk foo;
- private Junk bar;
- private Junk baz;
- private Junk joo;
- private Junk jar;
- private Junk jaz;
-
- private Junk tom;
- private Junk dick;
- private Junk harry;
-
- public ItemPropertyListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.foo = new Junk("this.foo");
- this.bar = new Junk("this.bar");
- this.baz = new Junk("this.baz");
- this.joo = new Junk("this.joo");
- this.jar = new Junk("this.jar");
- this.jaz = new Junk("this.jaz");
-
- this.tom = new Junk("this.tom");
- this.dick = new Junk("this.dick");
- this.harry = new Junk("this.harry");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testCollectionSynchronization() {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(collectionHolder, Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.setValues(this.buildCollection());
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- public void testListSynchronization() {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(listHolder, Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.add(6, this.tom);
- listHolder.add(7, this.dick);
- listHolder.add(8, this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.remove(8);
- listHolder.remove(0);
- listHolder.remove(4);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- // test concurrent modification exception
- listHolder.setListValues(this.buildList());
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- private void compare(ListValueModel<Junk> listValueModel, List<Junk> list) {
- assertEquals(listValueModel.size(), list.size());
- for (int i = 0; i < listValueModel.size(); i++) {
- assertEquals(listValueModel.get(i), list.get(i));
- }
- }
-
- public void testCollectionSort() {
- this.verifyCollectionSort(null);
- }
-
- public void testListSort() {
- this.verifyListSort(null);
- }
-
- public void testCustomCollectionSort() {
- this.verifyCollectionSort(this.buildCustomComparator());
- }
-
- public void testCustomListSort() {
- this.verifyListSort(this.buildCustomComparator());
- }
-
- private Comparator<Junk> buildCustomComparator() {
- // sort with reverse order
- return new Comparator<Junk>() {
- public int compare(Junk o1, Junk o2) {
- return o2.displayString().compareTo(o1.displayString());
- }
- };
- }
-
- private void verifyCollectionSort(Comparator<Junk> comparator) {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(new SortedListValueModelAdapter<Junk>(collectionHolder, comparator), Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- collectionHolder.setValues(this.buildCollection());
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
- }
-
- private void verifyListSort(Comparator<Junk> comparator) {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(new SortedListValueModelWrapper<Junk>(listHolder, comparator), Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- listHolder.add(0, this.tom);
- listHolder.add(0, this.dick);
- listHolder.add(0, this.harry);
- assertEquals(9, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- listHolder.remove(8);
- listHolder.remove(4);
- listHolder.remove(0);
- listHolder.remove(5);
- assertEquals(5, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- listHolder.setListValues(this.buildList());
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
- }
-
- private void compareSort(ListValueModel<Junk> listValueModel, List<Junk> list, Comparator<Junk> comparator) {
- SortedSet<Junk> ss = new TreeSet<Junk>(comparator);
- for (int i = 0; i < listValueModel.size(); i++) {
- ss.add(listValueModel.get(i));
- }
- assertEquals(ss.size(), list.size());
- for (Iterator<Junk> stream1 = ss.iterator(), stream2 = list.iterator(); stream1.hasNext(); ) {
- assertEquals(stream1.next(), stream2.next());
- }
- }
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
-
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(new SortedListValueModelWrapper<Junk>(listHolder), Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- this.verifyHasNoListeners(listValueModel);
-
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.foo.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertTrue(this.foo.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- assertTrue(this.jaz.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertTrue(this.jaz.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- this.verifyHasListeners(listValueModel);
-
- listValueModel.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.foo.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.DISPLAY_STRING_PROPERTY));
- assertFalse(this.jaz.hasAnyPropertyChangeListeners(Displayable.ICON_PROPERTY));
- this.verifyHasNoListeners(listValueModel);
- }
-
- public void testGetSize() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemPropertyListValueModelAdapter<Junk>(new SortedListValueModelWrapper<Junk>(listHolder), Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(6, listValueModel.size());
- assertEquals(6, synchList.size());
- }
-
- public void testGet() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new SortedListValueModelWrapper<Junk>(new ItemPropertyListValueModelAdapter<Junk>(listHolder, Displayable.DISPLAY_STRING_PROPERTY, Displayable.ICON_PROPERTY));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(this.bar, listValueModel.get(0));
- assertEquals(this.bar, synchList.get(0));
- this.bar.setName("zzz");
- assertEquals(this.bar, listValueModel.get(5));
- assertEquals(this.bar, synchList.get(5));
- this.bar.setName("this.bar");
- }
-
- private void verifyHasNoListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private void verifyHasListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private SimpleCollectionValueModel<Junk> buildCollectionHolder() {
- return new SimpleCollectionValueModel<Junk>(this.buildCollection());
- }
-
- private Collection<Junk> buildCollection() {
- Bag<Junk> bag = new HashBag<Junk>();
- this.populateCollection(bag);
- return bag;
- }
-
- private SimpleListValueModel<Junk> buildListHolder() {
- return new SimpleListValueModel<Junk>(this.buildList());
- }
-
- private List<Junk> buildList() {
- List<Junk> list = new ArrayList<Junk>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<Junk> c) {
- c.add(this.foo);
- c.add(this.bar);
- c.add(this.baz);
- c.add(this.joo);
- c.add(this.jar);
- c.add(this.jaz);
- }
-
-
- // ********** Junk class **********
-
- private class Junk extends AbstractModel implements Displayable, Comparable<Junk> {
- private String name;
- public Junk(String name) {
- this.name = name;
- }
- public String displayString() {
- return this.name;
- }
- public Icon icon() {
- return null;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(DISPLAY_STRING_PROPERTY, old, name);
- }
- public int compareTo(Junk o) {
- return this.displayString().compareTo(o.displayString());
- }
- @Override
- public String toString() {
- return "Junk(" + this.name + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java
deleted file mode 100644
index 18730739e9..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ItemStateListValueModelAdapterTests.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ItemStateListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ItemStateListValueModelAdapterTests extends TestCase {
- private Junk foo;
- private Junk bar;
- private Junk baz;
- private Junk joo;
- private Junk jar;
- private Junk jaz;
-
- private Junk tom;
- private Junk dick;
- private Junk harry;
-
- public ItemStateListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.foo = new Junk("this.foo");
- this.bar = new Junk("this.bar");
- this.baz = new Junk("this.baz");
- this.joo = new Junk("this.joo");
- this.jar = new Junk("this.jar");
- this.jaz = new Junk("this.jaz");
-
- this.tom = new Junk("this.tom");
- this.dick = new Junk("this.dick");
- this.harry = new Junk("this.harry");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testCollectionSynchronization() {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(collectionHolder);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- public void testListSynchronization() {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(listHolder);
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.add(6, this.tom);
- listHolder.add(7, this.dick);
- listHolder.add(8, this.harry);
- assertEquals(9, synchList.size());
- this.compare(listValueModel, synchList);
-
- listHolder.remove(8);
- listHolder.remove(0);
- listHolder.remove(4);
- assertEquals(6, synchList.size());
- this.compare(listValueModel, synchList);
- }
-
- private void compare(ListValueModel<Junk> listValueModel, List<Junk> list) {
- assertEquals(listValueModel.size(), list.size());
- for (int i = 0; i < listValueModel.size(); i++) {
- assertEquals(listValueModel.get(i), list.get(i));
- }
- }
-
- public void testCollectionSort() {
- this.verifyCollectionSort(null);
- }
-
- public void testListSort() {
- this.verifyListSort(null);
- }
-
- public void testCustomCollectionSort() {
- this.verifyCollectionSort(this.buildCustomComparator());
- }
-
- public void testCustomListSort() {
- this.verifyListSort(this.buildCustomComparator());
- }
-
- private Comparator<Junk> buildCustomComparator() {
- // sort with reverse order
- return new Comparator<Junk>() {
- public int compare(Junk o1, Junk o2) {
- return o2.compareTo(o1);
- }
- };
- }
-
- private void verifyCollectionSort(Comparator<Junk> comparator) {
- SimpleCollectionValueModel<Junk> collectionHolder = this.buildCollectionHolder();
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(new SortedListValueModelAdapter<Junk>(collectionHolder, comparator));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- collectionHolder.add(this.tom);
- collectionHolder.add(this.dick);
- collectionHolder.add(this.harry);
- assertEquals(9, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- collectionHolder.remove(this.foo);
- collectionHolder.remove(this.jar);
- collectionHolder.remove(this.harry);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
- }
-
- private void verifyListSort(Comparator<Junk> comparator) {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(new SortedListValueModelWrapper<Junk>(listHolder, comparator));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertEquals(6, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- listHolder.add(0, this.tom);
- listHolder.add(0, this.dick);
- listHolder.add(0, this.harry);
- assertEquals(9, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
-
- listHolder.remove(8);
- listHolder.remove(4);
- listHolder.remove(0);
- listHolder.remove(5);
- assertEquals(5, synchList.size());
- this.compareSort(listValueModel, synchList, comparator);
- }
-
- private void compareSort(ListValueModel<Junk> listValueModel, List<Junk> list, Comparator<Junk> comparator) {
- SortedSet<Junk> ss = new TreeSet<Junk>(comparator);
- for (int i = 0; i < listValueModel.size(); i++) {
- ss.add(listValueModel.get(i));
- }
- assertEquals(ss.size(), list.size());
- for (Iterator<Junk> stream1 = ss.iterator(), stream2 = list.iterator(); stream1.hasNext(); ) {
- assertEquals(stream1.next(), stream2.next());
- }
- }
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
-
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(new SortedListValueModelWrapper<Junk>(listHolder));
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
- this.verifyHasNoListeners(listValueModel);
-
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.foo.hasAnyStateChangeListeners());
- assertTrue(this.foo.hasAnyStateChangeListeners());
- assertTrue(this.jaz.hasAnyStateChangeListeners());
- assertTrue(this.jaz.hasAnyStateChangeListeners());
- this.verifyHasListeners(listValueModel);
-
- listValueModel.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.foo.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
- assertFalse(this.jaz.hasAnyStateChangeListeners());
- this.verifyHasNoListeners(listValueModel);
- }
-
- public void testGetSize() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new ItemStateListValueModelAdapter<Junk>(new SortedListValueModelWrapper<Junk>(listHolder));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(6, listValueModel.size());
- assertEquals(6, synchList.size());
- }
-
- public void testGet() throws Exception {
- SimpleListValueModel<Junk> listHolder = this.buildListHolder();
- ListValueModel<Junk> listValueModel = new SortedListValueModelWrapper<Junk>(new ItemStateListValueModelAdapter<Junk>(listHolder));
- CoordinatedList<Junk> synchList = new CoordinatedList<Junk>(listValueModel);
- this.verifyHasListeners(listValueModel);
- assertEquals(this.bar, listValueModel.get(0));
- assertEquals(this.bar, synchList.get(0));
- this.bar.setName("zzz");
- assertEquals(this.bar, listValueModel.get(5));
- assertEquals(this.bar, synchList.get(5));
- this.bar.setName("this.bar");
- }
-
- private void verifyHasNoListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private void verifyHasListeners(ListValueModel<Junk> listValueModel) throws Exception {
- assertTrue(((AbstractModel) listValueModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private SimpleCollectionValueModel<Junk> buildCollectionHolder() {
- return new SimpleCollectionValueModel<Junk>(this.buildCollection());
- }
-
- private Collection<Junk> buildCollection() {
- Bag<Junk> bag = new HashBag<Junk>();
- this.populateCollection(bag);
- return bag;
- }
-
- private SimpleListValueModel<Junk> buildListHolder() {
- return new SimpleListValueModel<Junk>(this.buildList());
- }
-
- private List<Junk> buildList() {
- List<Junk> list = new ArrayList<Junk>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<Junk> c) {
- c.add(this.foo);
- c.add(this.bar);
- c.add(this.baz);
- c.add(this.joo);
- c.add(this.jar);
- c.add(this.jaz);
- }
-
- // ********** Junk class **********
- private class Junk extends AbstractModel implements Comparable<Junk> {
- private String name;
- public Junk(String name) {
- this.name = name;
- }
- public void setName(String name) {
- this.name = name;
- this.fireStateChanged();
- }
- public int compareTo(Junk j) {
- return this.name.compareTo(j.name);
- }
- @Override
- public String toString() {
- return "Junk(" + this.name + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/JptUtilityModelValueTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/JptUtilityModelValueTests.java
deleted file mode 100644
index 8f256b46f3..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/JptUtilityModelValueTests.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.prefs.JptUtilityModelValuePrefsTests;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.swing.JptUtilityModelValueSwingTests;
-
-public class JptUtilityModelValueTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityModelValueTests.class.getPackage().getName());
-
- suite.addTest(JptUtilityModelValuePrefsTests.suite());
- suite.addTest(JptUtilityModelValueSwingTests.suite());
-
- suite.addTestSuite(BufferedWritablePropertyValueModelTests.class);
- suite.addTestSuite(CachingTransformationPropertyValueModelTests.class);
- suite.addTestSuite(CachingTransformationWritablePropertyValueModelTests.class);
- suite.addTestSuite(CollectionAspectAdapterTests.class);
- suite.addTestSuite(CollectionListValueModelAdapterTests.class);
- suite.addTestSuite(CollectionPropertyValueModelAdapterTests.class);
- suite.addTestSuite(CompositeBooleanPropertyValueModelTests.class);
- suite.addTestSuite(CompositeCollectionValueModelTests.class);
- suite.addTestSuite(CompositeListValueModelTests.class);
- suite.addTestSuite(CompositePropertyValueModelTests.class);
- suite.addTestSuite(DoublePropertyValueModelTests.class);
- suite.addTestSuite(DoubleModifiablePropertyValueModelTests.class);
- suite.addTestSuite(ExtendedListValueModelWrapperTests.class);
- suite.addTestSuite(FilteringCollectionValueModelTests.class);
- suite.addTestSuite(FilteringPropertyValueModelTests.class);
- suite.addTestSuite(ItemCollectionListValueModelAdapterTests.class);
- suite.addTestSuite(ItemListListValueModelAdapterTests.class);
- suite.addTestSuite(ItemPropertyListValueModelAdapterTests.class);
- suite.addTestSuite(ItemStateListValueModelAdapterTests.class);
- suite.addTestSuite(ListAspectAdapterTests.class);
- suite.addTestSuite(ListCollectionValueModelAdapterTests.class);
- suite.addTestSuite(ListCuratorTests.class);
- suite.addTestSuite(NullCollectionValueModelTests.class);
- suite.addTestSuite(NullListValueModelTests.class);
- suite.addTestSuite(NullPropertyValueModelTests.class);
- suite.addTestSuite(PropertyAspectAdapterTests.class);
- suite.addTestSuite(PropertyCollectionValueModelAdapterTests.class);
- suite.addTestSuite(PropertyListValueModelAdapterTests.class);
- suite.addTestSuite(ReadOnlyWritablePropertyValueModelWrapperTests.class);
- suite.addTestSuite(SetCollectionValueModelTests.class);
- suite.addTestSuite(SimpleCollectionValueModelTests.class);
- suite.addTestSuite(SimpleListValueModelTests.class);
- suite.addTestSuite(SimplePropertyValueModelTests.class);
- suite.addTestSuite(SortedListValueModelAdapterTests.class);
- suite.addTestSuite(SortedListValueModelWrapperTests.class);
- suite.addTestSuite(StaticCollectionValueModelTests.class);
- suite.addTestSuite(StaticListValueModelTests.class);
- suite.addTestSuite(StaticValueModelTests.class);
- suite.addTestSuite(TransformationListValueModelTests.class);
- suite.addTestSuite(TransformationListValueModelTests.TransformerTests.class);
- suite.addTestSuite(TransformationPropertyValueModelTests.class);
- suite.addTestSuite(ValueCollectionAdapterTests.class);
- suite.addTestSuite(ValueListAdapterTests.class);
- suite.addTestSuite(ValuePropertyAdapterTests.class);
- suite.addTestSuite(ValueStateAdapterTests.class);
-
- return suite;
- }
-
- private JptUtilityModelValueTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListAspectAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListAspectAdapterTests.java
deleted file mode 100644
index 4d7850d4c3..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListAspectAdapterTests.java
+++ /dev/null
@@ -1,475 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ListIterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ListAspectAdapterTests extends TestCase {
- private TestSubject subject1;
- private ModifiablePropertyValueModel<TestSubject> subjectHolder1;
- private LocalListAspectAdapter aa1;
- private ListEvent event1;
- private ListChangeListener listener1;
-
- private TestSubject subject2;
-
- public ListAspectAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject1 = new TestSubject();
- this.subject1.addNames(this.subject1Names());
- this.subject1.addDescriptions(this.subject1Descriptions());
- this.subjectHolder1 = new SimplePropertyValueModel<TestSubject>(this.subject1);
- this.aa1 = this.buildAspectAdapter(this.subjectHolder1);
- this.listener1 = this.buildValueChangeListener1();
- this.aa1.addListChangeListener(ListValueModel.LIST_VALUES, this.listener1);
- this.event1 = null;
-
- this.subject2 = new TestSubject();
- this.subject2.addNames(this.subject2Names());
- this.subject2.addDescriptions(this.subject2Descriptions());
- }
-
- private List<String> subject1Names() {
- List<String> result = new ArrayList<String>();
- result.add("foo");
- result.add("bar");
- result.add("baz");
- result.add("bam");
- return result;
- }
-
- private List<String> subject1Descriptions() {
- List<String> result = new ArrayList<String>();
- result.add("this.subject1 description1");
- result.add("this.subject1 description2");
- return result;
- }
-
- private List<String> subject2Names() {
- List<String> result = new ArrayList<String>();
- result.add("joo");
- result.add("jar");
- result.add("jaz");
- result.add("jam");
- return result;
- }
-
- private List<String> subject2Descriptions() {
- List<String> result = new ArrayList<String>();
- result.add("this.subject2 description1");
- result.add("this.subject2 description2");
- return result;
- }
-
- private LocalListAspectAdapter buildAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- return new LocalListAspectAdapter(subjectHolder);
- }
-
- private ListChangeListener buildValueChangeListener1() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- public void itemsRemoved(ListRemoveEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- public void itemsReplaced(ListReplaceEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- public void itemsMoved(ListMoveEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- public void listCleared(ListClearEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- public void listChanged(ListChangeEvent e) {
- ListAspectAdapterTests.this.value1Changed(e);
- }
- };
- }
-
- void value1Changed(ListEvent e) {
- this.event1 = e;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSubjectHolder() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- this.subjectHolder1.setValue(this.subject2);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(this.subject2Names(), CollectionTools.list(this.aa1.listIterator()));
-
- this.event1 = null;
- this.subjectHolder1.setValue(null);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertFalse(this.aa1.iterator().hasNext());
-
- this.event1 = null;
- this.subjectHolder1.setValue(this.subject1);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testAdd() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- this.subject1.addName("jam");
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(this.subject1Names().size(), ((ListAddEvent) this.event1).getIndex());
- assertEquals("jam", ((ListAddEvent) this.event1).getItems().iterator().next());
- List<String> namesPlus = this.subject1Names();
- namesPlus.add("jam");
- assertEquals(namesPlus, CollectionTools.list(this.aa1.listIterator()));
-
- this.event1 = null;
- this.aa1.add(2, "jaz");
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(2, ((ListAddEvent) this.event1).getIndex());
- assertEquals("jaz", ((ListAddEvent) this.event1).getItems().iterator().next());
- namesPlus.add(2, "jaz");
- assertEquals(namesPlus, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testDefaultAdd() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- List<String> items = new ArrayList<String>();
- items.add("joo");
- items.add("jar");
- items.add("jaz");
- items.add("jam");
-
- this.event1 = null;
- this.aa1.addAll(2, items);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(5, ((ListAddEvent) this.event1).getIndex()); // only the last "add" event will still be there
- assertEquals("jam", ((ListAddEvent) this.event1).getItems().iterator().next());
- List<String> namesPlus = this.subject1Names();
- namesPlus.addAll(2, items);
- assertEquals(namesPlus, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testRemove() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- String removedName = this.subject1.removeName(0); // should be "foo"
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(0, ((ListRemoveEvent) this.event1).getIndex());
- assertEquals(removedName, ((ListRemoveEvent) this.event1).getItems().iterator().next());
- List<String> namesMinus = this.subject1Names();
- namesMinus.remove(0);
- assertEquals(namesMinus, CollectionTools.list(this.aa1.listIterator()));
-
- this.event1 = null;
- Object removedItem = this.aa1.remove(0);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(0, ((ListRemoveEvent) this.event1).getIndex());
- assertEquals(removedItem, ((ListRemoveEvent) this.event1).getItems().iterator().next());
- namesMinus.remove(0);
- assertEquals(namesMinus, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testDefaultLength() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- List<String> items = new ArrayList<String>();
- items.add("bar");
- items.add("baz");
-
- this.event1 = null;
- this.aa1.remove(1, 2);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(1, ((ListRemoveEvent) this.event1).getIndex()); // only the last "remove" event will still be there
- assertEquals("baz", ((ListRemoveEvent) this.event1).getItems().iterator().next());
- List<String> namesPlus = this.subject1Names();
- namesPlus.remove(1);
- namesPlus.remove(1);
- assertEquals(namesPlus, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testReplace() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- String replacedName = this.subject1.setName(0, "jelly"); // should be "foo"
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(0, ((ListReplaceEvent) this.event1).getIndex());
- assertEquals("jelly", ((ListReplaceEvent) this.event1).getNewItems().iterator().next());
- assertEquals(replacedName, ((ListReplaceEvent) this.event1).getOldItems().iterator().next());
- List<String> namesChanged = this.subject1Names();
- namesChanged.set(0, "jelly");
- assertEquals(namesChanged, CollectionTools.list(this.aa1.listIterator()));
-
- this.event1 = null;
- replacedName = this.subject1.setName(1, "roll"); // should be "bar"
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(1, ((ListReplaceEvent) this.event1).getIndex());
- assertEquals("roll", ((ListReplaceEvent) this.event1).getNewItems().iterator().next());
- assertEquals(replacedName, ((ListReplaceEvent) this.event1).getOldItems().iterator().next());
- namesChanged = this.subject1Names();
- namesChanged.set(0, "jelly");
- namesChanged.set(1, "roll");
- assertEquals(namesChanged, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testListChange() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- assertNull(this.event1);
-
- this.subject1.addTwoNames("jam", "jaz");
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- List<String> namesPlus2 = this.subject1Names();
- namesPlus2.add(0, "jaz");
- namesPlus2.add(0, "jam");
- assertEquals(namesPlus2, CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testIterator() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.subject1.names()));
- assertEquals(this.subject1Names(), CollectionTools.list(this.aa1.listIterator()));
- }
-
- public void testGet() {
- assertEquals(this.subject1Names().get(0), this.subject1.getName(0));
- assertEquals(this.subject1Names().get(0), this.aa1.get(0));
- }
-
- public void testSize() {
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.subject1.names()));
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.aa1.listIterator()));
- }
-
- public void testHasListeners() {
- assertTrue(this.aa1.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.subject1.hasAnyListChangeListeners(TestSubject.NAMES_LIST));
- this.aa1.removeListChangeListener(ListValueModel.LIST_VALUES, this.listener1);
- assertFalse(this.subject1.hasAnyListChangeListeners(TestSubject.NAMES_LIST));
- assertFalse(this.aa1.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ChangeListener listener2 = new ChangeAdapter();
- this.aa1.addChangeListener(listener2);
- assertTrue(this.aa1.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.subject1.hasAnyListChangeListeners(TestSubject.NAMES_LIST));
- this.aa1.removeChangeListener(listener2);
- assertFalse(this.subject1.hasAnyListChangeListeners(TestSubject.NAMES_LIST));
- assertFalse(this.aa1.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
-
- // ********** inner class **********
-
- class TestSubject extends AbstractModel {
- private List<String> names;
- public static final String NAMES_LIST = "names";
- private List<String> descriptions;
- public static final String DESCRIPTIONS_LIST = "descriptions";
-
- public TestSubject() {
- this.names = new ArrayList<String>();
- this.descriptions = new ArrayList<String>();
- }
- public ListIterator<String> names() {
- return new ReadOnlyListIterator<String>(this.names);
- }
- public String getName(int index) {
- return this.names.get(index);
- }
- public void addName(int index, String name) {
- this.names.add(index, name);
- this.fireItemAdded(NAMES_LIST, index, name);
- }
- public void addName(String name) {
- this.addName(this.names.size(), name);
- }
- public void addNames(ListIterator<String> newNames) {
- while (newNames.hasNext()) {
- this.addName(newNames.next());
- }
- }
- public void addNames(List<String> newNames) {
- this.addNames(newNames.listIterator());
- }
- public void addTwoNames(String name1, String name2) {
- this.names.add(0, name2);
- this.names.add(0, name1);
- this.fireListChanged(NAMES_LIST, this.names);
- }
- public String removeName(int index) {
- String removedName = this.names.remove(index);
- this.fireItemRemoved(NAMES_LIST, index, removedName);
- return removedName;
- }
- public String setName(int index, String name) {
- String replacedName = this.names.set(index, name);
- this.fireItemReplaced(NAMES_LIST, index, name, replacedName);
- return replacedName;
- }
- public ListIterator<String> descriptions() {
- return new ReadOnlyListIterator<String>(this.descriptions);
- }
- public String getDescription(int index) {
- return this.descriptions.get(index);
- }
- public void addDescription(int index, String description) {
- this.descriptions.add(index, description);
- this.fireItemAdded(DESCRIPTIONS_LIST, index, description);
- }
- public void addDescription(String description) {
- this.addDescription(this.descriptions.size(), description);
- }
- public void addDescriptions(ListIterator<String> newDescriptions) {
- while (newDescriptions.hasNext()) {
- this.addDescription(newDescriptions.next());
- }
- }
- public void addDescriptions(List<String> newDescriptions) {
- this.addDescriptions(newDescriptions.listIterator());
- }
- public String removeDescription(int index) {
- String removedDescription = this.descriptions.remove(index);
- this.fireItemRemoved(DESCRIPTIONS_LIST, index, removedDescription);
- return removedDescription;
- }
- public String setDescription(int index, String description) {
- String replacedDescription = this.descriptions.set(index, description);
- this.fireItemReplaced(DESCRIPTIONS_LIST, index, description, replacedDescription);
- return replacedDescription;
- }
- }
-
-
- // this is not a typical aspect adapter - the value is determined by the aspect name
- class LocalListAspectAdapter extends ListAspectAdapter<TestSubject, String> {
-
- LocalListAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- super(subjectHolder, TestSubject.NAMES_LIST);
- }
-
- @Override
- protected ListIterator<String> listIterator_() {
- if (this.aspectNames[0] == TestSubject.NAMES_LIST) {
- return this.subject.names();
- } else if (this.aspectNames[0] == TestSubject.DESCRIPTIONS_LIST) {
- return this.subject.descriptions();
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.aspectNames[0]);
- }
- }
-
- public void add(int index, Object item) {
- if (this.aspectNames[0] == TestSubject.NAMES_LIST) {
- this.subject.addName(index, (String) item);
- } else if (this.aspectNames[0] == TestSubject.DESCRIPTIONS_LIST) {
- this.subject.addDescription(index, (String) item);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.aspectNames[0]);
- }
- }
-
- public void addAll(int index, List<String> items) {
- for (int i = 0; i < items.size(); i++) {
- this.add(index + i, items.get(i));
- }
- }
-
- public String remove(int index) {
- if (this.aspectNames[0] == TestSubject.NAMES_LIST) {
- return this.subject.removeName(index);
- } else if (this.aspectNames[0] == TestSubject.DESCRIPTIONS_LIST) {
- return this.subject.removeDescription(index);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.aspectNames[0]);
- }
- }
-
- public List<String> remove(int index, int length) {
- List<String> removedItems = new ArrayList<String>(length);
- for (int i = 0; i < length; i++) {
- removedItems.add(this.remove(index));
- }
- return removedItems;
- }
-
- public Object replace(int index, Object item) {
- if (this.aspectNames[0] == TestSubject.NAMES_LIST) {
- return this.subject.setName(index, (String) item);
- } else if (this.aspectNames[0] == TestSubject.DESCRIPTIONS_LIST) {
- return this.subject.setDescription(index, (String) item);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.aspectNames[0]);
- }
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java
deleted file mode 100644
index c499ad37ab..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListCollectionValueModelAdapterTests.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.JList;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ListCollectionValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ListCollectionValueModelAdapterTests extends TestCase {
- CollectionValueModel<String> adapter;
- private SimpleListValueModel<String> wrappedListHolder;
- private List<String> wrappedList;
-
- public ListCollectionValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedList = new ArrayList<String>();
- this.wrappedListHolder = new SimpleListValueModel<String>(this.wrappedList);
- this.adapter = new ListCollectionValueModelAdapter<String>(this.wrappedListHolder);
- }
-
- private Collection<String> wrappedCollection() {
- return CollectionTools.collection(this.wrappedList.iterator());
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {
- // override failure
- }
- });
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- }
-
- public void testStaleValues() {
- CollectionChangeListener listener = new TestListener() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {/* OK */}
- };
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
-
- this.adapter.removeCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(0, adapterCollection.size());
- assertEquals(new HashBag<String>(), adapterCollection);
-
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- }
-
- public void testAdd() {
- Bag<String> synchCollection = new CoordinatedBag<String>(this.adapter);
- List<String> synchList = new CoordinatedList<String>(this.wrappedListHolder);
- this.wrappedListHolder.add(0, "foo");
- assertTrue(this.wrappedList.contains("foo"));
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- this.wrappedListHolder.add(3, "joo");
- this.wrappedListHolder.add(4, "jar");
- this.wrappedListHolder.add(5, "jaz");
- assertEquals(6, this.wrappedList.size());
-
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(this.wrappedCollection(), adapterCollection);
- assertEquals(this.wrappedCollection(), CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection(), synchCollection);
- }
-
- public void testRemove() {
- Bag<String> synchCollection = new CoordinatedBag<String>(this.adapter);
- List<String> synchList = new CoordinatedList<String>(this.wrappedListHolder);
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- this.wrappedListHolder.add(3, "joo");
- this.wrappedListHolder.add(4, "jar");
- this.wrappedListHolder.add(5, "jaz");
- assertEquals("jaz", this.wrappedListHolder.remove(5));
- assertFalse(this.wrappedList.contains("jaz"));
- assertEquals("foo", this.wrappedListHolder.remove(0));
- assertFalse(this.wrappedList.contains("foo"));
- assertEquals(4, this.wrappedList.size());
-
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(this.wrappedCollection(), adapterCollection);
- assertEquals(this.wrappedCollection(), CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection(), synchCollection);
- }
-
- public void testListSynch() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {
- // override failure
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent e) {
- // override failure
- }
- });
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- this.wrappedListHolder.add(3, "joo");
- this.wrappedListHolder.add(4, "jar");
- this.wrappedListHolder.add(5, "jaz");
- this.wrappedListHolder.remove(5);
- assertFalse(this.wrappedList.contains("jaz"));
- this.wrappedListHolder.remove(0);
- assertFalse(this.wrappedList.contains("foo"));
- assertEquals(4, this.wrappedList.size());
-
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(this.wrappedCollection(), adapterCollection);
- }
-
- public void testReplace() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {
- // override failure
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent e) {
- // override failure
- }
- });
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(3, adapterCollection.size());
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsRemoved(CollectionRemoveEvent e) {
- assertEquals("foo", e.getItems().iterator().next());
- assertFalse(CollectionTools.contains(ListCollectionValueModelAdapterTests.this.adapter.iterator(), "joo"));
- assertEquals(2, ListCollectionValueModelAdapterTests.this.adapter.size());
- }
- @Override
- public void itemsAdded(CollectionAddEvent e) {
- assertEquals("joo", e.getItems().iterator().next());
- assertEquals(3, ListCollectionValueModelAdapterTests.this.adapter.size());
- }
- });
- this.wrappedListHolder.set(0, "joo");
- adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(3, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- CoordinatedBag<String> synchCollection = new CoordinatedBag<String>(this.adapter);
- assertTrue(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.adapter.removeCollectionChangeListener(CollectionValueModel.VALUES, synchCollection);
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- ChangeListener cl = new ChangeAdapter();
- this.adapter.addChangeListener(cl);
- assertTrue(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.adapter.removeChangeListener(cl);
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
- public void testListChangedToEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {/* OK */}
- @Override
- public void collectionCleared(CollectionClearEvent e) {/* OK */}
- });
- this.wrappedListHolder.add(0, "foo");
- this.wrappedListHolder.add(1, "bar");
- this.wrappedListHolder.add(2, "baz");
- JList jList = new JList(new ListModelAdapter(this.adapter));
- this.wrappedListHolder.setListValues(new ArrayList<String>());
- assertEquals(0, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {/* OK */}
- @Override
- public void itemsRemoved(CollectionRemoveEvent e) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- ArrayList<String> list = new ArrayList<String>();
- list.add("foo");
- list.add("bar");
- this.wrappedListHolder.setListValues(list);
- assertEquals(2, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmptyToEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {/* OK */}
- @Override
- public void itemsRemoved(CollectionRemoveEvent e) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- ArrayList<String> list = new ArrayList<String>();
- this.wrappedListHolder.setListValues(list);
- assertEquals(0, jList.getModel().getSize());
- }
-
-
- // ********** inner class **********
-
- class TestListener implements CollectionChangeListener {
- public void itemsAdded(CollectionAddEvent e) {
- fail("unexpected event");
- }
- public void itemsRemoved(CollectionRemoveEvent e) {
- fail("unexpected event");
- }
- public void collectionCleared(CollectionClearEvent e) {
- fail("unexpected event");
- }
- public void collectionChanged(CollectionChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListCuratorTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListCuratorTests.java
deleted file mode 100644
index e4dc5f5507..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ListCuratorTests.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ListCurator;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public final class ListCuratorTests
- extends TestCase
-{
- private TestSubject subject1;
- private ModifiablePropertyValueModel<TestSubject> subjectHolder1;
-
- private ListCurator<TestSubject, String> curator;
- private ListChangeListener listener1;
- private ListEvent event1;
-
- private TestSubject subject2;
-
- public ListCuratorTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject1 = new TestSubject(this.subject1Names());
- this.subjectHolder1 = new SimplePropertyValueModel<TestSubject>(this.subject1);
- this.curator = this.buildListCurator(this.subjectHolder1);
- this.listener1 = this.buildListChangeListener1();
- this.curator.addListChangeListener(ListValueModel.LIST_VALUES, this.listener1);
- this.event1 = null;
-
- this.subject2 = new TestSubject(this.subject2Names());
- }
-
- private List<String> subject1Names() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("alpha");
- list.add("bravo");
- list.add("charlie");
- list.add("delta");
- return list;
- }
-
- private List<String> subject2Names() {
- ArrayList<String> list = new ArrayList<String>();
- list.add("echo");
- list.add("foxtrot");
- list.add("glove");
- list.add("hotel");
- return list;
- }
-
- private ListCurator<TestSubject, String> buildListCurator(PropertyValueModel<TestSubject> subjectHolder) {
- return new ListCurator<TestSubject, String>(subjectHolder) {
- @Override
- public Iterator<String> iteratorForRecord() {
- return this.subject.strings();
- }
- };
- }
-
- private ListChangeListener buildListChangeListener1() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- public void itemsRemoved(ListRemoveEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- public void itemsReplaced(ListReplaceEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- public void itemsMoved(ListMoveEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- public void listCleared(ListClearEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- public void listChanged(ListChangeEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- };
- }
-
- void value1Changed(ListEvent e) {
- this.event1 = e;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSubjectHolder() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- assertNull(this.event1);
-
- this.subjectHolder1.setValue(this.subject2);
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(this.subject2Names(), CollectionTools.list(this.curator.listIterator()));
-
- this.event1 = null;
- this.subjectHolder1.setValue(null);
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertFalse(this.curator.iterator().hasNext());
-
- this.event1 = null;
- this.subjectHolder1.setValue(this.subject1);
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- }
-
- public void testAdd() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- assertNull(this.event1);
-
- this.subject1.addString("echo");
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(this.subject1Names().size(), ((ListAddEvent) this.event1).getIndex());
- assertEquals("echo", ((ListAddEvent) this.event1).getItems().iterator().next());
- List<String> stringsPlus = this.subject1Names();
- stringsPlus.add("echo");
- assertEquals(stringsPlus, CollectionTools.list(this.curator.listIterator()));
-
- this.event1 = null;
- this.subject1.addString(0, "zulu");
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(0, ((ListAddEvent) this.event1).getIndex());
- assertEquals("zulu", ((ListAddEvent) this.event1).getItems().iterator().next());
- stringsPlus.add(0, "zulu");
- assertEquals(stringsPlus, CollectionTools.list(this.curator.listIterator()));
- }
-
- public void testRemove() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- assertNull(this.event1);
-
- String removedString = this.subject1.removeString(0); // should be "alpha"
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(0, ((ListRemoveEvent) this.event1).getIndex());
- assertEquals(removedString, ((ListRemoveEvent) this.event1).getItems().iterator().next());
- List<String> stringsMinus = this.subject1Names();
- stringsMinus.remove(0);
- assertEquals(stringsMinus, CollectionTools.list(this.curator.listIterator()));
-
- removedString = this.subject1.removeString(2); // should be "delta"
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(2, ((ListRemoveEvent) this.event1).getIndex());
- assertEquals(removedString, ((ListRemoveEvent) this.event1).getItems().iterator().next());
- stringsMinus.remove(2);
- assertEquals(stringsMinus, CollectionTools.list(this.curator.listIterator()));
- }
-
- public void testCompleteListChange() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- assertNull(this.event1);
-
- this.subject1.setStrings(this.subject2Names());
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- List<String> newStrings = this.subject2Names();
- assertEquals(newStrings, CollectionTools.list(this.curator.listIterator()));
- }
-
- public void testPartialListChange() {
- List<String> startingList = CollectionTools.list(this.curator.listIterator());
- assertEquals(this.subject1Names(), startingList);
- assertNull(this.event1);
-
- String identicalString = startingList.get(1); // should be "bravo"
- String nonidenticalString = startingList.get(0); // should be "alpha"
- List<String> newStrings = CollectionTools.list(new String[] {new String("bravo"), new String("alpha"), "echo", "delta", "foxtrot"});
- this.subject1.setStrings(newStrings);
-
- List<String> finalList = CollectionTools.list(this.curator.listIterator());
- assertNotNull(this.event1);
- assertEquals(this.curator, this.event1.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event1.getListName());
- assertEquals(newStrings, finalList);
- assertTrue(identicalString == finalList.get(0));
- assertTrue(nonidenticalString != finalList.get(1));
- }
-
- public void testIterator() {
- assertEquals(this.subject1Names(), CollectionTools.list(this.subject1.strings()));
- assertEquals(this.subject1Names(), CollectionTools.list(this.curator.listIterator()));
- }
-
- public void testGet() {
- assertEquals(this.subject1Names().get(0), this.subject1.getString(0));
- assertEquals(this.subject1Names().get(0), this.curator.get(0));
- }
-
- public void testSize() {
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.subject1.strings()));
- assertEquals(this.subject1Names().size(), CollectionTools.size(this.curator.listIterator()));
- assertEquals(this.subject1Names().size(), this.curator.size());
- }
-
- public void testHasListeners() {
- assertTrue(this.curator.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.subject1.hasAnyStateChangeListeners());
- this.curator.removeListChangeListener(ListValueModel.LIST_VALUES, this.listener1);
- assertFalse(this.subject1.hasAnyStateChangeListeners());
- assertFalse(this.curator.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ChangeListener listener2 = this.buildChangeListener();
- this.curator.addChangeListener(listener2);
- assertTrue(this.curator.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(this.subject1.hasAnyStateChangeListeners());
- this.curator.removeChangeListener(listener2);
- assertFalse(this.subject1.hasAnyStateChangeListeners());
- assertFalse(this.curator.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private ChangeListener buildChangeListener() {
- return new ChangeAdapter() {
- @Override
- public void itemsAdded(ListAddEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- @Override
- public void itemsRemoved(ListRemoveEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- @Override
- public void itemsReplaced(ListReplaceEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- @Override
- public void itemsMoved(ListMoveEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- @Override
- public void listCleared(ListClearEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- @Override
- public void listChanged(ListChangeEvent e) {
- ListCuratorTests.this.value1Changed(e);
- }
- };
- }
-
-
- // **************** Inner Class *******************************************
-
- class TestSubject extends AbstractModel {
- private List<String> strings;
-
- public TestSubject() {
- this.strings = new ArrayList<String>();
- }
-
- public TestSubject(List<String> strings) {
- this();
- this.setStrings(strings);
- }
-
- public String getString(int index) {
- return this.strings.get(index);
- }
-
- public ListIterator<String> strings() {
- return new ReadOnlyListIterator<String>(this.strings);
- }
-
- public void addString(int index, String string) {
- this.strings.add(index, string);
- this.fireStateChanged();
- }
-
- public void addString(String string) {
- this.addString(this.strings.size(), string);
- }
-
- public String removeString(int index) {
- String string = this.strings.get(index);
- this.removeString(string);
- return string;
- }
-
- public void removeString(String string) {
- this.strings.remove(string);
- this.fireStateChanged();
- }
-
- public void setStrings(List<String> strings) {
- this.strings = new ArrayList<String>(strings);
- this.fireStateChanged();
- }
-
- public void setStrings(String[] strings) {
- this.strings = CollectionTools.list(strings);
- this.fireStateChanged();
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullCollectionValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullCollectionValueModelTests.java
deleted file mode 100644
index 786bd931eb..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullCollectionValueModelTests.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.model.value.NullCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-public class NullCollectionValueModelTests extends TestCase {
- private CollectionValueModel<Object> collectionHolder;
-
- public NullCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.collectionHolder = new NullCollectionValueModel<Object>();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSize() {
- assertEquals(0, this.collectionHolder.size());
- }
-
- public void testIterator() {
- assertFalse(this.collectionHolder.iterator().hasNext());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullListValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullListValueModelTests.java
deleted file mode 100644
index 63ba4ac5cf..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullListValueModelTests.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.model.value.NullListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-public class NullListValueModelTests extends TestCase {
- private ListValueModel<Object> listHolder;
-
- public NullListValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listHolder = new NullListValueModel<Object>();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGet() {
- boolean exCaught = false;
- try {
- this.listHolder.get(0);
- } catch (IndexOutOfBoundsException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- }
-
- public void testSize() {
- assertEquals(0, this.listHolder.size());
- }
-
- public void testIterator() {
- assertFalse(this.listHolder.iterator().hasNext());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullPropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullPropertyValueModelTests.java
deleted file mode 100644
index eaf6422b9b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/NullPropertyValueModelTests.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.model.value.NullPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-public class NullPropertyValueModelTests extends TestCase {
- private PropertyValueModel<Object> valueHolder;
-
- public NullPropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new NullPropertyValueModel<Object>();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- assertNull(this.valueHolder.getValue());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyAspectAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyAspectAdapterTests.java
deleted file mode 100644
index 6f5eaca4ba..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyAspectAdapterTests.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class PropertyAspectAdapterTests extends TestCase {
- private TestSubject subject1;
- private ModifiablePropertyValueModel<TestSubject> subjectHolder1;
- private PropertyAspectAdapter<TestSubject, String> aa1;
- private PropertyChangeEvent event1;
- private PropertyChangeListener listener1;
-
- private TestSubject subject2;
-
- private PropertyChangeEvent multipleValueEvent;
-
- private PropertyChangeEvent customValueEvent;
-
-
- public PropertyAspectAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.subject1 = new TestSubject("foo", "test subject 1");
- this.subjectHolder1 = new SimplePropertyValueModel<TestSubject> (this.subject1);
- this.aa1 = this.buildAspectAdapter(this.subjectHolder1);
- this.listener1 = this.buildValueChangeListener1();
- this.aa1.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- this.event1 = null;
-
- this.subject2 = new TestSubject("bar", "test subject 2");
- }
-
- private PropertyAspectAdapter<TestSubject, String> buildAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- return new PropertyAspectAdapter<TestSubject, String>(subjectHolder, TestSubject.NAME_PROPERTY) {
- // this is not a aspect adapter - the value is determined by the aspect name
- @Override
- protected String buildValue_() {
- if (this.aspectNames[0] == TestSubject.NAME_PROPERTY) {
- return this.subject.getName();
- } else if (this.aspectNames[0] == TestSubject.DESCRIPTION_PROPERTY) {
- return this.subject.getDescription();
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.aspectNames[0]);
- }
- }
- @Override
- protected void setValue_(String value) {
- if (this.aspectNames[0] == TestSubject.NAME_PROPERTY) {
- this.subject.setName(value);
- } else if (this.aspectNames[0] == TestSubject.DESCRIPTION_PROPERTY) {
- this.subject.setDescription(value);
- } else {
- throw new IllegalStateException("invalid aspect name: " + this.aspectNames[0]);
- }
- }
- };
- }
-
- private ChangeListener buildValueChangeListener1() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- PropertyAspectAdapterTests.this.value1Changed(e);
- }
- };
- }
-
- void value1Changed(PropertyChangeEvent e) {
- this.event1 = e;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSubjectHolder() {
- assertEquals("foo", this.aa1.getValue());
- assertNull(this.event1);
-
- this.subjectHolder1.setValue(this.subject2);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals("foo", this.event1.getOldValue());
- assertEquals("bar", this.event1.getNewValue());
- assertEquals("bar", this.aa1.getValue());
-
- this.event1 = null;
- this.subjectHolder1.setValue(null);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals("bar", this.event1.getOldValue());
- assertNull(this.event1.getNewValue());
- assertNull(this.aa1.getValue());
-
- this.event1 = null;
- this.subjectHolder1.setValue(this.subject1);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals(null, this.event1.getOldValue());
- assertEquals("foo", this.event1.getNewValue());
- assertEquals("foo", this.aa1.getValue());
- }
-
- public void testPropertyChange() {
- assertEquals("foo", this.aa1.getValue());
- assertNull(this.event1);
-
- this.subject1.setName("baz");
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals("foo", this.event1.getOldValue());
- assertEquals("baz", this.event1.getNewValue());
- assertEquals("baz", this.aa1.getValue());
-
- this.event1 = null;
- this.subject1.setName(null);
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals("baz", this.event1.getOldValue());
- assertEquals(null, this.event1.getNewValue());
- assertEquals(null, this.aa1.getValue());
-
- this.event1 = null;
- this.subject1.setName("foo");
- assertNotNull(this.event1);
- assertEquals(this.aa1, this.event1.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event1.getPropertyName());
- assertEquals(null, this.event1.getOldValue());
- assertEquals("foo", this.event1.getNewValue());
- assertEquals("foo", this.aa1.getValue());
- }
-
- public void testValue() {
- assertEquals("foo", this.subject1.getName());
- assertEquals("foo", this.aa1.getValue());
- }
-
- public void testStaleValue() {
- assertEquals("foo", this.subject1.getName());
- assertEquals("foo", this.aa1.getValue());
-
- this.aa1.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- assertEquals(null, this.aa1.getValue());
-
- this.aa1.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- assertEquals("foo", this.aa1.getValue());
-
- this.aa1.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- this.subjectHolder1.setValue(this.subject2);
- assertEquals(null, this.aa1.getValue());
-
- this.aa1.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- assertEquals("bar", this.aa1.getValue());
- }
-
- public void testSetValue() {
- this.aa1.setValue("baz");
- assertEquals("baz", this.aa1.getValue());
- assertEquals("baz", this.subject1.getName());
- }
-
- public void testHasListeners() {
- assertTrue(this.aa1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.subject1.hasAnyPropertyChangeListeners(TestSubject.NAME_PROPERTY));
- this.aa1.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener1);
- assertFalse(this.subject1.hasAnyPropertyChangeListeners(TestSubject.NAME_PROPERTY));
- assertFalse(this.aa1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- ChangeListener listener2 = this.buildValueChangeListener1();
- this.aa1.addChangeListener(listener2);
- assertTrue(this.aa1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.subject1.hasAnyPropertyChangeListeners(TestSubject.NAME_PROPERTY));
- this.aa1.removeChangeListener(listener2);
- assertFalse(this.subject1.hasAnyPropertyChangeListeners(TestSubject.NAME_PROPERTY));
- assertFalse(this.aa1.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testMultipleAspectAdapter() {
- TestSubject testSubject = new TestSubject("fred", "husband");
- ModifiablePropertyValueModel<TestSubject> testSubjectHolder = new SimplePropertyValueModel<TestSubject>(testSubject);
- ModifiablePropertyValueModel<String> testAA = this.buildMultipleAspectAdapter(testSubjectHolder);
- PropertyChangeListener testListener = this.buildMultipleValueChangeListener();
- testAA.addPropertyChangeListener(PropertyValueModel.VALUE, testListener);
- assertEquals("fred:husband", testAA.getValue());
-
- this.multipleValueEvent = null;
- testSubject.setName("wilma");
- assertEquals("wilma:husband", testAA.getValue());
- assertEquals("fred:husband", this.multipleValueEvent.getOldValue());
- assertEquals("wilma:husband", this.multipleValueEvent.getNewValue());
-
- this.multipleValueEvent = null;
- testSubject.setDescription("wife");
- assertEquals("wilma:wife", testAA.getValue());
- assertEquals("wilma:husband", this.multipleValueEvent.getOldValue());
- assertEquals("wilma:wife", this.multipleValueEvent.getNewValue());
- }
-
- private ModifiablePropertyValueModel<String> buildMultipleAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- return new PropertyAspectAdapter<TestSubject, String>(subjectHolder, TestSubject.NAME_PROPERTY, TestSubject.DESCRIPTION_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getName() + ":" + this.subject.getDescription();
- }
- };
- }
-
- private PropertyChangeListener buildMultipleValueChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- PropertyAspectAdapterTests.this.multipleValueChanged(e);
- }
- };
- }
-
- void multipleValueChanged(PropertyChangeEvent e) {
- this.multipleValueEvent = e;
- }
-
- /**
- * test a bug where we would call #buildValue() in
- * #engageNonNullSubject(), when we needed to call
- * it in #engageSubject(), so the cached value would
- * be rebuilt when the this.subject was set to null
- */
- public void testCustomBuildValueWithNullSubject() {
- TestSubject customSubject = new TestSubject("fred", "laborer");
- ModifiablePropertyValueModel<TestSubject> customSubjectHolder = new SimplePropertyValueModel<TestSubject>(customSubject);
- ModifiablePropertyValueModel<String> customAA = this.buildCustomAspectAdapter(customSubjectHolder);
- PropertyChangeListener customListener = this.buildCustomValueChangeListener();
- customAA.addPropertyChangeListener(PropertyValueModel.VALUE, customListener);
- assertEquals("fred", customAA.getValue());
-
- this.customValueEvent = null;
- customSubject.setName("wilma");
- assertEquals("wilma", customAA.getValue());
- assertEquals("fred", this.customValueEvent.getOldValue());
- assertEquals("wilma", this.customValueEvent.getNewValue());
-
- this.customValueEvent = null;
- customSubjectHolder.setValue(null);
- // this would fail - the value would be null...
- assertEquals("<unnamed>", customAA.getValue());
- assertEquals("wilma", this.customValueEvent.getOldValue());
- assertEquals("<unnamed>", this.customValueEvent.getNewValue());
- }
-
- /**
- * Test a bug:
- * If two listeners were added to an aspect adapter, one with an
- * aspect name and one without, the aspect adapter would add its
- * 'subjectChangeListener' to its 'subjectHolder' twice. As a result,
- * the following code will trigger an IllegalArgumentException
- * if the bug is present; otherwise, it completes silently.
- */
- public void testDuplicateListener() {
- ChangeListener listener2 = new ChangeAdapter();
- this.aa1.addChangeListener(listener2);
- }
-
- private ModifiablePropertyValueModel<String> buildCustomAspectAdapter(PropertyValueModel<TestSubject> subjectHolder) {
- return new PropertyAspectAdapter<TestSubject, String>(subjectHolder, TestSubject.NAME_PROPERTY) {
- @Override
- protected String buildValue() {
- return (this.subject == null) ? "<unnamed>" : this.subject.getName();
- }
- };
- }
-
- private PropertyChangeListener buildCustomValueChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- PropertyAspectAdapterTests.this.customValueChanged(e);
- }
- };
- }
-
- void customValueChanged(PropertyChangeEvent e) {
- this.customValueEvent = e;
- }
-
-
- // ********** test model **********
-
- private static class TestSubject extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
- private String description;
- public static final String DESCRIPTION_PROPERTY = "description";
-
- public TestSubject(String name, String description) {
- this.name = name;
- this.description = description;
- }
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
- public String getDescription() {
- return this.description;
- }
- public void setDescription(String description) {
- Object old = this.description;
- this.description = description;
- this.firePropertyChanged(DESCRIPTION_PROPERTY, old, description);
- }
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java
deleted file mode 100644
index aacfa746c7..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyCollectionValueModelAdapterTests.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.Collection;
-
-import javax.swing.JList;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyCollectionValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class PropertyCollectionValueModelAdapterTests extends TestCase {
- private CollectionValueModel<String> adapter;
- private ModifiablePropertyValueModel<String> wrappedValueHolder;
-
- public PropertyCollectionValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedValueHolder = new SimplePropertyValueModel<String>();
- this.adapter = new PropertyCollectionValueModelAdapter<String>(this.wrappedValueHolder);
- }
-
- private Collection<String> wrappedCollection() {
- return CollectionTools.collection(new SingleElementIterator<String>(this.wrappedValueHolder.getValue()));
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {/* OK */}
- });
- this.wrappedValueHolder.setValue("foo");
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(1, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- assertEquals("foo", adapterCollection.iterator().next());
- }
-
- public void testStaleValue() {
- CollectionChangeListener listener = new TestListener() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {/* OK */}
- };
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- this.wrappedValueHolder.setValue("foo");
- Collection<String> adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(1, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- assertEquals("foo", adapterCollection.iterator().next());
-
- this.adapter.removeCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(0, adapterCollection.size());
- assertEquals(new HashBag<String>(), adapterCollection);
-
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- adapterCollection = CollectionTools.collection(this.adapter.iterator());
- assertEquals(1, adapterCollection.size());
- assertEquals(this.wrappedCollection(), adapterCollection);
- assertEquals("foo", adapterCollection.iterator().next());
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- CoordinatedBag<String> synchCollection = new CoordinatedBag<String>(this.adapter);
- assertTrue(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.adapter.removeCollectionChangeListener(CollectionValueModel.VALUES, synchCollection);
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- ChangeListener cl = new ChangeAdapter();
- this.adapter.addChangeListener(cl);
- assertTrue(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.adapter.removeChangeListener(cl);
- assertFalse(((AbstractModel) this.adapter).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
- public void testListChangedToEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {/* OK */}
- @Override
- public void itemsRemoved(CollectionRemoveEvent e) {/* OK */}
- });
- this.wrappedValueHolder.setValue("foo");
- JList jList = new JList(new ListModelAdapter(this.adapter));
- this.wrappedValueHolder.setValue(null);
- assertEquals(0, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- this.wrappedValueHolder.setValue("foo");
- assertEquals(1, jList.getModel().getSize());
- }
-
- public void testCollectionChangedFromEmptyToEmpty() {
- this.adapter.addCollectionChangeListener(CollectionValueModel.VALUES, new TestListener());
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- this.wrappedValueHolder.setValue(null);
- assertEquals(0, jList.getModel().getSize());
- }
-
-
- // ********** member class **********
-
- static class TestListener implements CollectionChangeListener {
- public void collectionChanged(CollectionChangeEvent event) {
- fail("unexpected event");
- }
- public void collectionCleared(CollectionClearEvent event) {
- fail("unexpected event");
- }
- public void itemsAdded(CollectionAddEvent event) {
- fail("unexpected event");
- }
- public void itemsRemoved(CollectionRemoveEvent event) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyListValueModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyListValueModelAdapterTests.java
deleted file mode 100644
index e39091c262..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/PropertyListValueModelAdapterTests.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.swing.JList;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class PropertyListValueModelAdapterTests extends TestCase {
- private ListValueModel<String> adapter;
- private ModifiablePropertyValueModel<String> wrappedValueHolder;
-
- public PropertyListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedValueHolder = new SimplePropertyValueModel<String>();
- this.adapter = new PropertyListValueModelAdapter<String>(this.wrappedValueHolder);
- }
-
- private Collection<String> wrappedList() {
- return CollectionTools.list(new SingleElementIterator<String>(this.wrappedValueHolder.getValue()));
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsAdded(ListAddEvent event) {/* OK */}
- });
- assertFalse(this.adapter.iterator().hasNext());
- this.wrappedValueHolder.setValue("foo");
- List<String> adapterList = CollectionTools.list(this.adapter.iterator());
- assertEquals(1, adapterList.size());
- assertEquals(this.wrappedList(), adapterList);
- assertEquals("foo", adapterList.iterator().next());
- }
-
- public void testGetInt() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsAdded(ListAddEvent event) {/* OK */}
- });
- this.wrappedValueHolder.setValue("foo");
- assertEquals("foo", this.adapter.get(0));
- }
-
- public void testToArray1() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsAdded(ListAddEvent event) {/* OK */}
- });
- this.wrappedValueHolder.setValue("foo");
- Object[] array = this.adapter.toArray();
- assertEquals("foo", array[0]);
- assertEquals(1, array.length);
- }
-
- public void testToArray2() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener());
- Object[] array = this.adapter.toArray();
- assertEquals(0, array.length);
- }
-
- public void testStaleValue() {
- ListChangeListener listener = new TestListener() {
- @Override
- public void itemsAdded(ListAddEvent event) {/* OK */}
- };
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- this.wrappedValueHolder.setValue("foo");
- List<String> adapterList = CollectionTools.list(this.adapter.iterator());
- assertEquals(1, adapterList.size());
- assertEquals(this.wrappedList(), adapterList);
- assertEquals("foo", adapterList.iterator().next());
-
- this.adapter.removeListChangeListener(ListValueModel.LIST_VALUES, listener);
- adapterList = CollectionTools.list(this.adapter.iterator());
- assertEquals(0, adapterList.size());
- assertEquals(new ArrayList<String>(), adapterList);
-
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- adapterList = CollectionTools.list(this.adapter.iterator());
- assertEquals(1, adapterList.size());
- assertEquals(this.wrappedList(), adapterList);
- assertEquals("foo", adapterList.iterator().next());
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- CoordinatedList<String> synchList = new CoordinatedList<String>(this.adapter);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ChangeListener cl = new ChangeAdapter();
- this.adapter.addChangeListener(cl);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeChangeListener(cl);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- public void testListChangedToEmpty() {
- this.wrappedValueHolder.setValue("foo");
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsRemoved(ListRemoveEvent event) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
- this.wrappedValueHolder.setValue(null);
- assertEquals(0, jList.getModel().getSize());
- }
-
- public void testListChangedFromEmpty() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsAdded(ListAddEvent event) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- this.wrappedValueHolder.setValue("foo");
- assertEquals(1, jList.getModel().getSize());
- }
-
- public void testListItemChanged() {
- this.wrappedValueHolder.setValue("foo");
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener() {
- @Override
- public void itemsReplaced(ListReplaceEvent event) {/* OK */}
- });
- JList jList = new JList(new ListModelAdapter(this.adapter));
- assertEquals(1, jList.getModel().getSize());
- assertEquals("foo", jList.getModel().getElementAt(0));
-
- this.wrappedValueHolder.setValue("bar");
- assertEquals(1, jList.getModel().getSize());
- assertEquals("bar", jList.getModel().getElementAt(0));
- }
-
- public void testListChangedFromEmptyToEmpty() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListener());
- JList jList = new JList(new ListModelAdapter(this.adapter));
-
- this.wrappedValueHolder.setValue(null);
- assertEquals(0, jList.getModel().getSize());
- }
-
-
- // ********** member class **********
-
- static class TestListener implements ListChangeListener {
- public void listChanged(ListChangeEvent event) {
- fail("unexpected event");
- }
- public void listCleared(ListClearEvent event) {
- fail("unexpected event");
- }
- public void itemsAdded(ListAddEvent event) {
- fail("unexpected event");
- }
- public void itemsRemoved(ListRemoveEvent event) {
- fail("unexpected event");
- }
- public void itemsMoved(ListMoveEvent event) {
- fail("unexpected event");
- }
- public void itemsReplaced(ListReplaceEvent event) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ReadOnlyWritablePropertyValueModelWrapperTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ReadOnlyWritablePropertyValueModelWrapperTests.java
deleted file mode 100644
index b25ede951c..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ReadOnlyWritablePropertyValueModelWrapperTests.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ReadOnlyWritablePropertyValueModelWrapper;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ReadOnlyWritablePropertyValueModelWrapperTests
- extends TestCase
-{
- private ModifiablePropertyValueModel<String> objectHolder;
-
- PropertyChangeEvent event;
-
- private ModifiablePropertyValueModel<String> wrapperObjectHolder;
-
- PropertyChangeEvent wrapperEvent;
-
-
- public ReadOnlyWritablePropertyValueModelWrapperTests(String name) {
- super(name);
- }
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.objectHolder = new SimplePropertyValueModel<String>("foo");
- this.wrapperObjectHolder = new ReadOnlyWritablePropertyValueModelWrapper<String>(this.objectHolder);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
-
- public void testValue() {
- assertEquals("foo", this.objectHolder.getValue());
- assertEquals("foo", this.wrapperObjectHolder.getValue());
-
- this.objectHolder.setValue("bar");
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("bar", this.wrapperObjectHolder.getValue());
-
- this.objectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.wrapperObjectHolder.getValue());
-
- this.objectHolder.setValue("foo");
- assertEquals("foo", this.objectHolder.getValue());
- assertEquals("foo", this.wrapperObjectHolder.getValue());
- }
-
- public void testSetValue() {
- boolean exceptionOccurred = false;
- try {
- this.wrapperObjectHolder.setValue("bar");
- }
- catch (UnsupportedOperationException uoe) {
- exceptionOccurred = true;
- }
-
- assertTrue(exceptionOccurred);
- assertEquals("foo", this.objectHolder.getValue());
- assertEquals("foo", this.wrapperObjectHolder.getValue());
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- ChangeListener listener = buildWrapperListener();
- this.wrapperObjectHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.wrapperObjectHolder.removeChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.wrapperObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.wrapperObjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testPropertyChange1() {
- this.objectHolder.addChangeListener(this.buildListener());
- this.wrapperObjectHolder.addChangeListener(this.buildWrapperListener());
- this.verifyPropertyChanges();
- }
-
- public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.wrapperObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildWrapperListener());
- this.verifyPropertyChanges();
- }
-
- private void verifyPropertyChanges() {
- this.event = null;
- this.wrapperEvent = null;
- this.objectHolder.setValue("bar");
- verifyEvent(this.event, this.objectHolder, "foo", "bar");
- verifyEvent(this.wrapperEvent, this.wrapperObjectHolder, "foo", "bar");
-
- this.event = null;
- this.wrapperEvent = null;
- this.objectHolder.setValue(null);
- verifyEvent(this.event, this.objectHolder, "bar", null);
- verifyEvent(this.wrapperEvent, this.wrapperObjectHolder, "bar", null);
-
- this.event = null;
- this.wrapperEvent = null;
- this.objectHolder.setValue("foo");
- verifyEvent(this.event, this.objectHolder, null, "foo");
- verifyEvent(this.wrapperEvent, this.wrapperObjectHolder, null, "foo");
- }
-
- private ChangeListener buildListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- ReadOnlyWritablePropertyValueModelWrapperTests.this.event = e;
- }
- };
- }
-
- private ChangeListener buildWrapperListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- ReadOnlyWritablePropertyValueModelWrapperTests.this.wrapperEvent = e;
- }
- };
- }
-
- private void verifyEvent(PropertyChangeEvent e, Object source, Object oldValue, Object newValue) {
- assertEquals(source, e.getSource());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- assertEquals(oldValue, e.getOldValue());
- assertEquals(newValue, e.getNewValue());
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SetCollectionValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SetCollectionValueModelTests.java
deleted file mode 100644
index cddfb7d38b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SetCollectionValueModelTests.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SetCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class SetCollectionValueModelTests extends TestCase {
- private SimpleCollectionValueModel<String> collectionHolder;
- CollectionAddEvent addEvent;
- CollectionRemoveEvent removeEvent;
- CollectionClearEvent collectionClearedEvent;
- CollectionChangeEvent collectionChangedEvent;
-
- private CollectionValueModel<String> setHolder;
- CollectionAddEvent setAddEvent;
- CollectionRemoveEvent setRemoveEvent;
- CollectionClearEvent setClearedEvent;
- CollectionChangeEvent setChangedEvent;
-
- public SetCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.collectionHolder = new SimpleCollectionValueModel<String>(this.buildCollection());
- this.setHolder = new SetCollectionValueModel<String>(this.collectionHolder);
- }
-
- private Collection<String> buildCollection() {
- Collection<String> collection = new ArrayList<String>();
- collection.add("foo");
- collection.add("foo");
- return collection;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- // add a listener to "activate" the wrapper
- this.setHolder.addChangeListener(this.buildSetChangeListener());
-
- this.verify(this.collectionHolder, "foo", "foo");
- this.verify(this.setHolder, "foo");
-
- this.collectionHolder.add("bar");
- this.collectionHolder.add("bar");
- this.verify(this.collectionHolder, "foo", "foo", "bar", "bar");
- this.verify(this.setHolder, "foo", "bar");
-
- this.collectionHolder.remove("bar");
- this.verify(this.collectionHolder, "foo", "foo", "bar");
- this.verify(this.setHolder, "foo", "bar");
-
- this.collectionHolder.remove("bar");
- this.verify(this.collectionHolder, "foo", "foo");
- this.verify(this.setHolder, "foo");
-
- this.collectionHolder.remove("foo");
- this.verify(this.collectionHolder, "foo");
- this.verify(this.setHolder, "foo");
-
- this.collectionHolder.remove("foo");
- assertFalse(this.collectionHolder.iterator().hasNext());
- assertFalse(this.setHolder.iterator().hasNext());
- }
-
- public void testSize() {
- // add a listener to "activate" the wrapper
- this.setHolder.addChangeListener(this.buildSetChangeListener());
-
- assertEquals(2, this.collectionHolder.size());
- assertEquals(1, this.setHolder.size());
-
- this.collectionHolder.add("bar");
- this.collectionHolder.add("bar");
- assertEquals(4, this.collectionHolder.size());
- assertEquals(2, this.setHolder.size());
-
- this.collectionHolder.remove("bar");
- assertEquals(3, this.collectionHolder.size());
- assertEquals(2, this.setHolder.size());
-
- this.collectionHolder.remove("bar");
- assertEquals(2, this.collectionHolder.size());
- assertEquals(1, this.setHolder.size());
-
- this.collectionHolder.remove("foo");
- assertEquals(1, this.collectionHolder.size());
- assertEquals(1, this.setHolder.size());
-
- this.collectionHolder.remove("foo");
- assertEquals(0, this.collectionHolder.size());
- assertEquals(0, this.setHolder.size());
- }
-
- public void testBulkChange() {
- // add a listener to "activate" the wrapper
- this.setHolder.addChangeListener(this.buildSetChangeListener());
-
- Collection<String> newCollection = new ArrayList<String>();
- newCollection.add("fox");
- newCollection.add("fox");
- newCollection.add("bat");
-
- this.collectionHolder.setValues(newCollection);
- this.verify(this.collectionHolder, "fox", "fox", "bat");
- this.verify(this.setHolder, "fox", "bat");
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.collectionHolder).hasNoCollectionChangeListeners(CollectionValueModel.VALUES));
- ChangeListener listener = this.buildSetChangeListener();
- this.setHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.setHolder.removeChangeListener(listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasNoCollectionChangeListeners(CollectionValueModel.VALUES));
-
- this.setHolder.addCollectionChangeListener(CollectionValueModel.VALUES, listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- this.setHolder.removeCollectionChangeListener(CollectionValueModel.VALUES, listener);
- assertTrue(((AbstractModel) this.collectionHolder).hasNoCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
- public void testEvents1() {
- this.collectionHolder.addChangeListener(this.buildChangeListener());
- this.setHolder.addChangeListener(this.buildSetChangeListener());
- this.verifyEvents();
- }
-
- public void testEvents2() {
- this.collectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildCollectionChangeListener());
- this.setHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildSetCollectionChangeListener());
- this.verifyEvents();
- }
-
- private void clearEvents() {
- this.addEvent = null;
- this.removeEvent = null;
- this.collectionClearedEvent = null;
- this.collectionChangedEvent = null;
- this.setAddEvent = null;
- this.setRemoveEvent = null;
- this.setClearedEvent = null;
- this.setChangedEvent = null;
- }
-
- private void verifyEvents() {
- this.clearEvents();
- this.collectionHolder.add("bar");
- this.verifyEvent(this.addEvent, this.collectionHolder, "bar");
- this.verifyEvent(this.setAddEvent, this.setHolder, "bar");
-
- this.clearEvents();
- this.collectionHolder.remove("foo");
- this.verifyEvent(this.removeEvent, this.collectionHolder, "foo");
- assertNull(this.setRemoveEvent);
-
- this.clearEvents();
- this.collectionHolder.add("bar");
- this.verifyEvent(this.addEvent, this.collectionHolder, "bar");
- assertNull(this.setAddEvent);
-
- this.clearEvents();
- this.collectionHolder.remove("foo");
- this.verifyEvent(this.removeEvent, this.collectionHolder, "foo");
- this.verifyEvent(this.setRemoveEvent, this.setHolder, "foo");
-
- this.clearEvents();
- this.collectionHolder.add("foo");
- this.verifyEvent(this.addEvent, this.collectionHolder, "foo");
- this.verifyEvent(this.setAddEvent, this.setHolder, "foo");
-
- this.clearEvents();
- this.collectionHolder.clear();
- this.verifyEvent(this.collectionClearedEvent, this.collectionHolder);
- this.verifyEvent(this.setClearedEvent, this.setHolder);
-
- this.clearEvents();
- Collection<String> newCollection = new ArrayList<String>();
- newCollection.add("fox");
- newCollection.add("fox");
- newCollection.add("bat");
- newCollection.add("bat");
- newCollection.add("bat");
- this.collectionHolder.setValues(newCollection);
- this.verifyEvent(this.collectionChangedEvent, this.collectionHolder, "fox", "fox", "bat", "bat", "bat");
- this.verifyEvent(this.setChangedEvent, this.setHolder, "fox", "bat");
-
- }
-
- private CollectionChangeListener buildCollectionChangeListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent event) {
- SetCollectionValueModelTests.this.addEvent = event;
- }
- public void itemsRemoved(CollectionRemoveEvent event) {
- SetCollectionValueModelTests.this.removeEvent = event;
- }
- public void collectionCleared(CollectionClearEvent event) {
- SetCollectionValueModelTests.this.collectionClearedEvent = event;
- }
- public void collectionChanged(CollectionChangeEvent event) {
- SetCollectionValueModelTests.this.collectionChangedEvent = event;
- }
- };
- }
-
- private ChangeListener buildChangeListener() {
- return new ChangeAdapter() {
- @Override
- public void itemsAdded(CollectionAddEvent event) {
- SetCollectionValueModelTests.this.addEvent = event;
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent event) {
- SetCollectionValueModelTests.this.removeEvent = event;
- }
- @Override
- public void collectionCleared(CollectionClearEvent event) {
- SetCollectionValueModelTests.this.collectionClearedEvent = event;
- }
- @Override
- public void collectionChanged(CollectionChangeEvent event) {
- SetCollectionValueModelTests.this.collectionChangedEvent = event;
- }
- };
- }
-
- private CollectionChangeListener buildSetCollectionChangeListener() {
- return new CollectionChangeListener() {
- public void itemsAdded(CollectionAddEvent event) {
- SetCollectionValueModelTests.this.setAddEvent = event;
- }
- public void itemsRemoved(CollectionRemoveEvent event) {
- SetCollectionValueModelTests.this.setRemoveEvent = event;
- }
- public void collectionCleared(CollectionClearEvent event) {
- SetCollectionValueModelTests.this.setClearedEvent = event;
- }
- public void collectionChanged(CollectionChangeEvent event) {
- SetCollectionValueModelTests.this.setChangedEvent = event;
- }
- };
- }
-
- private ChangeListener buildSetChangeListener() {
- return new ChangeAdapter() {
- @Override
- public void itemsAdded(CollectionAddEvent event) {
- SetCollectionValueModelTests.this.setAddEvent = event;
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent event) {
- SetCollectionValueModelTests.this.setRemoveEvent = event;
- }
- @Override
- public void collectionCleared(CollectionClearEvent event) {
- SetCollectionValueModelTests.this.setClearedEvent = event;
- }
- @Override
- public void collectionChanged(CollectionChangeEvent event) {
- SetCollectionValueModelTests.this.setChangedEvent = event;
- }
- };
- }
-
- private void verify(CollectionValueModel<String> cvm, String... expectedItems) {
- Bag<String> actual = CollectionTools.bag(cvm);
- Bag<String> expected = CollectionTools.bag(expectedItems);
- assertEquals(expected, actual);
- }
-
- private void verifyEvent(CollectionAddEvent event, Object source, Object... expectedItems) {
- assertEquals(source, event.getSource());
- assertEquals(CollectionValueModel.VALUES, event.getCollectionName());
- assertEquals(CollectionTools.bag(expectedItems), CollectionTools.bag(event.getItems()));
- }
-
- private void verifyEvent(CollectionRemoveEvent event, Object source, Object... expectedItems) {
- assertEquals(source, event.getSource());
- assertEquals(CollectionValueModel.VALUES, event.getCollectionName());
- assertEquals(CollectionTools.bag(expectedItems), CollectionTools.bag(event.getItems()));
- }
-
- private void verifyEvent(CollectionClearEvent event, Object source) {
- assertEquals(source, event.getSource());
- assertEquals(CollectionValueModel.VALUES, event.getCollectionName());
- }
-
- private void verifyEvent(CollectionChangeEvent event, Object source, Object... expectedItems) {
- assertEquals(source, event.getSource());
- assertEquals(CollectionValueModel.VALUES, event.getCollectionName());
- assertEquals(CollectionTools.bag(expectedItems), CollectionTools.bag(event.getCollection()));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java
deleted file mode 100644
index e3e4a70a58..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimpleCollectionValueModelTests.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class SimpleCollectionValueModelTests extends TestCase {
- private SimpleCollectionValueModel<String> bagHolder;
- CollectionEvent bagEvent;
- String bagEventType;
-
- private SimpleCollectionValueModel<String> setHolder;
- CollectionEvent setEvent;
- String setEventType;
-
- private static final String ADD = "add";
- private static final String REMOVE = "remove";
- private static final String CHANGE = "change";
- private static final String CLEAR = "clear";
-
-
- public SimpleCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.bagHolder = new SimpleCollectionValueModel<String>(this.buildBag());
- this.setHolder = new SimpleCollectionValueModel<String>(this.buildSet());
- }
-
- private Bag<String> buildBag() {
- Bag<String> result = new HashBag<String>();
- this.addItemsTo(result);
- return result;
- }
-
- private Set<String> buildSet() {
- Set<String> result = new HashSet<String>();
- this.addItemsTo(result);
- return result;
- }
-
- private void addItemsTo(Collection<String> c) {
- c.add("foo");
- c.add("bar");
- c.add("baz");
- }
-
- private Bag<String> buildAddItems() {
- Bag<String> result = new HashBag<String>();
- result.add("joo");
- result.add("jar");
- result.add("jaz");
- return result;
- }
-
- private Bag<String> buildRemoveItems() {
- Bag<String> result = new HashBag<String>();
- result.add("foo");
- result.add("baz");
- return result;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- assertEquals(this.buildBag(), CollectionTools.bag(this.bagHolder.iterator()));
- assertEquals(this.buildSet(), CollectionTools.set(this.setHolder.iterator()));
- }
-
- public void testSize() {
- assertEquals(this.buildBag().size(), CollectionTools.size(this.bagHolder.iterator()));
- assertEquals(this.buildSet().size(), CollectionTools.size(this.setHolder.iterator()));
- }
-
- private boolean bagHolderContains(Object item) {
- return CollectionTools.contains(this.bagHolder.iterator(), item);
- }
-
- private boolean setHolderContains(Object item) {
- return CollectionTools.contains(this.setHolder.iterator(), item);
- }
-
- private boolean bagHolderContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.bagHolder.iterator(), items);
- }
-
- private boolean setHolderContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.setHolder.iterator(), items);
- }
-
- private boolean bagHolderContainsAny(Collection<String> items) {
- Bag<String> bag = CollectionTools.bag(this.bagHolder.iterator());
- for (String string : items) {
- if (bag.contains(string)) {
- return true;
- }
- }
- return false;
- }
-
- private boolean setHolderContainsAny(Collection<String> items) {
- Set<String> set = CollectionTools.set(this.setHolder.iterator());
- for (String string : items) {
- if (set.contains(string)) {
- return true;
- }
- }
- return false;
- }
-
- public void testAdd() {
- assertFalse(this.bagHolderContains("joo"));
- this.bagHolder.add("joo");
- assertTrue(this.bagHolderContains("joo"));
-
- assertFalse(this.bagHolderContains(null));
- this.bagHolder.add(null);
- assertTrue(this.bagHolderContains(null));
-
- assertFalse(this.setHolderContains("joo"));
- this.setHolder.add("joo");
- assertTrue(this.setHolderContains("joo"));
-
- assertFalse(this.setHolderContains(null));
- this.setHolder.add(null);
- assertTrue(this.setHolderContains(null));
- }
-
- public void testAddAll() {
- assertFalse(this.bagHolderContainsAny(this.buildAddItems()));
- this.bagHolder.addAll(this.buildAddItems());
- assertTrue(this.bagHolderContainsAll(this.buildAddItems()));
-
- assertFalse(this.setHolderContainsAny(this.buildAddItems()));
- this.setHolder.addAll(this.buildAddItems());
- assertTrue(this.setHolderContainsAll(this.buildAddItems()));
- }
-
- public void testRemove() {
- assertTrue(this.bagHolderContains("bar"));
- this.bagHolder.remove("bar");
- assertFalse(this.bagHolderContains("bar"));
-
- this.bagHolder.add(null);
- assertTrue(this.bagHolderContains(null));
- this.bagHolder.remove(null);
- assertFalse(this.bagHolderContains(null));
-
- assertTrue(this.setHolderContains("bar"));
- this.setHolder.remove("bar");
- assertFalse(this.setHolderContains("bar"));
-
- this.setHolder.add(null);
- assertTrue(this.setHolderContains(null));
- this.setHolder.remove(null);
- assertFalse(this.setHolderContains(null));
- }
-
- public void testRemoveAll() {
- assertTrue(this.bagHolderContainsAll(this.buildRemoveItems()));
- this.bagHolder.removeAll(this.buildRemoveItems());
- assertFalse(this.bagHolderContainsAny(this.buildRemoveItems()));
-
- assertTrue(this.setHolderContainsAll(this.buildRemoveItems()));
- this.setHolder.removeAll(this.buildRemoveItems());
- assertFalse(this.setHolderContainsAny(this.buildRemoveItems()));
- }
-
- public void testSetValues() {
- assertTrue(this.bagHolderContains("bar"));
- assertFalse(this.bagHolderContains("jar"));
- this.bagHolder.setValues(this.buildAddItems());
- assertFalse(this.bagHolderContains("bar"));
- assertTrue(this.bagHolderContains("jar"));
-
- this.bagHolder.add(null);
- assertTrue(this.bagHolderContains(null));
- this.bagHolder.remove(null);
- assertFalse(this.bagHolderContains(null));
-
- this.bagHolder.setValues(new HashBag<String>());
- assertFalse(this.bagHolderContains("jar"));
-
- assertTrue(this.setHolderContains("bar"));
- assertFalse(this.setHolderContains("jar"));
- this.setHolder.setValues(this.buildAddItems());
- assertFalse(this.setHolderContains("bar"));
- assertTrue(this.setHolderContains("jar"));
-
- this.setHolder.add(null);
- assertTrue(this.setHolderContains(null));
- this.setHolder.remove(null);
- assertFalse(this.setHolderContains(null));
-
- this.setHolder.setValues(new HashBag<String>());
- assertFalse(this.setHolderContains("jar"));
- }
-
- public void testCollectionChange1() {
- this.bagHolder.addChangeListener(this.buildBagListener());
- this.verifyBagChange();
-
- this.setHolder.addChangeListener(this.buildSetListener());
- this.verifySetChange();
- }
-
- public void testCollectionChange2() {
- this.bagHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildBagListener());
- this.verifyBagChange();
-
- this.setHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.buildSetListener());
- this.verifySetChange();
- }
-
- private void verifyBagChange() {
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.add("foo");
- this.verifyBagEvent(ADD, "foo");
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.add("foo");
- this.verifyBagEvent(ADD, "foo");
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.add("joo");
- this.verifyBagEvent(ADD, "joo");
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.add(null);
- this.verifyBagEvent(ADD, null);
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.add(null);
- this.verifyBagEvent(ADD, null);
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.remove("joo");
- this.verifyBagEvent(REMOVE, "joo");
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.remove(null);
- this.verifyBagEvent(REMOVE, null);
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.setValues(this.buildBag());
- this.verifyBagEvent(CHANGE);
-
- this.bagEvent = null;
- this.bagEventType = null;
- this.bagHolder.addAll(this.buildBag());
- this.verifyBagEvent(ADD);
- assertEquals(this.buildBag(), CollectionTools.bag(((CollectionAddEvent) this.bagEvent).getItems()));
- }
-
- private void verifySetChange() {
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.add("foo");
- assertNull(this.setEvent);
- assertNull(this.setEventType);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.add("joo");
- this.verifySetEvent(ADD, "joo");
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.add("joo");
- assertNull(this.setEvent);
- assertNull(this.setEventType);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.add(null);
- this.verifySetEvent(ADD, null);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.add(null);
- assertNull(this.setEvent);
- assertNull(this.setEventType);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.remove("joo");
- this.verifySetEvent(REMOVE, "joo");
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.remove("joo");
- assertNull(this.setEvent);
- assertNull(this.setEventType);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.remove(null);
- this.verifySetEvent(REMOVE, null);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.setValues(this.buildSet());
- this.verifySetEvent(CHANGE);
-
- this.setEvent = null;
- this.setEventType = null;
- this.setHolder.addAll(this.buildSet());
- assertNull(this.setEvent);
- assertNull(this.setEventType);
- }
-
- private ChangeListener buildBagListener() {
- return new ChangeAdapter() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {
- SimpleCollectionValueModelTests.this.bagEventType = ADD;
- SimpleCollectionValueModelTests.this.bagEvent = e;
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent e) {
- SimpleCollectionValueModelTests.this.bagEventType = REMOVE;
- SimpleCollectionValueModelTests.this.bagEvent = e;
- }
- @Override
- public void collectionCleared(CollectionClearEvent e) {
- SimpleCollectionValueModelTests.this.bagEventType = CLEAR;
- SimpleCollectionValueModelTests.this.bagEvent = e;
- }
- @Override
- public void collectionChanged(CollectionChangeEvent e) {
- SimpleCollectionValueModelTests.this.bagEventType = CHANGE;
- SimpleCollectionValueModelTests.this.bagEvent = e;
- }
- };
- }
-
- private ChangeListener buildSetListener() {
- return new ChangeAdapter() {
- @Override
- public void itemsAdded(CollectionAddEvent e) {
- SimpleCollectionValueModelTests.this.setEventType = ADD;
- SimpleCollectionValueModelTests.this.setEvent = e;
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent e) {
- SimpleCollectionValueModelTests.this.setEventType = REMOVE;
- SimpleCollectionValueModelTests.this.setEvent = e;
- }
- @Override
- public void collectionCleared(CollectionClearEvent e) {
- SimpleCollectionValueModelTests.this.setEventType = CLEAR;
- SimpleCollectionValueModelTests.this.setEvent = e;
- }
- @Override
- public void collectionChanged(CollectionChangeEvent e) {
- SimpleCollectionValueModelTests.this.setEventType = CHANGE;
- SimpleCollectionValueModelTests.this.setEvent = e;
- }
- };
- }
-
- private void verifyBagEvent(String eventType) {
- assertEquals(eventType, this.bagEventType);
- assertEquals(this.bagHolder, this.bagEvent.getSource());
- assertEquals(CollectionValueModel.VALUES, this.bagEvent.getCollectionName());
- }
-
- private void verifyBagEvent(String eventType, Object item) {
- this.verifyBagEvent(eventType);
- assertEquals(item, this.getBagEventItems().iterator().next());
- }
-
- private Iterable<?> getBagEventItems() {
- if (this.bagEvent instanceof CollectionAddEvent) {
- return ((CollectionAddEvent) this.bagEvent).getItems();
- } else if (this.bagEvent instanceof CollectionRemoveEvent) {
- return ((CollectionRemoveEvent) this.bagEvent).getItems();
- }
- throw new IllegalStateException();
- }
-
- private void verifySetEvent(String eventType) {
- assertEquals(eventType, this.setEventType);
- assertEquals(this.setHolder, this.setEvent.getSource());
- assertEquals(CollectionValueModel.VALUES, this.setEvent.getCollectionName());
- }
-
- private void verifySetEvent(String eventType, Object item) {
- this.verifySetEvent(eventType);
- assertEquals(item, this.getSetEventItems().iterator().next());
- }
-
- private Iterable<?> getSetEventItems() {
- if (this.setEvent instanceof CollectionAddEvent) {
- return ((CollectionAddEvent) this.setEvent).getItems();
- } else if (this.setEvent instanceof CollectionRemoveEvent) {
- return ((CollectionRemoveEvent) this.setEvent).getItems();
- }
- throw new IllegalStateException();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimpleListValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimpleListValueModelTests.java
deleted file mode 100644
index 50db81128b..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimpleListValueModelTests.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class SimpleListValueModelTests extends TestCase {
- private SimpleListValueModel<String> listHolder;
- ListEvent event;
- String eventType;
-
- private static final String ADD = "add";
- private static final String REMOVE = "remove";
- private static final String REPLACE = "replace";
- private static final String MOVE = "move";
- private static final String CLEAR = "clear";
- private static final String CHANGE = "change";
-
-
- public SimpleListValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listHolder = new SimpleListValueModel<String>(this.buildList());
- }
-
- private List<String> buildList() {
- List<String> result = new ArrayList<String>();
- result.add("foo");
- result.add("bar");
- result.add("baz");
- return result;
- }
-
- private List<String> buildAddList() {
- List<String> result = new ArrayList<String>();
- result.add("joo");
- result.add("jar");
- result.add("jaz");
- return result;
- }
-
-// private List<String> buildRemoveList() {
-// List<String> result = new ArrayList<String>();
-// result.add("foo");
-// result.add("bar");
-// return result;
-// }
-//
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- assertEquals(this.buildList(), CollectionTools.list(this.listHolder.iterator()));
- }
-
- public void testListIterator() {
- assertEquals(this.buildList(), CollectionTools.list(this.listHolder.listIterator()));
- }
-
- public void testListIteratorInt() {
- assertEquals(CollectionTools.list(this.buildList().listIterator(1)), CollectionTools.list(this.listHolder.listIterator(1)));
- }
-
- public void testSize() {
- assertEquals(this.buildList().size(), this.listHolder.size());
- }
-
- private boolean listContains(Object item) {
- return CollectionTools.contains(this.listHolder.listIterator(), item);
- }
-
- private boolean listContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.listHolder.listIterator(), items);
- }
-
- private boolean listContainsAny(Collection<String> items) {
- Set<String> set = CollectionTools.set(this.listHolder.iterator());
- for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
- if (set.contains(stream.next())) {
- return true;
- }
- }
- return false;
- }
-
- public void testAddObject() {
- assertFalse(this.listContains("joo"));
- this.listHolder.add("joo");
- assertTrue(this.listContains("joo"));
-
- assertFalse(this.listContains(null));
- this.listHolder.add(null);
- assertTrue(this.listContains(null));
- }
-
- public void testAddIntObject() {
- assertFalse(this.listContains("joo"));
- this.listHolder.add(2, "joo");
- assertTrue(this.listContains("joo"));
-
- assertFalse(this.listContains(null));
- this.listHolder.add(0, null);
- assertTrue(this.listContains(null));
- }
-
- public void testAddAllCollection() {
- assertFalse(this.listContainsAny(this.buildAddList()));
- this.listHolder.addAll(this.buildAddList());
- assertTrue(this.listContainsAll(this.buildAddList()));
- }
-
- public void testAddAllIntCollection() {
- assertFalse(this.listContainsAny(this.buildAddList()));
- this.listHolder.addAll(2, this.buildAddList());
- assertTrue(this.listContainsAll(this.buildAddList()));
- }
-
- public void testClear() {
- assertFalse(this.listHolder.isEmpty());
- this.listHolder.clear();
- assertTrue(this.listHolder.isEmpty());
- }
-
- public void testContainsObject() {
- assertTrue(this.listHolder.contains("foo"));
- assertFalse(this.listHolder.contains("joo"));
- }
-
- public void testContainsAllCollection() {
- Collection<String> c = new ArrayList<String>();
- c.add("foo");
- c.add("bar");
- assertTrue(this.listHolder.containsAll(c));
-
- c.add("joo");
- assertFalse(this.listHolder.containsAll(c));
- }
-
- public void testEquals() {
- assertEquals(new SimpleListValueModel<String>(this.buildList()), this.listHolder);
- assertFalse(this.listHolder.equals(new SimpleListValueModel<String>(this.buildAddList())));
- assertFalse(this.listHolder.equals(this.buildList()));
- assertFalse(this.listHolder.equals(new SimpleListValueModel<String>()));
- }
-
- public void testGetInt() {
- assertEquals("foo", this.listHolder.get(0));
- assertEquals("bar", this.listHolder.get(1));
- assertEquals("baz", this.listHolder.get(2));
- }
-
- public void testHashCode() {
- assertEquals(new SimpleListValueModel<String>(this.buildList()).hashCode(), this.listHolder.hashCode());
- }
-
- public void testIndexOfObject() {
- assertEquals(0, this.listHolder.indexOf("foo"));
- assertEquals(1, this.listHolder.indexOf("bar"));
- assertEquals(2, this.listHolder.indexOf("baz"));
- assertEquals(-1, this.listHolder.indexOf("joo"));
- }
-
- public void testLastIndexOfObject() {
- assertEquals(0, this.listHolder.lastIndexOf("foo"));
- assertEquals(1, this.listHolder.lastIndexOf("bar"));
- assertEquals(2, this.listHolder.lastIndexOf("baz"));
- assertEquals(-1, this.listHolder.lastIndexOf("joo"));
-
- this.listHolder.add("foo");
- assertEquals(3, this.listHolder.lastIndexOf("foo"));
- }
-
- public void testIsEmpty() {
- assertFalse(this.listHolder.isEmpty());
- this.listHolder.clear();
- assertTrue(this.listHolder.isEmpty());
- }
-
- public void testRemove() {
- assertTrue(this.listContains("bar"));
- this.listHolder.remove(this.buildList().indexOf("bar"));
- assertFalse(this.listContains("bar"));
-
- this.listHolder.add(1, null);
- assertTrue(this.listContains(null));
- this.listHolder.remove(1);
- assertFalse(this.listContains(null));
- }
-
- public void testSetValues() {
- List<String> newList = new ArrayList<String>();
- newList.add("joo");
- newList.add("jar");
- newList.add("jaz");
-
- assertTrue(this.listContains("bar"));
- assertFalse(this.listContains("jar"));
- this.listHolder.setListValues(newList);
- assertFalse(this.listContains("bar"));
- assertTrue(this.listContains("jar"));
-
- this.listHolder.add(1, null);
- assertTrue(this.listContains(null));
- this.listHolder.remove(1);
- assertFalse(this.listContains(null));
-
- this.listHolder.setListValues(new ArrayList<String>());
- assertFalse(this.listContains("jar"));
- }
-
- public void testListChange1() {
- this.listHolder.addChangeListener(this.buildChangeListener());
- this.verifyListChange();
- }
-
- public void testListChange2() {
- this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- this.verifyListChange();
- }
-
- private void verifyListChange() {
- this.event = null;
- this.eventType = null;
- this.listHolder.add(1, "joo");
- this.verifyEvent(ADD, 1, "joo");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.add(1, null);
- this.verifyEvent(ADD, 1, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(1);
- this.verifyEvent(REMOVE, 1, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(1);
- this.verifyEvent(REMOVE, 1, "joo");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.setListValues(this.buildList());
- this.verifyEvent(CHANGE);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.addAll(0, this.buildList());
- this.verifyEvent(ADD);
- assertEquals(this.buildList(), CollectionTools.list(((ListAddEvent) this.event).getItems()));
-
- this.event = null;
- this.eventType = null;
- this.listHolder.set(0, "joo");
- this.verifyEvent(REPLACE);
- assertFalse(CollectionTools.contains(((ListReplaceEvent) this.event).getNewItems(), "foo"));
- assertTrue(CollectionTools.contains(((ListReplaceEvent) this.event).getNewItems(), "joo"));
- }
-
- private ListChangeListener buildListener() {
- return new ListChangeListener() {
- public void itemsAdded(ListAddEvent e) {
- SimpleListValueModelTests.this.eventType = ADD;
- SimpleListValueModelTests.this.event = e;
- }
- public void itemsRemoved(ListRemoveEvent e) {
- SimpleListValueModelTests.this.eventType = REMOVE;
- SimpleListValueModelTests.this.event = e;
- }
- public void itemsReplaced(ListReplaceEvent e) {
- SimpleListValueModelTests.this.eventType = REPLACE;
- SimpleListValueModelTests.this.event = e;
- }
- public void itemsMoved(ListMoveEvent e) {
- SimpleListValueModelTests.this.eventType = MOVE;
- SimpleListValueModelTests.this.event = e;
- }
- public void listCleared(ListClearEvent e) {
- SimpleListValueModelTests.this.eventType = CLEAR;
- SimpleListValueModelTests.this.event = e;
- }
- public void listChanged(ListChangeEvent e) {
- SimpleListValueModelTests.this.eventType = CHANGE;
- SimpleListValueModelTests.this.event = e;
- }
- };
- }
-
- private ChangeListener buildChangeListener() {
- return new ChangeAdapter() {
- @Override
- public void itemsAdded(ListAddEvent e) {
- SimpleListValueModelTests.this.eventType = ADD;
- SimpleListValueModelTests.this.event = e;
- }
- @Override
- public void itemsRemoved(ListRemoveEvent e) {
- SimpleListValueModelTests.this.eventType = REMOVE;
- SimpleListValueModelTests.this.event = e;
- }
- @Override
- public void itemsReplaced(ListReplaceEvent e) {
- SimpleListValueModelTests.this.eventType = REPLACE;
- SimpleListValueModelTests.this.event = e;
- }
- @Override
- public void itemsMoved(ListMoveEvent e) {
- SimpleListValueModelTests.this.eventType = MOVE;
- SimpleListValueModelTests.this.event = e;
- }
- @Override
- public void listCleared(ListClearEvent e) {
- SimpleListValueModelTests.this.eventType = CLEAR;
- SimpleListValueModelTests.this.event = e;
- }
- @Override
- public void listChanged(ListChangeEvent e) {
- SimpleListValueModelTests.this.eventType = CHANGE;
- SimpleListValueModelTests.this.event = e;
- }
- };
- }
-
- private void verifyEvent(String e) {
- assertEquals(e, this.eventType);
- assertEquals(this.listHolder, this.event.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event.getListName());
- }
-
- private void verifyEvent(String e, int index, Object item) {
- this.verifyEvent(e);
- if (e == ADD) {
- assertEquals(index, ((ListAddEvent) this.event).getIndex());
- assertEquals(item, ((ListAddEvent) this.event).getItems().iterator().next());
- } else if (e == REMOVE) {
- assertEquals(index, ((ListRemoveEvent) this.event).getIndex());
- assertEquals(item, ((ListRemoveEvent) this.event).getItems().iterator().next());
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimplePropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimplePropertyValueModelTests.java
deleted file mode 100644
index 07dbebea72..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SimplePropertyValueModelTests.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class SimplePropertyValueModelTests extends TestCase {
- private ModifiablePropertyValueModel<String> objectHolder;
- PropertyChangeEvent event;
-
-
- public SimplePropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.objectHolder = new SimplePropertyValueModel<String>("foo");
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- assertEquals("foo", this.objectHolder.getValue());
- }
-
- public void testSetValue() {
- this.objectHolder.setValue("bar");
- assertEquals("bar", this.objectHolder.getValue());
- this.objectHolder.setValue(null);
- assertEquals(null, this.objectHolder.getValue());
- this.objectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- }
-
- public void testPropertyChange1() {
- this.objectHolder.addChangeListener(this.buildListener());
- this.verifyPropertyChange();
- }
-
- public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.verifyPropertyChange();
- }
-
- private void verifyPropertyChange() {
- this.event = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent("foo", "bar");
-
- this.event = null;
- this.objectHolder.setValue(null);
- this.verifyEvent("bar", null);
-
- this.event = null;
- this.objectHolder.setValue("baz");
- this.verifyEvent(null, "baz");
- }
-
- private ChangeListener buildListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- SimplePropertyValueModelTests.this.event = e;
- }
- };
- }
-
- private void verifyEvent(Object oldValue, Object newValue) {
- assertEquals(this.objectHolder, this.event.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event.getPropertyName());
- assertEquals(oldValue, this.event.getOldValue());
- assertEquals(newValue, this.event.getNewValue());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java
deleted file mode 100644
index 46607e8921..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SortedListValueModelAdapterTests.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.TreeSet;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.ReverseComparator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class SortedListValueModelAdapterTests extends TestCase {
- private SortedListValueModelAdapter<String> adapter;
- private SimpleCollectionValueModel<String> wrappedCollectionHolder;
- private Collection<String> wrappedCollection;
-
-
- public SortedListValueModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.wrappedCollection = new HashBag<String>();
- this.wrappedCollectionHolder = new SimpleCollectionValueModel<String>(this.wrappedCollection);
- this.adapter = new SortedListValueModelAdapter<String>(this.wrappedCollectionHolder);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- private void verifyList(Collection<String> expected, ListValueModel<String> actual) {
- this.verifyList(expected, actual, null);
- }
-
- private void verifyList(Collection<String> expected, ListValueModel<String> actual, Comparator<String> comparator) {
- Collection<String> sortedSet = new TreeSet<String>(comparator);
- sortedSet.addAll(expected);
- List<String> expectedList = new ArrayList<String>(sortedSet);
- List<String> actualList = CollectionTools.list(actual.iterator());
- assertEquals(expectedList, actualList);
- }
-
- public void testAdd() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListAddEvent e) {/* OK */}
- @Override
- public void itemsReplaced(ListReplaceEvent e) {/* OK */}
- });
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- assertEquals(3, this.adapter.size());
- this.verifyList(this.wrappedCollection, this.adapter);
- }
-
- public void testAddItem() {
- List<String> synchList = new CoordinatedList<String>(this.adapter);
- Bag<String> synchCollection = new CoordinatedBag<String>(this.wrappedCollectionHolder);
- this.wrappedCollectionHolder.add("foo");
- assertTrue(this.wrappedCollection.contains("foo"));
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- assertEquals(6, this.wrappedCollection.size());
-
- this.verifyList(this.wrappedCollection, this.adapter);
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
- }
-
- public void testRemoveItem() {
- List<String> synchList = new CoordinatedList<String>(this.adapter);
- Bag<String> synchCollection = new CoordinatedBag<String>(this.wrappedCollectionHolder);
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- this.wrappedCollectionHolder.remove("jaz");
- assertFalse(this.wrappedCollection.contains("jaz"));
- this.wrappedCollectionHolder.remove("foo");
- assertFalse(this.wrappedCollection.contains("foo"));
- assertEquals(4, this.wrappedCollection.size());
-
- this.verifyList(this.wrappedCollection, this.adapter);
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
- }
-
- public void testListSynch() {
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListAddEvent e) {/* OK */}
- @Override
- public void itemsRemoved(ListRemoveEvent e) {/* OK */}
- @Override
- public void itemsReplaced(ListReplaceEvent e) {/* OK */}
- });
- this.wrappedCollectionHolder.add("foo");
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- this.wrappedCollectionHolder.remove("jaz");
- assertFalse(this.wrappedCollection.contains("jaz"));
- this.wrappedCollectionHolder.remove("foo");
- assertFalse(this.wrappedCollection.contains("foo"));
- assertEquals(4, this.wrappedCollection.size());
-
- this.verifyList(this.wrappedCollection, this.adapter);
- }
-
- public void testSetComparator() {
- List<String> synchList = new CoordinatedList<String>(this.adapter);
- Bag<String> synchCollection = new CoordinatedBag<String>(this.wrappedCollectionHolder);
- this.wrappedCollectionHolder.add("foo");
- assertTrue(this.wrappedCollection.contains("foo"));
- this.wrappedCollectionHolder.add("bar");
- this.wrappedCollectionHolder.add("baz");
- this.wrappedCollectionHolder.add("joo");
- this.wrappedCollectionHolder.add("jar");
- this.wrappedCollectionHolder.add("jaz");
- assertEquals(6, this.wrappedCollection.size());
-
- this.verifyList(this.wrappedCollection, this.adapter);
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
-
- this.adapter.setComparator(new ReverseComparator<String>());
- this.verifyList(this.wrappedCollection, this.adapter, new ReverseComparator<String>());
- assertEquals(this.wrappedCollection, CollectionTools.collection(synchList.iterator()));
- assertEquals(this.wrappedCollection, synchCollection);
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- CoordinatedList<String> synchList = new CoordinatedList<String>(this.adapter);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeListChangeListener(ListValueModel.LIST_VALUES, synchList);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ChangeListener cl = new ChangeAdapter();
- this.adapter.addChangeListener(cl);
- assertTrue(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.adapter.removeChangeListener(cl);
- assertFalse(((AbstractModel) this.adapter).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- public void testCollectionChange() {
- this.wrappedCollectionHolder.add("fred");
- this.adapter.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListAddEvent e) {/* OK */}
- @Override
- public void itemsReplaced(ListReplaceEvent e) {/* OK */}
- });
- this.wrappedCollectionHolder.setValues(Arrays.asList(new String[] {"foo", "bar", "baz"}));
- assertEquals(3, this.adapter.size());
- this.verifyList(this.wrappedCollection, this.adapter);
- }
-
- class TestListChangeListener implements ListChangeListener {
- public void itemsAdded(ListAddEvent e) {
- fail("unexpected event");
- }
- public void itemsRemoved(ListRemoveEvent e) {
- fail("unexpected event");
- }
- public void itemsReplaced(ListReplaceEvent e) {
- fail("unexpected event");
- }
- public void itemsMoved(ListMoveEvent e) {
- fail("unexpected event");
- }
- public void listCleared(ListClearEvent e) {
- fail("unexpected event");
- }
- public void listChanged(ListChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SortedListValueModelWrapperTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SortedListValueModelWrapperTests.java
deleted file mode 100644
index 0f4f945eec..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/SortedListValueModelWrapperTests.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.TreeSet;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.ReverseComparator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class SortedListValueModelWrapperTests extends TestCase {
- private List<String> list;
- private SimpleListValueModel<String> listModel;
- private SortedListValueModelWrapper<String> sortedListModel;
-
-
- public SortedListValueModelWrapperTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.list = new ArrayList<String>();
- this.listModel = new SimpleListValueModel<String>(this.list);
- this.sortedListModel = new SortedListValueModelWrapper<String>(this.listModel);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- private void verifyList(Collection<String> expected, ListValueModel<String> actual) {
- this.verifyList(expected, actual, null);
- }
-
- private void verifyList(Collection<String> expected, ListValueModel<String> actual, Comparator<String> comparator) {
- Collection<String> sortedSet = new TreeSet<String>(comparator);
- sortedSet.addAll(expected);
- List<String> expectedList = new ArrayList<String>(sortedSet);
- List<String> actualList = CollectionTools.list(actual);
- assertEquals(expectedList, actualList);
- }
-
- public void testAdd() {
- this.sortedListModel.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListAddEvent e) {/* OK */}
- @Override
- public void itemsReplaced(ListReplaceEvent e) {/* OK */}
- });
- this.listModel.add("foo");
- this.listModel.add("bar");
- this.listModel.add("baz");
- assertEquals(3, this.sortedListModel.size());
- this.verifyList(this.list, this.sortedListModel);
- }
-
- public void testAddItem() {
- List<String> sortedSynchList = new CoordinatedList<String>(this.sortedListModel);
- List<String> synchList = new CoordinatedList<String>(this.listModel);
- this.listModel.add("foo");
- assertTrue(this.list.contains("foo"));
- this.listModel.add("bar");
- this.listModel.add("baz");
- this.listModel.add("joo");
- this.listModel.add("jar");
- this.listModel.add("jaz");
- assertEquals(6, this.list.size());
-
- this.verifyList(this.list, this.sortedListModel);
- assertEquals(this.list, synchList);
- assertEquals(CollectionTools.list(this.sortedListModel), sortedSynchList);
- }
-
- public void testRemoveItem() {
- List<String> sortedSynchList = new CoordinatedList<String>(this.sortedListModel);
- List<String> synchList = new CoordinatedList<String>(this.listModel);
- this.listModel.add("foo");
- this.listModel.add("bar");
- this.listModel.add("baz");
- this.listModel.add("joo");
- this.listModel.add("jar");
- this.listModel.add("jaz");
- this.listModel.remove("jaz");
- assertFalse(this.list.contains("jaz"));
- this.listModel.remove("foo");
- assertFalse(this.list.contains("foo"));
- assertEquals(4, this.list.size());
-
- this.verifyList(this.list, this.sortedListModel);
- assertEquals(this.list, synchList);
- assertEquals(CollectionTools.list(this.sortedListModel), sortedSynchList);
- }
-
- public void testReplaceItem() {
- List<String> sortedSynchList = new CoordinatedList<String>(this.sortedListModel);
- List<String> synchList = new CoordinatedList<String>(this.listModel);
- this.listModel.add("foo");
- assertTrue(this.list.contains("foo"));
- this.listModel.add("bar");
- this.listModel.add("baz");
- this.listModel.add("joo");
- this.listModel.add("jar");
- this.listModel.add("jaz");
- assertEquals(6, this.list.size());
- this.listModel.set(3, "ttt");
- this.listModel.set(4, "xxx");
- assertTrue(this.list.contains("xxx"));
-
- this.verifyList(this.list, this.sortedListModel);
- assertEquals(this.list, synchList);
- assertEquals(CollectionTools.list(this.sortedListModel), sortedSynchList);
- }
-
- public void testListSynch() {
- this.sortedListModel.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void itemsAdded(ListAddEvent e) {/* OK */}
- @Override
- public void itemsRemoved(ListRemoveEvent e) {/* OK */}
- @Override
- public void itemsReplaced(ListReplaceEvent e) {/* OK */}
- });
- this.listModel.add("foo");
- this.listModel.add("bar");
- this.listModel.add("baz");
- this.listModel.add("joo");
- this.listModel.add("jar");
- this.listModel.add("jaz");
- this.listModel.remove("jaz");
- assertFalse(this.list.contains("jaz"));
- this.listModel.remove("foo");
- assertFalse(this.list.contains("foo"));
- assertEquals(4, this.list.size());
-
- this.verifyList(this.list, this.sortedListModel);
- }
-
- public void testSetComparator() {
- List<String> sortedSynchList = new CoordinatedList<String>(this.sortedListModel);
- List<String> synchList = new CoordinatedList<String>(this.listModel);
- this.listModel.add("foo");
- assertTrue(this.list.contains("foo"));
- this.listModel.add("bar");
- this.listModel.add("baz");
- this.listModel.add("joo");
- this.listModel.add("jar");
- this.listModel.add("jaz");
- assertEquals(6, this.list.size());
-
- this.verifyList(this.list, this.sortedListModel);
- assertEquals(this.list, synchList);
- assertEquals(CollectionTools.list(this.sortedListModel), sortedSynchList);
-
- this.sortedListModel.setComparator(new ReverseComparator<String>());
- this.verifyList(this.list, this.sortedListModel, new ReverseComparator<String>());
- assertEquals(this.list, synchList);
- }
-
- public void testHasListeners() {
- assertFalse(((AbstractModel) this.sortedListModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- CoordinatedList<String> sortedSynchList = new CoordinatedList<String>(this.sortedListModel);
- assertTrue(((AbstractModel) this.sortedListModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.sortedListModel.removeListChangeListener(ListValueModel.LIST_VALUES, sortedSynchList);
- assertFalse(((AbstractModel) this.sortedListModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ChangeListener cl = new ChangeAdapter();
- this.sortedListModel.addChangeListener(cl);
- assertTrue(((AbstractModel) this.sortedListModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.sortedListModel.removeChangeListener(cl);
- assertFalse(((AbstractModel) this.sortedListModel).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- public void testListChange() {
- this.listModel.add("fred");
- this.sortedListModel.addListChangeListener(ListValueModel.LIST_VALUES, new TestListChangeListener() {
- @Override
- public void listChanged(ListChangeEvent e) {/* OK */}
- });
- this.listModel.setListValues(Arrays.asList(new String[] {"foo", "bar", "baz"}));
- assertEquals(3, this.sortedListModel.size());
- this.verifyList(this.list, this.sortedListModel);
- }
-
- class TestListChangeListener implements ListChangeListener {
- public void itemsAdded(ListAddEvent e) {
- fail("unexpected event");
- }
- public void itemsRemoved(ListRemoveEvent e) {
- fail("unexpected event");
- }
- public void itemsReplaced(ListReplaceEvent e) {
- fail("unexpected event");
- }
- public void itemsMoved(ListMoveEvent e) {
- fail("unexpected event");
- }
- public void listCleared(ListClearEvent e) {
- fail("unexpected event");
- }
- public void listChanged(ListChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticCollectionValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticCollectionValueModelTests.java
deleted file mode 100644
index 920f57d506..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticCollectionValueModelTests.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.Collection;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class StaticCollectionValueModelTests extends TestCase {
-
- private static final Collection<String> COLLECTION = buildCollection();
- private static Collection<String> buildCollection() {
- Collection<String> result = new HashBag<String>();
- result.add("foo");
- result.add("bar");
- return result;
- }
-
- private CollectionValueModel<String> collectionHolder;
-
-
- public StaticCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.collectionHolder = this.buildCollectionHolder();
- }
-
- private CollectionValueModel<String> buildCollectionHolder() {
- return new StaticCollectionValueModel<String>(COLLECTION);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- assertEquals(buildCollection(), CollectionTools.bag(this.collectionHolder.iterator()));
- }
-
- public void testSize() {
- assertEquals(buildCollection().size(), this.collectionHolder.size());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticListValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticListValueModelTests.java
deleted file mode 100644
index 620a4ab071..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticListValueModelTests.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.List;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class StaticListValueModelTests extends TestCase {
-
- private static final List<String> LIST = buildList();
- private static List<String> buildList() {
- List<String> result = new ArrayList<String>();
- result.add("foo");
- result.add("bar");
- return result;
- }
-
- private ListValueModel<String> listHolder;
-
-
- public StaticListValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listHolder = new StaticListValueModel<String>(LIST);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGet() {
- List<String> expected = buildList();
- for (int i = 0; i < this.listHolder.size(); i++) {
- assertEquals(expected.get(i), this.listHolder.get(i));
- }
- }
-
- public void testIterator() {
- assertEquals(buildList(), CollectionTools.list(this.listHolder.listIterator()));
- }
-
- public void testSize() {
- assertEquals(buildList().size(), this.listHolder.size());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticValueModelTests.java
deleted file mode 100644
index 535a700f52..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/StaticValueModelTests.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class StaticValueModelTests extends TestCase {
- private PropertyValueModel<String> objectHolder;
- private static final PropertyValueModel<String> OBJECT_HOLDER = new StaticPropertyValueModel<String>("foo");
-
-
- public StaticValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.objectHolder = OBJECT_HOLDER;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- assertEquals("foo", this.objectHolder.getValue());
- }
-
- public void testToString() {
- assertTrue(this.objectHolder.toString().indexOf("foo") >= 0);
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationListValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationListValueModelTests.java
deleted file mode 100644
index 78963bc685..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationListValueModelTests.java
+++ /dev/null
@@ -1,339 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationListValueModel;
-import org.eclipse.jpt.common.utility.model.event.ListAddEvent;
-import org.eclipse.jpt.common.utility.model.event.ListChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.ListClearEvent;
-import org.eclipse.jpt.common.utility.model.event.ListEvent;
-import org.eclipse.jpt.common.utility.model.event.ListMoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class TransformationListValueModelTests extends TestCase {
- private SimpleListValueModel<String> listHolder;
- private ListValueModel<String> transformedListHolder;
- ListEvent event;
- String eventType;
-
- private static final String ADD = "add";
- private static final String REMOVE = "remove";
- private static final String REPLACE = "replace";
- private static final String MOVE = "move";
- private static final String CLEAR = "clear";
- private static final String CHANGE = "change";
-
-
- public TransformationListValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listHolder = new SimpleListValueModel<String>(this.buildList());
- this.transformedListHolder = this.buildTransformedListHolder(this.listHolder);
- }
-
- private List<String> buildList() {
- List<String> result = new ArrayList<String>();
- result.add("foo");
- result.add("bar");
- result.add("baz");
- return result;
- }
-
- private List<String> buildTransformedList() {
- return this.transform(this.buildList());
- }
-
- private List<String> transform(List<String> list) {
- List<String> result = new ArrayList<String>(list.size());
- for (String string : list) {
- if (string == null) {
- result.add(null);
- } else {
- result.add(string.toUpperCase());
- }
- }
- return result;
- }
-
- private List<String> buildAddList() {
- List<String> result = new ArrayList<String>();
- result.add("joo");
- result.add("jar");
- result.add("jaz");
- return result;
- }
-
- private List<String> buildTransformedAddList() {
- return this.transform(this.buildAddList());
- }
-
-// private List<String> buildRemoveList() {
-// List<String> result = new ArrayList<String>();
-// result.add("foo");
-// result.add("bar");
-// return result;
-// }
-//
-// private List<String> buildTransformedRemoveList() {
-// return this.transform(this.buildRemoveList());
-// }
-//
- ListValueModel<String> buildTransformedListHolder(ListValueModel<String> lvm) {
- return new TransformationListValueModel<String, String>(lvm) {
- @Override
- protected String transformItem_(String s) {
- return s.toUpperCase();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testIterator() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- assertEquals(this.buildTransformedList(), CollectionTools.list(this.transformedListHolder.iterator()));
- }
-
- public void testStaleValues() {
- ListChangeListener listener = this.buildListener();
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertEquals(this.buildTransformedList(), CollectionTools.list(this.transformedListHolder.iterator()));
-
- this.transformedListHolder.removeListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertEquals(Collections.EMPTY_LIST, CollectionTools.list(this.transformedListHolder.iterator()));
- }
-
- public void testSize() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- assertEquals(this.buildTransformedList().size(), CollectionTools.size(this.transformedListHolder.iterator()));
- }
-
- private boolean transformedListContains(Object item) {
- return CollectionTools.contains(this.transformedListHolder.iterator(), item);
- }
-
- private boolean transformedListContainsAll(Collection<String> items) {
- return CollectionTools.containsAll(this.transformedListHolder.iterator(), items);
- }
-
- private boolean transformedListContainsAny(Collection<String> items) {
- List<String> transformedList = CollectionTools.list(this.transformedListHolder.iterator());
- for (Iterator<String> stream = items.iterator(); stream.hasNext(); ) {
- if (transformedList.contains(stream.next())) {
- return true;
- }
- }
- return false;
- }
-
- public void testAdd() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertFalse(this.transformedListContains("JOO"));
- this.listHolder.add(2, "joo");
- assertTrue(this.transformedListContains("JOO"));
-
- assertFalse(this.transformedListContains(null));
- this.listHolder.add(0, null);
- assertTrue(this.transformedListContains(null));
- }
-
- public void testAddAll() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertFalse(this.transformedListContainsAny(this.buildTransformedAddList()));
- this.listHolder.addAll(2, this.buildAddList());
- assertTrue(this.transformedListContainsAll(this.buildTransformedAddList()));
- }
-
- public void testRemove() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
-
- assertTrue(this.transformedListContains("BAR"));
- this.listHolder.remove(this.buildList().indexOf("bar"));
- assertFalse(this.transformedListContains("BAR"));
-
- this.listHolder.add(1, null);
- assertTrue(this.transformedListContains(null));
- this.listHolder.remove(1);
- assertFalse(this.transformedListContains(null));
- }
-
- public void testListChangeGeneric() {
- this.transformedListHolder.addChangeListener(this.buildListener());
- this.verifyListChange();
- }
-
- public void testListChangeNamed() {
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.buildListener());
- this.verifyListChange();
- }
-
- private void verifyListChange() {
- this.event = null;
- this.eventType = null;
- this.listHolder.add(1, "joo");
- this.verifyEvent(ADD, 1, "JOO");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.add(1, null);
- this.verifyEvent(ADD, 1, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(1);
- this.verifyEvent(REMOVE, 1, null);
-
- this.event = null;
- this.eventType = null;
- this.listHolder.remove(1);
- this.verifyEvent(REMOVE, 1, "JOO");
-
- this.event = null;
- this.eventType = null;
- this.listHolder.addAll(0, this.buildList());
- this.verifyEvent(ADD);
- assertEquals(this.buildTransformedList(), CollectionTools.list(((ListAddEvent) this.event).getItems()));
-
- this.event = null;
- this.eventType = null;
- this.listHolder.set(0, "joo");
- this.verifyEvent(REPLACE);
- assertFalse(CollectionTools.contains(((ListReplaceEvent) this.event).getNewItems(), "FOO"));
- assertTrue(CollectionTools.contains(((ListReplaceEvent) this.event).getNewItems(), "JOO"));
- }
-
- private ChangeListener buildListener() {
- return new ChangeAdapter() {
- @Override
- public void itemsAdded(ListAddEvent e) {
- TransformationListValueModelTests.this.eventType = ADD;
- TransformationListValueModelTests.this.event = e;
- }
- @Override
- public void itemsRemoved(ListRemoveEvent e) {
- TransformationListValueModelTests.this.eventType = REMOVE;
- TransformationListValueModelTests.this.event = e;
- }
- @Override
- public void itemsReplaced(ListReplaceEvent e) {
- TransformationListValueModelTests.this.eventType = REPLACE;
- TransformationListValueModelTests.this.event = e;
- }
- @Override
- public void itemsMoved(ListMoveEvent e) {
- TransformationListValueModelTests.this.eventType = MOVE;
- TransformationListValueModelTests.this.event = e;
- }
- @Override
- public void listCleared(ListClearEvent e) {
- TransformationListValueModelTests.this.eventType = CLEAR;
- TransformationListValueModelTests.this.event = e;
- }
- @Override
- public void listChanged(ListChangeEvent e) {
- TransformationListValueModelTests.this.eventType = CHANGE;
- TransformationListValueModelTests.this.event = e;
- }
- };
- }
-
- private void verifyEvent(String type) {
- assertEquals(type, this.eventType);
- assertEquals(this.transformedListHolder, this.event.getSource());
- assertEquals(ListValueModel.LIST_VALUES, this.event.getListName());
- }
-
- private void verifyEvent(String type, int index, Object item) {
- this.verifyEvent(type);
- if (type == ADD) {
- assertEquals(index, ((ListAddEvent) this.event).getIndex());
- assertEquals(item, ((ListAddEvent) this.event).getItems().iterator().next());
- } else if (type == REMOVE) {
- assertEquals(index, ((ListRemoveEvent) this.event).getIndex());
- assertEquals(item, ((ListRemoveEvent) this.event).getItems().iterator().next());
- }
- }
-
- public void testHasListeners() {
- /*
- * adding listeners to the transformed list will cause listeners
- * to be added to the wrapped list;
- * likewise, removing listeners from the transformed list will
- * cause listeners to be removed from the wrapped list
- */
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ChangeListener listener = this.buildListener();
-
- this.transformedListHolder.addListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertTrue(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.transformedListHolder.removeListChangeListener(ListValueModel.LIST_VALUES, listener);
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.transformedListHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- this.transformedListHolder.removeChangeListener(listener);
- assertFalse(((AbstractModel) this.listHolder).hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
-
- /**
- * execute the same set of tests again, but by passing a Transformer to the adapter
- * (as opposed to overriding #transformItem(Object))
- */
- public static class TransformerTests extends TransformationListValueModelTests {
- public TransformerTests(String name) {
- super(name);
- }
- @Override
- ListValueModel<String> buildTransformedListHolder(ListValueModel<String> lvm) {
- return new TransformationListValueModel<String, String>(lvm, this.buildTransformer());
- }
- private Transformer<String, String> buildTransformer() {
- return new Transformer<String, String>() {
- public String transform(String s) {
- return (s == null) ? null : s.toUpperCase();
- }
- };
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java
deleted file mode 100644
index 4c72608454..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/TransformationPropertyValueModelTests.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationWritablePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class TransformationPropertyValueModelTests
- extends TestCase
-{
- private ModifiablePropertyValueModel<String> objectHolder;
- PropertyChangeEvent event;
-
- private ModifiablePropertyValueModel<String> transformationObjectHolder;
- PropertyChangeEvent transformationEvent;
-
- public TransformationPropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.objectHolder = new SimplePropertyValueModel<String>("foo");
- this.transformationObjectHolder = new TransformationWritablePropertyValueModel<String, String>(this.objectHolder, this.buildTransformer(), this.buildReverseTransformer());
- }
-
- private Transformer<String, String> buildTransformer() {
- return new Transformer<String, String>() {
- public String transform(String s) {
- return (s == null) ? null : s.toUpperCase();
- }
- };
- }
-
- private Transformer<String, String> buildReverseTransformer() {
- return new Transformer<String, String>() {
- public String transform(String s) {
- return (s == null) ? null : s.toLowerCase();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testValue() {
- assertEquals("foo", this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
- ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
- assertEquals("FOO", this.transformationObjectHolder.getValue());
-
- this.objectHolder.setValue("bar");
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("BAR", this.transformationObjectHolder.getValue());
-
- this.objectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- assertEquals("BAZ", this.transformationObjectHolder.getValue());
-
- this.objectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
-
- this.objectHolder.setValue("foo");
- assertEquals("foo", this.objectHolder.getValue());
- assertEquals("FOO", this.transformationObjectHolder.getValue());
- }
-
- public void testSetValue() {
- this.transformationObjectHolder.setValue("BAR");
- assertEquals("bar", this.objectHolder.getValue());
- assertEquals("BAR", this.transformationObjectHolder.getValue());
-
- // NB: odd behavior(!)
- this.transformationObjectHolder.setValue("Foo");
- assertEquals("foo", this.objectHolder.getValue());
- assertEquals("Foo", this.transformationObjectHolder.getValue());
- ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
- assertEquals("FOO", this.transformationObjectHolder.getValue());
- this.transformationObjectHolder.removeChangeListener(listener);
-
- this.transformationObjectHolder.setValue(null);
- assertNull(this.objectHolder.getValue());
- assertNull(this.transformationObjectHolder.getValue());
-
- // NB: odd behavior(!)
- this.transformationObjectHolder.setValue("baz");
- assertEquals("baz", this.objectHolder.getValue());
- assertEquals("baz", this.transformationObjectHolder.getValue());
- this.transformationObjectHolder.addChangeListener(listener);
- assertEquals("BAZ", this.transformationObjectHolder.getValue());
- this.transformationObjectHolder.removeChangeListener(listener);
- }
-
- public void testLazyListening() {
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- ChangeListener listener = this.buildTransformationListener();
- this.transformationObjectHolder.addChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removeChangeListener(listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.transformationObjectHolder.removePropertyChangeListener(PropertyValueModel.VALUE, listener);
- assertTrue(((AbstractModel) this.objectHolder).hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testPropertyChange1() {
- this.objectHolder.addChangeListener(this.buildListener());
- this.transformationObjectHolder.addChangeListener(this.buildTransformationListener());
- this.verifyPropertyChanges();
- }
-
- public void testPropertyChange2() {
- this.objectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildListener());
- this.transformationObjectHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.buildTransformationListener());
- this.verifyPropertyChanges();
- }
-
- private void verifyPropertyChanges() {
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent(this.event, this.objectHolder, "foo", "bar");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "FOO", "BAR");
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("baz");
- this.verifyEvent(this.event, this.objectHolder, "bar", "baz");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "BAR", "BAZ");
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("Foo");
- this.verifyEvent(this.event, this.objectHolder, "baz", "Foo");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "BAZ", "FOO");
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("FOO");
- this.verifyEvent(this.event, this.objectHolder, "Foo", "FOO");
- assertNull(this.transformationEvent);
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue(null);
- this.verifyEvent(this.event, this.objectHolder, "FOO", null);
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, "FOO", null);
-
- this.event = null;
- this.transformationEvent = null;
- this.objectHolder.setValue("bar");
- this.verifyEvent(this.event, this.objectHolder, null, "bar");
- this.verifyEvent(this.transformationEvent, this.transformationObjectHolder, null, "BAR");
- }
-
- private ChangeListener buildListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- TransformationPropertyValueModelTests.this.event = e;
- }
- };
- }
-
- private ChangeListener buildTransformationListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- TransformationPropertyValueModelTests.this.transformationEvent = e;
- }
- };
- }
-
- private void verifyEvent(PropertyChangeEvent e, Object source, Object oldValue, Object newValue) {
- assertEquals(source, e.getSource());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- assertEquals(oldValue, e.getOldValue());
- assertEquals(newValue, e.getNewValue());
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueCollectionAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueCollectionAdapterTests.java
deleted file mode 100644
index 316c2c4812..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueCollectionAdapterTests.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ValueCollectionAdapter;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ValueCollectionAdapterTests extends TestCase {
- private Junk junk;
- private SimplePropertyValueModel<Junk> junkHolder;
- private ValueCollectionAdapter<Junk> junkHolder2;
-
-
- public ValueCollectionAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.junk = new Junk("foo");
- this.junkHolder = new SimplePropertyValueModel<Junk>(this.junk);
- this.junkHolder2 = new ValueCollectionAdapter<Junk>(this.junkHolder, Junk.STUFF_COLLECTION);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testWrappedPVM() {
- Junk junk2 = new Junk("bar");
- LocalListener l = new LocalListener(this.junkHolder2, this.junk, junk2);
- this.junkHolder2.addChangeListener(l);
- this.junkHolder.setValue(junk2);
- assertTrue(l.eventReceived());
- }
-
- public void testHasPropertyChangeListeners() throws Exception {
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addChangeListener(l);
- assertTrue(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.junkHolder2.removeChangeListener(l);
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testHasStateChangeListeners() throws Exception {
- assertFalse(this.junk.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- assertTrue(this.junk.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertTrue(this.junkHolder2.hasAnyStateChangeListeners());
-
- this.junkHolder2.removeStateChangeListener(l);
- assertFalse(this.junk.hasAnyCollectionChangeListeners(Junk.STUFF_COLLECTION));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
- }
-
- public void testCollectionAdd() {
- LocalListener l = new LocalListener(this.junkHolder2);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.addStuff("bar");
- assertTrue(l.eventReceived());
- }
-
- public void testCollectionRemove() {
- LocalListener l = new LocalListener(this.junkHolder2);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.removeStuff("foo");
- assertTrue(l.eventReceived());
- }
-
-
- class LocalListener extends ChangeAdapter {
- private boolean eventReceived = false;
- private final Object source;
- private final Object oldValue;
- private final Object newValue;
- LocalListener(Object source) {
- this(source, null, null);
- }
- LocalListener(Object source, Object oldValue, Object newValue) {
- super();
- this.source = source;
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- }
- @Override
- public void stateChanged(StateChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- }
- boolean eventReceived() {
- return this.eventReceived;
- }
- }
-
-
- private class Junk extends AbstractModel {
- private Collection<String> stuff;
- public static final String STUFF_COLLECTION = "stuff";
-
- public Junk(String stuffItem) {
- this.stuff = new ArrayList<String>();
- this.stuff.add(stuffItem);
- }
-
- public void addStuff(String stuffItem) {
- this.addItemToCollection(stuffItem, this.stuff, STUFF_COLLECTION);
- }
-
- public void removeStuff(String stuffItem) {
- this.removeItemFromCollection(stuffItem, this.stuff, STUFF_COLLECTION);
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.stuff + ")";
- }
-
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueListAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueListAdapterTests.java
deleted file mode 100644
index 4a447a431c..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueListAdapterTests.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ValueListAdapter;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ValueListAdapterTests extends TestCase {
- private Junk junk;
- private SimplePropertyValueModel<Junk> junkHolder;
- private ValueListAdapter<Junk> junkHolder2;
-
-
- public ValueListAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.junk = new Junk("foo");
- this.junkHolder = new SimplePropertyValueModel<Junk>(this.junk);
- this.junkHolder2 = new ValueListAdapter<Junk>(this.junkHolder, Junk.STUFF_LIST);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testWrappedPVM() {
- Junk junk2 = new Junk("bar");
- LocalListener l = new LocalListener(this.junkHolder2, this.junk, junk2);
- this.junkHolder2.addChangeListener(l);
- this.junkHolder.setValue(junk2);
- assertTrue(l.eventReceived());
- }
-
- public void testHasPropertyChangeListeners() throws Exception {
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addChangeListener(l);
- assertTrue(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.junkHolder2.removeChangeListener(l);
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testHasStateChangeListeners() throws Exception {
- assertFalse(this.junk.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- assertTrue(this.junk.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertTrue(this.junkHolder2.hasAnyStateChangeListeners());
-
- this.junkHolder2.removeStateChangeListener(l);
- assertFalse(this.junk.hasAnyListChangeListeners(Junk.STUFF_LIST));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
- }
-
- public void testListAdd() {
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.addStuff("bar");
- assertTrue(l.eventReceived());
- }
-
- public void testListRemove() {
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.removeStuff("foo");
- assertTrue(l.eventReceived());
- }
-
- public void testListReplace() {
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.replaceStuff("foo", "bar");
- assertTrue(l.eventReceived());
- }
-
-
- class LocalListener extends ChangeAdapter {
- private boolean eventReceived = false;
- private final Object source;
- private final Object oldValue;
- private final Object newValue;
- LocalListener(Object source) {
- this(source, null, null);
- }
- LocalListener(Object source, Object oldValue, Object newValue) {
- super();
- this.source = source;
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- }
- @Override
- public void stateChanged(StateChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- }
- boolean eventReceived() {
- return this.eventReceived;
- }
- }
-
- private class Junk extends AbstractModel {
- private List<String> stuff;
- public static final String STUFF_LIST = "stuff";
-
- public Junk(String stuffItem) {
- this.stuff = new ArrayList<String>();
- this.stuff.add(stuffItem);
- }
-
- public void addStuff(String stuffItem) {
- this.addItemToList(stuffItem, this.stuff, STUFF_LIST);
- }
-
- public void removeStuff(String stuffItem) {
- this.removeItemFromList(stuffItem, this.stuff, STUFF_LIST);
- }
-
- public void replaceStuff(String oldStuffItem, String newStuffItem) {
- this.replaceItemInList(oldStuffItem, newStuffItem, this.stuff, STUFF_LIST);
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.stuff + ")";
- }
-
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValuePropertyAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValuePropertyAdapterTests.java
deleted file mode 100644
index c3f5be6675..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValuePropertyAdapterTests.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ValuePropertyAdapter;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ValuePropertyAdapterTests extends TestCase {
- private Junk junk;
- private SimplePropertyValueModel<Junk> junkHolder;
- private ValuePropertyAdapter<Junk> junkHolder2;
-
-
- public ValuePropertyAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.junk = new Junk("foo");
- this.junkHolder = new SimplePropertyValueModel<Junk>(this.junk);
- this.junkHolder2 = new ValuePropertyAdapter<Junk>(this.junkHolder, Junk.NAME_PROPERTY);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testWrappedPVM() {
- Junk junk2 = new Junk("bar");
- LocalListener l = new LocalListener(this.junkHolder2, this.junk, junk2);
- this.junkHolder2.addChangeListener(l);
- this.junkHolder.setValue(junk2);
- assertTrue(l.eventReceived());
- }
-
- public void testHasPropertyChangeListeners() throws Exception {
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addChangeListener(l);
- assertTrue(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.junkHolder2.removeChangeListener(l);
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testHasStateChangeListeners() throws Exception {
- assertFalse(this.junk.hasAnyPropertyChangeListeners(Junk.NAME_PROPERTY));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- assertTrue(this.junk.hasAnyPropertyChangeListeners(Junk.NAME_PROPERTY));
- assertTrue(this.junkHolder2.hasAnyStateChangeListeners());
-
- this.junkHolder2.removeStateChangeListener(l);
- assertFalse(this.junk.hasAnyPropertyChangeListeners(Junk.NAME_PROPERTY));
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
- }
-
- public void testChangeProperty() {
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.setName("bar");
- assertTrue(l.eventReceived());
- }
-
-
- class LocalListener extends ChangeAdapter {
- private boolean eventReceived = false;
- private final Object source;
- private final Object oldValue;
- private final Object newValue;
- LocalListener(Object source) {
- this(source, null, null);
- }
- LocalListener(Object source, Object oldValue, Object newValue) {
- super();
- this.source = source;
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- }
- @Override
- public void stateChanged(StateChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- }
- boolean eventReceived() {
- return this.eventReceived;
- }
- }
-
- class Junk extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- public Junk(String name) {
- this.name = name;
- }
-
- public void setName(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.name + ")";
- }
-
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueStateAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueStateAdapterTests.java
deleted file mode 100644
index d23581257a..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/ValueStateAdapterTests.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ValueStateAdapter;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ValueStateAdapterTests extends TestCase {
- private Junk junk;
- private SimplePropertyValueModel<Junk> junkHolder;
- private ValueStateAdapter<Junk> junkHolder2;
-
-
- public ValueStateAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.junk = new Junk("foo");
- this.junkHolder = new SimplePropertyValueModel<Junk>(this.junk);
- this.junkHolder2 = new ValueStateAdapter<Junk>(this.junkHolder);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testWrappedPVM() {
- Junk junk2 = new Junk("bar");
- LocalListener l = new LocalListener(this.junkHolder2, this.junk, junk2);
- this.junkHolder2.addChangeListener(l);
- this.junkHolder.setValue(junk2);
- assertTrue(l.eventReceived());
- }
-
- public void testHasPropertyChangeListeners() throws Exception {
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addChangeListener(l);
- assertTrue(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- this.junkHolder2.removeChangeListener(l);
- assertFalse(this.junkHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertFalse(this.junkHolder2.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- public void testHasStateChangeListeners() throws Exception {
- assertFalse(this.junk.hasAnyStateChangeListeners());
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
-
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addStateChangeListener(l);
- assertTrue(this.junk.hasAnyStateChangeListeners());
- assertTrue(this.junkHolder2.hasAnyStateChangeListeners());
-
- this.junkHolder2.removeStateChangeListener(l);
- assertFalse(this.junk.hasAnyStateChangeListeners());
- assertFalse(this.junkHolder2.hasAnyStateChangeListeners());
- }
-
- public void testChangeState() {
- LocalListener l = new LocalListener(this.junkHolder2, null, this.junk);
- this.junkHolder2.addChangeListener(l);
- this.junkHolder2.addStateChangeListener(l);
- this.junk.setName("bar");
- assertTrue(l.eventReceived());
- }
-
-
- class LocalListener extends ChangeAdapter {
- private boolean eventReceived = false;
- private final Object source;
- private final Object oldValue;
- private final Object newValue;
- LocalListener(Object source) {
- this(source, null, null);
- }
- LocalListener(Object source, Object oldValue, Object newValue) {
- super();
- this.source = source;
- this.oldValue = oldValue;
- this.newValue = newValue;
- }
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- assertEquals(this.oldValue, e.getOldValue());
- assertEquals(this.newValue, e.getNewValue());
- assertEquals(PropertyValueModel.VALUE, e.getPropertyName());
- }
- @Override
- public void stateChanged(StateChangeEvent e) {
- this.eventReceived = true;
- assertEquals(this.source, e.getSource());
- }
- boolean eventReceived() {
- return this.eventReceived;
- }
- }
-
- class Junk extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- public Junk(String name) {
- this.name = name;
- }
-
- public void setName(String name) {
- this.name = name;
- this.fireStateChanged();
- }
-
- @Override
- public String toString() {
- return "Junk(" + this.name + ")";
- }
-
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/JptUtilityModelValuePrefsTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/JptUtilityModelValuePrefsTests.java
deleted file mode 100644
index ad966a9607..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/JptUtilityModelValuePrefsTests.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.prefs;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptUtilityModelValuePrefsTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityModelValuePrefsTests.class.getPackage().getName());
-
- suite.addTestSuite(PreferencesCollectionValueModelTests.class);
- suite.addTestSuite(PreferencePropertyValueModelTests.class);
-
- return suite;
- }
-
- private JptUtilityModelValuePrefsTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
deleted file mode 100644
index d332feda79..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.prefs;
-
-import java.util.prefs.NodeChangeEvent;
-import java.util.prefs.NodeChangeListener;
-import java.util.prefs.PreferenceChangeEvent;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.Preferences;
-
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.prefs.PreferencePropertyValueModel;
-import org.eclipse.jpt.common.utility.model.Model;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-@SuppressWarnings("nls")
-public class PreferencePropertyValueModelTests extends PreferencesTestCase {
- private ModifiablePropertyValueModel<Preferences> nodeHolder;
- PreferencePropertyValueModel<String> preferenceAdapter;
- PropertyChangeEvent event;
- PropertyChangeListener listener;
- boolean listenerRemoved = false;
- PreferenceChangeEvent preferenceEvent;
- private static final String KEY_NAME = "foo";
- private static final String STRING_VALUE = "original string value";
-
- public PreferencePropertyValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.testNode.put(KEY_NAME, STRING_VALUE);
-
- this.nodeHolder = new SimplePropertyValueModel<Preferences>(this.testNode);
- this.preferenceAdapter = new PreferencePropertyValueModel<String>(this.nodeHolder, KEY_NAME);
- this.listener = this.buildValueChangeListener();
- this.preferenceAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- this.event = null;
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- private PropertyChangeListener buildValueChangeListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- if (PreferencePropertyValueModelTests.this.event != null) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- PreferencePropertyValueModelTests.this.event = e;
- }
- };
- }
-
- public void testSubjectHolder() throws Exception {
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- assertNull(this.event);
-
- String ANOTHER_STRING_VALUE = "some other value";
- Preferences anotherNode = this.classNode.node("another test node");
- anotherNode.put(KEY_NAME, ANOTHER_STRING_VALUE);
-
- this.nodeHolder.setValue(anotherNode);
- this.verifyEvent(STRING_VALUE, ANOTHER_STRING_VALUE);
- assertEquals(ANOTHER_STRING_VALUE, this.preferenceAdapter.getValue());
-
- this.event = null;
- this.nodeHolder.setValue(null);
- this.verifyEvent(ANOTHER_STRING_VALUE, null);
- assertNull(this.preferenceAdapter.getValue());
-
- this.event = null;
- this.nodeHolder.setValue(this.testNode);
- this.verifyEvent(null, STRING_VALUE);
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testPreferenceChange() throws Exception {
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- assertNull(this.event);
-
- this.testNode.put(KEY_NAME, STRING_VALUE + STRING_VALUE);
- this.waitForEventQueueToClear();
- this.verifyEvent(STRING_VALUE, STRING_VALUE + STRING_VALUE);
- assertEquals(STRING_VALUE + STRING_VALUE, this.preferenceAdapter.getValue());
-
- this.event = null;
- this.testNode.remove(KEY_NAME);
- this.waitForEventQueueToClear();
- this.verifyEvent(STRING_VALUE + STRING_VALUE, null);
- assertNull(this.preferenceAdapter.getValue());
-
- this.event = null;
- this.testNode.put(KEY_NAME, STRING_VALUE);
- this.waitForEventQueueToClear();
- this.verifyEvent(null, STRING_VALUE);
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testValue() throws Exception {
- assertEquals(STRING_VALUE, this.testNode.get(KEY_NAME, "<missing preference>"));
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testSetValue() throws Exception {
- String ANOTHER_STRING_VALUE = "some other value";
- this.preferenceAdapter.setValue(ANOTHER_STRING_VALUE);
- assertEquals(ANOTHER_STRING_VALUE, this.preferenceAdapter.getValue());
- assertEquals(ANOTHER_STRING_VALUE, this.testNode.get(KEY_NAME, "<missing preference>"));
- }
-
- public void testHasListeners() throws Exception {
- assertTrue(this.preferenceAdapter.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.nodeHasAnyPrefListeners(this.testNode));
- this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- assertFalse(this.nodeHasAnyPrefListeners(this.testNode));
- assertFalse(this.preferenceAdapter.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- ChangeListener listener2 = this.buildChangeListener();
- this.preferenceAdapter.addChangeListener(listener2);
- assertTrue(this.preferenceAdapter.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- assertTrue(this.nodeHasAnyPrefListeners(this.testNode));
- this.preferenceAdapter.removeChangeListener(listener2);
- assertFalse(this.nodeHasAnyPrefListeners(this.testNode));
- assertFalse(this.preferenceAdapter.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- private ChangeListener buildChangeListener() {
- return new ChangeAdapter() {
- @Override
- public void propertyChanged(PropertyChangeEvent e) {
- if (PreferencePropertyValueModelTests.this.event != null) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- PreferencePropertyValueModelTests.this.event = e;
- }
- };
- }
-
- public void testRemoveAndReAddPreference() throws Exception {
- assertEquals(STRING_VALUE, this.testNode.get(KEY_NAME, null));
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- assertNull(this.event);
-
- // remove the preference entirely...
- this.testNode.remove(KEY_NAME);
- this.waitForEventQueueToClear();
- assertNull(this.testNode.get(KEY_NAME, null));
- this.verifyEvent(STRING_VALUE, null);
- assertNull(this.preferenceAdapter.getValue());
-
- // ...then re-add it with the same key
- this.event = null;
- this.testNode.put(KEY_NAME, STRING_VALUE);
- this.waitForEventQueueToClear();
- assertEquals(STRING_VALUE, this.testNode.get(KEY_NAME, null));
- this.verifyEvent(null, STRING_VALUE);
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testDefaultValue() throws Exception {
- // rebuild the adapter with a default value
- String DEFAULT_VALUE = "default value";
- this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- this.preferenceAdapter = new PreferencePropertyValueModel<String>(this.nodeHolder, KEY_NAME, DEFAULT_VALUE);
- this.preferenceAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener);
-
- assertEquals(STRING_VALUE, this.testNode.get(KEY_NAME, null));
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- assertNull(this.event);
-
- // remove the preference entirely...
- this.testNode.remove(KEY_NAME);
- this.waitForEventQueueToClear();
- assertNull(this.testNode.get(KEY_NAME, null));
- this.verifyEvent(STRING_VALUE, DEFAULT_VALUE);
- assertEquals(DEFAULT_VALUE, this.preferenceAdapter.getValue());
-
- // ...then re-add it with the same key
- this.event = null;
- this.testNode.put(KEY_NAME, STRING_VALUE);
- this.waitForEventQueueToClear();
- assertEquals(STRING_VALUE, this.testNode.get(KEY_NAME, null));
- this.verifyEvent(DEFAULT_VALUE, STRING_VALUE);
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testUnsynchronizedValue() throws Exception {
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- assertNull(this.event);
-
- // remove the this.listener so the adapter no longer listens to the preference
- this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
-
- this.testNode.put(KEY_NAME, STRING_VALUE + STRING_VALUE);
- this.waitForEventQueueToClear();
- // no this.event should have been fired...
- assertNull(this.event);
- // ...and the adapter's value should be null
- assertNull(this.preferenceAdapter.getValue());
-
- this.testNode.remove(KEY_NAME);
- this.waitForEventQueueToClear();
- assertNull(this.event);
- assertNull(this.preferenceAdapter.getValue());
-
- this.testNode.put(KEY_NAME, STRING_VALUE);
- this.waitForEventQueueToClear();
- assertNull(this.event);
- assertNull(this.preferenceAdapter.getValue());
-
- // add the this.listener so the adapter synchs
- this.preferenceAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- assertEquals(STRING_VALUE, this.preferenceAdapter.getValue());
- }
-
- public void testIntegerPreference() throws Exception {
- // stop listening to the node and convert it to an integer
- this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
-
- PreferencePropertyValueModel<Integer> integerPreferenceAdapter = new PreferencePropertyValueModel<Integer>(this.nodeHolder, KEY_NAME);
- this.testNode.putInt(KEY_NAME, 123);
- integerPreferenceAdapter = PreferencePropertyValueModel.forInteger(this.testNode, KEY_NAME, 0);
- integerPreferenceAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- assertEquals(new Integer(123), integerPreferenceAdapter.getValue());
- assertNull(this.event);
-
- this.testNode.putInt(KEY_NAME, 246);
- this.waitForEventQueueToClear();
- this.verifyEvent(integerPreferenceAdapter, new Integer(123), new Integer(246));
- assertEquals(new Integer(246), integerPreferenceAdapter.getValue());
-
- this.event = null;
- this.testNode.remove(KEY_NAME);
- this.waitForEventQueueToClear();
- this.verifyEvent(integerPreferenceAdapter, new Integer(246), new Integer(0));
- assertEquals(new Integer(0), integerPreferenceAdapter.getValue());
-
- this.event = null;
- this.testNode.putInt(KEY_NAME, 123);
- this.waitForEventQueueToClear();
- this.verifyEvent(integerPreferenceAdapter, new Integer(0), new Integer(123));
- assertEquals(new Integer(123), integerPreferenceAdapter.getValue());
- }
-
- /**
- * test a situation where
- * - we are listening to the node when it gets removed from the preferences "repository"
- * - we get notification that it has been removed
- * - we try to remove our this.listener
- * - the node will throw an IllegalStateException - the adapter should handle it OK...
- */
- public void testRemoveNode() throws Exception {
- assertTrue(this.preferenceAdapter.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- Preferences parent = this.testNode.parent();
- parent.addNodeChangeListener(this.buildParentNodeChangeListener());
- this.testNode.removeNode();
- this.testNode.flush(); // this seems to be required for the this.event to trigger...
- this.waitForEventQueueToClear();
-
- assertTrue(this.listenerRemoved);
- assertTrue(this.preferenceAdapter.hasNoPropertyChangeListeners(PropertyValueModel.VALUE));
- }
-
- private NodeChangeListener buildParentNodeChangeListener() {
- return new NodeChangeListener() {
- public void childAdded(NodeChangeEvent e) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- public void childRemoved(NodeChangeEvent e) {
- if (e.getChild() == PreferencePropertyValueModelTests.this.testNode) {
- PreferencePropertyValueModelTests.this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, PreferencePropertyValueModelTests.this.listener);
- // this line of code will not execute if the line above triggers an exception
- PreferencePropertyValueModelTests.this.listenerRemoved = true;
- }
- }
- };
- }
-
- public void testSetSameValue() {
- assertNull(this.event);
- assertNull(this.preferenceEvent);
- this.testNode.addPreferenceChangeListener(this.buildPreferenceChangeListener());
-
- String ANOTHER_STRING_VALUE = "some other value";
- this.preferenceAdapter.setValue(ANOTHER_STRING_VALUE);
-
- this.verifyEvent(STRING_VALUE, ANOTHER_STRING_VALUE);
- this.waitForEventQueueToClear();
- this.verifyPreferenceEvent(ANOTHER_STRING_VALUE);
-
- // now set to *same* value - nothing should happen...
- this.event = null;
- this.preferenceEvent = null;
- this.preferenceAdapter.setValue(ANOTHER_STRING_VALUE);
-
- assertNull(this.event);
- assertNull(this.preferenceEvent);
- }
-
- public void testSetSameValueForcePassThrough() throws Exception {
- assertNull(this.event);
- assertNull(this.preferenceEvent);
-
- this.preferenceAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.listener);
- this.preferenceAdapter = new AlwaysUpdatePreferencePropertyValueModel<String>(this.nodeHolder, KEY_NAME);
- this.preferenceAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.listener);
-
- this.testNode.addPreferenceChangeListener(this.buildPreferenceChangeListener());
-
- String ANOTHER_STRING_VALUE = "some other value";
- this.preferenceAdapter.setValue(ANOTHER_STRING_VALUE);
-
- this.verifyEvent(STRING_VALUE, ANOTHER_STRING_VALUE);
- this.waitForEventQueueToClear();
- this.verifyPreferenceEvent(ANOTHER_STRING_VALUE);
-
- // now set to *same* value - only one this.event should fire
- this.event = null;
- this.preferenceEvent = null;
- this.preferenceAdapter.setValue(ANOTHER_STRING_VALUE);
-
- assertNull(this.event);
- this.waitForEventQueueToClear();
- this.verifyPreferenceEvent(ANOTHER_STRING_VALUE);
- assertNull(this.event);
- }
-
- private PreferenceChangeListener buildPreferenceChangeListener() {
- return new PreferenceChangeListener() {
- public void preferenceChange(PreferenceChangeEvent evt) {
- PreferencePropertyValueModelTests.this.preferenceEvent = evt;
- }
- };
- }
-
- private void verifyEvent(Model source, Object oldValue, Object newValue) {
- assertNotNull(this.event);
- assertEquals(source, this.event.getSource());
- assertEquals(PropertyValueModel.VALUE, this.event.getPropertyName());
- assertEquals(oldValue, this.event.getOldValue());
- assertEquals(newValue, this.event.getNewValue());
- }
-
- private void verifyEvent(Object oldValue, Object newValue) {
- this.verifyEvent(this.preferenceAdapter, oldValue, newValue);
- }
-
- private void verifyPreferenceEvent(Object newValue) {
- assertNotNull(this.preferenceEvent);
- assertEquals(this.testNode, this.preferenceEvent.getSource());
- assertEquals(KEY_NAME, this.preferenceEvent.getKey());
- assertEquals(newValue, this.preferenceEvent.getNewValue());
- assertEquals(newValue, this.testNode.get(KEY_NAME, "<missing preference>"));
- }
-
- private boolean nodeHasAnyPrefListeners(Preferences node) throws Exception {
- PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ReflectionTools.getFieldValue(node, "prefListeners");
- return prefListeners.length > 0;
- }
-
-
- /**
- * Use this adapter to test out always passing through the new value
- * to the preference.
- */
- private class AlwaysUpdatePreferencePropertyValueModel<P> extends PreferencePropertyValueModel<P> {
-
- AlwaysUpdatePreferencePropertyValueModel(PropertyValueModel<Preferences> preferencesHolder, String key) {
- super(preferencesHolder, key);
- }
-
- @Override
- protected boolean preferenceIsToBeSet(Object oldValue, Object newValue) {
- return true;
- }
-
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
deleted file mode 100644
index fe5349da73..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.prefs;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.prefs.NodeChangeEvent;
-import java.util.prefs.NodeChangeListener;
-import java.util.prefs.PreferenceChangeListener;
-import java.util.prefs.Preferences;
-
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.prefs.PreferencePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.prefs.PreferencesCollectionValueModel;
-import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionClearEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionEvent;
-import org.eclipse.jpt.common.utility.model.event.CollectionRemoveEvent;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ChangeAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-@SuppressWarnings("nls")
-public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
- private Map<String, String> expectedValues;
- private ModifiablePropertyValueModel<Preferences> nodeHolder;
- PreferencesCollectionValueModel<String> preferencesAdapter;
- CollectionEvent event;
- CollectionChangeListener listener;
- private PropertyChangeListener itemListener;
- boolean listenerRemoved = false;
- private static final String KEY_NAME_1 = "foo 1";
- private static final String KEY_NAME_2 = "foo 2";
- private static final String KEY_NAME_3 = "foo 3";
- private static final String STRING_VALUE_1 = "original string value 1";
- private static final String STRING_VALUE_2 = "original string value 2";
- private static final String STRING_VALUE_3 = "original string value 3";
-
- public PreferencesCollectionValueModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.expectedValues = new HashMap<String, String>();
- this.testNode.put(KEY_NAME_1, STRING_VALUE_1); this.expectedValues.put(KEY_NAME_1, STRING_VALUE_1);
- this.testNode.put(KEY_NAME_2, STRING_VALUE_2); this.expectedValues.put(KEY_NAME_2, STRING_VALUE_2);
- this.testNode.put(KEY_NAME_3, STRING_VALUE_3); this.expectedValues.put(KEY_NAME_3, STRING_VALUE_3);
-
- this.nodeHolder = new SimplePropertyValueModel<Preferences>(this.testNode);
- this.preferencesAdapter = new PreferencesCollectionValueModel<String>(this.nodeHolder);
- this.listener = this.buildCollectionChangeListener();
- this.itemListener = this.buildItemListener();
- this.preferencesAdapter.addCollectionChangeListener(CollectionValueModel.VALUES, this.listener);
- this.event = null;
- }
-
- private CollectionChangeListener buildCollectionChangeListener() {
- return new CollectionChangeListener() {
- public void collectionChanged(CollectionChangeEvent e) {
- this.logEvent(e);
- }
- public void collectionCleared(CollectionClearEvent e) {
- this.logEvent(e);
- }
- public void itemsAdded(CollectionAddEvent e) {
- this.logEvent(e);
- }
- public void itemsRemoved(CollectionRemoveEvent e) {
- this.logEvent(e);
- }
- private void logEvent(CollectionEvent e) {
- if (PreferencesCollectionValueModelTests.this.event != null) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- PreferencesCollectionValueModelTests.this.event = e;
- }
- };
- }
-
- private PropertyChangeListener buildItemListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- };
- }
-
- public void testSubjectHolder() throws Exception {
- this.verifyAdapter(this.preferencesAdapter);
- assertNull(this.event);
-
- String ANOTHER_KEY_NAME_1 = "another key 1";
- String ANOTHER_KEY_NAME_2 = "another key 2";
- String ANOTHER_KEY_NAME_3 = "another key 3";
- String ANOTHER_STRING_VALUE_1 = "another string value 1";
- String ANOTHER_STRING_VALUE_2 = "another string value 2";
- String ANOTHER_STRING_VALUE_3 = "another string value 3";
- Preferences anotherNode = this.classNode.node("another test node");
- this.expectedValues.clear();
- anotherNode.put(ANOTHER_KEY_NAME_1, ANOTHER_STRING_VALUE_1); this.expectedValues.put(ANOTHER_KEY_NAME_1, ANOTHER_STRING_VALUE_1);
- anotherNode.put(ANOTHER_KEY_NAME_2, ANOTHER_STRING_VALUE_2); this.expectedValues.put(ANOTHER_KEY_NAME_2, ANOTHER_STRING_VALUE_2);
- anotherNode.put(ANOTHER_KEY_NAME_3, ANOTHER_STRING_VALUE_3); this.expectedValues.put(ANOTHER_KEY_NAME_3, ANOTHER_STRING_VALUE_3);
-
- this.nodeHolder.setValue(anotherNode);
- // collectionChanged does not pass any items in the this.event
- this.verifyEvent();
- this.verifyAdapter(this.preferencesAdapter);
-
- this.event = null;
- this.expectedValues.clear();
- this.nodeHolder.setValue(null);
- this.verifyEvent();
- assertFalse(this.preferencesAdapter.iterator().hasNext());
-
- this.event = null;
- this.nodeHolder.setValue(this.testNode);
- this.verifyEvent();
- this.expectedValues.clear();
- this.expectedValues.put(KEY_NAME_1, STRING_VALUE_1);
- this.expectedValues.put(KEY_NAME_2, STRING_VALUE_2);
- this.expectedValues.put(KEY_NAME_3, STRING_VALUE_3);
- this.verifyAdapter(this.preferencesAdapter);
- }
-
- public void testAddPreference() throws Exception {
- this.verifyAdapter(this.preferencesAdapter);
- assertNull(this.event);
-
- String ANOTHER_KEY_NAME = "another key";
- String ANOTHER_STRING_VALUE = "another string value";
- this.testNode.put(ANOTHER_KEY_NAME, ANOTHER_STRING_VALUE);
- this.waitForEventQueueToClear();
- Map<String, String> expectedItems = new HashMap<String, String>();
- expectedItems.put(ANOTHER_KEY_NAME, ANOTHER_STRING_VALUE);
- this.verifyEvent(expectedItems);
- this.expectedValues.put(ANOTHER_KEY_NAME, ANOTHER_STRING_VALUE);
- this.verifyAdapter(this.preferencesAdapter);
- }
-
- public void testRemovePreference() throws Exception {
- this.verifyAdapter(this.preferencesAdapter);
- assertNull(this.event);
-
- this.testNode.remove(KEY_NAME_2);
- this.waitForEventQueueToClear();
-
- assertNotNull(this.event);
- assertEquals(this.preferencesAdapter, this.event.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event.getCollectionName());
- assertEquals(1, ((CollectionRemoveEvent) this.event).getItemsSize());
- @SuppressWarnings("unchecked")
- String key = ((PreferencePropertyValueModel<String>) ((CollectionRemoveEvent) this.event).getItems().iterator().next()).getKey();
- assertEquals(KEY_NAME_2, key);
-
- this.expectedValues.remove(KEY_NAME_2);
- this.verifyAdapter(this.preferencesAdapter);
- }
-
- public void testChangePreference() throws Exception {
- this.verifyAdapter(this.preferencesAdapter);
- assertNull(this.event);
-
- String DIFFERENT = "something completely different";
- this.testNode.put(KEY_NAME_2, DIFFERENT);
- this.waitForEventQueueToClear();
-
- assertNull(this.event);
-
- this.expectedValues.put(KEY_NAME_2, DIFFERENT);
- this.verifyAdapter(this.preferencesAdapter);
- }
-
- public void testValues() throws Exception {
- this.verifyNode(this.testNode);
- this.verifyAdapter(this.preferencesAdapter);
- }
-
- /**
- * test a situation where
- * - we are listening to the node when it gets removed from the preferences "repository"
- * - we get notification that it has been removed
- * - we try to remove our this.listener
- * - the node will throw an IllegalStateException - the adapter should handle it OK...
- */
- public void testRemoveNode() throws Exception {
- assertTrue(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- Preferences parent = this.testNode.parent();
- parent.addNodeChangeListener(this.buildParentNodeChangeListener());
- this.testNode.removeNode();
- this.testNode.flush(); // this seems to be required for the this.event to trigger...
- this.waitForEventQueueToClear();
-
- assertTrue(this.listenerRemoved);
- assertFalse(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
- private NodeChangeListener buildParentNodeChangeListener() {
- return new NodeChangeListener() {
- public void childAdded(NodeChangeEvent e) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- public void childRemoved(NodeChangeEvent e) {
- if (e.getChild() == PreferencesCollectionValueModelTests.this.testNode) {
- PreferencesCollectionValueModelTests.this.preferencesAdapter.removeCollectionChangeListener(CollectionValueModel.VALUES, PreferencesCollectionValueModelTests.this.listener);
- // this line of code will not execute if the line above triggers an exception
- PreferencesCollectionValueModelTests.this.listenerRemoved = true;
- }
- }
- };
- }
-
- public void testHasListeners() throws Exception {
- assertTrue(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(this.nodeHasAnyPrefListeners(this.testNode));
- this.preferencesAdapter.removeCollectionChangeListener(CollectionValueModel.VALUES, this.listener);
- assertFalse(this.nodeHasAnyPrefListeners(this.testNode));
- assertFalse(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
-
- ChangeListener listener2 = this.buildChangeListener();
- this.preferencesAdapter.addChangeListener(listener2);
- assertTrue(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- assertTrue(this.nodeHasAnyPrefListeners(this.testNode));
- this.preferencesAdapter.removeChangeListener(listener2);
- assertFalse(this.nodeHasAnyPrefListeners(this.testNode));
- assertFalse(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
- }
-
- private ChangeListener buildChangeListener() {
- return new ChangeAdapter() {
- @Override
- public void collectionChanged(CollectionChangeEvent e) {
- this.logEvent(e);
- }
- @Override
- public void collectionCleared(CollectionClearEvent e) {
- this.logEvent(e);
- }
- @Override
- public void itemsAdded(CollectionAddEvent e) {
- this.logEvent(e);
- }
- @Override
- public void itemsRemoved(CollectionRemoveEvent e) {
- this.logEvent(e);
- }
- private void logEvent(CollectionEvent e) {
- if (PreferencesCollectionValueModelTests.this.event != null) {
- throw new IllegalStateException("unexpected this.event: " + e);
- }
- PreferencesCollectionValueModelTests.this.event = e;
- }
- };
- }
-
- private void verifyEvent(Map<String, String> items) {
- this.verifyEvent();
- assertEquals(items.size(), ((CollectionAddEvent) this.event).getItemsSize());
- @SuppressWarnings("unchecked")
- Iterable<PreferencePropertyValueModel<String>> eventItems = (Iterable<PreferencePropertyValueModel<String>>) ((CollectionAddEvent) this.event).getItems();
- this.verifyItems(items, eventItems);
- }
-
- private void verifyEvent() {
- assertNotNull(this.event);
- assertEquals(this.preferencesAdapter, this.event.getSource());
- assertEquals(CollectionValueModel.VALUES, this.event.getCollectionName());
- }
-
- private void verifyNode(Preferences node) throws Exception {
- String[] keys = node.keys();
- assertEquals(this.expectedValues.size(), keys.length);
- for (int i = 0; i < keys.length; i++) {
- assertEquals(this.expectedValues.get(keys[i]), node.get(keys[i], "<missing preference>"));
- }
- }
-
- private void verifyAdapter(PreferencesCollectionValueModel<String> cvm) {
- assertEquals(this.expectedValues.size(), cvm.size());
- this.verifyItems(this.expectedValues, cvm);
- }
-
- private void verifyItems(Map<String, String> expected, Iterable<PreferencePropertyValueModel<String>> actual) {
- for (PreferencePropertyValueModel<String> model : actual) {
- model.addPropertyChangeListener(PropertyValueModel.VALUE, this.itemListener);
- assertEquals(expected.get(model.getKey()), model.getValue());
- model.removePropertyChangeListener(PropertyValueModel.VALUE, this.itemListener);
- }
- }
-
- private boolean nodeHasAnyPrefListeners(Preferences node) throws Exception {
- PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ReflectionTools.getFieldValue(node, "prefListeners");
- return prefListeners.length > 0;
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencesTestCase.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencesTestCase.java
deleted file mode 100644
index 3ae2c74db7..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/prefs/PreferencesTestCase.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.prefs;
-
-import java.util.EventObject;
-import java.util.List;
-import java.util.prefs.AbstractPreferences;
-import java.util.prefs.Preferences;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-/**
- * set up and tear down a test node for any subclass that
- * needs to test preferences-related stuff
- */
-@SuppressWarnings("nls")
-public abstract class PreferencesTestCase extends TestCase {
- protected Preferences classNode;
- public Preferences testNode;
- protected static final String TEST_NODE_NAME = "test node";
-
- public PreferencesTestCase(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- Preferences packageNode = Preferences.userNodeForPackage(this.getClass());
- this.classNode = packageNode.node(this.getClass().getSimpleName());
- // clean out any leftover crap...
- if ((this.classNode.keys().length > 0) || (this.classNode.childrenNames().length > 0)) {
- this.classNode.removeNode();
- // ...and re-create the node
- this.classNode = packageNode.node(this.getClass().getSimpleName());
- }
- this.testNode = this.classNode.node(TEST_NODE_NAME);
- }
-
- @Override
- protected void tearDown() throws Exception {
- // wait for all the events to be delivered before tearing down
- this.waitForEventQueueToClear();
- Preferences node = this.classNode.parent();
- this.classNode.removeNode();
- while (this.nodeIsVestigial(node)) {
- Preferences parent = node.parent();
- node.removeNode();
- node = parent;
- }
- TestTools.clear(this);
- super.tearDown();
- }
-
- private boolean nodeIsVestigial(Preferences node) throws Exception {
- return (node != null)
- && (node.keys().length == 0)
- && (node.childrenNames().length == 0)
- && (node != Preferences.userRoot());
- }
-
- protected void waitForEventQueueToClear() {
- while ( ! this.preferencesEventQueue().isEmpty()) {
- TestTools.sleep(100);
- }
- TestTools.sleep(100);
- }
-
- @SuppressWarnings("unchecked")
- private List<EventObject> preferencesEventQueue() {
- return (List<EventObject>) ReflectionTools.getStaticFieldValue(AbstractPreferences.class, "eventQueue");
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java
deleted file mode 100644
index ded9a0334c..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import javax.swing.ButtonModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.EventListenerList;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.CheckBoxModelAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class CheckBoxModelAdapterTests extends TestCase {
- private ModifiablePropertyValueModel<Boolean> booleanHolder;
- private ButtonModel buttonModelAdapter;
- boolean eventFired;
-
- public CheckBoxModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.booleanHolder = new SimplePropertyValueModel<Boolean>(Boolean.TRUE);
- this.buttonModelAdapter = new CheckBoxModelAdapter(this.booleanHolder) {
- @Override
- protected PropertyChangeListener buildBooleanChangeListener() {
- return this.buildBooleanChangeListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetSelected() throws Exception {
- this.eventFired = false;
- this.buttonModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CheckBoxModelAdapterTests.this.eventFired = true;
- }
- });
- this.buttonModelAdapter.setSelected(false);
- assertTrue(this.eventFired);
- assertEquals(Boolean.FALSE, this.booleanHolder.getValue());
- }
-
- public void testSetValue() throws Exception {
- this.eventFired = false;
- this.buttonModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CheckBoxModelAdapterTests.this.eventFired = true;
- }
- });
- assertTrue(this.buttonModelAdapter.isSelected());
- this.booleanHolder.setValue(Boolean.FALSE);
- assertTrue(this.eventFired);
- assertFalse(this.buttonModelAdapter.isSelected());
- }
-
- public void testDefaultValue() throws Exception {
- this.eventFired = false;
- this.buttonModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- CheckBoxModelAdapterTests.this.eventFired = true;
- }
- });
- assertTrue(this.buttonModelAdapter.isSelected());
- this.booleanHolder.setValue(null);
- assertTrue(this.eventFired);
- assertFalse(this.buttonModelAdapter.isSelected());
-
- this.eventFired = false;
- this.booleanHolder.setValue(Boolean.FALSE);
- assertFalse(this.eventFired);
- assertFalse(this.buttonModelAdapter.isSelected());
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Boolean> localBooleanHolder = (SimplePropertyValueModel<Boolean>) this.booleanHolder;
- assertFalse(localBooleanHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.buttonModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.buttonModelAdapter.addChangeListener(listener);
- assertTrue(localBooleanHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.buttonModelAdapter);
-
- this.buttonModelAdapter.removeChangeListener(listener);
- assertFalse(localBooleanHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.buttonModelAdapter);
- }
-
- private void verifyHasNoListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ReflectionTools.getFieldValue(model, "listenerList");
- assertEquals(0, listenerList.getListenerList().length);
- }
-
- private void verifyHasListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ReflectionTools.getFieldValue(model, "listenerList");
- assertFalse(listenerList.getListenerList().length == 0);
- }
-
-
- // ********** member class **********
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java
deleted file mode 100644
index 91faa42d64..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/CheckBoxModelAdapterUITest.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ButtonModel;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.WindowConstants;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.CheckBoxModelAdapter;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Play around with a set of check boxes.
- */
-@SuppressWarnings("nls")
-public class CheckBoxModelAdapterUITest {
-
- private TestModel testModel;
- private ModifiablePropertyValueModel<TestModel> testModelHolder;
- private ModifiablePropertyValueModel<Boolean> flag1Holder;
- private ModifiablePropertyValueModel<Boolean> flag2Holder;
- private ModifiablePropertyValueModel<Boolean> notFlag2Holder;
- private ButtonModel flag1ButtonModel;
- private ButtonModel flag2ButtonModel;
- private ButtonModel notFlag2ButtonModel;
-
- public static void main(String[] args) throws Exception {
- new CheckBoxModelAdapterUITest().exec();
- }
-
- private CheckBoxModelAdapterUITest() {
- super();
- }
-
- private void exec() throws Exception {
- this.testModel = new TestModel(true, true);
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.flag1Holder = this.buildFlag1Holder(this.testModelHolder);
- this.flag1ButtonModel = this.buildCheckBoxModelAdapter(this.flag1Holder);
- this.flag2Holder = this.buildFlag2Holder(this.testModelHolder);
- this.flag2ButtonModel = this.buildCheckBoxModelAdapter(this.flag2Holder);
- this.notFlag2Holder = this.buildNotFlag2Holder(this.testModelHolder);
- this.notFlag2ButtonModel = this.buildCheckBoxModelAdapter(this.notFlag2Holder);
- this.openWindow();
- }
-
- private ModifiablePropertyValueModel<Boolean> buildFlag1Holder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Boolean>(vm, TestModel.FLAG1_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isFlag1());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag1(value.booleanValue());
- }
- };
- }
-
- private ModifiablePropertyValueModel<Boolean> buildFlag2Holder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Boolean>(vm, TestModel.FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isFlag2());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setFlag2(value.booleanValue());
- }
- };
- }
-
- private ModifiablePropertyValueModel<Boolean> buildNotFlag2Holder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Boolean>(vm, TestModel.NOT_FLAG2_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isNotFlag2());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setNotFlag2(value.booleanValue());
- }
- };
- }
-
- private ButtonModel buildCheckBoxModelAdapter(ModifiablePropertyValueModel<Boolean> booleanHolder) {
- return new CheckBoxModelAdapter(booleanHolder);
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setSize(400, 100);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildCheckBoxPanel(), BorderLayout.NORTH);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildCheckBoxPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildFlag1CheckBox());
- taskListPanel.add(this.buildFlag2CheckBox());
- taskListPanel.add(this.buildNotFlag2CheckBox());
- taskListPanel.add(this.buildUnattachedCheckBox());
- return taskListPanel;
- }
-
- private JCheckBox buildFlag1CheckBox() {
- JCheckBox checkBox = new JCheckBox();
- checkBox.setText("flag 1");
- checkBox.setModel(this.flag1ButtonModel);
- return checkBox;
- }
-
- private JCheckBox buildFlag2CheckBox() {
- JCheckBox checkBox = new JCheckBox();
- checkBox.setText("flag 2");
- checkBox.setModel(this.flag2ButtonModel);
- return checkBox;
- }
-
- private JCheckBox buildNotFlag2CheckBox() {
- JCheckBox checkBox = new JCheckBox();
- checkBox.setText("not flag 2");
- checkBox.setModel(this.notFlag2ButtonModel);
- return checkBox;
- }
-
- private JCheckBox buildUnattachedCheckBox() {
- JCheckBox checkBox = new JCheckBox("unattached");
- checkBox.getModel().addItemListener(this.buildUnattachedItemListener());
- return checkBox;
- }
-
- private ItemListener buildUnattachedItemListener() {
- return new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- System.out.println("unattached state changed: " + e);
- }
- };
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(1, 0));
- controlPanel.add(this.buildFlipFlag1Button());
- controlPanel.add(this.buildClearModelButton());
- controlPanel.add(this.buildRestoreModelButton());
- controlPanel.add(this.buildPrintModelButton());
- return controlPanel;
- }
-
- private JButton buildFlipFlag1Button() {
- return new JButton(this.buildFlipFlag1Action());
- }
-
- private Action buildFlipFlag1Action() {
- Action action = new AbstractAction("flip flag 1") {
- public void actionPerformed(ActionEvent event) {
- CheckBoxModelAdapterUITest.this.flipFlag1();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void flipFlag1() {
- this.testModel.setFlag1( ! this.testModel.isFlag1());
- }
-
- private JButton buildClearModelButton() {
- return new JButton(this.buildClearModelAction());
- }
-
- private Action buildClearModelAction() {
- Action action = new AbstractAction("clear model") {
- public void actionPerformed(ActionEvent event) {
- CheckBoxModelAdapterUITest.this.clearModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private JButton buildRestoreModelButton() {
- return new JButton(this.buildRestoreModelAction());
- }
-
- private Action buildRestoreModelAction() {
- Action action = new AbstractAction("restore model") {
- public void actionPerformed(ActionEvent event) {
- CheckBoxModelAdapterUITest.this.restoreModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private JButton buildPrintModelButton() {
- return new JButton(this.buildPrintModelAction());
- }
-
- private Action buildPrintModelAction() {
- Action action = new AbstractAction("print model") {
- public void actionPerformed(ActionEvent event) {
- CheckBoxModelAdapterUITest.this.printModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printModel() {
- System.out.println("flag 1: " + this.testModel.isFlag1());
- System.out.println("flag 2: " + this.testModel.isFlag2());
- System.out.println("not flag 2: " + this.testModel.isNotFlag2());
- System.out.println("***");
- }
-
-
- private class TestModel extends AbstractModel {
- private boolean flag1;
- public static final String FLAG1_PROPERTY = "flag1";
- private boolean flag2;
- public static final String FLAG2_PROPERTY = "flag2";
- private boolean notFlag2;
- public static final String NOT_FLAG2_PROPERTY = "notFlag2";
-
- public TestModel(boolean flag1, boolean flag2) {
- this.flag1 = flag1;
- this.flag2 = flag2;
- this.notFlag2 = ! flag2;
- }
- public boolean isFlag1() {
- return this.flag1;
- }
- public void setFlag1(boolean flag1) {
- boolean old = this.flag1;
- this.flag1 = flag1;
- this.firePropertyChanged(FLAG1_PROPERTY, old, flag1);
- }
- public boolean isFlag2() {
- return this.flag2;
- }
- public void setFlag2(boolean flag2) {
- boolean old = this.flag2;
- this.flag2 = flag2;
- this.firePropertyChanged(FLAG2_PROPERTY, old, flag2);
-
- old = this.notFlag2;
- this.notFlag2 = ! flag2;
- this.firePropertyChanged(NOT_FLAG2_PROPERTY, old, this.notFlag2);
- }
- public boolean isNotFlag2() {
- return this.notFlag2;
- }
- public void setNotFlag2(boolean notFlag2) {
- this.setFlag2( ! notFlag2);
- }
- @Override
- public String toString() {
- return "TestModel(" + this.isFlag1() + " - " + this.isFlag2() + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java
deleted file mode 100644
index 891611573d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterTests.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import javax.swing.ComboBoxModel;
-import javax.swing.ListModel;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ComboBoxModelAdapter;
-import org.eclipse.jpt.common.utility.internal.swing.Displayable;
-import org.eclipse.jpt.common.utility.internal.swing.SimpleDisplayable;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.CoordinatedList;
-
-@SuppressWarnings("nls")
-public class ComboBoxModelAdapterTests extends TestCase {
-
- public ComboBoxModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // nothing yet...
- }
-
- @Override
- protected void tearDown() throws Exception {
- // nothing yet...
- super.tearDown();
- }
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<Displayable> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- SimplePropertyValueModel<Object> selectionHolder = new SimplePropertyValueModel<Object>(listHolder.iterator().next());
- assertFalse(selectionHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
-
- ComboBoxModel comboBoxModel = new ComboBoxModelAdapter(listHolder, selectionHolder);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(selectionHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(comboBoxModel);
-
- CoordinatedList<Displayable> synchList = new CoordinatedList<Displayable>(comboBoxModel);
- PropertyChangeListener selectionListener = this.buildSelectionListener();
- selectionHolder.addPropertyChangeListener(PropertyValueModel.VALUE, selectionListener);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(selectionHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(comboBoxModel);
-
- comboBoxModel.removeListDataListener(synchList);
- selectionHolder.removePropertyChangeListener(PropertyValueModel.VALUE, selectionListener);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertFalse(selectionHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(comboBoxModel);
- }
-
- private PropertyChangeListener buildSelectionListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent evt) {
- // do nothing...
- }
- };
- }
-
- private void verifyHasNoListeners(ListModel listModel) throws Exception {
- boolean hasNoListeners = ((Boolean) ReflectionTools.executeMethod(listModel, "hasNoListDataListeners")).booleanValue();
- assertTrue(hasNoListeners);
- }
-
- private void verifyHasListeners(ListModel listModel) throws Exception {
- boolean hasListeners = ((Boolean) ReflectionTools.executeMethod(listModel, "hasListDataListeners")).booleanValue();
- assertTrue(hasListeners);
- }
-
- private SimpleListValueModel<Displayable> buildListHolder() {
- return new SimpleListValueModel<Displayable>(this.buildList());
- }
-
- private List<Displayable> buildList() {
- List<Displayable> list = new ArrayList<Displayable>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<Displayable> c) {
- c.add(new SimpleDisplayable("foo"));
- c.add(new SimpleDisplayable("bar"));
- c.add(new SimpleDisplayable("baz"));
- c.add(new SimpleDisplayable("joo"));
- c.add(new SimpleDisplayable("jar"));
- c.add(new SimpleDisplayable("jaz"));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java
deleted file mode 100644
index ac12b38a71..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ComboBoxModel;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.ListCellRenderer;
-import javax.swing.UIManager;
-import javax.swing.WindowConstants;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ComboBoxModelAdapter;
-import org.eclipse.jpt.common.utility.internal.swing.FilteringListBrowser;
-import org.eclipse.jpt.common.utility.internal.swing.ListChooser;
-import org.eclipse.jpt.common.utility.internal.swing.SimpleListCellRenderer;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-
-/**
- * Play around with a set of combo-boxes.
- *
- * DefaultLongListBrowserDialogUITest subclasses this class; so be
- * careful when making changes.
- */
-@SuppressWarnings("nls")
-public class ComboBoxModelAdapterUITest {
-
- protected JFrame window;
- private TestModel testModel;
- private ModifiablePropertyValueModel<TestModel> testModelHolder;
- private ModifiablePropertyValueModel<Object> colorHolder;
- private SimpleListValueModel<String> colorListHolder;
- protected ComboBoxModel colorComboBoxModel;
- private int nextColorNumber = 0;
-
- public static void main(String[] args) throws Exception {
- new ComboBoxModelAdapterUITest().exec();
- }
-
- protected ComboBoxModelAdapterUITest() {
- super();
- }
-
- protected void exec() throws Exception {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
-// UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); // Metal LAF
-// UIManager.setLookAndFeel(com.sun.java.swing.plaf.windows.WindowsLookAndFeel.class.getName());
-// UIManager.setLookAndFeel(com.sun.java.swing.plaf.motif.MotifLookAndFeel.class.getName());
-// UIManager.setLookAndFeel(oracle.bali.ewt.olaf.OracleLookAndFeel.class.getName());
- this.testModel = this.buildTestModel();
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.colorHolder = this.buildColorHolder(this.testModelHolder);
- this.colorListHolder = this.buildColorListHolder();
- this.colorComboBoxModel = this.buildComboBoxModelAdapter(this.colorListHolder, this.colorHolder);
- this.openWindow();
- }
-
- private ModifiablePropertyValueModel<Object> buildColorHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Object>(vm, TestModel.COLOR_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getColor();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setColor((String) value);
- }
- };
- }
-
- protected TestModel buildTestModel() {
- return new TestModel();
- }
-
- private SimpleListValueModel<String> buildColorListHolder() {
- return new SimpleListValueModel<String>(TestModel.validColors());
-// return new AbstractReadOnlyListValueModel() {
-// public Object value() {
-// return new ArrayListIterator(TestModel.VALID_COLORS);
-// }
-// public int size() {
-// return TestModel.VALID_COLORS.length;
-// }
-// };
- }
-
- protected ListValueModel<String> uiColorListHolder() {
- return this.colorListHolder;
- }
-
- private ComboBoxModel buildComboBoxModelAdapter(ListValueModel<String> listHolder, ModifiablePropertyValueModel<Object> selectionHolder) {
- return new ComboBoxModelAdapter(listHolder, selectionHolder);
- }
-
- private void openWindow() {
- this.window = new JFrame(this.getClass().getSimpleName());
- this.window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- this.window.addWindowListener(this.buildWindowListener());
- this.window.getContentPane().add(this.buildMainPanel(), "Center");
- this.window.setLocation(300, 300);
- this.window.setSize(400, 150);
- this.window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildComboBoxPanel(), BorderLayout.NORTH);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- protected JPanel buildComboBoxPanel() {
- JPanel panel = new JPanel(new GridLayout(1, 0));
- panel.add(this.buildComboBox());
- panel.add(this.buildComboBox());
- panel.add(this.buildListChooser1());
- panel.add(this.buildListChooser2());
- return panel;
- }
-
- private JComboBox buildComboBox() {
- JComboBox comboBox = new JComboBox(this.colorComboBoxModel);
- comboBox.setRenderer(this.buildComboBoxRenderer());
- return comboBox;
- }
-
- protected ListCellRenderer buildComboBoxRenderer() {
- return new SimpleListCellRenderer() {
- @Override
- protected String buildText(Object value) {
- return super.buildText(value);
- }
- };
- }
-
- private ListChooser buildListChooser1() {
- return new LocalListChooser1(this.colorComboBoxModel);
- }
-
- private ListChooser buildListChooser2() {
- return new LocalListChooser2(this.colorComboBoxModel);
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(2, 0));
- controlPanel.add(this.buildResetColorButton());
- controlPanel.add(this.buildClearModelButton());
- controlPanel.add(this.buildRestoreModelButton());
- controlPanel.add(this.buildPrintModelButton());
- controlPanel.add(this.buildAddTenButton());
- controlPanel.add(this.buildRemoveTenButton());
- return controlPanel;
- }
-
- // ********** reset color button **********
- private JButton buildResetColorButton() {
- return new JButton(this.buildResetColorAction());
- }
-
- private Action buildResetColorAction() {
- Action action = new AbstractAction("reset color") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.resetColor();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void resetColor() {
- this.testModel.setColor(TestModel.DEFAULT_COLOR);
- }
-
- // ********** clear model button **********
- private JButton buildClearModelButton() {
- return new JButton(this.buildClearModelAction());
- }
-
- private Action buildClearModelAction() {
- Action action = new AbstractAction("clear model") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.clearModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- // ********** restore model button **********
- private JButton buildRestoreModelButton() {
- return new JButton(this.buildRestoreModelAction());
- }
-
- private Action buildRestoreModelAction() {
- Action action = new AbstractAction("restore model") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.restoreModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- // ********** print model button **********
- private JButton buildPrintModelButton() {
- return new JButton(this.buildPrintModelAction());
- }
-
- private Action buildPrintModelAction() {
- Action action = new AbstractAction("print model") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.printModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printModel() {
- System.out.println(this.testModel);
- }
-
- // ********** add 20 button **********
- private JButton buildAddTenButton() {
- return new JButton(this.buildAddTenAction());
- }
-
- private Action buildAddTenAction() {
- Action action = new AbstractAction("add 20") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.addTen();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void addTen() {
- for (int i = this.nextColorNumber; i < this.nextColorNumber + 20; i++) {
- this.colorListHolder.add(this.colorListHolder.size(), "color" + i);
- }
- this.nextColorNumber += 20;
- }
-
- // ********** remove 20 button **********
- private JButton buildRemoveTenButton() {
- return new JButton(this.buildRemoveTenAction());
- }
-
- private Action buildRemoveTenAction() {
- Action action = new AbstractAction("remove 20") {
- public void actionPerformed(ActionEvent event) {
- ComboBoxModelAdapterUITest.this.removeTen();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void removeTen() {
- for (int i = 0; i < 20; i++) {
- if (this.colorListHolder.size() > 0) {
- this.colorListHolder.remove(this.colorListHolder.size() - 1);
- }
- }
- }
-
-
- protected static class TestModel extends AbstractModel {
- private String color;
- public static final String COLOR_PROPERTY = "color";
- public static final String RED = "red";
- public static final String ORANGE = "orange";
- public static final String YELLOW = "yellow";
- public static final String GREEN = "green";
- public static final String BLUE = "blue";
- public static final String INDIGO = "indigo";
- public static final String VIOLET = "violet";
- public static final String DEFAULT_COLOR = RED;
- public static List<String> validColors;
- public static final String[] DEFAULT_VALID_COLORS = {
- RED,
- ORANGE,
- YELLOW,
- GREEN,
- BLUE,
- INDIGO,
- VIOLET
- };
-
- public static List<String> validColors() {
- if (validColors == null) {
- validColors = buildDefaultValidColors();
- }
- return validColors;
- }
- public static List<String> buildDefaultValidColors() {
- List<String> result = new ArrayList<String>();
- CollectionTools.addAll(result, DEFAULT_VALID_COLORS);
- return result;
- }
-
- public TestModel() {
- this(DEFAULT_COLOR);
- }
- public TestModel(String color) {
- this.color = color;
- }
- public String getColor() {
- return this.color;
- }
- public void setColor(String color) {
- this.checkColor(color);
- Object old = this.color;
- this.color = color;
- this.firePropertyChanged(COLOR_PROPERTY, old, color);
- }
- public void checkColor(String c) {
- if ( ! validColors().contains(c)) {
- throw new IllegalArgumentException(c);
- }
- }
- @Override
- public String toString() {
- return "TestModel(" + this.color + ")";
- }
- }
-
-
- private class LocalListChooser1 extends ListChooser {
- public LocalListChooser1(ComboBoxModel model) {
- super(model);
- }
- }
-
-
- private class LocalListChooser2 extends ListChooser {
- public LocalListChooser2(ComboBoxModel model) {
- super(model);
- }
- @Override
- protected ListBrowser buildBrowser() {
- return new FilteringListBrowser<String>();
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java
deleted file mode 100644
index ed00f4cf18..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import javax.swing.ListCellRenderer;
-import org.eclipse.jpt.common.utility.internal.model.value.ExtendedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.internal.swing.SimpleListCellRenderer;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-
-/**
- *
- */
-@SuppressWarnings("nls")
-public class ComboBoxModelAdapterUITest2 extends ComboBoxModelAdapterUITest {
-
- public static void main(String[] args) throws Exception {
- new ComboBoxModelAdapterUITest2().exec();
- }
-
- public ComboBoxModelAdapterUITest2() {
- super();
- }
-
- /**
- * use a different model that allows the color to be set to null
- */
- @Override
- protected TestModel buildTestModel() {
- return new TestModel2();
- }
-
- /**
- * add a null to the front of the list
- */
- @Override
- protected ListValueModel<String> uiColorListHolder() {
- // the default is to prepend the wrapped list with a null item
- return new ExtendedListValueModelWrapper<String>(super.uiColorListHolder());
- }
-
- /**
- * convert null to some text
- */
- @Override
- protected ListCellRenderer buildComboBoxRenderer() {
- return new SimpleListCellRenderer() {
- @Override
- protected String buildText(Object value) {
- return (value == null) ? "<none selected>" : super.buildText(value);
- }
- };
- }
-
-
- protected static class TestModel2 extends TestModel {
- /**
- * null is OK here
- */
- @Override
- public void checkColor(String color) {
- if (color == null) {
- return;
- }
- super.checkColor(color);
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java
deleted file mode 100644
index 813550a23e..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.util.Date;
-import javax.swing.SpinnerModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.DateSpinnerModelAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class DateSpinnerModelAdapterTests extends TestCase {
- private ModifiablePropertyValueModel<Object> valueHolder;
- private SpinnerModel spinnerModelAdapter;
- boolean eventFired;
-
- public DateSpinnerModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Object>(new Date());
- this.spinnerModelAdapter = new DateSpinnerModelAdapter(this.valueHolder) {
- @Override
- protected PropertyChangeListener buildDateChangeListener() {
- return this.buildDateChangeListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetValueSpinnerModel() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- DateSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- Date newDate = new Date();
- newDate.setTime(777777);
- this.spinnerModelAdapter.setValue(newDate);
- assertTrue(this.eventFired);
- assertEquals(777777, ((Date) this.valueHolder.getValue()).getTime());
- }
-
- public void testSetValueValueHolder() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- DateSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- Date newDate = new Date();
- newDate.setTime(777777);
- this.valueHolder.setValue(newDate);
- assertTrue(this.eventFired);
- assertEquals(777777, ((Date) this.spinnerModelAdapter.getValue()).getTime());
- }
-
- public void testDefaultValue() throws Exception {
- Date newDate = new Date();
- newDate.setTime(777777);
- this.valueHolder.setValue(newDate);
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- DateSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(777777, ((Date) this.spinnerModelAdapter.getValue()).getTime());
- this.valueHolder.setValue(null);
- assertTrue(this.eventFired);
- assertFalse(((Date) this.spinnerModelAdapter.getValue()).getTime() == 777777);
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.spinnerModelAdapter.addChangeListener(listener);
- assertTrue(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.spinnerModelAdapter);
-
- this.spinnerModelAdapter.removeChangeListener(listener);
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
- }
-
- private void verifyHasNoListeners(SpinnerModel adapter) throws Exception {
- assertEquals(0, ((DateSpinnerModelAdapter) adapter).getChangeListeners().length);
- }
-
- private void verifyHasListeners(Object adapter) throws Exception {
- assertFalse(((DateSpinnerModelAdapter) adapter).getChangeListeners().length == 0);
- }
-
- public void testNullInitialValue() {
- Date today = new Date();
- this.valueHolder = new SimplePropertyValueModel<Object>();
- this.spinnerModelAdapter = new DateSpinnerModelAdapter(this.valueHolder, today) {
- @Override
- protected PropertyChangeListener buildDateChangeListener() {
- return this.buildDateChangeListener_();
- }
- };
-
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- DateSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(today, this.spinnerModelAdapter.getValue());
-
- Date newDate = new Date();
- newDate.setTime(777777);
- this.valueHolder.setValue(newDate);
-
- assertTrue(this.eventFired);
- assertEquals(777777, ((Date) this.spinnerModelAdapter.getValue()).getTime());
- }
-
-
- // ********** inner class **********
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DocumentAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DocumentAdapterTests.java
deleted file mode 100644
index 8a271c029d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DocumentAdapterTests.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import javax.swing.event.DocumentEvent;
-import javax.swing.event.DocumentListener;
-import javax.swing.event.DocumentEvent.EventType;
-import javax.swing.text.Document;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.DocumentAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class DocumentAdapterTests extends TestCase {
- private ModifiablePropertyValueModel<String> stringHolder;
- Document documentAdapter;
- boolean eventFired;
-
- public DocumentAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.stringHolder = new SimplePropertyValueModel<String>("0123456789");
- this.documentAdapter = new DocumentAdapter(this.stringHolder) {
- @Override
- protected PropertyChangeListener buildStringListener() {
- return this.buildStringListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testRemove() throws Exception {
- this.eventFired = false;
- this.documentAdapter.addDocumentListener(new TestDocumentListener() {
- @Override
- public void removeUpdate(DocumentEvent e) {
- DocumentAdapterTests.this.eventFired = true;
- assertEquals(EventType.REMOVE, e.getType());
- assertEquals(DocumentAdapterTests.this.documentAdapter, e.getDocument());
- // this will be the removal of "23456"
- assertEquals(2, e.getOffset());
- assertEquals(5, e.getLength());
- }
- });
- this.documentAdapter.remove(2, 5);
- assertTrue(this.eventFired);
- assertEquals("01789", this.stringHolder.getValue());
- }
-
- public void testInsert() throws Exception {
- this.eventFired = false;
- this.documentAdapter.addDocumentListener(new TestDocumentListener() {
- @Override
- public void insertUpdate(DocumentEvent e) {
- DocumentAdapterTests.this.eventFired = true;
- assertEquals(EventType.INSERT, e.getType());
- assertEquals(DocumentAdapterTests.this.documentAdapter, e.getDocument());
- // this will be the insert of "xxxxxx"
- assertEquals(2, e.getOffset());
- assertEquals(5, e.getLength());
- }
- });
- this.documentAdapter.insertString(2, "xxxxx", null);
- assertTrue(this.eventFired);
- assertEquals("01xxxxx23456789", this.stringHolder.getValue());
- }
-
- public void testSetValue() throws Exception {
- this.eventFired = false;
- this.documentAdapter.addDocumentListener(new TestDocumentListener() {
- @Override
- public void insertUpdate(DocumentEvent e) {
- DocumentAdapterTests.this.eventFired = true;
- assertEquals(EventType.INSERT, e.getType());
- assertEquals(DocumentAdapterTests.this.documentAdapter, e.getDocument());
- // this will be the insert of "foo"
- assertEquals(0, e.getOffset());
- assertEquals(3, e.getLength());
- }
- @Override
- public void removeUpdate(DocumentEvent e) {
- assertEquals(EventType.REMOVE, e.getType());
- assertEquals(DocumentAdapterTests.this.documentAdapter, e.getDocument());
- // this will be the removal of "0123456789"
- assertEquals(0, e.getOffset());
- assertEquals(10, e.getLength());
- }
- });
- assertEquals("0123456789", this.documentAdapter.getText(0, this.documentAdapter.getLength()));
- this.stringHolder.setValue("foo");
- assertTrue(this.eventFired);
- assertEquals("foo", this.documentAdapter.getText(0, this.documentAdapter.getLength()));
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<String> localStringHolder = (SimplePropertyValueModel<String>) this.stringHolder;
- assertFalse(localStringHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.documentAdapter);
-
- DocumentListener listener = new TestDocumentListener();
- this.documentAdapter.addDocumentListener(listener);
- assertTrue(localStringHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.documentAdapter);
-
- this.documentAdapter.removeDocumentListener(listener);
- assertFalse(localStringHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.documentAdapter);
- }
-
- private void verifyHasNoListeners(Object document) throws Exception {
- Object delegate = ReflectionTools.getFieldValue(document, "delegate");
- Object[] listeners = (Object[]) ReflectionTools.executeMethod(delegate, "getDocumentListeners");
- assertEquals(0, listeners.length);
- }
-
- private void verifyHasListeners(Object document) throws Exception {
- Object delegate = ReflectionTools.getFieldValue(document, "delegate");
- Object[] listeners = (Object[]) ReflectionTools.executeMethod(delegate, "getDocumentListeners");
- assertFalse(listeners.length == 0);
- }
-
-
-private class TestDocumentListener implements DocumentListener {
- TestDocumentListener() {
- super();
- }
- public void changedUpdate(DocumentEvent e) {
- fail("unexpected event");
- }
- public void insertUpdate(DocumentEvent e) {
- fail("unexpected event");
- }
- public void removeUpdate(DocumentEvent e) {
- fail("unexpected event");
- }
-}
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java
deleted file mode 100644
index 5347191b57..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/DocumentAdapterUITest.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.WindowConstants;
-import javax.swing.text.AbstractDocument;
-import javax.swing.text.AttributeSet;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.Document;
-import javax.swing.text.PlainDocument;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.DocumentAdapter;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Play around with a set of entry fields.
- */
-@SuppressWarnings("nls")
-public class DocumentAdapterUITest {
-
- private TestModel testModel;
- private static final String DEFAULT_NAME = "Scooby Doo";
- private ModifiablePropertyValueModel<TestModel> testModelHolder;
- private ModifiablePropertyValueModel<String> nameHolder;
- private Document nameDocument;
- private Document upperCaseNameDocument;
-
- public static void main(String[] args) throws Exception {
- new DocumentAdapterUITest().exec();
- }
-
- private DocumentAdapterUITest() {
- super();
- }
-
- private void exec() throws Exception {
- this.testModel = new TestModel(DEFAULT_NAME);
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.nameHolder = this.buildNameHolder(this.testModelHolder);
- this.nameDocument = this.buildNameDocument(this.nameHolder);
- this.upperCaseNameDocument = this.buildUpperCaseNameDocument(this.nameHolder);
- this.openWindow();
- }
-
- private ModifiablePropertyValueModel<String> buildNameHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, String>(vm, TestModel.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
- @Override
- protected void setValue_(String value) {
- this.subject.setName(value);
- }
- };
- }
-
- private Document buildNameDocument(ModifiablePropertyValueModel<String> stringHolder) {
- return new DocumentAdapter(stringHolder);
- }
-
- private Document buildUpperCaseNameDocument(ModifiablePropertyValueModel<String> stringHolder) {
- return new DocumentAdapter(stringHolder, this.buildUpperCaseNameDocumentDelegate());
- }
-
- private AbstractDocument buildUpperCaseNameDocumentDelegate() {
- return new PlainDocument() {
- @Override
- public void insertString(int offset, String string, AttributeSet a) throws BadLocationException {
- if (string == null) {
- return;
- }
- char[] upper = string.toCharArray();
- for (int i = 0; i < upper.length; i++) {
- upper[i] = Character.toUpperCase(upper[i]);
- }
- super.insertString(offset, new String(upper), a);
- }
- };
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setSize(400, 100);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildTextFieldPanel(), BorderLayout.NORTH);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildTextFieldPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildNameTextField());
- taskListPanel.add(this.buildReadOnlyNameTextField());
- taskListPanel.add(this.buildUpperCaseNameTextField());
- return taskListPanel;
- }
-
- private JTextField buildNameTextField() {
- return new JTextField(this.nameDocument, null, 0);
- }
-
- private JTextField buildReadOnlyNameTextField() {
- JTextField nameTextField = this.buildNameTextField();
- nameTextField.setEditable(false);
- return nameTextField;
- }
-
- private JTextField buildUpperCaseNameTextField() {
- return new JTextField(this.upperCaseNameDocument, null, 0);
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(1, 0));
- controlPanel.add(this.buildResetNameButton());
- controlPanel.add(this.buildClearModelButton());
- controlPanel.add(this.buildRestoreModelButton());
- controlPanel.add(this.buildPrintModelButton());
- return controlPanel;
- }
-
- private JButton buildResetNameButton() {
- return new JButton(this.buildResetNameAction());
- }
-
- private Action buildResetNameAction() {
- Action action = new AbstractAction("reset name") {
- public void actionPerformed(ActionEvent event) {
- DocumentAdapterUITest.this.resetName();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void resetName() {
- this.testModel.setName(DEFAULT_NAME);
- }
-
- private JButton buildClearModelButton() {
- return new JButton(this.buildClearModelAction());
- }
-
- private Action buildClearModelAction() {
- Action action = new AbstractAction("clear model") {
- public void actionPerformed(ActionEvent event) {
- DocumentAdapterUITest.this.clearModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private JButton buildRestoreModelButton() {
- return new JButton(this.buildRestoreModelAction());
- }
-
- private Action buildRestoreModelAction() {
- Action action = new AbstractAction("restore model") {
- public void actionPerformed(ActionEvent event) {
- DocumentAdapterUITest.this.restoreModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private JButton buildPrintModelButton() {
- return new JButton(this.buildPrintModelAction());
- }
-
- private Action buildPrintModelAction() {
- Action action = new AbstractAction("print model") {
- public void actionPerformed(ActionEvent event) {
- DocumentAdapterUITest.this.printModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printModel() {
- System.out.println("name: " + this.testModel.getName());
- }
-
-
- private class TestModel extends AbstractModel {
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- public TestModel(String name) {
- this.name = name;
- }
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
- @Override
- public String toString() {
- return "TestModel(" + this.getName() + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/JptUtilityModelValueSwingTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/JptUtilityModelValueSwingTests.java
deleted file mode 100644
index 93c6b41c9d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/JptUtilityModelValueSwingTests.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptUtilityModelValueSwingTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityModelValueSwingTests.class.getPackage().getName());
-
- suite.addTestSuite(CheckBoxModelAdapterTests.class);
- suite.addTestSuite(ComboBoxModelAdapterTests.class);
- suite.addTestSuite(DateSpinnerModelAdapterTests.class);
- suite.addTestSuite(DocumentAdapterTests.class);
- suite.addTestSuite(ListModelAdapterTests.class);
- suite.addTestSuite(ListSpinnerModelAdapterTests.class);
- suite.addTestSuite(NumberSpinnerModelAdapterTests.class);
- suite.addTestSuite(ObjectListSelectionModelTests.class);
- suite.addTestSuite(PrimitiveListTreeModelTests.class);
- suite.addTestSuite(RadioButtonModelAdapterTests.class);
- suite.addTestSuite(SpinnerModelAdapterTests.class);
- suite.addTestSuite(TableModelAdapterTests.class);
- suite.addTestSuite(TreeModelAdapterTests.class);
-
- return suite;
- }
-
- private JptUtilityModelValueSwingTests() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
deleted file mode 100644
index 0be426de9f..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.swing.ListModel;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.Bag;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.CoordinatedList;
-
-@SuppressWarnings("nls")
-public class ListModelAdapterTests extends TestCase {
-
- public ListModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- // nothing yet...
- }
-
- @Override
- protected void tearDown() throws Exception {
- // nothing yet...
- super.tearDown();
- }
-
- private ListModelAdapter buildListModel(ListValueModel<String> listHolder) {
- return new ListModelAdapter(listHolder) {
- @Override
- protected ListChangeListener buildListChangeListener() {
- return this.buildListChangeListener_();
- }
- };
- }
-
- private ListModel buildListModel(CollectionValueModel<String> collectionHolder) {
- return new ListModelAdapter(collectionHolder) {
- @Override
- protected ListChangeListener buildListChangeListener() {
- return this.buildListChangeListener_();
- }
- };
- }
-
- public void testCollectionSynchronization() {
- SimpleCollectionValueModel<String> collectionHolder = this.buildCollectionHolder();
- ListModel listModel = this.buildListModel(collectionHolder);
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertEquals(6, synchList.size());
- this.compare(listModel, synchList);
-
- collectionHolder.add("tom");
- collectionHolder.add("dick");
- collectionHolder.add("harry");
- collectionHolder.add(null);
- assertEquals(10, synchList.size());
- this.compare(listModel, synchList);
-
- collectionHolder.remove("foo");
- collectionHolder.remove("jar");
- collectionHolder.remove("harry");
- collectionHolder.remove(null);
- assertEquals(6, synchList.size());
- this.compare(listModel, synchList);
- }
-
- public void testListSynchronization() {
- SimpleListValueModel<String> listHolder = this.buildListHolder();
- ListModel listModel = this.buildListModel(listHolder);
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertEquals(6, synchList.size());
- this.compare(listModel, synchList);
-
- listHolder.add(6, "tom");
- listHolder.add(7, "dick");
- listHolder.add(8, "harry");
- listHolder.add(9, null);
- assertEquals(10, synchList.size());
- this.compare(listModel, synchList);
-
- listHolder.remove(9);
- listHolder.remove(8);
- listHolder.remove(4);
- listHolder.remove(0);
- assertEquals(6, synchList.size());
- this.compare(listModel, synchList);
- }
-
- public void testSetModel() {
- SimpleListValueModel<String> listHolder1 = this.buildListHolder();
- ListModelAdapter listModel = this.buildListModel(listHolder1);
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertTrue(listHolder1.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- assertEquals(6, synchList.size());
- this.compare(listModel, synchList);
-
- SimpleListValueModel<String> listHolder2 = this.buildListHolder2();
- listModel.setModel(listHolder2);
- assertEquals(3, synchList.size());
- this.compare(listModel, synchList);
- assertTrue(listHolder1.hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(listHolder2.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- listModel.setModel(new SimpleListValueModel<String>());
- assertEquals(0, synchList.size());
- this.compare(listModel, synchList);
- assertTrue(listHolder1.hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- assertTrue(listHolder2.hasNoListChangeListeners(ListValueModel.LIST_VALUES));
- }
-
- private void compare(ListModel listModel, List<String> list) {
- assertEquals(listModel.getSize(), list.size());
- for (int i = 0; i < listModel.getSize(); i++) {
- assertEquals(listModel.getElementAt(i), list.get(i));
- }
- }
-
- public void testCollectionSort() {
- this.verifyCollectionSort(null);
- }
-
- public void testListSort() {
- this.verifyListSort(null);
- }
-
- public void testCustomCollectionSort() {
- this.verifyCollectionSort(this.buildCustomComparator());
- }
-
- public void testCustomListSort() {
- this.verifyListSort(this.buildCustomComparator());
- }
-
- private Comparator<String> buildCustomComparator() {
- // sort with reverse order
- return new Comparator<String>() {
- public int compare(String s1, String s2) {
- return s2.compareTo(s1);
- }
- };
- }
-
- private void verifyCollectionSort(Comparator<String> comparator) {
- SimpleCollectionValueModel<String> collectionHolder = this.buildCollectionHolder();
- ListModel listModel = this.buildListModel(new SortedListValueModelAdapter<String>(collectionHolder, comparator));
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertEquals(6, synchList.size());
- this.compareSort(listModel, synchList, comparator);
-
- collectionHolder.add("tom");
- collectionHolder.add("dick");
- collectionHolder.add("harry");
- assertEquals(9, synchList.size());
- this.compareSort(listModel, synchList, comparator);
-
- collectionHolder.remove("foo");
- collectionHolder.remove("jar");
- collectionHolder.remove("harry");
- assertEquals(6, synchList.size());
- this.compareSort(listModel, synchList, comparator);
- }
-
- private void verifyListSort(Comparator<String> comparator) {
- SimpleListValueModel<String> listHolder = this.buildListHolder();
- ListModel listModel = this.buildListModel(new SortedListValueModelWrapper<String>(listHolder, comparator));
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertEquals(6, synchList.size());
- this.compareSort(listModel, synchList, comparator);
-
- listHolder.add(0, "tom");
- listHolder.add(0, "dick");
- listHolder.add(0, "harry");
- assertEquals(9, synchList.size());
- this.compareSort(listModel, synchList, comparator);
-
- listHolder.remove(8);
- listHolder.remove(4);
- listHolder.remove(0);
- listHolder.remove(5);
- assertEquals(5, synchList.size());
- this.compareSort(listModel, synchList, comparator);
- }
-
- private void compareSort(ListModel listModel, List<String> list, Comparator<String> comparator) {
- SortedSet<String> ss = new TreeSet<String>(comparator);
- for (int i = 0; i < listModel.getSize(); i++) {
- ss.add((String) listModel.getElementAt(i));
- }
- assertEquals(ss.size(), list.size());
- for (Iterator<String> stream1 = ss.iterator(), stream2 = list.iterator(); stream1.hasNext(); ) {
- assertEquals(stream1.next(), stream2.next());
- }
- }
-
- public void testHasListeners() throws Exception {
- SimpleListValueModel<String> listHolder = this.buildListHolder();
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
-
- ListModel listModel = this.buildListModel(listHolder);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.verifyHasNoListeners(listModel);
-
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.verifyHasListeners(listModel);
-
- listModel.removeListDataListener(synchList);
- assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- this.verifyHasNoListeners(listModel);
- }
-
- public void testGetSize() throws Exception {
- SimpleListValueModel<String> listHolder = this.buildListHolder();
- ListModel listModel = this.buildListModel(listHolder);
- this.verifyHasNoListeners(listModel);
- assertEquals(6, listModel.getSize());
-
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- this.verifyHasListeners(listModel);
- assertEquals(6, listModel.getSize());
-
- listModel.removeListDataListener(synchList);
- this.verifyHasNoListeners(listModel);
- assertEquals(6, listModel.getSize());
- }
-
- public void testGetElementAt() throws Exception {
- SimpleListValueModel<String> listHolder = this.buildListHolder();
- ListModel listModel = this.buildListModel(new SortedListValueModelWrapper<String>(listHolder));
- CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
- this.verifyHasListeners(listModel);
- assertEquals("bar", listModel.getElementAt(0));
- assertEquals("bar", synchList.get(0));
- }
-
- private void verifyHasNoListeners(ListModel listModel) throws Exception {
- boolean hasNoListeners = ((Boolean) ReflectionTools.executeMethod(listModel, "hasNoListDataListeners")).booleanValue();
- assertTrue(hasNoListeners);
- }
-
- private void verifyHasListeners(ListModel listModel) throws Exception {
- boolean hasListeners = ((Boolean) ReflectionTools.executeMethod(listModel, "hasListDataListeners")).booleanValue();
- assertTrue(hasListeners);
- }
-
- private SimpleCollectionValueModel<String> buildCollectionHolder() {
- return new SimpleCollectionValueModel<String>(this.buildCollection());
- }
-
- private Collection<String> buildCollection() {
- Bag<String> bag = new HashBag<String>();
- this.populateCollection(bag);
- return bag;
- }
-
- private SimpleListValueModel<String> buildListHolder() {
- return new SimpleListValueModel<String>(this.buildList());
- }
-
- private List<String> buildList() {
- List<String> list = new ArrayList<String>();
- this.populateCollection(list);
- return list;
- }
-
- private void populateCollection(Collection<String> c) {
- c.add("foo");
- c.add("bar");
- c.add("baz");
- c.add("joo");
- c.add("jar");
- c.add("jaz");
- }
-
- private SimpleListValueModel<String> buildListHolder2() {
- return new SimpleListValueModel<String>(this.buildList2());
- }
-
- private List<String> buildList2() {
- List<String> list = new ArrayList<String>();
- this.populateCollection2(list);
- return list;
- }
-
- private void populateCollection2(Collection<String> c) {
- c.add("tom");
- c.add("dick");
- c.add("harry");
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java
deleted file mode 100644
index ca51772dae..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.TextField;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.List;
-import java.util.ListIterator;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.Icon;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.ListModel;
-import javax.swing.WindowConstants;
-
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.common.utility.internal.swing.Displayable;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * an example UI for testing various permutations of the ListModelAdapter
- */
-@SuppressWarnings("nls")
-public class ListModelAdapterUITest {
-
- private ModifiablePropertyValueModel<TaskList> taskListHolder;
- private TextField taskTextField;
-
- public static void main(String[] args) throws Exception {
- new ListModelAdapterUITest().exec(args);
- }
-
- private ListModelAdapterUITest() {
- super();
- }
-
- private void exec(@SuppressWarnings("unused") String[] args) throws Exception {
- this.taskListHolder = new SimplePropertyValueModel<TaskList>(new TaskList());
- this.openWindow();
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setSize(800, 400);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildTaskListPanel(), BorderLayout.CENTER);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildTaskListPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(0, 1));
- taskListPanel.add(this.buildPrimitiveTaskListPanel());
- taskListPanel.add(this.buildDisplayableTaskListPanel());
- return taskListPanel;
- }
-
- private Component buildPrimitiveTaskListPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildUnsortedPrimitiveListPanel());
- taskListPanel.add(this.buildStandardSortedPrimitiveListPanel());
- taskListPanel.add(this.buildCustomSortedPrimitiveListPanel());
- return taskListPanel;
- }
-
- private Component buildDisplayableTaskListPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildUnsortedDisplayableListPanel());
- taskListPanel.add(this.buildStandardSortedDisplayableListPanel());
- taskListPanel.add(this.buildCustomSortedDisplayableListPanel());
- return taskListPanel;
- }
-
- private Component buildUnsortedPrimitiveListPanel() {
- return this.buildListPanel("primitive unsorted", this.buildUnsortedPrimitiveListModel());
- }
-
- private Component buildStandardSortedPrimitiveListPanel() {
- return this.buildListPanel("primitive sorted", this.buildStandardSortedPrimitiveListModel());
- }
-
- private Component buildCustomSortedPrimitiveListPanel() {
- return this.buildListPanel("primitive reverse sorted", this.buildCustomSortedPrimitiveListModel());
- }
-
- private Component buildUnsortedDisplayableListPanel() {
- return this.buildListPanel("displayable unsorted", this.buildUnsortedDisplayableListModel());
- }
-
- private Component buildStandardSortedDisplayableListPanel() {
- return this.buildListPanel("displayable sorted", this.buildStandardSortedDisplayableListModel());
- }
-
- private Component buildCustomSortedDisplayableListPanel() {
- return this.buildListPanel("displayable reverse sorted", this.buildCustomSortedDisplayableListModel());
- }
-
- private ListModel buildUnsortedPrimitiveListModel() {
- return new ListModelAdapter(this.buildPrimitiveTaskListAdapter());
- }
-
- private ListModel buildStandardSortedPrimitiveListModel() {
- return new ListModelAdapter(new SortedListValueModelWrapper<String>(this.buildPrimitiveTaskListAdapter()));
- }
-
- private ListModel buildCustomSortedPrimitiveListModel() {
- return new ListModelAdapter(new SortedListValueModelWrapper<String>(this.buildPrimitiveTaskListAdapter(), this.buildCustomStringComparator()));
- }
-
- private ListModel buildUnsortedDisplayableListModel() {
- return new ListModelAdapter(this.buildDisplayableTaskListAdapter());
- }
-
- private ListModel buildStandardSortedDisplayableListModel() {
- return new ListModelAdapter(new SortedListValueModelWrapper<Task>(this.buildDisplayableTaskListAdapter()));
- }
-
- private ListModel buildCustomSortedDisplayableListModel() {
- return new ListModelAdapter(new SortedListValueModelWrapper<Task>(this.buildDisplayableTaskListAdapter(), this.buildCustomTaskObjectComparator()));
- }
-
- private Component buildListPanel(String label, ListModel listModel) {
- JPanel listPanel = new JPanel(new BorderLayout());
- JLabel listLabel = new JLabel(" " + label);
- listPanel.add(listLabel, BorderLayout.NORTH);
-
- JList listBox = new JList();
- listBox.setModel(listModel);
- listBox.setDoubleBuffered(true);
- listLabel.setLabelFor(listBox);
- listPanel.add(new JScrollPane(listBox), BorderLayout.CENTER);
- return listPanel;
- }
-
- private Comparator<String> buildCustomStringComparator() {
- return new Comparator<String>() {
- public int compare(String s1, String s2) {
- return s2.compareTo(s1);
- }
- };
- }
-
- private Comparator<Task> buildCustomTaskObjectComparator() {
- return new Comparator<Task>() {
- public int compare(Task to1, Task to2) {
- return to2.displayString().compareTo(to1.displayString());
- }
- };
- }
-
- private ListValueModel<String> buildPrimitiveTaskListAdapter() {
- return new ListAspectAdapter<TaskList, String>(TaskList.TASK_NAMES_LIST, this.taskList()) {
- @Override
- protected ListIterator<String> listIterator_() {
- return this.subject.taskNames();
- }
- };
- }
-
- private ListValueModel<Task> buildDisplayableTaskListAdapter() {
- return new ListAspectAdapter<TaskList, Task>(TaskList.TASKS_LIST, this.taskList()) {
- @Override
- protected ListIterator<Task> listIterator_() {
- return this.subject.tasks();
- }
- };
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new BorderLayout());
- controlPanel.add(this.buildAddRemoveTaskPanel(), BorderLayout.CENTER);
- controlPanel.add(this.buildClearButton(), BorderLayout.EAST);
- return controlPanel;
- }
-
- private Component buildAddRemoveTaskPanel() {
- JPanel addRemoveTaskPanel = new JPanel(new BorderLayout());
- addRemoveTaskPanel.add(this.buildAddButton(), BorderLayout.WEST);
- addRemoveTaskPanel.add(this.buildTaskTextField(), BorderLayout.CENTER);
- addRemoveTaskPanel.add(this.buildRemoveButton(), BorderLayout.EAST);
- return addRemoveTaskPanel;
- }
-
- private String getTask() {
- return this.taskTextField.getText();
- }
-
- private TaskList taskList() {
- return this.taskListHolder.getValue();
- }
-
- void addTask() {
- String task = this.getTask();
- if (task.length() != 0) {
- this.taskList().addTask(task);
- }
- }
-
- void removeTask() {
- String task = this.getTask();
- if (task.length() != 0) {
- this.taskList().removeTask(task);
- }
- }
-
- void clearTasks() {
- this.taskList().clearTasks();
- }
-
- private TextField buildTaskTextField() {
- this.taskTextField = new TextField();
- return this.taskTextField;
- }
-
- private JButton buildAddButton() {
- return new JButton(this.buildAddAction());
- }
-
- private Action buildAddAction() {
- Action action = new AbstractAction("add") {
- public void actionPerformed(ActionEvent event) {
- ListModelAdapterUITest.this.addTask();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- private JButton buildRemoveButton() {
- return new JButton(this.buildRemoveAction());
- }
-
- private Action buildRemoveAction() {
- Action action = new AbstractAction("remove") {
- public void actionPerformed(ActionEvent event) {
- ListModelAdapterUITest.this.removeTask();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- private JButton buildClearButton() {
- return new JButton(this.buildClearAction());
- }
-
- private Action buildClearAction() {
- Action action = new AbstractAction("clear") {
- public void actionPerformed(ActionEvent event) {
- ListModelAdapterUITest.this.clearTasks();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- public class TaskList extends AbstractModel {
- private List<String> taskNames = new ArrayList<String>();
- private List<Task> taskObjects = new ArrayList<Task>();
- public static final String TASK_NAMES_LIST = "taskNames";
- public static final String TASKS_LIST = "tasks";
- TaskList() {
- super();
- }
- public ListIterator<String> taskNames() {
- return this.taskNames.listIterator();
- }
- public ListIterator<Task> tasks() {
- return this.taskObjects.listIterator();
- }
- public void addTask(String taskName) {
- int index = this.taskNames.size();
- this.taskNames.add(index, taskName);
- this.fireItemAdded(TASK_NAMES_LIST, index, taskName);
-
- Task taskObject = new Task(taskName);
- this.taskObjects.add(index, taskObject);
- this.fireItemAdded(TASKS_LIST, index, taskObject);
- }
- public void removeTask(String taskName) {
- int index = this.taskNames.indexOf(taskName);
- if (index != -1) {
- Object removedTask = this.taskNames.remove(index);
- this.fireItemRemoved(TASK_NAMES_LIST, index, removedTask);
- // assume the indexes match...
- Object removedTaskObject = this.taskObjects.remove(index);
- this.fireItemRemoved(TASKS_LIST, index, removedTaskObject);
- }
- }
- public void clearTasks() {
- this.taskNames.clear();
- this.fireListChanged(TASK_NAMES_LIST, this.taskNames);
- this.taskObjects.clear();
- this.fireListChanged(TASKS_LIST, this.taskObjects);
- }
- }
-
- public class Task extends AbstractModel implements Displayable {
- private String name;
- private Date creationTimeStamp;
- public Task(String name) {
- this.name = name;
- this.creationTimeStamp = new Date();
- }
- public String displayString() {
- return this.name + ": " + this.creationTimeStamp.getTime();
- }
- public Icon icon() {
- return null;
- }
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(DISPLAY_STRING_PROPERTY, old, name);
- }
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.displayString());
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java
deleted file mode 100644
index 90d50326e7..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import javax.swing.SpinnerModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ListSpinnerModelAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ListSpinnerModelAdapterTests extends TestCase {
- private ModifiablePropertyValueModel<Object> valueHolder;
- private SpinnerModel spinnerModelAdapter;
- boolean eventFired;
- private static final String[] VALUE_LIST = {"red", "green", "blue"};
- private static final String DEFAULT_VALUE = VALUE_LIST[0];
-
- public ListSpinnerModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Object>(DEFAULT_VALUE);
- this.spinnerModelAdapter = new ListSpinnerModelAdapter(this.valueHolder, VALUE_LIST) {
- @Override
- protected PropertyChangeListener buildValueChangeListener() {
- return this.buildValueChangeListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetValueSpinnerModel() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- ListSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(DEFAULT_VALUE, this.valueHolder.getValue());
- this.spinnerModelAdapter.setValue(VALUE_LIST[2]);
- assertTrue(this.eventFired);
- assertEquals(VALUE_LIST[2], this.valueHolder.getValue());
- }
-
- public void testSetValueValueHolder() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- ListSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(DEFAULT_VALUE, this.spinnerModelAdapter.getValue());
- this.valueHolder.setValue(VALUE_LIST[2]);
- assertTrue(this.eventFired);
- assertEquals(VALUE_LIST[2], this.spinnerModelAdapter.getValue());
- }
-
- public void testDefaultValue() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- ListSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(DEFAULT_VALUE, this.spinnerModelAdapter.getValue());
-
- this.valueHolder.setValue(VALUE_LIST[2]);
- assertTrue(this.eventFired);
- assertEquals(VALUE_LIST[2], this.spinnerModelAdapter.getValue());
-
- this.eventFired = false;
- this.valueHolder.setValue(null);
- assertTrue(this.eventFired);
- assertEquals(VALUE_LIST[0], this.spinnerModelAdapter.getValue());
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.spinnerModelAdapter.addChangeListener(listener);
- assertTrue(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.spinnerModelAdapter);
-
- this.spinnerModelAdapter.removeChangeListener(listener);
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
- }
-
- private void verifyHasNoListeners(SpinnerModel adapter) throws Exception {
- assertEquals(0, ((ListSpinnerModelAdapter) adapter).getChangeListeners().length);
- }
-
- private void verifyHasListeners(Object adapter) throws Exception {
- assertFalse(((ListSpinnerModelAdapter) adapter).getChangeListeners().length == 0);
- }
-
-
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java
deleted file mode 100644
index ee0bc85994..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import javax.swing.SpinnerModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.NumberSpinnerModelAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class NumberSpinnerModelAdapterTests extends TestCase {
- private ModifiablePropertyValueModel<Number> valueHolder;
- private SpinnerModel spinnerModelAdapter;
- boolean eventFired;
-
- public NumberSpinnerModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Number>(new Integer(0));
- this.spinnerModelAdapter = new NumberSpinnerModelAdapter(this.valueHolder, -33, 33, 1) {
- @Override
- protected PropertyChangeListener buildNumberChangeListener() {
- return this.buildNumberChangeListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetValueSpinnerModel() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- NumberSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- this.spinnerModelAdapter.setValue(new Integer(5));
- assertTrue(this.eventFired);
- assertEquals(new Integer(5), this.valueHolder.getValue());
- }
-
- public void testSetValueValueHolder() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- NumberSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(new Integer(0), this.spinnerModelAdapter.getValue());
- this.valueHolder.setValue(new Integer(7));
- assertTrue(this.eventFired);
- assertEquals(new Integer(7), this.spinnerModelAdapter.getValue());
- }
-
- public void testDefaultValue() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- NumberSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(new Integer(0), this.spinnerModelAdapter.getValue());
- this.valueHolder.setValue(null);
- assertTrue(this.eventFired);
- assertEquals(new Integer(-33), this.spinnerModelAdapter.getValue());
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Number> localValueHolder = (SimplePropertyValueModel<Number>) this.valueHolder;
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.spinnerModelAdapter.addChangeListener(listener);
- assertTrue(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.spinnerModelAdapter);
-
- this.spinnerModelAdapter.removeChangeListener(listener);
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
- }
-
- private void verifyHasNoListeners(SpinnerModel adapter) throws Exception {
- assertEquals(0, ((NumberSpinnerModelAdapter) adapter).getChangeListeners().length);
- }
-
- private void verifyHasListeners(Object adapter) throws Exception {
- assertFalse(((NumberSpinnerModelAdapter) adapter).getChangeListeners().length == 0);
- }
-
- public void testNullInitialValue() {
- this.valueHolder = new SimplePropertyValueModel<Number>();
- this.spinnerModelAdapter = new NumberSpinnerModelAdapter(this.valueHolder, new Integer(-33), new Integer(33), new Integer(1), new Integer(0)) {
- @Override
- protected PropertyChangeListener buildNumberChangeListener() {
- return this.buildNumberChangeListener_();
- }
- };
-
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- NumberSpinnerModelAdapterTests.this.eventFired = true;
- }
- });
- assertEquals(new Integer(0), this.spinnerModelAdapter.getValue());
- this.valueHolder.setValue(new Integer(7));
- assertTrue(this.eventFired);
- assertEquals(new Integer(7), this.spinnerModelAdapter.getValue());
- }
-
-
- // ********** inner class **********
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java
deleted file mode 100644
index 4f55864415..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import javax.swing.DefaultListModel;
-import javax.swing.ListModel;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class ObjectListSelectionModelTests extends TestCase {
- private DefaultListModel listModel;
- private ObjectListSelectionModel selectionModel;
-
- public ObjectListSelectionModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.listModel = this.buildListModel();
- this.selectionModel = this.buildSelectionModel(this.listModel);
- }
-
- private DefaultListModel buildListModel() {
- DefaultListModel lm = new DefaultListModel();
- lm.addElement("foo");
- lm.addElement("bar");
- lm.addElement("baz");
- return lm;
- }
-
- private ObjectListSelectionModel buildSelectionModel(ListModel lm) {
- return new ObjectListSelectionModel(lm);
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testListDataListener() {
- this.selectionModel.addListSelectionListener(this.buildListSelectionListener());
- this.selectionModel.setSelectionInterval(0, 0);
- assertEquals("foo", this.selectionModel.selectedValue());
- this.listModel.set(0, "jar");
- assertEquals("jar", this.selectionModel.selectedValue());
- }
-
- public void testGetSelectedValue() {
- this.selectionModel.setSelectionInterval(0, 0);
- assertEquals("foo", this.selectionModel.selectedValue());
- }
-
- public void testGetSelectedValues() {
- this.selectionModel.setSelectionInterval(0, 0);
- this.selectionModel.addSelectionInterval(2, 2);
- assertEquals(2, this.selectionModel.selectedValues().length);
- assertTrue(ArrayTools.contains(this.selectionModel.selectedValues(), "foo"));
- assertTrue(ArrayTools.contains(this.selectionModel.selectedValues(), "baz"));
- }
-
- public void testSetSelectedValue() {
- this.selectionModel.setSelectedValue("foo");
- assertEquals(0, this.selectionModel.getMinSelectionIndex());
- assertEquals(0, this.selectionModel.getMaxSelectionIndex());
- }
-
- public void testSetSelectedValues() {
- this.selectionModel.setSelectedValues(new Object[] {"foo", "baz"});
- assertEquals(0, this.selectionModel.getMinSelectionIndex());
- assertEquals(2, this.selectionModel.getMaxSelectionIndex());
- }
-
- public void testAddSelectedValue() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValue("foo");
- this.selectionModel.addSelectedValue("jaz");
- assertEquals(0, this.selectionModel.getMinSelectionIndex());
- assertEquals(5, this.selectionModel.getMaxSelectionIndex());
- assertTrue(this.selectionModel.isSelectedIndex(0));
- assertFalse(this.selectionModel.isSelectedIndex(1));
- assertFalse(this.selectionModel.isSelectedIndex(2));
- assertFalse(this.selectionModel.isSelectedIndex(3));
- assertFalse(this.selectionModel.isSelectedIndex(4));
- assertTrue(this.selectionModel.isSelectedIndex(5));
- }
-
- public void testAddSelectedValues() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValue("foo");
- this.selectionModel.addSelectedValues(new Object[] {"bar", "jar"});
- assertEquals(0, this.selectionModel.getMinSelectionIndex());
- assertEquals(4, this.selectionModel.getMaxSelectionIndex());
- assertTrue(this.selectionModel.isSelectedIndex(0));
- assertTrue(this.selectionModel.isSelectedIndex(1));
- assertFalse(this.selectionModel.isSelectedIndex(2));
- assertFalse(this.selectionModel.isSelectedIndex(3));
- assertTrue(this.selectionModel.isSelectedIndex(4));
- assertFalse(this.selectionModel.isSelectedIndex(5));
- }
-
- public void testRemoveSelectedValue() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValues(new Object[] {"foo", "baz", "jar"});
- this.selectionModel.removeSelectedValue("jar");
- assertEquals(0, this.selectionModel.getMinSelectionIndex());
- assertEquals(2, this.selectionModel.getMaxSelectionIndex());
- assertTrue(this.selectionModel.isSelectedIndex(0));
- assertFalse(this.selectionModel.isSelectedIndex(1));
- assertTrue(this.selectionModel.isSelectedIndex(2));
- assertFalse(this.selectionModel.isSelectedIndex(3));
- assertFalse(this.selectionModel.isSelectedIndex(4));
- assertFalse(this.selectionModel.isSelectedIndex(5));
- }
-
- public void testRemoveSelectedValues() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValues(new Object[] {"foo", "baz", "joo", "jar"});
- this.selectionModel.removeSelectedValues(new Object[] {"foo", "joo"});
- assertEquals(2, this.selectionModel.getMinSelectionIndex());
- assertEquals(4, this.selectionModel.getMaxSelectionIndex());
- assertFalse(this.selectionModel.isSelectedIndex(0));
- assertFalse(this.selectionModel.isSelectedIndex(1));
- assertTrue(this.selectionModel.isSelectedIndex(2));
- assertFalse(this.selectionModel.isSelectedIndex(3));
- assertTrue(this.selectionModel.isSelectedIndex(4));
- assertFalse(this.selectionModel.isSelectedIndex(5));
- }
-
- public void testGetAnchorSelectedValue() {
- this.selectionModel.setAnchorSelectionIndex(1);
- assertEquals("bar", this.selectionModel.getAnchorSelectedValue());
- }
-
- public void testGetLeadSelectedValue() {
- this.selectionModel.setSelectedValue("bar");
- assertEquals("bar", this.selectionModel.getLeadSelectedValue());
- this.selectionModel.setSelectedValues(new Object[] {"foo", "baz"});
- assertEquals("baz", this.selectionModel.getLeadSelectedValue());
- }
-
- public void testGetMinMaxSelectedValue() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValue("foo");
- this.selectionModel.addSelectedValues(new Object[] {"bar", "jar"});
- assertEquals("foo", this.selectionModel.getMinSelectedValue());
- assertEquals("jar", this.selectionModel.getMaxSelectedValue());
- }
-
- public void testValueIsSelected() {
- this.listModel.addElement("joo");
- this.listModel.addElement("jar");
- this.listModel.addElement("jaz");
- this.selectionModel.setSelectedValue("foo");
- this.selectionModel.addSelectedValues(new Object[] {"bar", "jar"});
- assertTrue(this.selectionModel.valueIsSelected("foo"));
- assertTrue(this.selectionModel.valueIsSelected("bar"));
- assertTrue(this.selectionModel.valueIsSelected("jar"));
- assertFalse(this.selectionModel.valueIsSelected("baz"));
- }
-
- public void testHasListeners() throws Exception {
- ListSelectionListener listener = this.buildListSelectionListener();
- assertEquals(0, this.listModel.getListDataListeners().length);
- this.selectionModel.addListSelectionListener(listener);
- assertEquals(1, this.listModel.getListDataListeners().length);
- this.selectionModel.removeListSelectionListener(listener);
- assertEquals(0, this.listModel.getListDataListeners().length);
- }
-
- private ListSelectionListener buildListSelectionListener() {
- return new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent e) {
- // do nothing for now...
- }
- };
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java
deleted file mode 100644
index eca1bee8dd..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.ListIterator;
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.TreeModel;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyListIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.PrimitiveListTreeModel;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class PrimitiveListTreeModelTests extends TestCase {
- TestModel testModel;
- private TreeModel treeModel;
-
- public PrimitiveListTreeModelTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.testModel = this.buildTestModel();
- this.treeModel = this.buildTreeModel();
- }
-
- private TestModel buildTestModel() {
- return new TestModel();
- }
-
- private TreeModel buildTreeModel() {
- return new PrimitiveListTreeModel(this.buildListValueModel()) {
- @Override
- protected void primitiveChanged(int index, Object newValue) {
- if ( ! newValue.equals("")) {
- PrimitiveListTreeModelTests.this.testModel.replaceName(index, (String) newValue);
- }
- }
- @Override
- protected ListChangeListener buildListChangeListener() {
- return this.buildListChangeListener_();
- }
- };
- }
-
- private ListValueModel<?> buildListValueModel() {
- return new ListAspectAdapter<TestModel, String>(TestModel.NAMES_LIST, this.testModel) {
- @Override
- protected ListIterator<String> listIterator_() {
- return this.subject.names();
- }
- @Override
- public String get(int index) {
- return this.subject.getName(index);
- }
- @Override
- public int size() {
- return this.subject.namesSize();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testAddPrimitive() {
- this.treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesInserted(TreeModelEvent e) {
- PrimitiveListTreeModelTests.this.verifyTreeModelEvent(e, new int[] {0}, new String[] {"foo"});
- }
- });
- this.testModel.addName("foo");
- }
-
- public void testRemovePrimitive() {
- this.testModel.addName("foo");
- this.testModel.addName("bar");
- this.testModel.addName("baz");
- this.treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesRemoved(TreeModelEvent e) {
- PrimitiveListTreeModelTests.this.verifyTreeModelEvent(e, new int[] {1}, new String[] {"bar"});
- }
- });
- String name = this.testModel.removeName(1);
- assertEquals("bar", name);
- }
-
- public void testReplacePrimitive() {
- this.testModel.addName("foo");
- this.testModel.addName("bar");
- this.testModel.addName("baz");
- this.treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesChanged(TreeModelEvent e) {
- PrimitiveListTreeModelTests.this.verifyTreeModelEvent(e, new int[] {1}, new String[] {"jar"});
- }
- });
- String name = this.testModel.replaceName(1, "jar");
- assertEquals("bar", name);
- }
-
- void verifyTreeModelEvent(TreeModelEvent e, int[] expectedChildIndices, String[] expectedNames) {
- assertTrue(Arrays.equals(expectedChildIndices, e.getChildIndices()));
- Object[] actualChildren = e.getChildren();
- assertEquals(expectedNames.length, actualChildren.length);
- for (int i = 0; i < expectedNames.length; i++) {
- DefaultMutableTreeNode node = (DefaultMutableTreeNode) actualChildren[i];
- assertEquals(expectedNames[i], node.getUserObject());
- }
- assertEquals(1, e.getPath().length);
- assertEquals(this.treeModel.getRoot(), e.getPath()[0]);
- assertEquals(this.treeModel, e.getSource());
- }
-
-
-// ********** inner classes **********
-
- class TestModel extends AbstractModel {
- private final List<String> names;
- static final String NAMES_LIST = "names";
-
- TestModel() {
- super();
- this.names = new ArrayList<String>();
- }
-
- public ListIterator<String> names() {
- return new ReadOnlyListIterator<String>(this.names);
- }
- public int namesSize() {
- return this.names.size();
- }
- public String getName(int index) {
- return this.names.get(index);
- }
- public void addName(int index, String name) {
- this.addItemToList(index, name, this.names, NAMES_LIST);
- }
- public void addName(String name) {
- this.addName(this.namesSize(), name);
- }
- public void addNames(int index, List<String> list) {
- this.addItemsToList(index, this.names, list, NAMES_LIST);
- }
- public void addNames(List<String> list) {
- this.addNames(this.namesSize(), list);
- }
- public String removeName(int index) {
- return this.removeItemFromList(index, this.names, NAMES_LIST);
- }
- public List<String> removeNames(int index, int length) {
- return this.removeItemsFromList(index, length, this.names, NAMES_LIST);
- }
- public String replaceName(int index, String newName) {
- return this.setItemInList(index, newName, this.names, NAMES_LIST);
- }
- }
-
-
- public class TestTreeModelListener implements TreeModelListener {
- public void treeNodesChanged(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeNodesInserted(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeNodesRemoved(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeStructureChanged(TreeModelEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java
deleted file mode 100644
index fd9749bbce..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import javax.swing.ButtonModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import javax.swing.event.EventListenerList;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.RadioButtonModelAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class RadioButtonModelAdapterTests extends TestCase {
- private ModifiablePropertyValueModel<Object> valueHolder;
-
- private ButtonModel redButtonModelAdapter;
- private ChangeListener redListener;
- boolean redEventFired;
-
- private ButtonModel greenButtonModelAdapter;
- private ChangeListener greenListener;
- boolean greenEventFired;
-
- private ButtonModel blueButtonModelAdapter;
- private ChangeListener blueListener;
- boolean blueEventFired;
-
-// private ButtonGroup buttonGroup; // DO NOT use a ButtonGroup
-
- private static final String RED = "red";
- private static final String GREEN = "green";
- private static final String BLUE = "blue";
-
- public RadioButtonModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Object>(null);
-// buttonGroup = new ButtonGroup();
-
- this.redButtonModelAdapter = this.buildButtonModel(this.valueHolder, RED);
-// this.redButtonModelAdapter.setGroup(buttonGroup);
- this.redListener = new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- RadioButtonModelAdapterTests.this.redEventFired = true;
- }
- };
-
- this.greenButtonModelAdapter = this.buildButtonModel(this.valueHolder, GREEN);
-// this.greenButtonModelAdapter.setGroup(buttonGroup);
- this.greenListener = new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- RadioButtonModelAdapterTests.this.greenEventFired = true;
- }
- };
-
- this.blueButtonModelAdapter = this.buildButtonModel(this.valueHolder, BLUE);
-// this.blueButtonModelAdapter.setGroup(buttonGroup);
- this.blueListener = new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- RadioButtonModelAdapterTests.this.blueEventFired = true;
- }
- };
-
- this.clearFlags();
- }
-
- private ButtonModel buildButtonModel(ModifiablePropertyValueModel<Object> pvm, Object buttonValue) {
- return new RadioButtonModelAdapter(pvm, buttonValue) {
- @Override
- protected PropertyChangeListener buildBooleanChangeListener() {
- return this.buildBooleanChangeListener_();
- }
- };
- }
-
- private void listenToModelAdapters() {
- this.redButtonModelAdapter.addChangeListener(this.redListener);
- this.greenButtonModelAdapter.addChangeListener(this.greenListener);
- this.blueButtonModelAdapter.addChangeListener(this.blueListener);
- }
-
- private void clearFlags() {
- this.redEventFired = false;
- this.greenEventFired = false;
- this.blueEventFired = false;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetSelected() throws Exception {
- this.listenToModelAdapters();
-
- this.greenButtonModelAdapter.setSelected(true);
- assertFalse(this.redEventFired);
- assertTrue(this.greenEventFired);
- assertFalse(this.blueEventFired);
- assertEquals(GREEN, this.valueHolder.getValue());
-
- this.clearFlags();
- this.blueButtonModelAdapter.setSelected(true);
- assertFalse(this.redEventFired);
- assertTrue(this.greenEventFired);
- assertTrue(this.blueEventFired);
- assertEquals(BLUE, this.valueHolder.getValue());
-
- this.clearFlags();
- this.redButtonModelAdapter.setSelected(true);
- assertTrue(this.redEventFired);
- assertFalse(this.greenEventFired);
- assertTrue(this.blueEventFired);
- assertEquals(RED, this.valueHolder.getValue());
- }
-
- public void testSetValue() throws Exception {
- this.listenToModelAdapters();
-
- this.greenButtonModelAdapter.setSelected(true);
-
- this.clearFlags();
- this.valueHolder.setValue(BLUE);
- assertFalse(this.redEventFired);
- assertTrue(this.greenEventFired);
- assertTrue(this.blueEventFired);
- assertFalse(this.redButtonModelAdapter.isSelected());
- assertFalse(this.greenButtonModelAdapter.isSelected());
- assertTrue(this.blueButtonModelAdapter.isSelected());
-
- this.clearFlags();
- this.valueHolder.setValue(RED);
- assertTrue(this.redEventFired);
- assertFalse(this.greenEventFired);
- assertTrue(this.blueEventFired);
- assertTrue(this.redButtonModelAdapter.isSelected());
- assertFalse(this.greenButtonModelAdapter.isSelected());
- assertFalse(this.blueButtonModelAdapter.isSelected());
- }
-
- public void testDefaultValue() throws Exception {
- this.listenToModelAdapters();
-
- this.valueHolder.setValue(GREEN);
- assertFalse(this.redButtonModelAdapter.isSelected());
- assertTrue(this.greenButtonModelAdapter.isSelected());
- assertFalse(this.blueButtonModelAdapter.isSelected());
-
- this.clearFlags();
- this.valueHolder.setValue(null);
- assertFalse(this.redEventFired);
- assertTrue(this.greenEventFired);
- assertFalse(this.blueEventFired);
- assertFalse(this.redButtonModelAdapter.isSelected());
- assertFalse(this.greenButtonModelAdapter.isSelected());
- assertFalse(this.blueButtonModelAdapter.isSelected());
-
- this.clearFlags();
- this.valueHolder.setValue(BLUE);
- assertFalse(this.redEventFired);
- assertFalse(this.greenEventFired);
- assertTrue(this.blueEventFired);
- assertFalse(this.redButtonModelAdapter.isSelected());
- assertFalse(this.greenButtonModelAdapter.isSelected());
- assertTrue(this.blueButtonModelAdapter.isSelected());
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.redButtonModelAdapter);
- this.verifyHasNoListeners(this.greenButtonModelAdapter);
- this.verifyHasNoListeners(this.blueButtonModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.redButtonModelAdapter.addChangeListener(listener);
- assertTrue(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.redButtonModelAdapter);
- this.verifyHasNoListeners(this.greenButtonModelAdapter);
- this.verifyHasNoListeners(this.blueButtonModelAdapter);
-
- this.redButtonModelAdapter.removeChangeListener(listener);
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.redButtonModelAdapter);
- this.verifyHasNoListeners(this.greenButtonModelAdapter);
- this.verifyHasNoListeners(this.blueButtonModelAdapter);
- }
-
- private void verifyHasNoListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ReflectionTools.getFieldValue(model, "listenerList");
- assertEquals(0, listenerList.getListenerList().length);
- }
-
- private void verifyHasListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ReflectionTools.getFieldValue(model, "listenerList");
- assertFalse(listenerList.getListenerList().length == 0);
- }
-
-
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java
deleted file mode 100644
index 9bc19631d7..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ButtonModel;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JRadioButton;
-import javax.swing.WindowConstants;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.RadioButtonModelAdapter;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-
-/**
- * Play around with a set of radio buttons.
- */
-@SuppressWarnings("nls")
-public class RadioButtonModelAdapterUITest {
-
- private TestModel testModel;
- private ModifiablePropertyValueModel<TestModel> testModelHolder;
- private ModifiablePropertyValueModel<Object> colorHolder;
- private ButtonModel redButtonModel;
- private ButtonModel greenButtonModel;
- private ButtonModel blueButtonModel;
-
- public static void main(String[] args) throws Exception {
- new RadioButtonModelAdapterUITest().exec();
- }
-
- private RadioButtonModelAdapterUITest() {
- super();
- }
-
- private void exec() throws Exception {
- this.testModel = new TestModel();
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
- this.colorHolder = this.buildColorHolder(this.testModelHolder);
- this.redButtonModel = this.buildRadioButtonModelAdapter(this.colorHolder, TestModel.RED);
- this.greenButtonModel = this.buildRadioButtonModelAdapter(this.colorHolder, TestModel.GREEN);
- this.blueButtonModel = this.buildRadioButtonModelAdapter(this.colorHolder, TestModel.BLUE);
- this.openWindow();
- }
-
- private ModifiablePropertyValueModel<Object> buildColorHolder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, Object>(subjectHolder, TestModel.COLOR_PROPERTY) {
- @Override
- protected Object buildValue_() {
- return this.subject.getColor();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setColor((String) value);
- }
- };
- }
-
- private ButtonModel buildRadioButtonModelAdapter(ModifiablePropertyValueModel<Object> colorPVM, String color) {
- return new RadioButtonModelAdapter(colorPVM, color);
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setSize(400, 100);
- window.setLocation(200, 200);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildRadioButtonPanel(), BorderLayout.NORTH);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildRadioButtonPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildRedRadioButton());
- taskListPanel.add(this.buildGreenRadioButton());
- taskListPanel.add(this.buildBlueRadioButton());
- return taskListPanel;
- }
-
- private JRadioButton buildRedRadioButton() {
- JRadioButton radioButton = new JRadioButton();
- radioButton.setText("red");
- radioButton.setModel(this.redButtonModel);
- return radioButton;
- }
-
- private JRadioButton buildGreenRadioButton() {
- JRadioButton radioButton = new JRadioButton();
- radioButton.setText("green");
- radioButton.setModel(this.greenButtonModel);
- return radioButton;
- }
-
- private JRadioButton buildBlueRadioButton() {
- JRadioButton radioButton = new JRadioButton();
- radioButton.setText("blue");
- radioButton.setModel(this.blueButtonModel);
- return radioButton;
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(1, 0));
- controlPanel.add(this.buildResetColorButton());
- controlPanel.add(this.buildClearModelButton());
- controlPanel.add(this.buildRestoreModelButton());
- controlPanel.add(this.buildPrintModelButton());
- return controlPanel;
- }
-
- private JButton buildResetColorButton() {
- return new JButton(this.buildResetColorAction());
- }
-
- private Action buildResetColorAction() {
- Action action = new AbstractAction("reset color") {
- public void actionPerformed(ActionEvent event) {
- RadioButtonModelAdapterUITest.this.resetColor();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void resetColor() {
- this.testModel.setColor(TestModel.DEFAULT_COLOR);
- }
-
- private JButton buildClearModelButton() {
- return new JButton(this.buildClearModelAction());
- }
-
- private Action buildClearModelAction() {
- Action action = new AbstractAction("clear model") {
- public void actionPerformed(ActionEvent event) {
- RadioButtonModelAdapterUITest.this.clearModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private JButton buildRestoreModelButton() {
- return new JButton(this.buildRestoreModelAction());
- }
-
- private Action buildRestoreModelAction() {
- Action action = new AbstractAction("restore model") {
- public void actionPerformed(ActionEvent event) {
- RadioButtonModelAdapterUITest.this.restoreModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private JButton buildPrintModelButton() {
- return new JButton(this.buildPrintModelAction());
- }
-
- private Action buildPrintModelAction() {
- Action action = new AbstractAction("print model") {
- public void actionPerformed(ActionEvent event) {
- RadioButtonModelAdapterUITest.this.printModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printModel() {
- System.out.println(this.testModel);
- }
-
-
- private static class TestModel extends AbstractModel {
- private String color;
- public static final String COLOR_PROPERTY = "color";
- public static final String RED = "red";
- public static final String GREEN = "green";
- public static final String BLUE = "blue";
- public static final String DEFAULT_COLOR = RED;
- public static final String[] VALID_COLORS = {
- RED,
- GREEN,
- BLUE
- };
-
- public TestModel() {
- this(DEFAULT_COLOR);
- }
- public TestModel(String color) {
- this.color = color;
- }
- public String getColor() {
- return this.color;
- }
- public void setColor(String color) {
- if ( ! ArrayTools.contains(VALID_COLORS, color)) {
- throw new IllegalArgumentException(color);
- }
- Object old = this.color;
- this.color = color;
- this.firePropertyChanged(COLOR_PROPERTY, old, color);
- }
- @Override
- public String toString() {
- return "TestModel(" + this.color + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java
deleted file mode 100644
index 72cb1d2d31..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ColumnAdapter;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.swing.TableModelAdapterTests.PersonColumnAdapter;
-
-/**
- * Make it easy to test the table model adapter and
- * renderers without any editing allowed.
- */
-public class ReadOnlyTableModelAdapterUITest extends TableModelAdapterUITest {
-
- public static void main(String[] args) throws Exception {
- new ReadOnlyTableModelAdapterUITest().exec(args);
- }
-
- protected ReadOnlyTableModelAdapterUITest() {
- super();
- }
-
- @Override
- protected ColumnAdapter buildColumnAdapter() {
- return new PersonColumnAdapter() {
- @Override
- public boolean columnIsEditable(int index) {
- return false;
- }
- };
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java
deleted file mode 100644
index 2beb3ea9d0..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import javax.swing.SpinnerModel;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.SpinnerModelAdapter;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class SpinnerModelAdapterTests extends TestCase {
- private ModifiablePropertyValueModel<Object> valueHolder;
- SpinnerModel spinnerModelAdapter;
- boolean eventFired;
-
- public SpinnerModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Object>(new Integer(0));
- this.spinnerModelAdapter = new SpinnerModelAdapter(this.valueHolder) {
- @Override
- protected PropertyChangeListener buildValueListener() {
- return this.buildValueListener_();
- }
- };
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testSetValueSpinnerModel() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- SpinnerModelAdapterTests.this.eventFired = true;
- assertEquals(SpinnerModelAdapterTests.this.spinnerModelAdapter, e.getSource());
- }
- });
- this.spinnerModelAdapter.setValue(new Integer(5));
- assertTrue(this.eventFired);
- assertEquals(new Integer(5), this.valueHolder.getValue());
- }
-
- public void testSetValueValueHolder() throws Exception {
- this.eventFired = false;
- this.spinnerModelAdapter.addChangeListener(new TestChangeListener() {
- @Override
- public void stateChanged(ChangeEvent e) {
- SpinnerModelAdapterTests.this.eventFired = true;
- assertEquals(SpinnerModelAdapterTests.this.spinnerModelAdapter, e.getSource());
- }
- });
- assertEquals(new Integer(0), this.spinnerModelAdapter.getValue());
- this.valueHolder.setValue(new Integer(7));
- assertTrue(this.eventFired);
- assertEquals(new Integer(7), this.spinnerModelAdapter.getValue());
- }
-
- public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
-
- ChangeListener listener = new TestChangeListener();
- this.spinnerModelAdapter.addChangeListener(listener);
- assertTrue(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasListeners(this.spinnerModelAdapter);
-
- this.spinnerModelAdapter.removeChangeListener(listener);
- assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
- this.verifyHasNoListeners(this.spinnerModelAdapter);
- }
-
- private void verifyHasNoListeners(Object adapter) throws Exception {
- Object delegate = ReflectionTools.getFieldValue(adapter, "delegate");
- Object[] listeners = (Object[]) ReflectionTools.executeMethod(delegate, "getChangeListeners");
- assertEquals(0, listeners.length);
- }
-
- private void verifyHasListeners(Object adapter) throws Exception {
- Object delegate = ReflectionTools.getFieldValue(adapter, "delegate");
- Object[] listeners = (Object[]) ReflectionTools.executeMethod(delegate, "getChangeListeners");
- assertFalse(listeners.length == 0);
- }
-
-
- private class TestChangeListener implements ChangeListener {
- TestChangeListener() {
- super();
- }
- public void stateChanged(ChangeEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java
deleted file mode 100644
index 0d18f92b6d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.util.Calendar;
-import java.util.Date;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JSpinner;
-import javax.swing.SpinnerModel;
-import javax.swing.WindowConstants;
-
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.DateSpinnerModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ListSpinnerModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.NumberSpinnerModelAdapter;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-/**
- * Play around with a set of spinners.
- */
-@SuppressWarnings("nls")
-public class SpinnerModelAdapterUITest {
-
- private TestModel testModel;
- private ModifiablePropertyValueModel<TestModel> testModelHolder;
-
- private ModifiablePropertyValueModel<Object> birthDateHolder;
- private SpinnerModel birthDateSpinnerModel;
-
- private ModifiablePropertyValueModel<Number> ageHolder;
- private SpinnerModel ageSpinnerModel;
-
- private ModifiablePropertyValueModel<Object> eyeColorHolder;
- private SpinnerModel eyeColorSpinnerModel;
-
-
- public static void main(String[] args) throws Exception {
- new SpinnerModelAdapterUITest().exec();
- }
-
- private SpinnerModelAdapterUITest() {
- super();
- }
-
- private void exec() throws Exception {
- this.testModel = new TestModel();
- this.testModelHolder = new SimplePropertyValueModel<TestModel>(this.testModel);
-
- this.birthDateHolder = this.buildBirthDateHolder(this.testModelHolder);
- this.birthDateSpinnerModel = this.buildBirthDateSpinnerModel(this.birthDateHolder);
-
- this.ageHolder = this.buildAgeHolder(this.testModelHolder);
- this.ageSpinnerModel = this.buildAgeSpinnerModel(this.ageHolder);
-
- this.eyeColorHolder = this.buildEyeColorHolder(this.testModelHolder);
- this.eyeColorSpinnerModel = this.buildEyeColorSpinnerModel(this.eyeColorHolder);
-
- this.openWindow();
- }
-
- private ModifiablePropertyValueModel<Object> buildBirthDateHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Object>(vm, TestModel.BIRTH_DATE_PROPERTY) {
- @Override
- protected Object buildValue_() {
- return this.subject.getBirthDate();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setBirthDate((Date) value);
- }
- };
- }
-
- private SpinnerModel buildBirthDateSpinnerModel(ModifiablePropertyValueModel<Object> valueHolder) {
- return new DateSpinnerModelAdapter(valueHolder);
- }
-
- private ModifiablePropertyValueModel<Number> buildAgeHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Number>(vm, TestModel.AGE_PROPERTY) {
- @Override
- protected Number buildValue_() {
- return new Integer(this.subject.getAge());
- }
- @Override
- protected void setValue_(Number value) {
- this.subject.setAge(value.intValue());
- }
- };
- }
-
- private SpinnerModel buildAgeSpinnerModel(ModifiablePropertyValueModel<Number> valueHolder) {
- return new NumberSpinnerModelAdapter(valueHolder, valueHolder.getValue().intValue(), TestModel.MIN_AGE, TestModel.MAX_AGE, 1);
- }
-
- private ModifiablePropertyValueModel<Object> buildEyeColorHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Object>(vm, TestModel.EYE_COLOR_PROPERTY) {
- @Override
- protected Object buildValue_() {
- return this.subject.getEyeColor();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setEyeColor((String) value);
- }
- };
- }
-
- private SpinnerModel buildEyeColorSpinnerModel(ModifiablePropertyValueModel<Object> valueHolder) {
- return new ListSpinnerModelAdapter(valueHolder, TestModel.VALID_EYE_COLORS);
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setSize(600, 100);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildSpinnerPanel(), BorderLayout.NORTH);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildSpinnerPanel() {
- JPanel taskListPanel = new JPanel(new GridLayout(1, 0));
- taskListPanel.add(this.buildBirthDateSpinner());
- taskListPanel.add(this.buildAgeSpinner());
- taskListPanel.add(this.buildEyeColorSpinner());
- return taskListPanel;
- }
-
- private JSpinner buildBirthDateSpinner() {
- return new JSpinner(this.birthDateSpinnerModel);
- }
-
- private JSpinner buildAgeSpinner() {
- return new JSpinner(this.ageSpinnerModel);
- }
-
- private JSpinner buildEyeColorSpinner() {
- return new JSpinner(this.eyeColorSpinnerModel);
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(1, 0));
- controlPanel.add(this.buildResetModelButton());
- controlPanel.add(this.buildClearModelButton());
- controlPanel.add(this.buildRestoreModelButton());
- controlPanel.add(this.buildPrintModelButton());
- return controlPanel;
- }
-
- private JButton buildResetModelButton() {
- return new JButton(this.buildResetModelAction());
- }
-
- private Action buildResetModelAction() {
- Action action = new AbstractAction("reset model") {
- public void actionPerformed(ActionEvent event) {
- SpinnerModelAdapterUITest.this.resetModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void resetModel() {
- this.testModel.setBirthDate(TestModel.DEFAULT_BIRTH_DATE);
- this.testModel.setEyeColor(TestModel.DEFAULT_EYE_COLOR);
- }
-
- private JButton buildClearModelButton() {
- return new JButton(this.buildClearModelAction());
- }
-
- private Action buildClearModelAction() {
- Action action = new AbstractAction("clear model") {
- public void actionPerformed(ActionEvent event) {
- SpinnerModelAdapterUITest.this.clearModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void clearModel() {
- this.testModelHolder.setValue(null);
- }
-
- private JButton buildRestoreModelButton() {
- return new JButton(this.buildRestoreModelAction());
- }
-
- private Action buildRestoreModelAction() {
- Action action = new AbstractAction("restore model") {
- public void actionPerformed(ActionEvent event) {
- SpinnerModelAdapterUITest.this.restoreModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void restoreModel() {
- this.testModelHolder.setValue(this.testModel);
- }
-
- private JButton buildPrintModelButton() {
- return new JButton(this.buildPrintModelAction());
- }
-
- private Action buildPrintModelAction() {
- Action action = new AbstractAction("print model") {
- public void actionPerformed(ActionEvent event) {
- SpinnerModelAdapterUITest.this.printModel();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printModel() {
- System.out.println("birth date: " + this.testModel.getBirthDate());
- System.out.println("age: " + this.testModel.getAge());
- System.out.println("eyes: " + this.testModel.getEyeColor());
- }
-
-
- static class TestModel extends AbstractModel {
- private Calendar birthCal = Calendar.getInstance();
- // "virtual" properties
- public static final String BIRTH_DATE_PROPERTY = "birthDate";
- public static final String AGE_PROPERTY = "age";
- public static final Date DEFAULT_BIRTH_DATE = new Date();
- public static final int DEFAULT_AGE = 0;
- public static final int MIN_AGE = 0;
- public static final int MAX_AGE = 150;
- private String eyeColor;
- public static final String EYE_COLOR_PROPERTY = "eyeColor";
- public static final String[] VALID_EYE_COLORS = {"blue", "brown", "green", "hazel", "pink"};
- public static final String DEFAULT_EYE_COLOR = VALID_EYE_COLORS[3];
-
- TestModel() {
- this(DEFAULT_BIRTH_DATE, DEFAULT_EYE_COLOR);
- }
- public TestModel(Date birthDate, String eyeColor) {
- this.setBirthDate(birthDate);
- this.setEyeColor(eyeColor);
- }
- public Date getBirthDate() {
- return (Date) this.birthCal.getTime().clone();
- }
- public void setBirthDate(Date birthDate) {
- Date oldBirthDate = this.getBirthDate();
- int oldAge = this.getAge();
- this.birthCal.setTimeInMillis(birthDate.getTime());
- int newAge = this.getAge();
- if (newAge < MIN_AGE || newAge > MAX_AGE) {
- throw new IllegalArgumentException(birthDate.toString());
- }
- this.firePropertyChanged(BIRTH_DATE_PROPERTY, oldBirthDate, this.getBirthDate());
- this.firePropertyChanged(AGE_PROPERTY, oldAge, newAge);
- }
- public int getAge() {
- Calendar currentCal = Calendar.getInstance();
- int age = currentCal.get(Calendar.YEAR) - this.birthCal.get(Calendar.YEAR);
- if (currentCal.get(Calendar.MONTH) < this.birthCal.get(Calendar.MONTH)) {
- age--;
- } else if (currentCal.get(Calendar.MONTH) == this.birthCal.get(Calendar.MONTH)) {
- if (currentCal.get(Calendar.DAY_OF_MONTH) < this.birthCal.get(Calendar.DAY_OF_MONTH)) {
- age--;
- }
- }
- return age;
- }
- public void setAge(int newAge) {
- if (newAge < MIN_AGE || newAge > MAX_AGE) {
- throw new IllegalArgumentException(String.valueOf(newAge));
- }
-
- int oldAge = this.getAge();
- int delta = newAge - oldAge;
-
- Calendar newBirthCal = Calendar.getInstance();
- newBirthCal.setTimeInMillis(this.birthCal.getTime().getTime());
- // if the age increased, the birth date must be "decreased"; and vice versa
- newBirthCal.set(Calendar.YEAR, newBirthCal.get(Calendar.YEAR) - delta);
- this.setBirthDate(newBirthCal.getTime());
- }
- public String getEyeColor() {
- return this.eyeColor;
- }
- public void setEyeColor(String eyeColor) {
- if ( ! ArrayTools.contains(VALID_EYE_COLORS, eyeColor)) {
- throw new IllegalArgumentException(eyeColor);
- }
- Object old = this.eyeColor;
- this.eyeColor = eyeColor;
- this.firePropertyChanged(EYE_COLOR_PROPERTY, old, eyeColor);
- }
- @Override
- public String toString() {
- return "TestModel(birth: " + this.getBirthDate() + " - eyes: " + this.eyeColor + ")";
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TableModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TableModelAdapterTests.java
deleted file mode 100644
index d1eb281ea5..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TableModelAdapterTests.java
+++ /dev/null
@@ -1,641 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ColumnAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.TableModelAdapter;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class TableModelAdapterTests extends TestCase {
- private Crowd crowd;
- TableModelEvent event;
-
- public TableModelAdapterTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.crowd = this.buildCrowd();
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testGetRowCount() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- assertEquals(0, tableModelAdapter.getRowCount());
- // we need to add a listener to wake up the adapter
- tableModelAdapter.addTableModelListener(this.buildTableModelListener());
- assertEquals(this.crowd.peopleSize(), tableModelAdapter.getRowCount());
- }
-
- public void testGetColumnCount() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- assertEquals(PersonColumnAdapter.COLUMN_COUNT, tableModelAdapter.getColumnCount());
- }
-
- public void testGetValueAt() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- tableModelAdapter.addTableModelListener(this.buildTableModelListener());
-
- List<String> sortedNames = this.sortedNames();
- for (int i = 0; i < this.crowd.peopleSize(); i++) {
- assertEquals(sortedNames.get(i), tableModelAdapter.getValueAt(i, PersonColumnAdapter.NAME_COLUMN));
- }
- }
-
- public void testSetValueAt() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- this.event = null;
- tableModelAdapter.addTableModelListener(new TestTableModelListener() {
- @Override
- public void tableChanged(TableModelEvent e) {
- TableModelAdapterTests.this.event = e;
- }
- });
-
- Person person = this.crowd.personNamed("Gollum");
- assertEquals(Person.EYE_COLOR_BLUE, person.getEyeColor());
- assertFalse(person.isEvil());
- assertEquals(0, person.getRank());
-
- for (int i = 0; i < tableModelAdapter.getRowCount(); i++) {
- if (tableModelAdapter.getValueAt(i, PersonColumnAdapter.NAME_COLUMN).equals("Gollum")) {
- tableModelAdapter.setValueAt(Person.EYE_COLOR_HAZEL, i, PersonColumnAdapter.EYE_COLOR_COLUMN);
- tableModelAdapter.setValueAt(Boolean.TRUE, i, PersonColumnAdapter.EVIL_COLUMN);
- tableModelAdapter.setValueAt(new Integer(-1), i, PersonColumnAdapter.RANK_COLUMN);
- break;
- }
- }
- assertNotNull(this.event);
- assertEquals(Person.EYE_COLOR_HAZEL, person.getEyeColor());
- assertTrue(person.isEvil());
- assertEquals(-1, person.getRank());
- }
-
- public void testAddRow() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- this.event = null;
- tableModelAdapter.addTableModelListener(this.buildSingleEventListener());
- // add a person to the end of the list so we only trigger one event
- this.crowd.addPerson("Zzzzz");
- assertNotNull(this.event);
- assertEquals(TableModelEvent.INSERT, this.event.getType());
- assertEquals(TableModelEvent.ALL_COLUMNS, this.event.getColumn());
- }
-
- public void testRemoveRow() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- this.event = null;
- tableModelAdapter.addTableModelListener(this.buildSingleEventListener());
- // removing a person should only trigger one event, since a re-sort is not needed
- this.crowd.removePerson(this.crowd.personNamed("Gollum"));
- assertNotNull(this.event);
- assertEquals(TableModelEvent.DELETE, this.event.getType());
- assertEquals(TableModelEvent.ALL_COLUMNS, this.event.getColumn());
- }
-
- public void testChangeCell() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- this.event = null;
- tableModelAdapter.addTableModelListener(this.buildSingleEventListener());
- // add a person to the end of the list so we only trigger one event
- Person person = this.crowd.personNamed("Gollum");
- person.setEvil(true);
- assertNotNull(this.event);
- assertEquals(TableModelEvent.UPDATE, this.event.getType());
- assertEquals(PersonColumnAdapter.EVIL_COLUMN, this.event.getColumn());
- }
-
- public void testLazyListListener() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- TableModelListener listener = this.buildTableModelListener();
- assertTrue(this.crowd.hasNoCollectionChangeListeners(Crowd.PEOPLE_COLLECTION));
- tableModelAdapter.addTableModelListener(listener);
- assertTrue(this.crowd.hasAnyCollectionChangeListeners(Crowd.PEOPLE_COLLECTION));
- tableModelAdapter.removeTableModelListener(listener);
- assertTrue(this.crowd.hasNoCollectionChangeListeners(Crowd.PEOPLE_COLLECTION));
- }
-
- public void testLazyCellListener() throws Exception {
- TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
- TableModelListener listener = this.buildTableModelListener();
- Person person = this.crowd.personNamed("Gollum");
- assertTrue(person.hasNoPropertyChangeListeners(Person.NAME_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.BIRTH_DATE_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.EYE_COLOR_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.EVIL_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.RANK_PROPERTY));
-
- tableModelAdapter.addTableModelListener(listener);
- assertTrue(person.hasAnyPropertyChangeListeners(Person.NAME_PROPERTY));
- assertTrue(person.hasAnyPropertyChangeListeners(Person.BIRTH_DATE_PROPERTY));
- assertTrue(person.hasAnyPropertyChangeListeners(Person.EYE_COLOR_PROPERTY));
- assertTrue(person.hasAnyPropertyChangeListeners(Person.EVIL_PROPERTY));
- assertTrue(person.hasAnyPropertyChangeListeners(Person.RANK_PROPERTY));
-
- tableModelAdapter.removeTableModelListener(listener);
- assertTrue(person.hasNoPropertyChangeListeners(Person.NAME_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.BIRTH_DATE_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.EYE_COLOR_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.EVIL_PROPERTY));
- assertTrue(person.hasNoPropertyChangeListeners(Person.RANK_PROPERTY));
- }
-
- private TableModelAdapter<Person> buildTableModelAdapter() {
- return new TableModelAdapter<Person>(this.buildSortedPeopleAdapter(), this.buildColumnAdapter()) {
- @Override
- protected PropertyChangeListener buildCellListener() {
- return this.buildCellListener_();
- }
- @Override
- protected ListChangeListener buildListChangeListener() {
- return this.buildListChangeListener_();
- }
- };
- }
-
- private ListValueModel<Person> buildSortedPeopleAdapter() {
- return new SortedListValueModelAdapter<Person>(this.buildPeopleAdapter());
- }
-
- private CollectionValueModel<Person> buildPeopleAdapter() {
- return new CollectionAspectAdapter<Crowd, Person>(Crowd.PEOPLE_COLLECTION, this.crowd) {
- @Override
- protected Iterator<Person> iterator_() {
- return this.subject.people();
- }
- @Override
- protected int size_() {
- return this.subject.peopleSize();
- }
- };
- }
-
- private Crowd buildCrowd() {
- Crowd result = new Crowd();
- result.addPerson("Bilbo");
- result.addPerson("Gollum");
- result.addPerson("Frodo");
- result.addPerson("Samwise");
- return result;
- }
-
- private ColumnAdapter buildColumnAdapter() {
- return new PersonColumnAdapter();
- }
-
- private TableModelListener buildTableModelListener() {
- return new TestTableModelListener();
- }
-
- private List<String> sortedNames() {
- return new ArrayList<String>(CollectionTools.sortedSet(this.crowd.peopleNames()));
- }
-
- private TableModelListener buildSingleEventListener() {
- return new TestTableModelListener() {
- @Override
- public void tableChanged(TableModelEvent e) {
- // we expect only a single event
- if (TableModelAdapterTests.this.event == null) {
- TableModelAdapterTests.this.event = e;
- } else {
- fail("unexpected event");
- }
- }
- };
- }
-
-
- // ********** classes **********
-
- public static class PersonColumnAdapter implements ColumnAdapter {
- public static final int COLUMN_COUNT = 7;
-
- public static final int NAME_COLUMN = 0;
- public static final int BIRTH_DATE_COLUMN = 1;
- public static final int GONE_WEST_DATE_COLUMN = 2;
- public static final int EYE_COLOR_COLUMN = 3;
- public static final int EVIL_COLUMN = 4;
- public static final int RANK_COLUMN = 5;
- public static final int ADVENTURE_COUNT_COLUMN = 6;
-
- private static final String[] COLUMN_NAMES = new String[] {
- "Name",
- "Birth",
- "Gone West",
- "Eyes",
- "Evil",
- "Rank",
- "Adventures"
- };
-
-
- public int columnCount() {
- return COLUMN_COUNT;
- }
-
- public String columnName(int index) {
- return COLUMN_NAMES[index];
- }
-
- public Class<?> columnClass(int index) {
- switch (index) {
- case NAME_COLUMN: return Object.class;
- case BIRTH_DATE_COLUMN: return Date.class;
- case GONE_WEST_DATE_COLUMN: return Date.class;
- case EYE_COLOR_COLUMN: return Object.class;
- case EVIL_COLUMN: return Boolean.class;
- case RANK_COLUMN: return Integer.class;
- case ADVENTURE_COUNT_COLUMN:return Integer.class;
- default: return Object.class;
- }
- }
-
- public boolean columnIsEditable(int index) {
- return index != NAME_COLUMN;
- }
-
- public ModifiablePropertyValueModel<Object>[] cellModels(Object subject) {
- Person person = (Person) subject;
- @SuppressWarnings("unchecked")
- ModifiablePropertyValueModel<Object>[] result = new ModifiablePropertyValueModel[COLUMN_COUNT];
-
- result[NAME_COLUMN] = this.buildNameAdapter(person);
- result[BIRTH_DATE_COLUMN] = this.buildBirthDateAdapter(person);
- result[GONE_WEST_DATE_COLUMN] = this.buildGoneWestDateAdapter(person);
- result[EYE_COLOR_COLUMN] = this.buildEyeColorAdapter(person);
- result[EVIL_COLUMN] = this.buildEvilAdapter(person);
- result[RANK_COLUMN] = this.buildRankAdapter(person);
- result[ADVENTURE_COUNT_COLUMN] = this.buildAdventureCountAdapter(person);
-
- return result;
- }
-
- private ModifiablePropertyValueModel<Object> buildNameAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.NAME_PROPERTY, person) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setName((String) value);
- }
- };
- }
-
- private ModifiablePropertyValueModel<Object> buildBirthDateAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.BIRTH_DATE_PROPERTY, person) {
- @Override
- protected Date buildValue_() {
- return this.subject.getBirthDate();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setBirthDate((Date) value);
- }
- };
- }
-
- private ModifiablePropertyValueModel<Object> buildGoneWestDateAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.GONE_WEST_DATE_PROPERTY, person) {
- @Override
- protected Date buildValue_() {
- return this.subject.getGoneWestDate();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setGoneWestDate((Date) value);
- }
- };
- }
-
- private ModifiablePropertyValueModel<Object> buildEyeColorAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.EYE_COLOR_PROPERTY, person) {
- @Override
- protected String buildValue_() {
- return this.subject.getEyeColor();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setEyeColor((String) value);
- }
- };
- }
-
- private ModifiablePropertyValueModel<Object> buildEvilAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.EVIL_PROPERTY, person) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isEvil());
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setEvil(((Boolean)value).booleanValue());
- }
- };
- }
-
- private ModifiablePropertyValueModel<Object> buildRankAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.RANK_PROPERTY, person) {
- @Override
- protected Integer buildValue_() {
- return new Integer(this.subject.getRank());
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setRank(((Integer) value).intValue());
- }
- };
- }
-
- private ModifiablePropertyValueModel<Object> buildAdventureCountAdapter(Person person) {
- return new PropertyAspectAdapter<Person, Object>(Person.ADVENTURE_COUNT_PROPERTY, person) {
- @Override
- protected Integer buildValue_() {
- return new Integer(this.subject.getAdventureCount());
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setAdventureCount(((Integer) value).intValue());
- }
- };
- }
-
- }
-
-
- public static class Crowd extends AbstractModel {
- private final Collection<Person> people;
- public static final String PEOPLE_COLLECTION = "people";
-
- public Crowd() {
- super();
- this.people = new ArrayList<Person>();
- }
-
-
- public Iterator<Person> people() {
- return new CloneIterator<Person>(this.people) {
- @Override
- protected void remove(Person person) {
- Crowd.this.removePerson(person);
- }
- };
- }
-
- public int peopleSize() {
- return this.people.size();
- }
-
- public Person addPerson(String name) {
- this.checkPersonName(name);
- return this.addPerson(new Person(this, name));
- }
-
- private Person addPerson(Person person) {
- this.addItemToCollection(person, this.people, PEOPLE_COLLECTION);
- return person;
- }
-
- public void removePerson(Person person) {
- this.removeItemFromCollection(person, this.people, PEOPLE_COLLECTION);
- }
-
- public void removePeople(Collection<Person> persons) {
- this.removeItemsFromCollection(persons, this.people, PEOPLE_COLLECTION);
- }
-
- public void removePeople(Iterator<Person> persons) {
- this.removeItemsFromCollection(persons, this.people, PEOPLE_COLLECTION);
- }
-
- void checkPersonName(String personName) {
- if (personName == null) {
- throw new NullPointerException();
- }
- if (CollectionTools.contains(this.peopleNames(), personName)) {
- throw new IllegalArgumentException(personName);
- }
- }
-
- public Iterator<String> peopleNames() {
- return new TransformationIterator<Person, String>(this.people.iterator()) {
- @Override
- protected String transform(Person person) {
- return person.getName();
- }
- };
- }
-
- public Person personNamed(String name) {
- for (Iterator<Person> stream = this.people.iterator(); stream.hasNext(); ) {
- Person person = stream.next();
- if (person.getName().equals(name)) {
- return person;
- }
- }
- return null;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, String.valueOf(this.people.size()) + " people");
- }
-
- }
-
-
- public static class Person extends AbstractModel implements Comparable<Person> {
- private Crowd crowd;
- private String name;
- public static final String NAME_PROPERTY= "name";
- private Date birthDate;
- public static final String BIRTH_DATE_PROPERTY= "birthDate";
- private Date goneWestDate;
- public static final String GONE_WEST_DATE_PROPERTY= "goneWestDate";
- private String eyeColor;
- public static final String EYE_COLOR_PROPERTY= "eyeColor";
- public static final String EYE_COLOR_BLUE = "blue";
- public static final String EYE_COLOR_GREEN = "green";
- public static final String EYE_COLOR_BROWN = "brown";
- public static final String EYE_COLOR_HAZEL = "hazel";
- public static final String EYE_COLOR_PINK = "pink";
- private static Collection<String> validEyeColors;
- public static final String DEFAULT_EYE_COLOR = EYE_COLOR_BLUE;
- private boolean evil;
- public static final String EVIL_PROPERTY= "evil";
- private int rank;
- public static final String RANK_PROPERTY= "rank";
- private int adventureCount;
- public static final String ADVENTURE_COUNT_PROPERTY= "adventureCount";
-
- Person(Crowd crowd, String name) {
- super();
- this.crowd = crowd;
- this.name = name;
- this.birthDate = new Date();
- Calendar c = Calendar.getInstance();
- c.add(Calendar.YEAR, 250);
- this.goneWestDate = new Date(c.getTimeInMillis());
- this.eyeColor = DEFAULT_EYE_COLOR;
- this.evil = false;
- this.rank = 0;
- this.adventureCount = 0;
- }
-
- public static Collection<String> getValidEyeColors() {
- if (validEyeColors == null) {
- validEyeColors = buildValidEyeColors();
- }
- return validEyeColors;
- }
-
- private static Collection<String> buildValidEyeColors() {
- Collection<String> result = new ArrayList<String>();
- result.add(EYE_COLOR_BLUE);
- result.add(EYE_COLOR_GREEN);
- result.add(EYE_COLOR_BROWN);
- result.add(EYE_COLOR_HAZEL);
- result.add(EYE_COLOR_PINK);
- return result;
- }
-
- public Crowd getCrowd() {
- return this.crowd;
- }
-
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- this.crowd.checkPersonName(name);
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- public Date getBirthDate() {
- return this.birthDate;
- }
- public void setBirthDate(Date birthDate) {
- Object old = this.birthDate;
- this.birthDate = birthDate;
- this.firePropertyChanged(BIRTH_DATE_PROPERTY, old, birthDate);
- }
-
- public Date getGoneWestDate() {
- return this.goneWestDate;
- }
- public void setGoneWestDate(Date goneWestDate) {
- Object old = this.goneWestDate;
- this.goneWestDate = goneWestDate;
- this.firePropertyChanged(GONE_WEST_DATE_PROPERTY, old, goneWestDate);
- }
-
- public String getEyeColor() {
- return this.eyeColor;
- }
- public void setEyeColor(String eyeColor) {
- if (! getValidEyeColors().contains(eyeColor)) {
- throw new IllegalArgumentException(eyeColor);
- }
- Object old = this.eyeColor;
- this.eyeColor = eyeColor;
- this.firePropertyChanged(EYE_COLOR_PROPERTY, old, eyeColor);
- }
-
- public boolean isEvil() {
- return this.evil;
- }
- public void setEvil(boolean evil) {
- boolean old = this.evil;
- this.evil = evil;
- this.firePropertyChanged(EVIL_PROPERTY, old, evil);
- }
-
- public int getRank() {
- return this.rank;
- }
- public void setRank(int rank) {
- int old = this.rank;
- this.rank = rank;
- this.firePropertyChanged(RANK_PROPERTY, old, rank);
- }
-
- public int getAdventureCount() {
- return this.adventureCount;
- }
- public void setAdventureCount(int adventureCount) {
- int old = this.adventureCount;
- this.adventureCount = adventureCount;
- this.firePropertyChanged(ADVENTURE_COUNT_PROPERTY, old, adventureCount);
- }
-
- public int compareTo(Person p) {
- return this.name.compareToIgnoreCase(p.name);
- }
-
- @Override
- public String toString() {
- return this.name +
- "\tborn: " + DateFormat.getDateInstance().format(this.birthDate) +
- "\tgone west: " + DateFormat.getDateInstance().format(this.goneWestDate) +
- "\teyes: " + this.eyeColor +
- "\tevil: " + this.evil +
- "\trank: " + this.rank +
- "\tadventures: " + this.adventureCount
- ;
- }
-
- }
-
-
- private class TestTableModelListener implements TableModelListener {
- TestTableModelListener() {
- super();
- }
- public void tableChanged(TableModelEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
deleted file mode 100644
index 1fba1a6966..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
+++ /dev/null
@@ -1,733 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ButtonModel;
-import javax.swing.ComboBoxModel;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JFrame;
-import javax.swing.JList;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JSpinner;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.ListCellRenderer;
-import javax.swing.ListSelectionModel;
-import javax.swing.SpinnerModel;
-import javax.swing.UIManager;
-import javax.swing.WindowConstants;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import javax.swing.table.TableColumn;
-import javax.swing.table.TableModel;
-import javax.swing.text.Document;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleCollectionValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.CheckBoxModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ColumnAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ComboBoxModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.DateSpinnerModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.DocumentAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ListModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.NumberSpinnerModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.ObjectListSelectionModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.TableModelAdapter;
-import org.eclipse.jpt.common.utility.internal.swing.CheckBoxTableCellRenderer;
-import org.eclipse.jpt.common.utility.internal.swing.ComboBoxTableCellRenderer;
-import org.eclipse.jpt.common.utility.internal.swing.SpinnerTableCellRenderer;
-import org.eclipse.jpt.common.utility.internal.swing.TableCellEditorAdapter;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.swing.TableModelAdapterTests.Crowd;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.swing.TableModelAdapterTests.Person;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.swing.TableModelAdapterTests.PersonColumnAdapter;
-
-/**
- * an example UI for testing the TableModelAdapter
- * "name" column is read-only text field
- * "birth date" column is date text field
- * "gone west date" column is date spinner
- * "eye color" column is combo-box
- * "evil" column is check box
- * "rank" column is number text field
- * "adventure count" column is number spinner
- *
- * Note that the table model and row selection model share the same
- * list value model (the sorted people adapter)
- */
-@SuppressWarnings("nls")
-public class TableModelAdapterUITest {
- private SimpleCollectionValueModel<Object> eyeColorsHolder; // Object because it adapts to a combo-box
- private ModifiablePropertyValueModel<Crowd> crowdHolder;
- private ModifiablePropertyValueModel<Person> selectedPersonHolder;
- private ListValueModel<Person> sortedPeopleAdapter;
- private TableModel tableModel;
- private ObjectListSelectionModel rowSelectionModel;
- private Action removeAction;
- private Action renameAction;
-
- public static void main(String[] args) throws Exception {
- new TableModelAdapterUITest().exec(args);
- }
-
- protected TableModelAdapterUITest() {
- super();
- }
-
- protected void exec(@SuppressWarnings("unused") String[] args) throws Exception {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- this.eyeColorsHolder = this. buildEyeColorCollectionHolder();
- this.crowdHolder = this.buildCrowdHolder();
- this.selectedPersonHolder = this.buildSelectedPersonHolder();
- this.sortedPeopleAdapter = this.buildSortedPeopleAdapter();
- this.tableModel = this.buildTableModel();
- this.rowSelectionModel = this.buildRowSelectionModel();
- this.openWindow();
- }
-
- private SimpleCollectionValueModel<Object> buildEyeColorCollectionHolder() {
- return new SimpleCollectionValueModel<Object>(new ArrayList<Object>(Person.getValidEyeColors()));
- }
-
- private ModifiablePropertyValueModel<Crowd> buildCrowdHolder() {
- return new SimplePropertyValueModel<Crowd>(this.buildCrowd());
- }
-
- private Crowd buildCrowd() {
- Crowd crowd = new Crowd();
-
- Person p = crowd.addPerson("Bilbo");
- p.setEyeColor(Person.EYE_COLOR_BROWN);
- p.setRank(22);
- p.setAdventureCount(1);
-
- p = crowd.addPerson("Gollum");
- p.setEyeColor(Person.EYE_COLOR_PINK);
- p.setEvil(true);
- p.setRank(2);
- p.setAdventureCount(50);
-
- p = crowd.addPerson("Frodo");
- p.setEyeColor(Person.EYE_COLOR_BLUE);
- p.setRank(34);
- p.setAdventureCount(1);
-
- p = crowd.addPerson("Samwise");
- p.setEyeColor(Person.EYE_COLOR_GREEN);
- p.setRank(19);
- p.setAdventureCount(1);
-
- return crowd;
- }
-
- private ModifiablePropertyValueModel<Person> buildSelectedPersonHolder() {
- return new SimplePropertyValueModel<Person>();
- }
-
- private ListValueModel<Person> buildSortedPeopleAdapter() {
- return new SortedListValueModelWrapper<Person>(this.buildPeopleNameAdapter());
- }
-
- // the list will need to be re-sorted if a name changes
- private ListValueModel<Person> buildPeopleNameAdapter() {
- return new ItemPropertyListValueModelAdapter<Person>(this.buildPeopleAdapter(), Person.NAME_PROPERTY);
- }
-
- private CollectionValueModel<Person> buildPeopleAdapter() {
- return new CollectionAspectAdapter<Crowd, Person>(this.crowdHolder, Crowd.PEOPLE_COLLECTION) {
- @Override
- protected Iterator<Person> iterator_() {
- return this.subject.people();
- }
- @Override
- protected int size_() {
- return this.subject.peopleSize();
- }
- };
- }
-
- private TableModel buildTableModel() {
- return new TableModelAdapter<Person>(this.sortedPeopleAdapter, this.buildColumnAdapter());
- }
-
- protected ColumnAdapter buildColumnAdapter() {
- return new PersonColumnAdapter();
- }
-
- private ObjectListSelectionModel buildRowSelectionModel() {
- ObjectListSelectionModel rsm = new ObjectListSelectionModel(new ListModelAdapter(this.sortedPeopleAdapter));
- rsm.addListSelectionListener(this.buildRowSelectionListener());
- rsm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- return rsm;
- }
-
- private ListSelectionListener buildRowSelectionListener() {
- return new ListSelectionListener() {
- public void valueChanged(ListSelectionEvent e) {
- if (e.getValueIsAdjusting()) {
- return;
- }
- TableModelAdapterUITest.this.rowSelectionChanged(e);
- }
- };
- }
-
- void rowSelectionChanged(@SuppressWarnings("unused") ListSelectionEvent event) {
- Person selection = (Person) this.rowSelectionModel.selectedValue();
- this.selectedPersonHolder.setValue(selection);
- boolean personSelected = (selection != null);
- this.removeAction.setEnabled(personSelected);
- this.renameAction.setEnabled(personSelected);
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getSimpleName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setLocation(200, 200);
- window.setSize(600, 400);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildTablePane(), BorderLayout.CENTER);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildTablePane() {
- return new JScrollPane(this.buildTable());
- }
-
- private JTable buildTable() {
- JTable table = new JTable(this.tableModel);
- table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); // see Java bug 5007652
- table.setSelectionModel(this.rowSelectionModel);
- table.setDoubleBuffered(true);
- table.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
- int rowHeight = 20; // start with minimum of 20
-
- // gone west column (spinner)
- TableColumn column = table.getColumnModel().getColumn(PersonColumnAdapter.GONE_WEST_DATE_COLUMN);
- SpinnerTableCellRenderer spinnerRenderer = this.buildDateSpinnerRenderer();
- column.setCellRenderer(spinnerRenderer);
- column.setCellEditor(new TableCellEditorAdapter(this.buildDateSpinnerRenderer()));
- rowHeight = Math.max(rowHeight, spinnerRenderer.preferredHeight());
-
- // eye color column (combo-box)
- // the jdk combo-box renderer looks like a text field
- // until the user starts an edit - use a custom one
- column = table.getColumnModel().getColumn(PersonColumnAdapter.EYE_COLOR_COLUMN);
- ComboBoxTableCellRenderer eyeColorRenderer = this.buildEyeColorComboBoxRenderer();
- column.setCellRenderer(eyeColorRenderer);
- column.setCellEditor(new TableCellEditorAdapter(this.buildEyeColorComboBoxRenderer()));
- rowHeight = Math.max(rowHeight, eyeColorRenderer.preferredHeight());
-
- // evil (check box)
- // the jdk check box renderer and editor suck - use a custom ones
- column = table.getColumnModel().getColumn(PersonColumnAdapter.EVIL_COLUMN);
- CheckBoxTableCellRenderer evilRenderer = new CheckBoxTableCellRenderer();
- column.setCellRenderer(evilRenderer);
- column.setCellEditor(new TableCellEditorAdapter(new CheckBoxTableCellRenderer()));
- rowHeight = Math.max(rowHeight, evilRenderer.preferredHeight());
-
- // adventure count column (spinner)
- column = table.getColumnModel().getColumn(PersonColumnAdapter.ADVENTURE_COUNT_COLUMN);
- spinnerRenderer = this.buildNumberSpinnerRenderer();
- column.setCellRenderer(spinnerRenderer);
- column.setCellEditor(new TableCellEditorAdapter(this.buildNumberSpinnerRenderer()));
- rowHeight = Math.max(rowHeight, spinnerRenderer.preferredHeight());
-
- table.setRowHeight(rowHeight);
- return table;
- }
-
- private SpinnerTableCellRenderer buildDateSpinnerRenderer() {
- return new SpinnerTableCellRenderer(new DateSpinnerModelAdapter(new SimplePropertyValueModel<Object>()));
- }
-
- private SpinnerTableCellRenderer buildNumberSpinnerRenderer() {
- return new SpinnerTableCellRenderer(new NumberSpinnerModelAdapter(new SimplePropertyValueModel<Number>()));
- }
-
- private ComboBoxTableCellRenderer buildEyeColorComboBoxRenderer() {
- return new ComboBoxTableCellRenderer(this.buildReadOnlyEyeColorComboBoxModel(), this.buildEyeColorRenderer());
- }
-
- private ComboBoxModel buildReadOnlyEyeColorComboBoxModel() {
- return new ComboBoxModelAdapter(this.eyeColorsHolder, new SimplePropertyValueModel<Object>());
- }
-
- private ListCellRenderer buildEyeColorRenderer() {
- return new EyeColorRenderer();
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(0, 1));
- controlPanel.add(this.buildButtonPanel());
- controlPanel.add(this.buildPersonPanel());
- return controlPanel;
- }
-
- private Component buildButtonPanel() {
- JPanel buttonPanel = new JPanel(new GridLayout(1, 0));
- buttonPanel.add(this.buildAddButton());
- buttonPanel.add(this.buildRemoveButton());
- buttonPanel.add(this.buildRenameButton());
- buttonPanel.add(this.buildAddEyeColorButton());
- buttonPanel.add(this.buildPrintButton());
- buttonPanel.add(this.buildResetButton());
- return buttonPanel;
- }
-
- private Component buildPersonPanel() {
- JPanel personPanel = new JPanel(new GridLayout(1, 0));
- personPanel.add(this.buildNameTextField());
- personPanel.add(this.buildBirthDateSpinner());
- personPanel.add(this.buildGoneWestDateSpinner());
- personPanel.add(this.buildEyeColorComboBox());
- personPanel.add(this.buildEvilCheckBox());
- personPanel.add(this.buildRankSpinner());
- personPanel.add(this.buildAdventureCountSpinner());
- return personPanel;
- }
-
-
- // ********** add button **********
-
- private JButton buildAddButton() {
- return new JButton(this.buildAddAction());
- }
-
- private Action buildAddAction() {
- Action action = new AbstractAction("add") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.addPerson();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void addPerson() {
- String name = this.getNameFromUser();
- if (name != null) {
- this.setSelectedPerson(this.crowd().addPerson(name));
- }
- }
-
-
- // ********** remove button **********
-
- private JButton buildRemoveButton() {
- return new JButton(this.buildRemoveAction());
- }
-
- private Action buildRemoveAction() {
- this.removeAction = new AbstractAction("remove") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.removePerson();
- }
- };
- this.removeAction.setEnabled(false);
- return this.removeAction;
- }
-
- void removePerson() {
- Person person = this.selectedPerson();
- if (person != null) {
- this.crowd().removePerson(person);
- }
- }
-
-
- // ********** rename button **********
-
- private JButton buildRenameButton() {
- return new JButton(this.buildRenameAction());
- }
-
- private Action buildRenameAction() {
- this.renameAction = new AbstractAction("rename") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.renamePerson();
- }
- };
- this.renameAction.setEnabled(false);
- return this.renameAction;
- }
-
- void renamePerson() {
- Person person = this.selectedPerson();
- if (person != null) {
- String name = this.promptUserForName(person.getName());
- if (name != null) {
- person.setName(name);
- this.setSelectedPerson(person);
- }
- }
- }
-
-
- // ********** add eye color button **********
-
- private JButton buildAddEyeColorButton() {
- return new JButton(this.buildAddEyeColorAction());
- }
-
- private Action buildAddEyeColorAction() {
- Action action = new AbstractAction("add eye color") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.addEyeColor();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void addEyeColor() {
- String color = this.promptUserForEyeColor();
- if (color != null) {
- this.eyeColorsHolder.add(color);
- }
- }
-
- private String promptUserForEyeColor() {
- while (true) {
- String eyeColor = JOptionPane.showInputDialog("Eye Color");
- if (eyeColor == null) {
- return null; // user pressed <Cancel>
- }
- if ((eyeColor.length() == 0)) {
- JOptionPane.showMessageDialog(null, "The eye color is required.", "Invalid Eye Color", JOptionPane.ERROR_MESSAGE);
- } else if (CollectionTools.contains(this.eyeColorsHolder.iterator(), eyeColor)) {
- JOptionPane.showMessageDialog(null, "The eye color already exists.", "Invalid Eye Color", JOptionPane.ERROR_MESSAGE);
- } else {
- return eyeColor;
- }
- }
- }
-
-
- // ********** print button **********
-
- private JButton buildPrintButton() {
- return new JButton(this.buildPrintAction());
- }
-
- private Action buildPrintAction() {
- Action action = new AbstractAction("print") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.printCrowd();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void printCrowd() {
- System.out.println(this.crowd());
- for (Iterator<Person> stream = this.crowd().people(); stream.hasNext(); ) {
- System.out.println("\t" + stream.next());
- }
- }
-
-
- // ********** reset button **********
-
- private JButton buildResetButton() {
- return new JButton(this.buildResetAction());
- }
-
- private Action buildResetAction() {
- Action action = new AbstractAction("reset") {
- public void actionPerformed(ActionEvent event) {
- TableModelAdapterUITest.this.reset();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- void reset() {
- this.crowdHolder.setValue(this.buildCrowd());
- }
-
-
- // ********** new name dialog **********
-
- private String getNameFromUser() {
- return this.promptUserForName(null);
- }
-
- private String promptUserForName(@SuppressWarnings("unused") String originalName) {
- while (true) {
- String name = JOptionPane.showInputDialog("Person Name");
- if (name == null) {
- return null; // user pressed <Cancel>
- }
- if ((name.length() == 0)) {
- JOptionPane.showMessageDialog(null, "The name is required.", "Invalid Name", JOptionPane.ERROR_MESSAGE);
- } else if (CollectionTools.contains(this.crowd().peopleNames(), name)) {
- JOptionPane.showMessageDialog(null, "The name already exists.", "Invalid Name", JOptionPane.ERROR_MESSAGE);
- } else {
- return name;
- }
- }
- }
-
-
- // ********** name text field **********
-
- private Component buildNameTextField() {
- JTextField textField = new JTextField(this.buildNameDocument(), null, 0);
- textField.setEditable(false);
- return textField;
- }
-
- private Document buildNameDocument() {
- return new DocumentAdapter(this.buildNameAdapter());
- }
-
- private ModifiablePropertyValueModel<String> buildNameAdapter() {
- return new PropertyAspectAdapter<Person, String>(this.selectedPersonHolder, Person.NAME_PROPERTY) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
- @Override
- protected void setValue_(String value) {
- this.subject.setName(value);
- }
- };
- }
-
-
- // ********** birth date spinner **********
-
- private JSpinner buildBirthDateSpinner() {
- return new JSpinner(this.buildBirthDateSpinnerModel());
- }
-
- private SpinnerModel buildBirthDateSpinnerModel() {
- return new DateSpinnerModelAdapter(this.buildBirthDateAdapter());
- }
-
- private ModifiablePropertyValueModel<Object> buildBirthDateAdapter() {
- return new PropertyAspectAdapter<Person, Object>(this.selectedPersonHolder, Person.BIRTH_DATE_PROPERTY) {
- @Override
- protected Date buildValue_() {
- return this.subject.getBirthDate();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setBirthDate((Date) value);
- }
- };
- }
-
-
- // ********** gone west date spinner **********
-
- private JSpinner buildGoneWestDateSpinner() {
- return new JSpinner(this.buildGoneWestDateSpinnerModel());
- }
-
- private SpinnerModel buildGoneWestDateSpinnerModel() {
- return new DateSpinnerModelAdapter(this.buildGoneWestDateAdapter());
- }
-
- private ModifiablePropertyValueModel<Object> buildGoneWestDateAdapter() {
- return new PropertyAspectAdapter<Person, Object>(this.selectedPersonHolder, Person.GONE_WEST_DATE_PROPERTY) {
- @Override
- protected Date buildValue_() {
- return this.subject.getGoneWestDate();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setGoneWestDate((Date) value);
- }
- };
- }
-
-
- // ********** eye color combo-box **********
-
- private JComboBox buildEyeColorComboBox() {
- return new JComboBox(this.buildEyeColorComboBoxModel());
- }
-
- private ComboBoxModel buildEyeColorComboBoxModel() {
- return new ComboBoxModelAdapter(this.eyeColorsHolder, this.buildEyeColorAdapter());
- }
-
- private ModifiablePropertyValueModel<Object> buildEyeColorAdapter() {
- return new PropertyAspectAdapter<Person, Object>(this.selectedPersonHolder, Person.EYE_COLOR_PROPERTY) {
- @Override
- protected Object buildValue_() {
- return this.subject.getEyeColor();
- }
- @Override
- protected void setValue_(Object value) {
- this.subject.setEyeColor((String) value);
- }
- };
- }
-
-
- // ********** evil check box **********
-
- private JCheckBox buildEvilCheckBox() {
- JCheckBox checkBox = new JCheckBox();
- checkBox.setText("evil");
- checkBox.setModel(this.buildEvilCheckBoxModel());
- return checkBox;
- }
-
- private ButtonModel buildEvilCheckBoxModel() {
- return new CheckBoxModelAdapter(this.buildEvilAdapter());
- }
-
- private ModifiablePropertyValueModel<Boolean> buildEvilAdapter() {
- return new PropertyAspectAdapter<Person, Boolean>(this.selectedPersonHolder, Person.EVIL_PROPERTY) {
- @Override
- protected Boolean buildValue_() {
- return Boolean.valueOf(this.subject.isEvil());
- }
- @Override
- protected void setValue_(Boolean value) {
- this.subject.setEvil(value.booleanValue());
- }
- };
- }
-
-
- // ********** rank spinner **********
-
- private JSpinner buildRankSpinner() {
- return new JSpinner(this.buildRankSpinnerModel());
- }
-
- private SpinnerModel buildRankSpinnerModel() {
- return new NumberSpinnerModelAdapter(this.buildRankAdapter());
- }
-
- private ModifiablePropertyValueModel<Number> buildRankAdapter() {
- return new PropertyAspectAdapter<Person, Number>(this.selectedPersonHolder, Person.RANK_PROPERTY) {
- @Override
- protected Number buildValue_() {
- return new Integer(this.subject.getRank());
- }
- @Override
- protected void setValue_(Number value) {
- this.subject.setRank(value.intValue());
- }
- };
- }
-
-
- // ********** adventure count spinner **********
-
- private JSpinner buildAdventureCountSpinner() {
- return new JSpinner(this.buildAdventureCountSpinnerModel());
- }
-
- private SpinnerModel buildAdventureCountSpinnerModel() {
- return new NumberSpinnerModelAdapter(this.buildAdventureCountAdapter());
- }
-
- private ModifiablePropertyValueModel<Number> buildAdventureCountAdapter() {
- return new PropertyAspectAdapter<Person, Number>(this.selectedPersonHolder, Person.ADVENTURE_COUNT_PROPERTY) {
- @Override
- protected Number buildValue_() {
- return new Integer(this.subject.getAdventureCount());
- }
- @Override
- protected void setValue_(Number value) {
- this.subject.setAdventureCount(value.intValue());
- }
- };
- }
-
-
- // ********** queries **********
-
- private Crowd crowd() {
- return this.crowdHolder.getValue();
- }
-
- private Person selectedPerson() {
- if (this.rowSelectionModel.isSelectionEmpty()) {
- return null;
- }
- return (Person) this.rowSelectionModel.selectedValue();
- }
-
- private void setSelectedPerson(Person person) {
- this.rowSelectionModel.setSelectedValue(person);
- }
-
-
- // ********** custom renderer **********
-
- /**
- * This is simply an example of a renderer for the embedded combo-box.
- * It does nothing special unless you uncomment the code below....
- */
- private class EyeColorRenderer extends DefaultListCellRenderer {
- EyeColorRenderer() {
- super();
- }
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- // just do something to show the renderer is working...
- // value = ">" + value;
- return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java
deleted file mode 100644
index 247c3ae569..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java
+++ /dev/null
@@ -1,812 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.swing.Icon;
-import javax.swing.JTree;
-import javax.swing.event.TreeModelEvent;
-import javax.swing.event.TreeModelListener;
-import javax.swing.tree.TreeModel;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.IndentingPrintWriter;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.ReadOnlyIterator;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.common.utility.internal.model.value.AbstractTreeNodeValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.CollectionAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.ItemPropertyListValueModelAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.NullListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
-import org.eclipse.jpt.common.utility.internal.model.value.SimpleListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.SortedListValueModelWrapper;
-import org.eclipse.jpt.common.utility.internal.model.value.StaticPropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.TransformationListValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.TreeModelAdapter;
-import org.eclipse.jpt.common.utility.internal.swing.Displayable;
-import org.eclipse.jpt.common.utility.model.event.PropertyChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.PropertyChangeListener;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
-import org.eclipse.jpt.common.utility.model.value.ListValueModel;
-import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
-import org.eclipse.jpt.common.utility.model.value.TreeNodeValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-
-@SuppressWarnings("nls")
-public class TreeModelAdapterTests extends TestCase {
- boolean eventFired;
-
- public TreeModelAdapterTests(String name) {
- super(name);
- }
-
- public void testGetRoot() {
- TreeModel treeModel = this.buildSortedTreeModel();
- treeModel.addTreeModelListener(new TestTreeModelListener());
- TestNode rootNode = (TestNode) treeModel.getRoot();
- TestModel root = rootNode.getTestModel();
- assertEquals("root", root.getName());
-// root.dump();
-// rootNode.dump();
- }
-
- public void testGetChild() {
- TreeModel treeModel = this.buildSortedTreeModel();
- treeModel.addTreeModelListener(new TestTreeModelListener());
- TestNode rootNode = (TestNode) treeModel.getRoot();
-
- TestNode expected = rootNode.childNamed("node 1");
- TestNode actual = (TestNode) treeModel.getChild(rootNode, 1);
- assertEquals(expected, actual);
-
- expected = rootNode.childNamed("node 2");
- actual = (TestNode) treeModel.getChild(rootNode, 2);
- assertEquals(expected, actual);
- }
-
- public void testGetChildCount() {
- TreeModel treeModel = this.buildSortedTreeModel();
- treeModel.addTreeModelListener(new TestTreeModelListener());
- TestNode rootNode = (TestNode) treeModel.getRoot();
-
- assertEquals(5, treeModel.getChildCount(rootNode));
-
- TestNode node = rootNode.childNamed("node 1");
- assertEquals(1, treeModel.getChildCount(node));
- }
-
- public void testGetIndexOfChild() {
- TreeModel treeModel = this.buildSortedTreeModel();
- treeModel.addTreeModelListener(new TestTreeModelListener());
- TestNode rootNode = (TestNode) treeModel.getRoot();
-
- TestNode child = rootNode.childNamed("node 0");
- assertEquals(0, treeModel.getIndexOfChild(rootNode, child));
-
- child = rootNode.childNamed("node 1");
- assertEquals(1, treeModel.getIndexOfChild(rootNode, child));
-
- child = rootNode.childNamed("node 2");
- assertEquals(2, treeModel.getIndexOfChild(rootNode, child));
- TestNode grandchild = child.childNamed("node 2.2");
- assertEquals(2, treeModel.getIndexOfChild(child, grandchild));
- }
-
- public void testIsLeaf() {
- TreeModel treeModel = this.buildSortedTreeModel();
- treeModel.addTreeModelListener(new TestTreeModelListener());
- TestNode rootNode = (TestNode) treeModel.getRoot();
- assertFalse(treeModel.isLeaf(rootNode));
- TestNode node = rootNode.childNamed("node 1");
- assertFalse(treeModel.isLeaf(node));
- node = rootNode.childNamed("node 3");
- assertTrue(treeModel.isLeaf(node));
- }
-
-
- public void testTreeNodesChanged() {
- // the only way to trigger a "node changed" event is to use an unsorted tree;
- // a sorted tree will will trigger only "node removed" and "node inserted" events
- TreeModel treeModel = this.buildUnsortedTreeModel();
- this.eventFired = false;
- treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesChanged(TreeModelEvent e) {
- TreeModelAdapterTests.this.eventFired = true;
- }
- });
- TestNode rootNode = (TestNode) treeModel.getRoot();
- TestNode node = rootNode.childNamed("node 1");
- TestModel tm = node.getTestModel();
- tm.setName("node 1++");
- assertTrue(this.eventFired);
-
- this.eventFired = false;
- node = node.childNamed("node 1.1");
- tm = node.getTestModel();
- tm.setName("node 1.1++");
- assertTrue(this.eventFired);
- }
-
- public void testTreeNodesInserted() {
- // use an unsorted tree so the nodes are not re-shuffled...
- TreeModel treeModel = this.buildUnsortedTreeModel();
- this.eventFired = false;
- treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesInserted(TreeModelEvent e) {
- TreeModelAdapterTests.this.eventFired = true;
- }
- });
- TestNode rootNode = (TestNode) treeModel.getRoot();
- TestNode node = rootNode.childNamed("node 1");
- TestModel tm = node.getTestModel();
- tm.addChild("new child...");
- assertTrue(this.eventFired);
-
- this.eventFired = false;
- node = node.childNamed("node 1.1");
- tm = node.getTestModel();
- tm.addChild("another new child...");
- assertTrue(this.eventFired);
- }
-
- public void testTreeNodesRemoved() {
- TreeModel treeModel = this.buildUnsortedTreeModel();
- this.eventFired = false;
- treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesRemoved(TreeModelEvent e) {
- TreeModelAdapterTests.this.eventFired = true;
- }
- });
- TestNode rootNode = (TestNode) treeModel.getRoot();
- TestModel root = rootNode.getTestModel();
- root.removeChild(root.childNamed("node 3"));
- assertTrue(this.eventFired);
-
- this.eventFired = false;
- TestNode node = rootNode.childNamed("node 2");
- TestModel tm = node.getTestModel();
- tm.removeChild(tm.childNamed("node 2.2"));
- assertTrue(this.eventFired);
- }
-
- public void testTreeStructureChanged() {
- ModifiablePropertyValueModel<TreeNodeValueModel<Object>> nodeHolder = new SimplePropertyValueModel<TreeNodeValueModel<Object>>(this.buildSortedRootNode());
- TreeModel treeModel = this.buildTreeModel(nodeHolder);
- this.eventFired = false;
- treeModel.addTreeModelListener(new TestTreeModelListener() {
- @Override
- public void treeNodesInserted(TreeModelEvent e) {
- // do nothing
- }
- @Override
- public void treeNodesRemoved(TreeModelEvent e) {
- // do nothing
- }
- @Override
- public void treeStructureChanged(TreeModelEvent e) {
- TreeModelAdapterTests.this.eventFired = true;
- }
- });
- nodeHolder.setValue(this.buildUnsortedRootNode());
- assertTrue(this.eventFired);
- }
-
- /**
- * test a problem we had where removing a child from a tree would cause
- * the JTree to call #equals(Object) on each node removed (actually, it was
- * TreePath, but that was because its own #equals(Object) was called by
- * JTree); and since we had already removed the last listener from the
- * aspect adapter, the aspect adapter would say its value was null; this
- * would cause a NPE until we tweaked TreeModelAdapter to remove its
- * listeners from a node only *after* the node had been completely
- * removed from the JTree
- * @see TreeModelAdapter#removeNode(Object[], int, TreeNodeValueModel)
- * @see TreeModelAdapter#addNode(Object[], int, TreeNodeValueModel)
- */
- public void testLazyInitialization() {
- TreeModel treeModel = this.buildSpecialTreeModel();
- JTree jTree = new JTree(treeModel);
- TestNode rootNode = (TestNode) treeModel.getRoot();
- TestModel root = rootNode.getTestModel();
- // this would cause a NPE:
- root.removeChild(root.childNamed("node 3"));
- assertEquals(treeModel, jTree.getModel());
- }
-
-
- private TreeModel buildSortedTreeModel() {
- return this.buildTreeModel(this.buildSortedRootNode());
- }
-
- private TestNode buildSortedRootNode() {
- return new SortedTestNode(this.buildRoot());
- }
-
- private TreeModel buildUnsortedTreeModel() {
- return this.buildTreeModel(this.buildUnsortedRootNode());
- }
-
- private TestNode buildUnsortedRootNode() {
- return new UnsortedTestNode(this.buildRoot());
- }
-
- private TreeModel buildSpecialTreeModel() {
- return this.buildTreeModel(this.buildSpecialRootNode());
- }
-
- private TestNode buildSpecialRootNode() {
- return new SpecialTestNode(this.buildRoot());
- }
-
- private TestModel buildRoot() {
- TestModel root = new TestModel("root");
- /*Node node_0 = */root.addChild("node 0");
- TestModel node_1 = root.addChild("node 1");
- TestModel node_1_1 = node_1.addChild("node 1.1");
- /*Node node_1_1_1 = */node_1_1.addChild("node 1.1.1");
- TestModel node_2 = root.addChild("node 2");
- /*Node node_2_0 = */node_2.addChild("node 2.0");
- /*Node node_2_1 = */node_2.addChild("node 2.1");
- /*Node node_2_2 = */node_2.addChild("node 2.2");
- /*Node node_2_3 = */node_2.addChild("node 2.3");
- /*Node node_2_4 = */node_2.addChild("node 2.4");
- /*Node node_2_5 = */node_2.addChild("node 2.5");
- /*Node node_3 = */root.addChild("node 3");
- /*Node node_4 = */root.addChild("node 4");
- return root;
- }
-
-
- // ********** member classes **********
-
- /**
- * This is a typical model class with the typical change notifications
- * for #name and #children.
- */
- public static class TestModel extends AbstractModel {
-
- // the parent is immutable; the root's parent is null
- private final TestModel parent;
-
- // the name is mutable; so I guess it isn't the "primary key" :-)
- private String name;
- public static final String NAME_PROPERTY = "name";
-
- private final Collection<TestModel> children;
- public static final String CHILDREN_COLLECTION = "children";
-
-
- public TestModel(String name) { // root ctor
- this(null, name);
- }
- private TestModel(TestModel parent, String name) {
- super();
- this.parent = parent;
- this.name = name;
- this.children = new HashBag<TestModel>();
- }
-
- public TestModel getParent() {
- return this.parent;
- }
-
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- public Iterator<TestModel> children() {
- return new ReadOnlyIterator<TestModel>(this.children);
- }
- public int childrenSize() {
- return this.children.size();
- }
- public TestModel addChild(String childName) {
- TestModel child = new TestModel(this, childName);
- this.addItemToCollection(child, this.children, CHILDREN_COLLECTION);
- return child;
- }
- public TestModel[] addChildren(String[] childNames) {
- TestModel[] newChildren = new TestModel[childNames.length];
- for (int i = 0; i < childNames.length; i++) {
- newChildren[i] = new TestModel(this, childNames[i]);
- }
- this.addItemsToCollection(newChildren, this.children, CHILDREN_COLLECTION);
- return newChildren;
- }
- public void removeChild(TestModel child) {
- this.removeItemFromCollection(child, this.children, CHILDREN_COLLECTION);
- }
- public void removeChildren(TestModel[] testModels) {
- this.removeItemsFromCollection(testModels, this.children, CHILDREN_COLLECTION);
- }
- public void clearChildren() {
- this.clearCollection(this.children, CHILDREN_COLLECTION);
- }
- public TestModel childNamed(String childName) {
- for (TestModel child : this.children) {
- if (child.getName().equals(childName)) {
- return child;
- }
- }
- throw new RuntimeException("child not found: " + childName);
- }
-
- public String dumpString() {
- StringWriter sw = new StringWriter();
- IndentingPrintWriter ipw = new IndentingPrintWriter(sw);
- this.dumpOn(ipw);
- return sw.toString();
- }
- public void dumpOn(IndentingPrintWriter writer) {
- writer.println(this);
- writer.indent();
- for (TestModel child : this.children) {
- child.dumpOn(writer);
- }
- writer.undent();
- }
- public void dumpOn(OutputStream stream) {
- IndentingPrintWriter writer = new IndentingPrintWriter(new OutputStreamWriter(stream));
- this.dumpOn(writer);
- writer.flush();
- }
- public void dump() {
- this.dumpOn(System.out);
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.name);
- }
-
- }
-
-
- /**
- * This Node wraps a TestModel and converts into something that can
- * be used by TreeModelAdapter. It converts changes to the TestModel's
- * name into "state changes" to the Node; and converts the
- * TestModel's children into a ListValueModel of Nodes whose order is
- * determined by subclass implementations.
- */
- public static abstract class TestNode extends AbstractTreeNodeValueModel<Object> implements Displayable, Comparable<TestNode> {
- /** the model object wrapped by this node */
- private final TestModel testModel;
- /** this node's parent node; null for the root node */
- private final TestNode parent;
- /** this node's child nodes */
- private final ListValueModel<TreeNodeValueModel<Object>> childrenModel;
- /** a listener that notifies us when the model object's "internal state" changes */
- private final PropertyChangeListener testModelListener;
-
-
- // ********** constructors/initialization **********
-
- /**
- * root node constructor
- */
- public TestNode(TestModel testModel) {
- this(null, testModel);
- }
-
- /**
- * branch or leaf node constructor
- */
- public TestNode(TestNode parent, TestModel testModel) {
- super();
- this.parent = parent;
- this.testModel = testModel;
- this.childrenModel = this.buildChildrenModel(testModel);
- this.testModelListener = this.buildTestModelListener();
- }
-
- private PropertyChangeListener buildTestModelListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- TestNode.this.testModelChanged(e);
- }
- };
- }
-
- /**
- * subclasses decide the order of the child nodes
- */
- protected abstract ListValueModel<TreeNodeValueModel<Object>> buildChildrenModel(TestModel model);
-
- /**
- * used by subclasses;
- * transform the test model children into nodes
- */
- protected ListValueModel<TreeNodeValueModel<Object>> buildNodeAdapter(TestModel model) {
- return new TransformationListValueModel<TestModel, TreeNodeValueModel<Object>>(this.buildChildrenAdapter(model)) {
- @Override
- protected TestNode transformItem(TestModel item) {
- return TestNode.this.buildChildNode(item);
- }
- };
- }
-
- /**
- * subclasses must build a concrete node for the specified test model
- */
- protected abstract TestNode buildChildNode(TestModel childTestModel);
-
- /**
- * return a collection value model on the specified model's children
- */
- protected CollectionValueModel<TestModel> buildChildrenAdapter(TestModel model) {
- return new CollectionAspectAdapter<TestModel, TestModel>(TestModel.CHILDREN_COLLECTION, model) {
- @Override
- protected Iterator<TestModel> iterator_() {
- return this.subject.children();
- }
- @Override
- protected int size_() {
- return this.subject.childrenSize();
- }
- };
- }
-
-
- // ********** TreeNodeValueModel implementation **********
-
- public TestModel getValue() {
- return this.testModel;
- }
-
- public TreeNodeValueModel<Object> parent() {
- return this.parent;
- }
-
- public ListValueModel<TreeNodeValueModel<Object>> childrenModel() {
- return this.childrenModel;
- }
-
-
- // ********** AbstractTreeNodeValueModel implementation **********
-
- @Override
- protected void engageValue() {
- this.testModel.addPropertyChangeListener(TestModel.NAME_PROPERTY, this.testModelListener);
- }
-
- @Override
- protected void disengageValue() {
- this.testModel.removePropertyChangeListener(TestModel.NAME_PROPERTY, this.testModelListener);
- }
-
-
- // ********** Displayable implementation **********
-
- public String displayString() {
- return this.testModel.getName();
- }
-
- public Icon icon() {
- return null;
- }
-
-
- // ********** debugging support **********
-
- public String dumpString() {
- StringWriter sw = new StringWriter();
- IndentingPrintWriter ipw = new IndentingPrintWriter(sw);
- this.dumpOn(ipw);
- return sw.toString();
- }
-
- public void dumpOn(IndentingPrintWriter writer) {
- writer.println(this);
- writer.indent();
- for (Iterator<TreeNodeValueModel<Object>> stream = this.childrenModel.iterator(); stream.hasNext(); ) {
- // cast to a TestNode (i.e. this won't work with a NameTestNode in the tree)
- ((TestNode) stream.next()).dumpOn(writer);
- }
- writer.undent();
- }
-
- public void dumpOn(OutputStream stream) {
- IndentingPrintWriter writer = new IndentingPrintWriter(new OutputStreamWriter(stream));
- this.dumpOn(writer);
- writer.flush();
- }
-
- public void dump() {
- this.dumpOn(System.out);
- }
-
-
- // ********** behavior **********
-
- /**
- * the model's name has changed, forward the event to our listeners
- */
- protected void testModelChanged(PropertyChangeEvent e) {
- // we need to notify listeners that our "internal state" has changed
- this.fireStateChanged();
- // our display string stays in synch with the model's name
- this.firePropertyChanged(DISPLAY_STRING_PROPERTY, e.getOldValue(), e.getNewValue());
- }
-
-
- // ********** queries **********
-
- public TestModel getTestModel() {
- return this.testModel;
- }
-
- /**
- * testing convenience method
- */
- public TestNode childNamed(String name) {
- for (Iterator<TreeNodeValueModel<Object>> stream = this.childrenModel.iterator(); stream.hasNext(); ) {
- TreeNodeValueModel<Object> childNode = stream.next();
- if (childNode instanceof TestNode) {
- if (((TestNode) childNode).getTestModel().getName().equals(name)) {
- return (TestNode) childNode;
- }
- }
- }
- throw new IllegalArgumentException("child not found: " + name);
- }
-
-
- // ********** standard methods **********
-
- public int compareTo(TestNode o) {
- return this.displayString().compareTo(o.displayString());
- }
-
- @Override
- public String toString() {
- return "Node(" + this.testModel + ")";
- }
-
- }
-
- /**
- * concrete implementation that keeps its children sorted
- */
- public static class SortedTestNode extends TestNode {
-
- // ********** constructors **********
- public SortedTestNode(TestModel testModel) {
- super(testModel);
- }
- public SortedTestNode(TestNode parent, TestModel testModel) {
- super(parent, testModel);
- }
-
- // ********** initialization **********
- /** the list should be sorted */
- @Override
- protected ListValueModel<TreeNodeValueModel<Object>> buildChildrenModel(TestModel testModel) {
- return new SortedListValueModelWrapper<TreeNodeValueModel<Object>>(this.buildDisplayStringAdapter(testModel));
- }
- /** the display string (name) of each node can change */
- protected ListValueModel<TreeNodeValueModel<Object>> buildDisplayStringAdapter(TestModel testModel) {
- return new ItemPropertyListValueModelAdapter<TreeNodeValueModel<Object>>(this.buildNodeAdapter(testModel), DISPLAY_STRING_PROPERTY);
- }
- /** children are also sorted nodes */
- @Override
- protected TestNode buildChildNode(TestModel childNode) {
- return new SortedTestNode(this, childNode);
- }
-
- }
-
-
- /**
- * concrete implementation that leaves its children unsorted
- */
- public static class UnsortedTestNode extends TestNode {
-
- // ********** constructors **********
- public UnsortedTestNode(TestModel testModel) {
- super(testModel);
- }
- public UnsortedTestNode(TestNode parent, TestModel testModel) {
- super(parent, testModel);
- }
-
- // ********** initialization **********
- /** the list should NOT be sorted */
- @Override
- protected ListValueModel<TreeNodeValueModel<Object>> buildChildrenModel(TestModel testModel) {
- return this.buildNodeAdapter(testModel);
- }
- /** children are also unsorted nodes */
- @Override
- protected TestNode buildChildNode(TestModel childNode) {
- return new UnsortedTestNode(this, childNode);
- }
-
- }
-
-
- /**
- * concrete implementation that leaves its children unsorted
- * and has a special set of children for "node 3"
- */
- public static class SpecialTestNode extends UnsortedTestNode {
-
- // ********** constructors **********
- public SpecialTestNode(TestModel testModel) {
- super(testModel);
- }
- public SpecialTestNode(TestNode parent, TestModel testModel) {
- super(parent, testModel);
- }
-
- // ********** initialization **********
- /** return a different list of children for "node 3" */
- @Override
- protected ListValueModel<TreeNodeValueModel<Object>> buildChildrenModel(TestModel testModel) {
- if (testModel.getName().equals("node 3")) {
- return this.buildSpecialChildrenModel();
- }
- return super.buildChildrenModel(testModel);
- }
- protected ListValueModel<TreeNodeValueModel<Object>> buildSpecialChildrenModel() {
- TreeNodeValueModel<Object>[] children = new NameTestNode[1];
- children[0] = new NameTestNode(this);
- return new SimpleListValueModel<TreeNodeValueModel<Object>>(Arrays.asList(children));
- }
- /** children are also special nodes */
- @Override
- protected TestNode buildChildNode(TestModel childNode) {
- return new SpecialTestNode(this, childNode);
- }
-
- }
-
-
- public static class NameTestNode extends AbstractTreeNodeValueModel<Object> {
- private final ModifiablePropertyValueModel<String> nameAdapter;
- private final SpecialTestNode specialNode; // parent node
- private final PropertyChangeListener nameListener;
- private final ListValueModel<TreeNodeValueModel<Object>> childrenModel;
-
- // ********** construction/initialization **********
-
- public NameTestNode(SpecialTestNode specialNode) {
- super();
- this.nameListener = this.buildNameListener();
- this.specialNode = specialNode;
- this.nameAdapter = this.buildNameAdapter();
- this.childrenModel = new NullListValueModel<TreeNodeValueModel<Object>>();
- }
- protected PropertyChangeListener buildNameListener() {
- return new PropertyChangeListener() {
- public void propertyChanged(PropertyChangeEvent e) {
- NameTestNode.this.nameChanged(e);
- }
- };
- }
- protected ModifiablePropertyValueModel<String> buildNameAdapter() {
- return new PropertyAspectAdapter<TestModel, String>(TestModel.NAME_PROPERTY, this.getTestModel()) {
- @Override
- protected String buildValue_() {
- return this.subject.getName();
- }
- @Override
- protected void setValue_(String value) {
- this.subject.setName(value);
- }
- };
- }
-
- public TestModel getTestModel() {
- return this.specialNode.getTestModel();
- }
-
- // ********** TreeNodeValueModel implementation **********
-
- public String getValue() {
- return this.nameAdapter.getValue();
- }
- @Override
- public void setValue(Object value) {
- this.nameAdapter.setValue((String) value);
- }
- public TreeNodeValueModel<Object> parent() {
- return this.specialNode;
- }
- public ListValueModel<TreeNodeValueModel<Object>> childrenModel() {
- return this.childrenModel;
- }
-
- // ********** AbstractTreeNodeValueModel implementation **********
-
- @Override
- protected void engageValue() {
- this.nameAdapter.addPropertyChangeListener(PropertyValueModel.VALUE, this.nameListener);
- }
- @Override
- protected void disengageValue() {
- this.nameAdapter.removePropertyChangeListener(PropertyValueModel.VALUE, this.nameListener);
- }
-
- // ********** behavior **********
-
- protected void nameChanged(PropertyChangeEvent e) {
- // we need to notify listeners that our "value" has changed
- this.firePropertyChanged(VALUE, e.getOldValue(), e.getNewValue());
- }
- }
-
- private TreeModel buildTreeModel(TestNode root) {
- return this.buildTreeModel(new StaticPropertyValueModel<TreeNodeValueModel<Object>>(root));
- }
-
- private TreeModel buildTreeModel(PropertyValueModel<TreeNodeValueModel<Object>> rootHolder) {
- return new TreeModelAdapter<Object>(rootHolder) {
- @Override
- protected ListChangeListener buildChildrenListener() {
- return this.buildChildrenListener_();
- }
- @Override
- protected StateChangeListener buildNodeStateListener() {
- return this.buildNodeStateListener_();
- }
- @Override
- protected PropertyChangeListener buildNodeValueListener() {
- return this.buildNodeValueListener_();
- }
- @Override
- protected PropertyChangeListener buildRootListener() {
- return this.buildRootListener_();
- }
- };
- }
-
-
-
- /**
- * listener that will blow up with any event;
- * override and implement expected event methods
- */
- public class TestTreeModelListener implements TreeModelListener {
- public void treeNodesChanged(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeNodesInserted(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeNodesRemoved(TreeModelEvent e) {
- fail("unexpected event");
- }
- public void treeStructureChanged(TreeModelEvent e) {
- fail("unexpected event");
- }
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java
deleted file mode 100644
index 9ab759c561..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java
+++ /dev/null
@@ -1,425 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.model.value.swing;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.GridLayout;
-import java.awt.TextField;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTree;
-import javax.swing.WindowConstants;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-import javax.swing.tree.DefaultTreeSelectionModel;
-import javax.swing.tree.TreeModel;
-import javax.swing.tree.TreePath;
-import javax.swing.tree.TreeSelectionModel;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.EnumerationIterator;
-import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
-import org.eclipse.jpt.common.utility.internal.model.value.swing.TreeModelAdapter;
-import org.eclipse.jpt.common.utility.internal.swing.Displayable;
-import org.eclipse.jpt.common.utility.model.value.TreeNodeValueModel;
-import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.swing.TreeModelAdapterTests.SortedTestNode;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.swing.TreeModelAdapterTests.TestModel;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.swing.TreeModelAdapterTests.TestNode;
-import org.eclipse.jpt.common.utility.tests.internal.model.value.swing.TreeModelAdapterTests.UnsortedTestNode;
-
-/**
- * an example UI for testing the TreeModelAdapter
- */
-@SuppressWarnings("nls")
-public class TreeModelAdapterUITest {
-
- // hold the tree so we can restore its expansion state
- private JTree tree;
- private ModifiablePropertyValueModel<TreeNodeValueModel<Object>> rootNodeHolder;
- private boolean sorted;
- private TreeModel treeModel;
- private TreeSelectionModel treeSelectionModel;
- private TextField nameTextField;
-
- public static void main(String[] args) throws Exception {
- new TreeModelAdapterUITest().exec();
- }
-
- private TreeModelAdapterUITest() {
- super();
- }
-
- private void exec() throws Exception {
- this.rootNodeHolder = this.buildRootNodeHolder();
- this.sorted = this.rootNodeHolder.getValue() instanceof SortedTestNode;
- this.treeModel = this.buildTreeModel();
- this.treeSelectionModel = this.buildTreeSelectionModel();
- this.nameTextField = new TextField();
- this.openWindow();
- }
-
- private ModifiablePropertyValueModel<TreeNodeValueModel<Object>> buildRootNodeHolder() {
- return new SimplePropertyValueModel<TreeNodeValueModel<Object>>(this.buildSortedRootNode());
- }
-
- private TestNode buildSortedRootNode() {
- return new SortedTestNode(this.buildRoot());
- }
-
- private TestNode buildUnsortedRootNode() {
- return new UnsortedTestNode(this.buildRoot());
- }
-
- private TestModel buildRoot() {
- TestModel root = new TestModel("root");
-
- TestModel node_1 = root.addChild("node 1");
- /*Node node_1_1 = */node_1.addChild("node 1.1");
-
- TestModel node_2 = root.addChild("node 2");
- /*Node node_2_1 = */node_2.addChild("node 2.1");
- TestModel node_2_2 = node_2.addChild("node 2.2");
- /*Node node_2_2_1 = */node_2_2.addChild("node 2.2.1");
- /*Node node_2_2_2 = */node_2_2.addChild("node 2.2.2");
- /*Node node_2_3 = */node_2.addChild("node 2.3");
- /*Node node_2_4 = */node_2.addChild("node 2.4");
- /*Node node_2_5 = */node_2.addChild("node 2.5");
-
- TestModel node_3 = root.addChild("node 3");
- TestModel node_3_1 = node_3.addChild("node 3.1");
- TestModel node_3_1_1 = node_3_1.addChild("node 3.1.1");
- /*Node node_3_1_1_1 = */node_3_1_1.addChild("node 3.1.1.1");
-
- /*Node node_4 = */root.addChild("node 4");
-
- return root;
- }
-
- private TreeModel buildTreeModel() {
- return new TreeModelAdapter<Object>(this.rootNodeHolder);
- }
-
- private TreeSelectionModel buildTreeSelectionModel() {
- TreeSelectionModel tsm = new DefaultTreeSelectionModel();
- tsm.addTreeSelectionListener(this.buildTreeSelectionListener());
- tsm.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
- return tsm;
- }
-
- private TreeSelectionListener buildTreeSelectionListener() {
- return new TreeSelectionListener() {
- public void valueChanged(TreeSelectionEvent e) {
- TreeModelAdapterUITest.this.treeSelectionChanged(e);
- }
- };
- }
-
- void treeSelectionChanged(@SuppressWarnings("unused") TreeSelectionEvent e) {
- TestModel selectedTestModel = this.selectedTestModel();
- if (selectedTestModel != null) {
- this.nameTextField.setText(selectedTestModel.getName());
- }
- }
-
- private void openWindow() {
- JFrame window = new JFrame(this.getClass().getName());
- window.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
- window.addWindowListener(this.buildWindowListener());
- window.getContentPane().add(this.buildMainPanel(), "Center");
- window.setLocation(300, 300);
- window.setSize(400, 400);
- window.setVisible(true);
- }
-
- private WindowListener buildWindowListener() {
- return new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent e) {
- e.getWindow().setVisible(false);
- System.exit(0);
- }
- };
- }
-
- private Component buildMainPanel() {
- JPanel mainPanel = new JPanel(new BorderLayout());
- mainPanel.add(this.buildTreePane(), BorderLayout.CENTER);
- mainPanel.add(this.buildControlPanel(), BorderLayout.SOUTH);
- return mainPanel;
- }
-
- private Component buildTreePane() {
- return new JScrollPane(this.buildTree());
- }
-
- private JTree buildTree() {
- this.tree = new JTree(this.treeModel) {
- @Override
- public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
- return ((Displayable) value).displayString();
- }
- };
- this.tree.setSelectionModel(this.treeSelectionModel);
- this.tree.setRootVisible(true);
- this.tree.setShowsRootHandles(true);
- this.tree.setRowHeight(20);
- this.tree.setDoubleBuffered(true);
- return this.tree;
- }
-
- private Component buildControlPanel() {
- JPanel controlPanel = new JPanel(new GridLayout(0, 1));
- controlPanel.add(this.buildAddRenameNodePanel());
- controlPanel.add(this.buildMiscPanel());
- return controlPanel;
- }
-
- private Component buildAddRenameNodePanel() {
- JPanel addRenameNodePanel = new JPanel(new BorderLayout());
- addRenameNodePanel.add(this.buildAddButton(), BorderLayout.WEST);
- addRenameNodePanel.add(this.nameTextField, BorderLayout.CENTER);
- addRenameNodePanel.add(this.buildRenameButton(), BorderLayout.EAST);
- return addRenameNodePanel;
- }
-
- private Component buildMiscPanel() {
- JPanel miscPanel = new JPanel(new GridLayout(1, 0));
- miscPanel.add(this.buildClearChildrenButton());
- miscPanel.add(this.buildRemoveButton());
- miscPanel.add(this.buildResetButton());
- return miscPanel;
- }
-
- private String getName() {
- return this.nameTextField.getText();
- }
-
- // ********** queries **********
- private TestNode selectedNode() {
- if (this.treeSelectionModel.isSelectionEmpty()) {
- return null;
- }
- return (TestNode) this.treeSelectionModel.getSelectionPath().getLastPathComponent();
- }
-
- private TestModel selectedTestModel() {
- if (this.treeSelectionModel.isSelectionEmpty()) {
- return null;
- }
- return this.selectedNode().getValue();
- }
-
- private TestNode rootNode() {
- return (TestNode) this.treeModel.getRoot();
- }
-
- private TestModel root() {
- return this.rootNode().getValue();
- }
-
- private Collection<TreePath> expandedPaths() {
- Enumeration<TreePath> stream = this.tree.getExpandedDescendants(new TreePath(this.rootNode()));
- if (stream == null) {
- return Collections.emptyList();
- }
- return CollectionTools.list(new EnumerationIterator<TreePath>(stream));
- }
-
- // ********** behavior **********
- private void setSelectedNode(TestNode selectedNode) {
- this.treeSelectionModel.setSelectionPath(new TreePath(selectedNode.path()));
- }
-
- private void expandPaths(Collection<TreePath> paths) {
- for (TreePath path : paths) {
- this.tree.expandPath(path);
- }
- }
-
- // ********** add **********
- private JButton buildAddButton() {
- return new JButton(this.buildAddAction());
- }
-
- private Action buildAddAction() {
- Action action = new AbstractAction("add") {
- public void actionPerformed(ActionEvent event) {
- TreeModelAdapterUITest.this.addNode();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- /**
- * adding causes the tree to be sorted and nodes to be
- * removed and re-added; so we have to fiddle with the expansion state
- */
- void addNode() {
- TestModel selectedTestModel = this.selectedTestModel();
- if (selectedTestModel != null) {
- String name = this.getName();
- // save the expansion state and restore it after the add
- Collection<TreePath> paths = this.expandedPaths();
-
- selectedTestModel.addChild(name);
-
- this.expandPaths(paths);
- this.setSelectedNode(this.selectedNode().childNamed(name));
- }
- }
-
- // ********** remove **********
- private JButton buildRemoveButton() {
- return new JButton(this.buildRemoveAction());
- }
-
- private Action buildRemoveAction() {
- Action action = new AbstractAction("remove") {
- public void actionPerformed(ActionEvent event) {
- TreeModelAdapterUITest.this.removeNode();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- /**
- * we need to figure out which node to select after
- * the selected node is deleted
- */
- void removeNode() {
- TestModel selectedTestModel = this.selectedTestModel();
- // do not allow the root to be removed
- if ((selectedTestModel != null) && (selectedTestModel != this.root())) {
- // save the parent and index, so we can select another, nearby, node
- // once the selected node is removed
- TestNode parentNode = (TestNode) this.selectedNode().parent();
- int childIndex = parentNode.indexOfChild(this.selectedNode());
-
- selectedTestModel.getParent().removeChild(selectedTestModel);
-
- int childrenSize = parentNode.childrenSize();
- if (childIndex < childrenSize) {
- // select the child that moved up and replaced the just-deleted child
- this.setSelectedNode((TestNode) parentNode.child(childIndex));
- } else {
- if (childrenSize == 0) {
- // if there are no more children, select the parent
- this.setSelectedNode(parentNode);
- } else {
- // if the child at the bottom of the list was deleted, select the next child up
- this.setSelectedNode((TestNode) parentNode.child(childIndex - 1));
- }
- }
- }
- }
-
- // ********** rename **********
- private JButton buildRenameButton() {
- return new JButton(this.buildRenameAction());
- }
-
- private Action buildRenameAction() {
- Action action = new AbstractAction("rename") {
- public void actionPerformed(ActionEvent event) {
- TreeModelAdapterUITest.this.renameNode();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- /**
- * renaming causes the tree to be sorted and nodes to be
- * removed and re-added; so we have to fiddle with the expansion state
- */
- void renameNode() {
- TestModel selectedTestModel = this.selectedTestModel();
- if (selectedTestModel != null) {
- // save the node and re-select it after the rename
- TestNode selectedNode = this.selectedNode();
- // save the expansion state and restore it after the rename
- Collection<TreePath> paths = this.expandedPaths();
-
- selectedTestModel.setName(this.getName());
-
- this.expandPaths(paths);
- this.setSelectedNode(selectedNode);
- }
- }
-
- // ********** clear children **********
- private JButton buildClearChildrenButton() {
- return new JButton(this.buildClearChildrenAction());
- }
-
- private Action buildClearChildrenAction() {
- Action action = new AbstractAction("clear children") {
- public void actionPerformed(ActionEvent event) {
- TreeModelAdapterUITest.this.clearChildren();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- /**
- * nothing special, we just want to test #fireCollectionChanged(String)
- */
- void clearChildren() {
- TestModel selectedTestModel = this.selectedTestModel();
- if (selectedTestModel != null) {
- selectedTestModel.clearChildren();
- }
- }
-
- // ********** reset **********
- private JButton buildResetButton() {
- return new JButton(this.buildResetAction());
- }
-
- private Action buildResetAction() {
- Action action = new AbstractAction("reset") {
- public void actionPerformed(ActionEvent event) {
- TreeModelAdapterUITest.this.reset();
- }
- };
- action.setEnabled(true);
- return action;
- }
-
- /**
- * test the adapter's root node holder;
- * toggle between sorted and unsorted lists
- */
- void reset() {
- this.sorted = ! this.sorted;
- if (this.sorted) {
- this.rootNodeHolder.setValue(this.buildSortedRootNode());
- } else {
- this.rootNodeHolder.setValue(this.buildUnsortedRootNode());
- }
- this.tree.expandPath(new TreePath(this.rootNode()));
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/node/AbstractNodeTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/node/AbstractNodeTests.java
deleted file mode 100644
index 74cd629a88..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/node/AbstractNodeTests.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.node;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.common.utility.internal.node.AbstractNode;
-import org.eclipse.jpt.common.utility.internal.node.Node;
-import org.eclipse.jpt.common.utility.internal.node.Problem;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class AbstractNodeTests extends TestCase {
- private TestWorkbenchModel root;
-
- public AbstractNodeTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.root = this.buildRoot();
- }
-
- private TestWorkbenchModel buildRoot() {
- TestWorkbenchModel r = new RootTestWorkbenchModel("root");
- TestWorkbenchModel node1 = r.addTestChildNamed("node 1");
- TestWorkbenchModel node1_1 = node1.addTestChildNamed("node 1.1");
- node1_1.addTestChildNamed("node 1.1.1");
- node1_1.addTestChildNamed("node 1.1.2");
- node1_1.addTestChildNamed("node 1.1.3");
- node1.addTestChildNamed("node 1.2");
- TestWorkbenchModel node2 = r.addTestChildNamed("node 2");
- node2.addTestChildNamed("node 2.1");
- node2.addTestChildNamed("node 2.2");
- r.addTestChildNamed("node 3");
- r.addTestChildNamed("node 4");
-
- // mark the entire tree clean
- r.markEntireBranchClean();
- return r;
- }
-
- @Override
- protected void tearDown() throws Exception {
- TestTools.clear(this);
- super.tearDown();
- }
-
- public void testTestWorkbenchModel() {
- // make sure our test class works OK...
- assertNull(this.root.testChildNamed(""));
- assertNotNull(this.root.testChildNamed("node 1"));
- assertTrue(this.root.testChildNamed("node 1").isClean());
- assertTrue(this.root.testChildNamed("node 1").isCleanBranch());
- assertNotNull(this.root.testChildNamed("node 2"));
- assertTrue(this.root.testChildNamed("node 2").isClean());
- assertTrue(this.root.testChildNamed("node 2").isCleanBranch());
- assertNull(this.root.testChildNamed("node 2.1"));
-
- assertNull(this.root.testDescendantNamed(""));
- assertNotNull(this.root.testDescendantNamed("node 1"));
- assertNotNull(this.root.testDescendantNamed("node 2"));
- assertNotNull(this.root.testDescendantNamed("node 2.1"));
- assertTrue(this.root.testDescendantNamed("node 2.1").isClean());
- assertTrue(this.root.testDescendantNamed("node 2.1").isCleanBranch());
- assertNotNull(this.root.testDescendantNamed("node 1.1.3"));
- assertTrue(this.root.testDescendantNamed("node 1.1.3").isClean());
- assertTrue(this.root.testDescendantNamed("node 1.1.3").isCleanBranch());
- }
-
- public void testParentAndChildren() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- assertEquals("node 1.1.3", node.getName());
- assertEquals(0, CollectionTools.size(node.children()));
-
- node = (TestWorkbenchModel) node.getParent();
- assertEquals("node 1.1", node.getName());
- assertEquals(3, CollectionTools.size(node.children()));
-
- node = (TestWorkbenchModel) node.getParent();
- assertEquals("node 1", node.getName());
- assertEquals(2, CollectionTools.size(node.children()));
-
- node = (TestWorkbenchModel) node.getParent();
- assertEquals("root", node.getName());
- assertEquals(4, CollectionTools.size(node.children()));
-
- node = (TestWorkbenchModel) node.getParent();
- assertNull(node);
- }
-
- public void testDirty() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setSize(42);
- assertTrue(node.isDirty());
-
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- assertTrue(parent.isClean());
- assertTrue(this.root.isClean());
- }
-
- public void testDirtyUnchangedAttribute() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setSize(42);
- assertTrue(node.isDirty());
-
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- assertTrue(parent.isClean());
- assertTrue(this.root.isClean());
-
- this.root.markEntireBranchClean();
- // set size to same number - should stay clean
- node.setSize(42);
- assertTrue(node.isClean());
- assertTrue(parent.isClean());
- assertTrue(this.root.isClean());
- }
-
- public void testDirtyBranch() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setSize(42);
- assertTrue(node.isDirtyBranch());
-
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- assertTrue(parent.isDirtyBranch());
- assertTrue(this.root.isDirtyBranch());
-
- parent.setSize(77);
- assertTrue(parent.isDirty());
- assertTrue(parent.isDirtyBranch());
-
- node.markEntireBranchClean();
- assertTrue(parent.isDirty());
- assertTrue(parent.isDirtyBranch());
- }
-
- public void testDirtyBranchCleanChildDirtyParent() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setSize(42);
-
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- parent.setSize(77);
- assertTrue(parent.isDirty());
- assertTrue(parent.isDirtyBranch());
-
- // now, clean the child, but leave the parent dirty
- node.markEntireBranchClean();
- assertTrue(parent.isDirty());
- assertTrue(parent.isDirtyBranch());
- }
-
- public void testDirtyBranchCleanChildDirtyChild() {
- TestWorkbenchModel node1 = this.root.testDescendantNamed("node 1.1.1");
- node1.setSize(41);
- TestWorkbenchModel node2 = this.root.testDescendantNamed("node 1.1.2");
- node2.setSize(42);
-
- TestWorkbenchModel parent = (TestWorkbenchModel) node1.getParent();
- assertTrue(parent.isClean());
- assertTrue(parent.isDirtyBranch());
-
- // now, clean the first child, but leave the second child dirty
- node1.markEntireBranchClean();
- assertTrue(parent.isClean());
- assertTrue(parent.isDirtyBranch());
- }
-
- public void testDirtyBranchForced() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
-
- assertTrue(node.isClean());
- assertTrue(node.isCleanBranch());
- assertTrue(parent.isClean());
- assertTrue(parent.isCleanBranch());
- assertTrue(this.root.isClean());
- assertTrue(this.root.isCleanBranch());
-
- this.root.markEntireBranchDirty();
-
- assertTrue(node.isDirty());
- assertTrue(node.isDirtyBranch());
- assertTrue(parent.isDirty());
- assertTrue(parent.isDirtyBranch());
- assertTrue(this.root.isDirty());
- assertTrue(this.root.isDirtyBranch());
- }
-
- public void testDirtyTransientAttribute() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setName("BOGUS");
- assertTrue(node.isDirty());
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- assertTrue(parent.isClean());
- assertTrue(parent.isDirtyBranch());
- assertTrue(this.root.isClean());
- assertTrue(this.root.isDirtyBranch());
-
- this.root.markEntireBranchClean();
-
- this.root.validateBranch();
-
- assertTrue(this.root.problemsSize() == 0);
- assertTrue(node.branchProblems().hasNext());
- assertTrue(parent.problemsSize() == 0);
- assertTrue(parent.branchProblems().hasNext());
- assertTrue(node.problemsSize() > 0);
-
- // since problems are transient, everything should still be clean
- assertTrue(node.isClean());
- assertTrue(node.isCleanBranch());
- assertTrue(parent.isClean());
- assertTrue(parent.isCleanBranch());
- assertTrue(this.root.isClean());
- assertTrue(this.root.isCleanBranch());
- }
-
- public void testProblems() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setName("BOGUS");
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
-
- this.root.validateBranch();
-
- assertEquals(0, this.root.problemsSize());
- assertTrue(node.branchProblems().hasNext());
- assertEquals(0, parent.problemsSize());
- assertTrue(parent.branchProblems().hasNext());
- assertEquals(1, node.problemsSize());
- Problem problem1 = node.problems().next();
-
- // now create another problem that should remove the old problem
- node.setName("STILL BOGUS");
- this.root.validateBranch();
-
- assertEquals(0, this.root.problemsSize());
- assertTrue(node.branchProblems().hasNext());
- assertEquals(0, parent.problemsSize());
- assertTrue(parent.branchProblems().hasNext());
- assertEquals(1, node.problemsSize());
- Problem problem2 = node.problems().next();
- assertFalse(problem1 == problem2);
- problem1 = problem2;
-
- // now create another problem that should replace the old problem
- node.setName("STILL BOGUS");
- this.root.validateBranch();
-
- assertEquals(0, this.root.problemsSize());
- assertTrue(node.branchProblems().hasNext());
- assertEquals(0, parent.problemsSize());
- assertTrue(parent.branchProblems().hasNext());
- assertEquals(1, node.problemsSize());
- problem2 = node.problems().next();
- // the same problem should be there
- assertTrue(problem1.equals(problem2));
- }
-
- public void testBranchProblems() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setName("BOGUS");
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- parent.setName("BOGUS TOO");
- this.root.setName("BOGUS TOO TOO");
-
- this.root.validateBranch();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(3, this.root.branchProblemsSize());
- assertEquals(1, parent.problemsSize());
- assertEquals(2, parent.branchProblemsSize());
- assertEquals(1, node.problemsSize());
- assertEquals(1, node.branchProblemsSize());
-
- node.setName("okie-dokie");
-
- this.root.validateBranch();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(2, this.root.branchProblemsSize());
- assertEquals(1, parent.problemsSize());
- assertEquals(1, parent.branchProblemsSize());
- assertEquals(0, node.problemsSize());
- assertEquals(0, node.branchProblemsSize());
- }
-
- public void testClearAllBranchProblems() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setName("BOGUS");
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- parent.setName("BOGUS TOO");
- this.root.setName("BOGUS TOO TOO");
-
- this.root.validateBranch();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(3, this.root.branchProblemsSize());
- assertEquals(1, parent.problemsSize());
- assertEquals(2, parent.branchProblemsSize());
- assertEquals(1, node.problemsSize());
- assertEquals(1, node.branchProblemsSize());
-
- parent.clearAllBranchProblems();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(1, this.root.branchProblemsSize());
- assertEquals(0, parent.problemsSize());
- assertEquals(0, parent.branchProblemsSize());
- assertEquals(0, node.problemsSize());
- assertEquals(0, CollectionTools.size(node.branchProblems()));
- }
-
- public void testRemovedBranchProblems() {
- TestWorkbenchModel node = this.root.testDescendantNamed("node 1.1.3");
- node.setName("BOGUS");
- TestWorkbenchModel parent = (TestWorkbenchModel) node.getParent();
- parent.setName("BOGUS TOO");
- this.root.setName("BOGUS TOO TOO");
-
- this.root.validateBranch();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(3, CollectionTools.size(this.root.branchProblems()));
- assertEquals(1, parent.problemsSize());
- assertEquals(2, parent.branchProblemsSize());
- assertEquals(1, node.problemsSize());
- assertEquals(1, CollectionTools.size(node.branchProblems()));
-
- // completely remove a node that has problems -
- // the entire tree should recalculate its "branch" problems
- parent.removeTestChild(node);
-
- this.root.validateBranch();
-
- assertEquals(1, this.root.problemsSize());
- assertEquals(2, CollectionTools.size(this.root.branchProblems()));
- assertEquals(1, parent.problemsSize());
- assertEquals(1, parent.branchProblemsSize());
- }
-
-
- // ********** inner classes **********
-
- public class TestWorkbenchModel extends AbstractNode {
- private String name;
- public static final String NAME_PROPERTY = "name";
- private int size;
- public static final String SIZE_PROPERTY = "size";
- private Collection<TestWorkbenchModel> testChildren;
- public static final String TEST_CHILDREN_COLLECTION = "children";
-
- // ********** construction/initialization **********
- public TestWorkbenchModel(TestWorkbenchModel parent, String name) {
- super(parent);
- if (name == null) {
- throw new NullPointerException();
- }
- this.name = name;
- }
- @Override
- protected void initialize() {
- super.initialize();
- this.size = 0;
- this.testChildren = new HashBag<TestWorkbenchModel>();
- }
-
- @Override
- protected void checkParent(Node parent) {
- // do nothing
- }
-
-
- // ********** accessors **********
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- Object old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- public int getSize() {
- return this.size;
- }
- public void setSize(int size) {
- int old = this.size;
- this.size = size;
- this.firePropertyChanged(SIZE_PROPERTY, old, size);
- }
-
- public Iterator<TestWorkbenchModel> testChildren() {
- return new CloneIterator<TestWorkbenchModel>(this.testChildren) {
- @Override
- protected void remove(TestWorkbenchModel current) {
- TestWorkbenchModel.this.removeTestChild(current);
- }
- };
- }
- public int testChildrenSize() {
- return this.testChildren.size();
- }
- private TestWorkbenchModel addTestChild(TestWorkbenchModel testChild) {
- this.addItemToCollection(testChild, this.testChildren, TEST_CHILDREN_COLLECTION);
- return testChild;
- }
- public TestWorkbenchModel addTestChildNamed(String childName) {
- if (this.testChildNamed(childName) != null) {
- throw new IllegalArgumentException(childName);
- }
- return this.addTestChild(new TestWorkbenchModel(this, childName));
- }
- public void removeTestChild(TestWorkbenchModel testChild) {
- this.removeItemFromCollection(testChild, this.testChildren, TEST_CHILDREN_COLLECTION);
- }
-
- // ********** queries **********
- public String displayString() {
- return this.name;
- }
- public TestWorkbenchModel testChildNamed(String childName) {
- for (TestWorkbenchModel testChild : this.testChildren) {
- if (testChild.getName().equals(childName)) {
- return testChild;
- }
- }
- return null;
- }
- public TestWorkbenchModel testDescendantNamed(String descendantName) {
- for (TestWorkbenchModel testDescendant : this.testChildren) {
- if (testDescendant.getName().equals(descendantName)) {
- return testDescendant;
- }
- // recurse...
- testDescendant = testDescendant.testDescendantNamed(descendantName);
- if (testDescendant != null) {
- return testDescendant;
- }
- }
- return null;
- }
-
- // ********** behavior **********
- @Override
- protected void addChildrenTo(List<Node> children) {
- super.addChildrenTo(children);
- children.addAll(this.testChildren);
- }
- @Override
- protected void addProblemsTo(List<Problem> currentProblems) {
- super.addProblemsTo(currentProblems);
- // names must be all lowercase...
- for (int i = this.name.length(); i-- > 0; ) {
- char c = this.name.charAt(i);
- if (Character.isLetter(c) && ! Character.isLowerCase(c)) {
- currentProblems.add(this.buildProblem("NAME_MUST_BE_LOWERCASE", 3 ,this.name));
- return;
- }
- }
- }
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
- }
-
-
- private class RootTestWorkbenchModel extends TestWorkbenchModel {
- public RootTestWorkbenchModel(String name) {
- super(null, name);
- }
- @Override
- public Validator getValidator() {
- return Node.NULL_VALIDATOR;
- }
- }
-
-}
-
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/node/JptUtilityNodeTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/node/JptUtilityNodeTests.java
deleted file mode 100644
index 16f6dce93d..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/node/JptUtilityNodeTests.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.node;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class JptUtilityNodeTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilityNodeTests.class.getPackage().getName());
-
- suite.addTestSuite(AbstractNodeTests.class);
-
- return suite;
- }
-
- private JptUtilityNodeTests() {
- super();
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/JptUtilitySynchronizersTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/JptUtilitySynchronizersTests.java
deleted file mode 100644
index da7ad6f1f1..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/JptUtilitySynchronizersTests.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.synchronizers;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * decentralize test creation code
- */
-public class JptUtilitySynchronizersTests {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(JptUtilitySynchronizersTests.class.getPackage().getName());
-
- suite.addTestSuite(SynchronizerTests.class);
- suite.addTestSuite(SynchronousSynchronizerTests.class);
-
- return suite;
- }
-
- private JptUtilitySynchronizersTests() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/SynchronizerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/SynchronizerTests.java
deleted file mode 100644
index 8f7c67bb69..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/SynchronizerTests.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.synchronizers;
-
-import junit.framework.TestCase;
-import org.eclipse.jpt.common.utility.synchronizers.Synchronizer;
-
-public class SynchronizerTests extends TestCase {
-
- public SynchronizerTests(String name) {
- super(name);
- }
-
- public void testNullSynchronizerStart() {
- Synchronizer synchronizer = Synchronizer.Null.instance();
- synchronizer.start(); // just make sure it doesn't blow up?
- }
-
- public void testNullSynchronizerSynchronize() {
- Synchronizer synchronizer = Synchronizer.Null.instance();
- synchronizer.synchronize(); // just make sure it doesn't blow up?
- }
-
- public void testNullSynchronizerStop() {
- Synchronizer synchronizer = Synchronizer.Null.instance();
- synchronizer.stop(); // just make sure it doesn't blow up?
- }
-
- public void testNullSynchronizerToString() {
- Synchronizer synchronizer = Synchronizer.Null.instance();
- assertNotNull(synchronizer.toString());
- }
-
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java b/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java
deleted file mode 100644
index 4bec15e68c..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/src/org/eclipse/jpt/common/utility/tests/internal/synchronizers/SynchronousSynchronizerTests.java
+++ /dev/null
@@ -1,755 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.common.utility.tests.internal.synchronizers;
-
-import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.CompositeException;
-import org.eclipse.jpt.common.utility.internal.SynchronizedBoolean;
-import org.eclipse.jpt.common.utility.internal.synchronizers.SynchronousSynchronizer;
-import org.eclipse.jpt.common.utility.synchronizers.Synchronizer;
-import org.eclipse.jpt.common.utility.tests.internal.MultiThreadedTestCase;
-import org.eclipse.jpt.common.utility.tests.internal.TestTools;
-
-@SuppressWarnings("nls")
-public class SynchronousSynchronizerTests
- extends MultiThreadedTestCase
-{
- PrimaryModel1 primaryModel1;
- SecondaryModel1 secondaryModel1;
- Command command1;
- Synchronizer synchronizer1;
-
- PrimaryModel2 primaryModel2;
- SecondaryModel2 secondaryModel2;
- Command command2;
- Synchronizer synchronizer2;
-
- public SynchronousSynchronizerTests(String name) {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.primaryModel1 = new PrimaryModel1();
- this.secondaryModel1 = new SecondaryModel1(this.primaryModel1);
- this.command1 = new SynchronizeSecondaryModelCommand1(this.secondaryModel1);
- this.synchronizer1 = new SynchronousSynchronizer(this.command1);
- this.primaryModel1.setSynchronizer(this.synchronizer1);
-
- this.primaryModel2 = new PrimaryModel2();
- this.secondaryModel2 = new SecondaryModel2(this.primaryModel2);
- this.command2 = new SynchronizeSecondaryModelCommand2(this.primaryModel2, this.secondaryModel2);
- this.synchronizer2 = new SynchronousSynchronizer(this.command2);
- this.primaryModel2.setSynchronizer(this.synchronizer2);
- }
-
- public void testInitialization() {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- }
-
- public void testToString() {
- assertNotNull(this.synchronizer1.toString());
- }
-
- public void testChange() {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- this.primaryModel1.setCount(7);
- assertEquals(14, this.secondaryModel1.getDoubleCount());
- }
-
- public void testStart() {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- this.primaryModel1.setSynchronizer(Synchronizer.Null.instance());
- this.primaryModel1.setCount(7);
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- this.primaryModel1.setSynchronizer(this.synchronizer1);
- assertEquals(14, this.secondaryModel1.getDoubleCount());
- }
-
- public void testStop() {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- this.primaryModel1.dispose();
- this.primaryModel1.setCount(7);
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- }
-
- public void testDoubleStart() {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- boolean exCaught = false;
- try {
- this.primaryModel1.startSynchronizer();
- fail();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- this.primaryModel1.setCount(7);
- assertEquals(14, this.secondaryModel1.getDoubleCount());
- }
-
- public void testDoubleStop() {
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- this.primaryModel1.dispose();
- boolean exCaught = false;
- try {
- this.primaryModel1.dispose();
- fail();
- } catch (IllegalStateException ex) {
- exCaught = true;
- }
- assertTrue(exCaught);
- this.primaryModel1.setCount(7);
- assertEquals(4, this.secondaryModel1.getDoubleCount());
- }
-
- public void testRecursiveChange() {
- assertEquals(4, this.secondaryModel2.getDoubleCount());
- this.primaryModel2.setCount(7);
- assertEquals(10, this.primaryModel2.getCountPlus3());
- assertEquals(14, this.secondaryModel2.getDoubleCount());
- assertEquals(20, this.secondaryModel2.getDoubleCountPlus3());
- }
-
- /**
- * Call #stop() from another thread.
- * Verify that no further synchronizations occur.
- * Verify the call to #stop() does not return until the pending
- * synchronization is complete (must set {@link #DEBUG} to true and
- * look at the console).
- *
- * ticks:
- * 0 - start "sync" thread (which will sleep for 1 tick);
- * start "stop" thread (which will sleep for 2 ticks)
- * 1 - "sync" thread wakes up and calls PrimaryModel1.setCount(int)
- * which triggers call to Synchronizer.synchronize() to begin
- * synchronization of SecondaryModel (which will run for 2 ticks;
- * i.e. it will finish on tick 3)
- * 2 - "stop" thread wakes up and calls Synchronizer.stop() and should
- * wait until synchronization is complete
- * 3 - synchronization completes first execution and should stop;
- * "stop" thread should run to completion once the synchronization has stopped
- */
- public void testCallStopFromAnotherThread() throws Exception {
- log("=====" + this.getName() + "=====");
- PrimaryModel2 primaryModel3 = new PrimaryModel2();
- // a synchronize will occur here:
- SecondaryModel3 secondaryModel3 = new SecondaryModel3(primaryModel3);
- Command command3 = new SynchronizeSecondaryModelCommand2(primaryModel3, secondaryModel3);
- Synchronizer synchronizer3 = new SynchronousSynchronizer(command3);
- // another synchronize will occur here:
- primaryModel3.setSynchronizer(synchronizer3);
- secondaryModel3.setTicks(2);
-
- assertEquals(2, primaryModel3.getCount());
- assertEquals(5, primaryModel3.getCountPlus3());
- assertEquals(4, secondaryModel3.getDoubleCount());
- assertEquals(10, secondaryModel3.getDoubleCountPlus3());
-
- Thread syncThread = this.buildTriggerSynchronizeThread(primaryModel3, 1);
- Thread stopThread = this.buildStopThread(synchronizer3, 2);
-
- log("ALL threads start");
- stopThread.start();
- syncThread.start();
-
- stopThread.join();
- syncThread.join();
-
- // 'doubleCount' is synchronized; but the synchronization is stopped
- // while that is happening (by the 'stopThread'), so 'doubleCountPlus3'
- // does not get synchronized
- assertEquals(7, primaryModel3.getCount());
- assertEquals(10, primaryModel3.getCountPlus3());
- assertEquals(14, secondaryModel3.getDoubleCount());
-
- // this does not get updated because it would've been updated by the
- // recursive call to #synchronize(), but by that time #stop() had been called
- assertEquals(10, secondaryModel3.getDoubleCountPlus3());
- }
-
- private Thread buildTriggerSynchronizeThread(PrimaryModel2 primaryModel, long ticks) {
- return this.buildThread(this.buildTriggerSynchronizeRunnable(primaryModel, ticks), "trigger sync");
- }
-
- private Runnable buildTriggerSynchronizeRunnable(final PrimaryModel2 primaryModel, final long ticks) {
- return new Runnable() {
- public void run() {
- TestTools.sleep(ticks * TICK);
- primaryModel.setCount(7);
- }
- };
- }
-
- private Thread buildStopThread(Synchronizer synchronizer, long ticks) {
- return this.buildThread(this.buildStopRunnable(synchronizer, ticks), "stop");
- }
-
- private Runnable buildStopRunnable(final Synchronizer synchronizer, final long ticks) {
- return new Runnable() {
- public void run() {
- TestTools.sleep(ticks * TICK);
- log("STOP thread Synchronizer.stop()");
- synchronizer.stop();
- log("STOP thread stop");
- }
- };
- }
-
- /**
- * Code cloned from {@link #testStopCalledFromAnotherThread()}.
- *
- * Interrupt the "stop" thread while it is waiting for the "synch" thread to finish.
- * Verify that no further synchronizations occur.
- * Verify the call to #stop() returns *before*
- * synchronization is complete (must set {@link #DEBUG} to true and
- * look at the console).
- *
- * ticks:
- * 0 - start "sync" thread (which will sleep for 1 tick);
- * start "stop" thread (which will sleep for 2 ticks);
- * start "interrupt" thread (which will sleep for 3 ticks)
- * 1 - "sync" thread wakes up and calls PrimaryModel1.setCount(int)
- * which triggers call to Synchronizer.synchronize() to begin
- * synchronization of SecondaryModel (which will run for 3 ticks;
- * i.e. it will finish on tick 4)
- * 2 - "stop" thread wakes up and calls Synchronizer.stop() and should
- * wait until it is interrupted
- * 3 - "interrupt" thread wakes up and interrupts "stop" thread;
- * both will run to completion at that point
- * 4 - synchronization completes first execution and should stop since the
- * "stop" thread, before it was interrupted, told the "synch" thread to stop
- */
- public void testInterruptStopThread() throws Exception {
- log("=====" + this.getName() + "=====");
- PrimaryModel2 primaryModel3 = new PrimaryModel2();
- // a synchronize will occur here:
- SecondaryModel3 secondaryModel3 = new SecondaryModel3(primaryModel3);
- Command command3 = new SynchronizeSecondaryModelCommand2(primaryModel3, secondaryModel3);
- Synchronizer synchronizer3 = new SynchronousSynchronizer(command3);
- // another synchronize will occur here:
- primaryModel3.setSynchronizer(synchronizer3);
- secondaryModel3.setTicks(3);
-
- assertEquals(2, primaryModel3.getCount());
- assertEquals(5, primaryModel3.getCountPlus3());
- assertEquals(4, secondaryModel3.getDoubleCount());
- assertEquals(10, secondaryModel3.getDoubleCountPlus3());
-
- Thread syncThread = this.buildTriggerSynchronizeThread(primaryModel3, 1);
- Thread stopThread = this.buildStopThread(synchronizer3, 2);
- Thread interruptThread = this.buildInterruptThread(stopThread, 3);
-
- log("ALL threads start");
- stopThread.start();
- syncThread.start();
- interruptThread.start();
-
- stopThread.join();
- syncThread.join();
- interruptThread.join();
-
- // 'doubleCount' is synchronized; but the synchronization is stopped
- // while that is happening (by the 'stopThread'), so 'doubleCountPlus3'
- // does not get synchronized
- assertEquals(7, primaryModel3.getCount());
- assertEquals(10, primaryModel3.getCountPlus3());
- assertEquals(14, secondaryModel3.getDoubleCount());
-
- // this does not get updated because it would've been updated by the
- // recursive call to #synchronize(), but by that time #stop() had been called
- assertEquals(10, secondaryModel3.getDoubleCountPlus3());
- }
-
- /**
- * Code cloned from {@link #testStopCalledFromAnotherThread()}.
- *
- * Interrupt the "sync" thread while it is synchronizing, cutting short the synchronization.
- * Verify that no further synchronizations occur.
- * Verify the call to #stop() does not return until the pending
- * synchronization is stops after it is interrupted (must set {@link #DEBUG} to true and
- * look at the console).
- *
- * ticks:
- * 0 - start "sync" thread (which will sleep for 1 tick)
- * start "stop" thread (which will sleep for 2 ticks)
- * start "interrupt" thread (which will sleep for 3 ticks)
- * 1 - "sync" thread wakes up and calls PrimaryModel1.setCount(int)
- * which triggers call to Synchronizer.synchronize() to begin
- * synchronization of SecondaryModel (which will run for 4 ticks;
- * i.e. it will finish on tick 5)
- * 2 - "stop" thread wakes up and calls Synchronizer.stop() and should
- * wait until the synchronization is interrupted
- * 3 - "interrupt" thread wakes up and interrupts "sync" thread;
- * the "interrupt" thread runs to completion, while the "sync" thread keeps
- * going for another tick before it stops in "mid-synchronize"
- * 4 - the "sync" thread acknowledges the interrupt and stops in
- * "mid-synchronize"; it will stop since the "stop" thread told it to at tick 2;
- * the "sync" and "stop" threads run to completion
- */
- public void testInterruptSyncThread() throws Exception {
- log("=====" + this.getName() + "=====");
- PrimaryModel2 primaryModel3 = new PrimaryModel2();
- // a synchronize will occur here:
- SecondaryModel3 secondaryModel3 = new SecondaryModel3(primaryModel3);
- Command command3 = new SynchronizeSecondaryModelCommand2(primaryModel3, secondaryModel3);
- Synchronizer synchronizer3 = new SynchronousSynchronizer(command3);
- // another synchronize will occur here:
- primaryModel3.setSynchronizer(synchronizer3);
- secondaryModel3.setTicks(4);
-
- assertEquals(2, primaryModel3.getCount());
- assertEquals(5, primaryModel3.getCountPlus3());
- assertEquals(4, secondaryModel3.getDoubleCount());
- assertEquals(10, secondaryModel3.getDoubleCountPlus3());
-
- Thread syncThread = this.buildTriggerSynchronizeThread(primaryModel3, 1);
- Thread stopThread = this.buildStopThread(synchronizer3, 2);
- Thread interruptThread = this.buildInterruptThread(syncThread, 3);
-
- log("ALL threads start");
- stopThread.start();
- syncThread.start();
- interruptThread.start();
-
- stopThread.join();
- syncThread.join();
- interruptThread.join();
-
- assertEquals(7, primaryModel3.getCount());
- assertEquals(10, primaryModel3.getCountPlus3());
-
- // none of the secondary model is synchronized because the synchronize()
- // method was interrupted before any synchronization had occurred
- assertEquals(4, secondaryModel3.getDoubleCount());
- assertEquals(10, secondaryModel3.getDoubleCountPlus3());
- }
-
- private Thread buildInterruptThread(Thread thread, long ticks) {
- return this.buildThread(this.buildInterruptRunnable(thread, ticks), "interrupt");
- }
-
- private Runnable buildInterruptRunnable(final Thread thread, final long ticks) {
- return new Runnable() {
- public void run() {
- TestTools.sleep(ticks * TICK);
- log("INTERRUPT thread Thread.interrupt()");
- thread.interrupt();
- }
- };
- }
-
- /**
- * Call #stop() during a long-running "synchronize"; then call #start()
- * while the #stop() is waiting for the "synchronize" to complete.
- *
- * ticks:
- * 0 - start "sync" thread (which will sleep for 1 tick)
- * start "stop" thread (which will sleep for 2 ticks)
- * start "start" thread (which will sleep for 3 ticks)
- * 1 - "sync" thread wakes up and calls Synchronizer.synchronize() to begin
- * synchronization (which will run for 3 ticks; i.e. it will finish on tick 4)
- * 2 - "stop" thread wakes up and calls Synchronizer.stop() and should
- * wait until the synchronization is finished (i.e. tick 4)
- * 3 - "start" thread wakes up and calls Synchronizer.start()
- * which will throw an exception
- * 4 - the "sync" thread finishes execution;
- * it will stop since the "stop" thread told it to at tick 2;
- * the "sync" and "stop" threads run to completion
- */
- public void testCallStartDuringStop() throws Exception {
- log("=====" + this.getName() + "=====");
- DelayCommand command = this.buildDelayCommand(3);
- Synchronizer synchronizer = new SynchronousSynchronizer(command);
- synchronizer.start();
-
- Thread syncThread = this.buildSynchronizeThread(synchronizer, 1);
- Thread stopThread = this.buildStopThread(synchronizer, 2);
- SynchronizedBoolean exCaught = new SynchronizedBoolean(false);
- Thread startThread = this.buildStartThread(synchronizer, 3, exCaught);
-
- log("ALL threads start");
- syncThread.start();
- stopThread.start();
- startThread.start();
-
- syncThread.join();
- stopThread.join();
- startThread.join();
-
- assertTrue(exCaught.getValue());
- assertEquals(2, command.count);
- }
-
- private DelayCommand buildDelayCommand(int ticks) {
- return new DelayCommand(ticks);
- }
-
- class DelayCommand implements Command {
- final long ticks;
- boolean first = true;
- int count = 0;
-
- DelayCommand(int ticks) {
- super();
- this.ticks = ticks;
- }
-
- public void execute() {
- this.count++;
- // do nothing for the first call (from #start())
- if (this.first) {
- log("EXEC first");
- this.first = false;
- return;
- }
- log("EXEC start " + this.count);
- TestTools.sleep(this.ticks * TICK);
- log("EXEC stop " + this.count);
- }
-
- }
-
- private Thread buildStartThread(Synchronizer synchronizer, long ticks, SynchronizedBoolean exCaught) {
- return this.buildThread(this.buildStartRunnable(synchronizer, ticks, exCaught), "start");
- }
-
- private Runnable buildStartRunnable(final Synchronizer synchronizer, final long ticks, final SynchronizedBoolean exCaught) {
- return new Runnable() {
- public void run() {
- TestTools.sleep(ticks * TICK);
- log("START thread Synchronizer.start()");
- try {
- synchronizer.start();
- } catch (IllegalStateException ex) {
- exCaught.setTrue();
- log("START thread exception");
- }
- log("START thread stop");
- }
- };
- }
-
- private Thread buildSynchronizeThread(Synchronizer synchronizer, long ticks) {
- return this.buildThread(this.buildSynchronizeRunnable(synchronizer, ticks), "synchronize");
- }
-
- private Runnable buildSynchronizeRunnable(final Synchronizer synchronizer, final long ticks) {
- return new Runnable() {
- public void run() {
- TestTools.sleep(ticks * TICK);
- log("SYNC thread Synchronizer.synchronize()");
- synchronizer.synchronize();
- log("SYNC thread stop");
- }
- };
- }
-
- public void testException() throws Exception {
- BogusCommand command = new BogusCommand();
- Synchronizer synchronizer = new SynchronousSynchronizer(command);
- synchronizer.start();
-
- try {
- synchronizer.synchronize();
- } catch (NullPointerException ex) {
- // ignore
- }
-
- boolean exCaught = false;
- try {
- // we used to hang here, before we began handling exceptions
- synchronizer.stop();
- fail();
- } catch (CompositeException ex) {
- assertEquals(1, ex.getExceptions().length);
- exCaught = true;
- }
- assertTrue(exCaught);
- // start + synchronize
- assertEquals(2, command.count);
- }
-
- public class BogusCommand implements Command {
- int count = 0;
- public void execute() {
- this.count++;
- if (this.count > 1) {
- throw new NullPointerException();
- }
- }
- }
-
-
- // ********** synchronize commands **********
- public static class SynchronizeSecondaryModelCommand1 implements Command {
- private final SecondaryModel1 secondaryModel;
-
- public SynchronizeSecondaryModelCommand1(SecondaryModel1 secondaryModel) {
- super();
- this.secondaryModel = secondaryModel;
- }
-
- public void execute() {
- this.secondaryModel.synchronize();
- }
-
- }
-
- /**
- * the primary model (subclass) has to synchronize with itself (superclass)
- */
- public static class SynchronizeSecondaryModelCommand2 extends SynchronizeSecondaryModelCommand1 {
- private final PrimaryModel2 primaryModel;
-
- public SynchronizeSecondaryModelCommand2(PrimaryModel2 primaryModel, SecondaryModel2 secondaryModel) {
- super(secondaryModel);
- this.primaryModel = primaryModel;
- }
-
- @Override
- public void execute() {
- super.execute();
- this.primaryModel.synchronize();
- }
-
- }
-
- // ********** primary models **********
- /**
- * this object will call the synchronizer whenever its count changes,
- * allowing interested parties to synchronize with the change
- */
- public static class PrimaryModel1 {
- protected Synchronizer synchronizer;
- protected int count = 2;
-
- public PrimaryModel1() {
- super();
- this.setSynchronizer_(Synchronizer.Null.instance());
- }
-
- public int getCount() {
- return this.count;
- }
- public void setCount(int count) {
- if (count != this.count) {
- this.count = count;
- this.stateChanged();
- }
- }
-
- protected void stateChanged() {
- this.synchronizer.synchronize();
- }
-
- public void setSynchronizer(Synchronizer synchronizer) {
- if (synchronizer == null) {
- throw new NullPointerException();
- }
- this.synchronizer.stop();
- this.setSynchronizer_(synchronizer);
- }
-
- protected void setSynchronizer_(Synchronizer synchronizer) {
- this.synchronizer = synchronizer;
- this.synchronizer.start();
- }
-
- public void startSynchronizer() {
- this.synchronizer.start(); // this should cause an exception
- }
- public void dispose() {
- this.synchronizer.stop();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(this.getClass().getSimpleName());
- sb.append('(');
- this.toString(sb);
- sb.append(')');
- return sb.toString();
- }
- public void toString(StringBuilder sb) {
- sb.append("count=");
- sb.append(this.count);
- }
-
- }
-
- /**
- * This model synchronizes with itself, triggering a recursive synchronization
- * with the change. Whenever the [inherited] 'count' changes, 'countPlus3'
- * is updated appropriately and another synchronize is initiated if appropriate.
- */
- public static class PrimaryModel2 extends PrimaryModel1 {
- private int countPlus3 = 0;
-
- public PrimaryModel2() {
- super();
- this.countPlus3 = this.count + 3;
- }
-
- public int getCountPlus3() {
- return this.countPlus3;
- }
- protected void setCountPlus3(int countPlus3) {
- if (countPlus3 != this.countPlus3) {
- this.countPlus3 = countPlus3;
- this.stateChanged();
- }
- }
-
- // synchronize with itself, so to speak
- public void synchronize() {
- this.setCountPlus3(this.count + 3);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(", countPlus3=");
- sb.append(this.countPlus3);
- }
-
- }
-
- // ********** secondary models **********
- /**
- * This dependent object updates its 'doubleCount' whenever the
- * PrimaryModel1's 'count' changes, via the 'synchronizer'.
- */
- public static class SecondaryModel1 {
- protected final PrimaryModel1 primaryModel;
- protected int doubleCount = 0;
-
- public SecondaryModel1(PrimaryModel1 primaryModel) {
- super();
- this.primaryModel = primaryModel;
- this.synchronize();
- }
-
- public void synchronize() {
- this.doubleCount = this.primaryModel.getCount() * 2;
- }
-
- public int getDoubleCount() {
- return this.doubleCount;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(this.getClass().getSimpleName());
- sb.append('(');
- this.toString(sb);
- sb.append(')');
- return sb.toString();
- }
- public void toString(StringBuilder sb) {
- sb.append("doubleCount=");
- sb.append(this.doubleCount);
- }
-
- }
-
- public static class SecondaryModel2 extends SecondaryModel1 {
- private int doubleCountPlus3 = 0;
-
- public SecondaryModel2(PrimaryModel2 extendedPrimaryModel) {
- super(extendedPrimaryModel);
- }
-
- protected PrimaryModel2 getExtendedPrimaryModel() {
- return (PrimaryModel2) this.primaryModel;
- }
-
- @Override
- public void synchronize() {
- super.synchronize();
- int temp = this.getExtendedPrimaryModel().getCountPlus3() * 2;
- if (this.doubleCountPlus3 != temp) {
- this.doubleCountPlus3 = temp;
- }
- }
-
- public int getDoubleCountPlus3() {
- return this.doubleCountPlus3;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(", doubleCountPlus3=");
- sb.append(this.doubleCountPlus3);
- }
-
- }
-
- /**
- * Allow the time required to synchronize to be specified.
- * A (non-delayed) synchronize will execute before we have a chance to
- * change the tick count. (It is called in the SecondaryModel1 constructor.)
- */
- public static class SecondaryModel3 extends SecondaryModel2 {
- private long delay = 0;
- public SecondaryModel3(PrimaryModel2 primaryModel) {
- super(primaryModel);
- }
-
- public void setTicks(long ticks) {
- this.delay = ticks * TICK;
- }
-
- @Override
- public void synchronize() {
- // don't log anything until 'ticks' is set
- if (this.delay == 0) {
- super.synchronize();
- } else {
- log("SYNC thread start - sync duration will be: " + (this.delay / TICK) + " ticks");
- try {
- Thread.sleep(this.delay);
- } catch (InterruptedException ex) {
- log("SYNC thread interrupted");
- TestTools.sleep(TICK);
- return; // stop synchronize (i.e. don't call super.synchronize())
- }
- super.synchronize();
- log("SYNC thread stop");
- }
- }
-
- }
-
- public void testDEBUG() {
- assertFalse(DEBUG);
- }
-
- public static final boolean DEBUG = false;
- public static void log(String message) {
- if (DEBUG) {
- log_(message);
- }
- }
-
- private static void log_(String message) {
- System.out.print(timestamp());
- System.out.print(' ');
- System.out.print(message);
- System.out.println();
- }
-
- public static String timestamp() {
- return String.valueOf((System.currentTimeMillis() % 10000) / 1000f);
- }
-}
diff --git a/common/tests/org.eclipse.jpt.common.utility.tests/test.xml b/common/tests/org.eclipse.jpt.common.utility.tests/test.xml
deleted file mode 100644
index 14635f2af1..0000000000
--- a/common/tests/org.eclipse.jpt.common.utility.tests/test.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0"?> <!-- Copyright (c) 2007, 2010 Oracle. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0, which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html. Contributors: Oracle - initial API and implementation --> <project name="testsuite" default="run" basedir=".">
- <!-- The property ${eclipse-home} should be passed into this script -->
- <!-- Set a meaningful default value for when it is not. -->
- <echo message="basedir ${basedir}" />
- <echo message="eclipse place ${eclipse-home}" />
- <!-- sets the properties plugin-name -->
- <property name="plugin-name" value="org.eclipse.jpt.common.utility.tests"/>
-
- <!-- This target holds all initialization code that needs to be done for -->
- <!-- all tests that are to be run. Initialization for individual tests -->
- <!-- should be done within the body of the suite target. -->
- <target name="init">
- <tstamp/>
- <delete>
- <fileset dir="${eclipse-home}" includes="org*.xml"/>
- </delete>
- </target>
-
- <!-- This target defines the tests that need to be run. -->
- <target name="suite">
- <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
- <property name="plugin-name" value="${plugin-name}"/>
- <property name="classname" value="org.eclipse.jpt.common.utility.tests.internal.JptCommonUtilityTests" />
- <property name="plugin-path" value="${eclipse-home}/plugins/${plugin-name}"/>
- </ant>
- </target>
-
- <!-- This target holds code to cleanup the testing environment after -->
- <!-- after all of the tests have been run. You can use this target to -->
- <!-- delete temporary files that have been created. -->
- <target name="cleanup">
- </target>
-
- <!-- This target runs the test suite. Any actions that need to happen -->
- <!-- after all the tests have been run should go here. -->
- <target name="run" depends="init, suite, cleanup">
- </target>
-</project> \ No newline at end of file

Back to the top